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.
76 lines
2.3 KiB
Dart
76 lines
2.3 KiB
Dart
import 'package:cutdex/features/assistant/composer_document.dart';
|
|
import 'package:cutdex/features/assistant/composer_reference_validator.dart';
|
|
import 'package:cutdex/workspace/project_state.dart';
|
|
import 'package:cutdex_sdk/project.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
const media = ComposerReference(
|
|
kind: ComposerReferenceKind.media,
|
|
projectId: 'project',
|
|
id: 'asset',
|
|
label: '旧名称.mp4',
|
|
);
|
|
const timeline = ComposerReference(
|
|
kind: ComposerReferenceKind.timeline,
|
|
projectId: 'project',
|
|
id: 'timeline',
|
|
label: '时间线',
|
|
);
|
|
final workspace = ProjectState(
|
|
activeProject: const RecentProject(
|
|
id: 'project',
|
|
name: '项目',
|
|
path: '/project.cutdex',
|
|
),
|
|
assets: [
|
|
AssetDocument(
|
|
id: 'asset',
|
|
name: '新名称.mp4',
|
|
storage: AssetStorage.external,
|
|
location: 'file:///tmp/asset',
|
|
),
|
|
],
|
|
timelines: const [
|
|
TimelineSummary(id: 'timeline', name: '时间线', revision: 1),
|
|
],
|
|
);
|
|
|
|
test('rename keeps the stable media ID valid, deletion invalidates it', () {
|
|
final controller = ComposerDocumentController(text: '@');
|
|
addTearDown(controller.dispose);
|
|
controller.insertReference(0, 1, media);
|
|
ComposerReferenceValidator(
|
|
workspace: workspace,
|
|
projectId: 'project',
|
|
).validate(controller);
|
|
expect(controller.hasInvalidReferences, isFalse);
|
|
expect(controller.marks.single.reference.label, '旧名称.mp4');
|
|
ComposerReferenceValidator(
|
|
workspace: workspace.copyWith(assets: const []),
|
|
projectId: 'project',
|
|
).validate(controller);
|
|
expect(controller.hasInvalidReferences, isTrue);
|
|
});
|
|
|
|
test(
|
|
'draft references follow the active project without changing their IDs',
|
|
() {
|
|
final controller = ComposerDocumentController(text: '@');
|
|
addTearDown(controller.dispose);
|
|
controller.insertReference(0, 1, timeline);
|
|
ComposerReferenceValidator(
|
|
workspace: workspace,
|
|
projectId: 'other',
|
|
).validate(controller);
|
|
expect(controller.hasInvalidReferences, isTrue);
|
|
ComposerReferenceValidator(
|
|
workspace: workspace,
|
|
projectId: 'project',
|
|
).validate(controller);
|
|
expect(controller.hasInvalidReferences, isFalse);
|
|
expect(controller.marks.single.reference.id, 'timeline');
|
|
},
|
|
);
|
|
}
|