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
106 lines
3.8 KiB
Dart
106 lines
3.8 KiB
Dart
import 'support/creation_names.dart';
|
|
|
|
import 'package:cutdex_core/editor.dart';
|
|
|
|
import 'dart:async';
|
|
import 'dart:io';
|
|
|
|
import 'package:cutdex/workspace/persistence/project_workspace.dart';
|
|
import 'package:cutdex/integrations/runtime/media_thumbnails.dart';
|
|
import 'package:cutdex/integrations/runtime/media_waveforms.dart';
|
|
import 'package:cutdex_core/project.dart';
|
|
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
test(
|
|
'binding preserves selected tracks, explicit disabled tracks and images',
|
|
() {
|
|
final uris = {'asset': Uri.file('/movie.mov')};
|
|
EditorMediaBinding? binding(String type, Map<String, Object?> data) =>
|
|
EditorMediaBinding.resolve(
|
|
PayloadDocument(
|
|
id: 'payload',
|
|
type: type,
|
|
assetIds: ['asset'],
|
|
data: data,
|
|
),
|
|
uris,
|
|
);
|
|
expect(
|
|
binding('video', {
|
|
'videoTrackIndex': 2,
|
|
'audioTrackIndex': 1,
|
|
})!.videoTrackIndex,
|
|
2,
|
|
);
|
|
expect(
|
|
binding('video', {
|
|
'videoTrackIndex': 2,
|
|
'audioTrackIndex': 1,
|
|
})!.audioTrackIndex,
|
|
1,
|
|
);
|
|
expect(
|
|
binding('video', {'videoTrackIndex': null})!.videoTrackIndex,
|
|
isNull,
|
|
);
|
|
expect(binding('audio', {'audioTrackIndex': 0})!.audioTrackIndex, 0);
|
|
expect(binding('audio', {}), isNull);
|
|
expect(binding('video', {}), isNull);
|
|
expect(binding('image', {})!.media.isImage, isTrue);
|
|
expect(binding('audio', {'audioTrackIndex': -1}), isNull);
|
|
expect(binding('video', {'videoTrackIndex': 'invalid'}), isNull);
|
|
},
|
|
);
|
|
|
|
test('managed covers use resolved paths and generation survives a project switch', () async {
|
|
final root = await Directory.systemTemp.createTemp('cutdex-bindings-');
|
|
final workspace = ProjectWorkspace(creationNames: testCreationNames);
|
|
addTearDown(() async {
|
|
await workspace.close();
|
|
await root.delete(recursive: true);
|
|
});
|
|
await workspace.open('${root.path}/one.cutdex', name: 'One');
|
|
final project = workspace.project!;
|
|
final file = File('${root.path}/source.wav');
|
|
await file.writeAsBytes([1, 2, 3, 4]);
|
|
final asset = await project.importFile(file);
|
|
expect(Uri.parse(asset.location).hasScheme, isFalse);
|
|
final resolved = await project.resolveAsset(asset);
|
|
final calls = <String>[];
|
|
const channel = MethodChannel('cutdex_runtime');
|
|
final messenger =
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
|
|
messenger.setMockMethodCallHandler(channel, (call) async {
|
|
expect((call.arguments as Map)['media']['uri'], resolved.toString());
|
|
calls.add(call.method);
|
|
throw PlatformException(code: 'testSource');
|
|
});
|
|
addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
|
|
Future<T> load<T>(
|
|
AssetDocument asset,
|
|
Future<T> Function(MediaReference) action,
|
|
) => workspace.withAssetMedia(project.info.id, asset, action);
|
|
await MediaThumbnails(loadMedia: load).load(asset);
|
|
await MediaWaveforms(loadMedia: load).load(asset);
|
|
expect(calls, ['thumbnail', 'waveform']);
|
|
|
|
final started = Completer<void>(), finish = Completer<void>();
|
|
final operation = load(asset, (media) async {
|
|
started.complete();
|
|
await finish.future;
|
|
return File.fromUri(media.uri).readAsBytes();
|
|
});
|
|
await started.future;
|
|
await workspace.open('${root.path}/two.cutdex', name: 'Two');
|
|
finish.complete();
|
|
expect(await operation, [1, 2, 3, 4]);
|
|
expect((await load(asset, (media) async => media)).uri, resolved);
|
|
await workspace.close();
|
|
await expectLater(load(asset, (media) async => media), throwsStateError);
|
|
});
|
|
}
|