Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
99 lines
2.7 KiB
Dart
99 lines
2.7 KiB
Dart
import 'package:cutdex/features/assistant/composer_suggestions.dart';
|
|
import 'package:cutdex_sdk/project.dart';
|
|
import 'package:cutdex/l10n/app_localizations_en.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
test('all triggers appear at word boundaries but not in paths or email', () {
|
|
for (final trigger in ['@', '/', r'$']) {
|
|
final value = TextEditingValue(
|
|
text: 'hello $trigger片段',
|
|
selection: TextSelection.collapsed(offset: 'hello $trigger片段'.length),
|
|
);
|
|
final query = findComposerTrigger(value, const []);
|
|
expect(query?.trigger, trigger);
|
|
expect(query?.query, '片段');
|
|
}
|
|
for (final plain in ['foo@example.com', '/Users/name', r'price$100']) {
|
|
expect(
|
|
findComposerTrigger(
|
|
TextEditingValue(
|
|
text: plain,
|
|
selection: TextSelection.collapsed(offset: plain.length),
|
|
),
|
|
const [],
|
|
),
|
|
isNull,
|
|
);
|
|
}
|
|
const chinese = '看看@片段';
|
|
expect(
|
|
findComposerTrigger(
|
|
const TextEditingValue(
|
|
text: chinese,
|
|
selection: TextSelection.collapsed(offset: 5),
|
|
),
|
|
const [],
|
|
)?.query,
|
|
'片段',
|
|
);
|
|
expect(
|
|
findComposerTrigger(
|
|
const TextEditingValue(
|
|
text: '@p',
|
|
selection: TextSelection.collapsed(offset: 2),
|
|
composing: TextRange(start: 1, end: 2),
|
|
),
|
|
const [],
|
|
),
|
|
isNull,
|
|
);
|
|
});
|
|
|
|
test(
|
|
'built-in current-project options distinguish equal names and filter',
|
|
() {
|
|
final options = ComposerOptionCatalog.forTrigger(
|
|
'@',
|
|
l10n: AppLocalizationsEn(),
|
|
projectId: 'project',
|
|
assets: [
|
|
AssetDocument(
|
|
id: 'asset',
|
|
name: '片段',
|
|
storage: AssetStorage.external,
|
|
location: 'file:///tmp/a',
|
|
),
|
|
],
|
|
timelines: [
|
|
const TimelineSummary(id: 'timeline', name: '片段', revision: 1),
|
|
],
|
|
);
|
|
expect(options.length, 2);
|
|
expect(options.map((option) => option.subtitle).toSet().length, 2);
|
|
expect(filterComposerOptions(options, '片').length, 2);
|
|
expect(
|
|
ComposerOptionCatalog.forTrigger(
|
|
'/',
|
|
l10n: AppLocalizationsEn(),
|
|
projectId: 'project',
|
|
assets: const [],
|
|
timelines: const [],
|
|
),
|
|
isEmpty,
|
|
);
|
|
expect(
|
|
ComposerOptionCatalog.forTrigger(
|
|
r'$',
|
|
l10n: AppLocalizationsEn(),
|
|
projectId: 'project',
|
|
assets: const [],
|
|
timelines: const [],
|
|
),
|
|
isEmpty,
|
|
);
|
|
},
|
|
);
|
|
}
|