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.
88 lines
2.5 KiB
Dart
88 lines
2.5 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:cutdex_sdk/editor.dart';
|
|
import 'package:cutdex_sdk/project.dart';
|
|
import 'package:cutdex_sdk/timeline/model.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
class SavedEditValidation {
|
|
final _edits = <String, Map<String, Map<String, Object?>>>{};
|
|
|
|
Future<Map<String, Object?>> capture(
|
|
String projectPath,
|
|
String timelineId,
|
|
EditorSession session,
|
|
SequenceId sequence,
|
|
) async {
|
|
final edits = await _editingState(session, sequence);
|
|
_edits.putIfAbsent(projectPath, () => {})[timelineId] = edits;
|
|
return edits;
|
|
}
|
|
|
|
Future<void> verify({
|
|
required Future<void> Function(Duration) wait,
|
|
required void Function(
|
|
String projectPath,
|
|
String timelineId,
|
|
Map<String, Object?> edits,
|
|
)
|
|
onVerified,
|
|
}) async {
|
|
for (final project in _edits.entries) {
|
|
ProjectFile? reopened;
|
|
final deadline = DateTime.now().add(const Duration(seconds: 40));
|
|
while (reopened == null) {
|
|
try {
|
|
reopened = await ProjectFile.open(Directory(project.key));
|
|
} on ProjectFileException catch (error) {
|
|
if (error.code != ProjectFileError.conflict ||
|
|
DateTime.now().isAfter(deadline)) {
|
|
rethrow;
|
|
}
|
|
await wait(const Duration(milliseconds: 100));
|
|
}
|
|
}
|
|
try {
|
|
for (final entry in project.value.entries) {
|
|
final session = EditorSession(
|
|
document: await reopened.loadTimeline(entry.key),
|
|
persistence: await reopened.openTimelineSaveSession(entry.key),
|
|
);
|
|
late Map<String, Object?> actual;
|
|
try {
|
|
actual = await _editingState(
|
|
session,
|
|
SequenceId(entry.value['sequenceId'] as String),
|
|
);
|
|
} finally {
|
|
await session.close();
|
|
}
|
|
expect(
|
|
actual,
|
|
entry.value,
|
|
reason: 'Edited timeline changed after close/reopen',
|
|
);
|
|
onVerified(project.key, entry.key, actual);
|
|
}
|
|
} finally {
|
|
await reopened.close();
|
|
}
|
|
}
|
|
}
|
|
|
|
Future<Map<String, Object?>> _editingState(
|
|
EditorSession session,
|
|
SequenceId sequence,
|
|
) async {
|
|
final result = await session.executeCommand(
|
|
sequence,
|
|
const QueryTimeline(),
|
|
);
|
|
// History availability and save status describe the current session.
|
|
return Map<String, Object?>.of(result.data)
|
|
..remove('canUndo')
|
|
..remove('canRedo')
|
|
..remove('saveState');
|
|
}
|
|
}
|