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,329 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cutdex/features/settings/location_settings.dart';
|
||||
import 'package:cutdex/integrations/runtime/processing_resource_repository.dart';
|
||||
import 'package:cutdex/persistence/app_settings_repositories.dart';
|
||||
import 'package:cutdex/workspace/persistence/project_location_directory.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_riverpod/misc.dart' show ProviderListenable;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'support/memory_app_settings.dart';
|
||||
|
||||
void main() {
|
||||
test(
|
||||
'project location load errors can be retried and re-inspected',
|
||||
() async {
|
||||
final repository = _ProjectRepository()..failLoads = true;
|
||||
final inspector = _DirectoryInspector(ProjectLocationStatus.missing);
|
||||
final container = ProviderContainer.test(
|
||||
overrides: [
|
||||
projectLocationSettingsRepositoryProvider.overrideWithValue(
|
||||
repository,
|
||||
),
|
||||
projectLocationDirectoryProvider.overrideWithValue(inspector),
|
||||
],
|
||||
);
|
||||
await _ready(container, projectLocationSettingsProvider);
|
||||
expect(
|
||||
container.read(projectLocationSettingsProvider).error,
|
||||
LocationSettingsError.load,
|
||||
);
|
||||
repository.failLoads = false;
|
||||
final controller = container.read(
|
||||
projectLocationSettingsProvider.notifier,
|
||||
);
|
||||
await controller.reload();
|
||||
final loaded = container.read(projectLocationSettingsProvider);
|
||||
expect(loaded.directory, '/projects');
|
||||
expect(loaded.status, ProjectLocationStatus.missing);
|
||||
expect(loaded.error, isNull);
|
||||
inspector.status = ProjectLocationStatus.ready;
|
||||
await controller.reload();
|
||||
expect(
|
||||
container.read(projectLocationSettingsProvider).status,
|
||||
ProjectLocationStatus.ready,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'project saves keep the previous path on failure and reload on success',
|
||||
() async {
|
||||
final repository = _ProjectRepository();
|
||||
final inspector = _DirectoryInspector(ProjectLocationStatus.ready);
|
||||
final container = ProviderContainer.test(
|
||||
overrides: [
|
||||
projectLocationSettingsRepositoryProvider.overrideWithValue(
|
||||
repository,
|
||||
),
|
||||
projectLocationDirectoryProvider.overrideWithValue(inspector),
|
||||
],
|
||||
);
|
||||
await _ready(container, projectLocationSettingsProvider);
|
||||
final controller = container.read(
|
||||
projectLocationSettingsProvider.notifier,
|
||||
);
|
||||
repository.failWrites = true;
|
||||
await controller.save('/other');
|
||||
final failed = container.read(projectLocationSettingsProvider);
|
||||
expect(failed.directory, '/projects');
|
||||
expect(failed.error, LocationSettingsError.save);
|
||||
expect(failed.saving, isFalse);
|
||||
repository.failWrites = false;
|
||||
inspector.status = ProjectLocationStatus.unavailable;
|
||||
await controller.save('/other');
|
||||
final saved = container.read(projectLocationSettingsProvider);
|
||||
expect(saved.directory, '/other');
|
||||
expect(saved.status, ProjectLocationStatus.unavailable);
|
||||
expect(saved.error, isNull);
|
||||
expect(inspector.paths, ['/projects', '/other']);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'project saves and reloads run in order while storage is pending',
|
||||
() async {
|
||||
final repository = _ProjectRepository()..writeGate = Completer<void>();
|
||||
final container = ProviderContainer.test(
|
||||
overrides: [
|
||||
projectLocationSettingsRepositoryProvider.overrideWithValue(
|
||||
repository,
|
||||
),
|
||||
projectLocationDirectoryProvider.overrideWithValue(
|
||||
_DirectoryInspector(ProjectLocationStatus.ready),
|
||||
),
|
||||
],
|
||||
);
|
||||
await _ready(container, projectLocationSettingsProvider);
|
||||
final controller = container.read(
|
||||
projectLocationSettingsProvider.notifier,
|
||||
);
|
||||
final first = controller.save('/first');
|
||||
await repository.started.future;
|
||||
final second = controller.save('/second');
|
||||
final retry = controller.reload();
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
expect(repository.writes, ['/first']);
|
||||
expect(container.read(projectLocationSettingsProvider).saving, isTrue);
|
||||
expect(
|
||||
container.read(projectLocationSettingsProvider).directory,
|
||||
'/projects',
|
||||
);
|
||||
repository.writeGate!.complete();
|
||||
await Future.wait([first, second, retry]);
|
||||
expect(repository.writes, ['/first', '/second']);
|
||||
expect(
|
||||
container.read(projectLocationSettingsProvider).directory,
|
||||
'/second',
|
||||
);
|
||||
expect(container.read(projectLocationSettingsProvider).saving, isFalse);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'a resource save refreshes the repository even after the page closes',
|
||||
() async {
|
||||
final repository = _ResourceRepository()..writeGate = Completer<void>();
|
||||
var resourceBuilds = 0;
|
||||
final container = ProviderContainer.test(
|
||||
overrides: [
|
||||
resourceLocationSettingsRepositoryProvider.overrideWithValue(
|
||||
repository,
|
||||
),
|
||||
processingResourceRepositoryProvider.overrideWith((ref) {
|
||||
resourceBuilds++;
|
||||
final resources = ProcessingResourceRepository(
|
||||
root: Directory('${repository.value}/Processing'),
|
||||
catalog: [],
|
||||
);
|
||||
ref.onDispose(resources.dispose);
|
||||
return resources;
|
||||
}),
|
||||
],
|
||||
);
|
||||
container.listen(processingResourceRepositoryProvider, (_, _) {});
|
||||
final oldResources = await container.read(
|
||||
processingResourceRepositoryProvider.future,
|
||||
);
|
||||
expect(oldResources.root.path, '/resources/Processing');
|
||||
final page = container.listen(
|
||||
resourceLocationSettingsProvider,
|
||||
(_, _) {},
|
||||
);
|
||||
await _ready(
|
||||
container,
|
||||
resourceLocationSettingsProvider,
|
||||
closeAfterReady: true,
|
||||
);
|
||||
final save = container
|
||||
.read(resourceLocationSettingsProvider.notifier)
|
||||
.save('/new');
|
||||
await repository.started.future;
|
||||
page.close();
|
||||
await container.pump();
|
||||
expect(container.exists(resourceLocationSettingsProvider), isTrue);
|
||||
repository.writeGate!.complete();
|
||||
await save;
|
||||
await container.pump();
|
||||
final newResources = await container.read(
|
||||
processingResourceRepositoryProvider.future,
|
||||
);
|
||||
expect(newResources.root.path, '/new/Processing');
|
||||
expect(resourceBuilds, 2);
|
||||
expect(container.exists(resourceLocationSettingsProvider), isFalse);
|
||||
},
|
||||
);
|
||||
|
||||
test('resource location load errors are owned by the controller', () async {
|
||||
final repository = _ResourceRepository()..failLoads = true;
|
||||
final container = ProviderContainer.test(
|
||||
overrides: [
|
||||
resourceLocationSettingsRepositoryProvider.overrideWithValue(
|
||||
repository,
|
||||
),
|
||||
],
|
||||
);
|
||||
await _ready(container, resourceLocationSettingsProvider);
|
||||
final state = container.read(resourceLocationSettingsProvider);
|
||||
expect(state.error, LocationSettingsError.load);
|
||||
expect(state.loading, isFalse);
|
||||
repository.failLoads = false;
|
||||
await container
|
||||
.read(resourceLocationSettingsProvider.notifier)
|
||||
.save('/new');
|
||||
expect(container.read(resourceLocationSettingsProvider).directory, '/new');
|
||||
expect(container.read(resourceLocationSettingsProvider).error, isNull);
|
||||
});
|
||||
|
||||
test(
|
||||
'resource save failures retain the path and allow a later save',
|
||||
() async {
|
||||
final repository = _ResourceRepository();
|
||||
final container = ProviderContainer.test(
|
||||
overrides: [
|
||||
resourceLocationSettingsRepositoryProvider.overrideWithValue(
|
||||
repository,
|
||||
),
|
||||
],
|
||||
);
|
||||
await _ready(container, resourceLocationSettingsProvider);
|
||||
final controller = container.read(
|
||||
resourceLocationSettingsProvider.notifier,
|
||||
);
|
||||
repository.failWrites = true;
|
||||
await controller.save('/new');
|
||||
final failed = container.read(resourceLocationSettingsProvider);
|
||||
expect(failed.directory, '/resources');
|
||||
expect(failed.error, LocationSettingsError.save);
|
||||
expect(failed.saving, isFalse);
|
||||
repository.failWrites = false;
|
||||
await controller.save('/new');
|
||||
final saved = container.read(resourceLocationSettingsProvider);
|
||||
expect(saved.directory, '/new');
|
||||
expect(saved.error, isNull);
|
||||
expect(saved.saving, isFalse);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'closing directory settings during a save skips queued writes safely',
|
||||
() async {
|
||||
final repository = _ResourceRepository()..writeGate = Completer<void>();
|
||||
final container = ProviderContainer(
|
||||
overrides: [
|
||||
resourceLocationSettingsRepositoryProvider.overrideWithValue(
|
||||
repository,
|
||||
),
|
||||
],
|
||||
);
|
||||
await _ready(container, resourceLocationSettingsProvider);
|
||||
final controller = container.read(
|
||||
resourceLocationSettingsProvider.notifier,
|
||||
);
|
||||
final first = controller.save('/first');
|
||||
await repository.started.future;
|
||||
final second = controller.save('/second');
|
||||
container.dispose();
|
||||
repository.writeGate!.complete();
|
||||
await Future.wait([first, second]);
|
||||
expect(repository.value, '/first');
|
||||
expect(repository.writes, ['/first']);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _ready(
|
||||
ProviderContainer container,
|
||||
ProviderListenable<LocationSettingsState> provider, {
|
||||
bool closeAfterReady = false,
|
||||
}) {
|
||||
final completer = Completer<void>();
|
||||
final subscription = container.listen(provider, (_, state) {
|
||||
if (!state.loading && !completer.isCompleted) completer.complete();
|
||||
}, fireImmediately: true);
|
||||
return completer.future.then((_) {
|
||||
if (closeAfterReady) subscription.close();
|
||||
});
|
||||
}
|
||||
|
||||
class _DirectoryInspector extends ProjectLocationDirectory {
|
||||
_DirectoryInspector(this.status);
|
||||
ProjectLocationStatus status;
|
||||
final paths = <String>[];
|
||||
|
||||
@override
|
||||
Future<ProjectLocationStatus> inspect(String path) async {
|
||||
paths.add(path);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
class _ProjectRepository extends MemoryProjectLocationSettingsRepository {
|
||||
_ProjectRepository() : super('/projects');
|
||||
bool failLoads = false;
|
||||
bool failWrites = false;
|
||||
final writes = <String>[];
|
||||
final started = Completer<void>();
|
||||
Completer<void>? writeGate;
|
||||
|
||||
@override
|
||||
Future<String?> load() async {
|
||||
if (failLoads) throw StateError('read failed');
|
||||
return super.load();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> save(String directory) async {
|
||||
writes.add(directory);
|
||||
if (!started.isCompleted) started.complete();
|
||||
await writeGate?.future;
|
||||
if (failWrites) throw StateError('write failed');
|
||||
await super.save(directory);
|
||||
}
|
||||
}
|
||||
|
||||
class _ResourceRepository extends MemoryResourceLocationSettingsRepository {
|
||||
_ResourceRepository() : super('/resources');
|
||||
bool failLoads = false;
|
||||
bool failWrites = false;
|
||||
final writes = <String>[];
|
||||
final started = Completer<void>();
|
||||
Completer<void>? writeGate;
|
||||
|
||||
@override
|
||||
Future<String?> load() async {
|
||||
if (failLoads) throw StateError('read failed');
|
||||
return super.load();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> save(String directory) async {
|
||||
writes.add(directory);
|
||||
if (!started.isCompleted) started.complete();
|
||||
await writeGate?.future;
|
||||
if (failWrites) throw StateError('write failed');
|
||||
await super.save(directory);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user