Gitea CI / Check code and tests (pull_request) Failing after 8s
Gitea CI / Build Android APK (pull_request) Skipped
Gitea CI / Build Windows x64 app (pull_request) Skipped
Gitea CI / Audit and package Windows x64 (pull_request) Skipped
Gitea CI / Assemble and validate CI artifacts (pull_request) Skipped
Gitea CI / Gitea CI passed (pull_request) Failing after 1s
88 lines
2.5 KiB
Dart
88 lines
2.5 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:cutdex_core/editor.dart';
|
|
import 'package:cutdex_core/project.dart';
|
|
import 'package:cutdex_core/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');
|
|
}
|
|
}
|