feat: initial Cutdex application
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.
This commit is contained in:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,85 @@
|
||||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:cutdex/integrations/runtime/export_publication.dart';
|
||||
import 'package:cutdex_sdk/editor.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
late Directory root;
|
||||
setUp(
|
||||
() async =>
|
||||
root = await Directory.systemTemp.createTemp('export-recovery-'),
|
||||
);
|
||||
tearDown(() => root.delete(recursive: true));
|
||||
test(
|
||||
'published output is recovered repeatedly without encoding again',
|
||||
() async {
|
||||
final destination = File('${root.path}/result.mp4').uri;
|
||||
var calls = 0;
|
||||
Future<Uri> encode(Uri uri) async {
|
||||
calls++;
|
||||
await File.fromUri(uri).writeAsString('encoded movie');
|
||||
return uri;
|
||||
}
|
||||
|
||||
await ExportPublication(destination, 'op').run('snapshot', encode);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
expect(
|
||||
await ExportPublication(destination, 'op').run('snapshot', encode),
|
||||
destination,
|
||||
);
|
||||
}
|
||||
expect(calls, 1);
|
||||
await expectLater(
|
||||
ExportPublication(destination, 'op').run('other', encode),
|
||||
throwsA(isA<CommandRejected>()),
|
||||
);
|
||||
},
|
||||
);
|
||||
test('ready staging receipt recovers the publication crash window', () async {
|
||||
final destination = File('${root.path}/result.mp4').uri;
|
||||
final job = ExportPublication(destination, 'op');
|
||||
await job.directory.create();
|
||||
final bytes = utf8.encode('complete movie');
|
||||
await job.staged.writeAsBytes(bytes);
|
||||
await job.receipt.writeAsString(
|
||||
jsonEncode({
|
||||
'operationId': 'op',
|
||||
'destination': destination.toString(),
|
||||
'fingerprint': 'snapshot',
|
||||
'bytes': bytes.length,
|
||||
'sha256': sha256.convert(bytes).toString(),
|
||||
}),
|
||||
);
|
||||
expect(await ExportPublication(destination, 'op').recover(), destination);
|
||||
expect(await job.staged.exists(), false);
|
||||
expect(await File.fromUri(destination).readAsBytes(), bytes);
|
||||
});
|
||||
test(
|
||||
'incomplete and externally changed output never silently overwrites',
|
||||
() async {
|
||||
final destination = File('${root.path}/result.mp4').uri;
|
||||
final job = ExportPublication(destination, 'op');
|
||||
await expectLater(
|
||||
job.run('snapshot', (_) async => throw StateError('killed encoder')),
|
||||
throwsStateError,
|
||||
);
|
||||
expect(await job.recover(), null);
|
||||
await expectLater(
|
||||
job.run('snapshot', (_) async => destination),
|
||||
throwsA(isA<CommandRejected>()),
|
||||
);
|
||||
expect(await File.fromUri(destination).exists(), false);
|
||||
final next = ExportPublication(destination, 'explicit-retry');
|
||||
await next.run('snapshot', (uri) async {
|
||||
await File.fromUri(uri).writeAsString('complete');
|
||||
return uri;
|
||||
});
|
||||
await File.fromUri(destination).writeAsString('changed');
|
||||
await expectLater(next.recover(), throwsA(isA<CommandRejected>()));
|
||||
expect(await File.fromUri(destination).readAsString(), 'changed');
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user