Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m47s
Gitea CI / Check code and tests (push) Successful in 7m15s
Gitea CI / Build Android APK (push) Successful in 4m6s
Gitea CI / Build Windows x64 app (push) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m29s
Gitea CI / Gitea CI passed (push) Successful in 1s
Gitea Release / Prepare draft Release (push) Failing after 8s
Gitea Release / Upload Android to draft Release (push) Skipped
Gitea Release / Upload Windows to draft Release (push) Skipped
Gitea Release / Verify and publish Release (push) Skipped
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');
|
|
}
|
|
}
|