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
157 lines
5.2 KiB
Dart
157 lines
5.2 KiB
Dart
import '../test/support/creation_names.dart';
|
|
|
|
import 'dart:io';
|
|
|
|
import 'package:cutdex/workspace/persistence/project_workspace.dart';
|
|
import 'package:cutdex_core/project.dart';
|
|
import 'package:cutdex_core/timeline/model.dart';
|
|
import 'package:cutdex_core/editor.dart';
|
|
|
|
import '../test/support/processing_fixture.dart';
|
|
|
|
import 'package:cutdex/features/preview/preview_panel.dart';
|
|
import 'package:cutdex/integrations/editor_tools.dart';
|
|
import 'package:cutdex/persistence/app_database.dart';
|
|
import 'package:cutdex/workspace/projects.dart';
|
|
import 'package:cutdex/workspace/timeline_provider.dart';
|
|
import 'package:drift/native.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:integration_test/integration_test.dart';
|
|
|
|
void main() {
|
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
for (final mask in [0, 1, 2, 4, 3, 5, 6, 7, -1]) {
|
|
testWidgets('timeline native preview with optional capability mask $mask', (
|
|
tester,
|
|
) async {
|
|
final root = await Directory.systemTemp.createTemp(
|
|
'preview-capabilities-',
|
|
);
|
|
final config = await processingFixture(
|
|
root,
|
|
mask < 0 ? 7 : mask,
|
|
stale: mask < 0,
|
|
);
|
|
final workspace = ProjectWorkspace(
|
|
creationNames: testCreationNames,
|
|
processing: config,
|
|
);
|
|
try {
|
|
await workspace.open('${root.path}/Test.cutdex', name: 'Preview');
|
|
final document = TimelineDocument(
|
|
id: 'timeline',
|
|
name: 'Preview',
|
|
defaultSequenceId: SequenceId('main'),
|
|
sequences: [
|
|
TimelineDto(
|
|
id: SequenceId('main'),
|
|
format: TimelineFormat.fps30,
|
|
primaryStorylineId: StorylineId('primary'),
|
|
storylines: [
|
|
StorylineDto(id: StorylineId('primary'), elementIds: []),
|
|
],
|
|
elements: [],
|
|
),
|
|
],
|
|
);
|
|
await workspace.project!.saveTimeline(document);
|
|
final timeline = await workspace.openTimelineSession(
|
|
workspace.project!.info.id,
|
|
await workspace.project!.loadTimeline(document.id),
|
|
);
|
|
final ids = (workspace.project!.info.id, document.id);
|
|
final scoped = ProviderContainer(
|
|
overrides: [
|
|
editorTimelineProvider(
|
|
ids.$1,
|
|
ids.$2,
|
|
).overrideWith((ref) async => timeline),
|
|
],
|
|
);
|
|
try {
|
|
final subscription = scoped.listen(
|
|
editorPreviewProvider(ids.$1, ids.$2),
|
|
(_, _) {},
|
|
);
|
|
final preview = await scoped.read(
|
|
editorPreviewProvider(ids.$1, ids.$2).future,
|
|
);
|
|
expect(preview, isNotNull);
|
|
expect(preview!.ready, isTrue);
|
|
expect(preview.error, isNull);
|
|
final enabled = mask < 0 ? 0 : mask;
|
|
expect(
|
|
timeline.supportedCommandOperations.contains(
|
|
EditorOperation.startTranscription,
|
|
),
|
|
enabled & 1 != 0,
|
|
);
|
|
expect(
|
|
timeline.supportedCommandOperations.contains(
|
|
EditorOperation.startSubtitleTranslation,
|
|
),
|
|
enabled & 2 != 0,
|
|
);
|
|
expect(
|
|
timeline.supportedCommandOperations.contains(
|
|
EditorOperation.startVocalSeparation,
|
|
),
|
|
enabled & 4 != 0,
|
|
);
|
|
await preview.close();
|
|
subscription.close();
|
|
} finally {
|
|
scoped.dispose();
|
|
}
|
|
} finally {
|
|
await workspace.close();
|
|
await root.delete(recursive: true);
|
|
}
|
|
});
|
|
}
|
|
testWidgets(
|
|
'opening a timeline initializes native preview through App providers',
|
|
(tester) async {
|
|
final directory = await Directory.systemTemp.createTemp(
|
|
'cutdex preview startup ',
|
|
);
|
|
final database = AppDatabase(NativeDatabase.memory());
|
|
final container = ProviderContainer(
|
|
overrides: [appDatabaseProvider.overrideWithValue(database)],
|
|
);
|
|
try {
|
|
container.read(applicationToolAccessProvider);
|
|
final projects = container.read(projectsProvider.notifier);
|
|
expect(
|
|
await projects.open('${directory.path}/Test.cutdex', name: 'Preview'),
|
|
isTrue,
|
|
);
|
|
expect(await projects.createTimeline(name: 'Timeline'), isTrue);
|
|
final state = await container.read(projectsProvider.future);
|
|
final ids = (state.activeProject!.id, state.timeline!.id);
|
|
final subscription = container.listen(
|
|
editorPreviewProvider(ids.$1, ids.$2),
|
|
(_, _) {},
|
|
);
|
|
final preview = await container.read(
|
|
editorPreviewProvider(ids.$1, ids.$2).future,
|
|
);
|
|
expect(preview, isNull);
|
|
final timeline = await container.read(
|
|
editorTimelineProvider(ids.$1, ids.$2).future,
|
|
);
|
|
expect(timeline.preview, isNull);
|
|
subscription.close();
|
|
await timeline.close();
|
|
} finally {
|
|
container.dispose();
|
|
await Future<void>.delayed(const Duration(milliseconds: 200));
|
|
await database.close();
|
|
await directory.delete(recursive: true);
|
|
}
|
|
},
|
|
);
|
|
}
|