feat(workspace): refresh desktop editing experience and prepare 0.1.2
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
This commit is contained in:
1 parent
aa5255d1e4
commit
2e0033ce2d
260 files changed
+43963
-5591
No files matched your search
@@ -87,4 +87,95 @@ void main() {
|
||||
}
|
||||
},
|
||||
);
|
||||
test(
|
||||
'LRU trims idle output but preserves leased controllers until release',
|
||||
() async {
|
||||
var sessionId = 0;
|
||||
final closed = <String>[];
|
||||
for (final id in ['1', '2', '3']) {
|
||||
final events = MethodChannel('cutdex_runtime/sessions/$id');
|
||||
messenger.setMockMethodCallHandler(events, (call) async {
|
||||
if (call.method == 'listen') {
|
||||
scheduleMicrotask(
|
||||
() => messenger.handlePlatformMessage(
|
||||
events.name,
|
||||
const StandardMethodCodec().encodeSuccessEnvelope({
|
||||
'type': 'attached',
|
||||
}),
|
||||
(_) {},
|
||||
),
|
||||
);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
switch (call.method) {
|
||||
case 'capabilities':
|
||||
return {
|
||||
'contractVersion': 1,
|
||||
'features': {'playback.preview': 'available'},
|
||||
};
|
||||
case 'createSession':
|
||||
return {'sessionId': '${++sessionId}'};
|
||||
case 'probe':
|
||||
return {
|
||||
'duration': MediaTime(2, 1).toMap(),
|
||||
'videoTrackCount': 1,
|
||||
'videoTrackIds': [1],
|
||||
'audioTrackCount': 0,
|
||||
'audioTrackIds': <int>[],
|
||||
'isProtected': false,
|
||||
};
|
||||
case 'load':
|
||||
return (call.arguments as Map)['plan']['revision'];
|
||||
case 'close':
|
||||
closed.add((call.arguments as Map)['sessionId'] as String);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
final first = await createPreviewFixture(Uri.file('/fixture-1.mov'));
|
||||
final second = await createPreviewFixture(Uri.file('/fixture-2.mov'));
|
||||
final third = await createPreviewFixture(Uri.file('/fixture-3.mov'));
|
||||
final registry = PreviewControllerRegistry(
|
||||
CutdexRuntime(channel: channel),
|
||||
maximumCachedControllers: 2,
|
||||
);
|
||||
try {
|
||||
final releaseFirst = registry.retain(('p', 'first'));
|
||||
final releaseSecond = registry.retain(('p', 'second'));
|
||||
final releaseThird = registry.retain(('p', 'third'));
|
||||
final one = await registry.prepare(('p', 'first'), first.timeline);
|
||||
final two = await registry.prepare(('p', 'second'), second.timeline);
|
||||
final three = await registry.prepare(('p', 'third'), third.timeline);
|
||||
expect(one!.ready, isTrue);
|
||||
expect(two!.ready, isTrue);
|
||||
expect(three!.ready, isTrue);
|
||||
expect(registry.cached(('p', 'first')), same(one));
|
||||
releaseFirst();
|
||||
expect(registry.cached(('p', 'first')), isNull);
|
||||
expect(registry.cached(('p', 'second')), same(two));
|
||||
expect(registry.cached(('p', 'third')), same(three));
|
||||
releaseFirst(); // Releases are idempotent.
|
||||
releaseSecond();
|
||||
releaseThird();
|
||||
await registry.invalidate(('p', 'second'));
|
||||
await registry.invalidate(('p', 'third'));
|
||||
expect(closed.toSet(), {'1', '2', '3'});
|
||||
} finally {
|
||||
registry.dispose();
|
||||
for (final id in ['1', '2', '3']) {
|
||||
messenger.setMockMethodCallHandler(
|
||||
MethodChannel('cutdex_runtime/sessions/$id'),
|
||||
null,
|
||||
);
|
||||
}
|
||||
messenger.setMockMethodCallHandler(channel, null);
|
||||
for (final fixture in [first, second, third]) {
|
||||
await fixture.workspace.close();
|
||||
await fixture.directory.delete(recursive: true);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cutdex/persistence/app_database.dart';
|
||||
import 'package:cutdex/persistence/app_settings_repositories.dart';
|
||||
import 'package:cutdex/workspace/persistence/recent_projects.dart';
|
||||
import 'package:cutdex/workspace/projects.dart';
|
||||
import 'package:cutdex/workspace/view_settings.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../support/memory_app_settings.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
for (final superseded in [false, true]) {
|
||||
test(
|
||||
'project layout is prepared before publication (superseded: $superseded)',
|
||||
() async {
|
||||
final root = await Directory.systemTemp.createTemp(
|
||||
'cutdex-project-layout-',
|
||||
);
|
||||
final database = AppDatabase(NativeDatabase.memory());
|
||||
final layouts = _DelayedLayouts();
|
||||
final container = ProviderContainer(
|
||||
overrides: [
|
||||
appDatabaseProvider.overrideWithValue(database),
|
||||
recentProjectsProvider.overrideWithValue(
|
||||
MemoryRecentProjectsRepository(),
|
||||
),
|
||||
resourceLocationSettingsRepositoryProvider.overrideWithValue(
|
||||
MemoryResourceLocationSettingsRepository(root.path),
|
||||
),
|
||||
projectViewSettingsRepositoryProvider.overrideWithValue(layouts),
|
||||
],
|
||||
);
|
||||
try {
|
||||
final projects = container.read(projectsProvider.notifier);
|
||||
expect(
|
||||
await projects.open('${root.path}/First.cutdex', name: 'First'),
|
||||
isTrue,
|
||||
);
|
||||
final initial = container.read(projectsProvider).requireValue;
|
||||
var current = true;
|
||||
final opening = projects.open(
|
||||
'${root.path}/Second.cutdex',
|
||||
name: 'Second',
|
||||
isCurrent: () => current,
|
||||
);
|
||||
final targetId = await layouts.requested.future;
|
||||
expect(
|
||||
container.read(projectsProvider).requireValue.activeProject,
|
||||
initial.activeProject,
|
||||
);
|
||||
expect(
|
||||
container.read(projectsProvider).requireValue.timeline,
|
||||
initial.timeline,
|
||||
);
|
||||
expect(
|
||||
container.read(projectsProvider).requireValue.projectBusy,
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
container.read(projectViewSettingsProvider(targetId)).isLoading,
|
||||
isTrue,
|
||||
);
|
||||
current = !superseded;
|
||||
layouts.prepared.complete(
|
||||
const ProjectViewSettingsData(
|
||||
propertiesOpen: true,
|
||||
timelineHeight: 320,
|
||||
),
|
||||
);
|
||||
expect(await opening, !superseded);
|
||||
final published = container.read(projectsProvider).requireValue;
|
||||
expect(
|
||||
published.activeProject?.id,
|
||||
superseded ? initial.activeProject!.id : targetId,
|
||||
);
|
||||
expect(published.projectBusy, isFalse);
|
||||
expect(published.error, isNull);
|
||||
expect(
|
||||
container
|
||||
.read(projectViewSettingsProvider(targetId))
|
||||
.requireValue
|
||||
.propertiesOpen,
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
container
|
||||
.read(projectViewSettingsProvider(targetId))
|
||||
.requireValue
|
||||
.timelineHeight,
|
||||
320,
|
||||
);
|
||||
} finally {
|
||||
await container.read(projectsProvider.notifier).prepareToQuit();
|
||||
container.dispose();
|
||||
await database.close();
|
||||
await root.delete(recursive: true);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _DelayedLayouts implements ProjectViewSettingsRepository {
|
||||
String? _firstProjectId;
|
||||
final requested = Completer<String>();
|
||||
final prepared = Completer<ProjectViewSettingsData>();
|
||||
@override
|
||||
Future<ProjectViewSettingsData> load(String projectId) async {
|
||||
_firstProjectId ??= projectId;
|
||||
if (projectId == _firstProjectId) return const ProjectViewSettingsData();
|
||||
requested.complete(projectId);
|
||||
return prepared.future;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> save(String projectId, ProjectViewSettingsData settings) async {}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cutdex/features/projects/project_tabs_controller.dart';
|
||||
import 'package:cutdex/integrations/platform/device_experience.dart';
|
||||
import 'package:cutdex/persistence/app_settings_repositories.dart';
|
||||
import 'package:cutdex/workspace/persistence/recent_projects.dart';
|
||||
import 'package:cutdex/workspace/projects.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../support/memory_app_settings.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
test(
|
||||
'closing active project preserves files, history and a reusable session',
|
||||
() async {
|
||||
final root = await Directory.systemTemp.createTemp(
|
||||
'cutdex-project-tabs-',
|
||||
);
|
||||
final container = ProviderContainer(
|
||||
overrides: [
|
||||
deviceExperienceProvider.overrideWithValue(DeviceExperience.desktop),
|
||||
recentProjectsProvider.overrideWithValue(
|
||||
MemoryRecentProjectsRepository(),
|
||||
),
|
||||
resourceLocationSettingsRepositoryProvider.overrideWithValue(
|
||||
MemoryResourceLocationSettingsRepository(root.path),
|
||||
),
|
||||
],
|
||||
);
|
||||
final projects = container.read(projectsProvider.notifier);
|
||||
final tabs = container.read(projectTabsProvider.notifier);
|
||||
try {
|
||||
expect(
|
||||
await projects.open('${root.path}/One.cutdex', name: 'One'),
|
||||
isTrue,
|
||||
);
|
||||
final first = container.read(projectsProvider).requireValue;
|
||||
final session = await projects.openTimelineSession(
|
||||
first.activeProject!.id,
|
||||
first.timeline!.id,
|
||||
);
|
||||
final view = session.view(session.activeSequenceId!);
|
||||
view.seekTo(100);
|
||||
expect(
|
||||
await projects.open('${root.path}/Two.cutdex', name: 'Two'),
|
||||
isTrue,
|
||||
);
|
||||
final second = container
|
||||
.read(projectsProvider)
|
||||
.requireValue
|
||||
.activeProject!;
|
||||
expect(
|
||||
container.read(projectTabsProvider).map((project) => project.id),
|
||||
[first.activeProject!.id, second.id],
|
||||
);
|
||||
expect(await projects.closeActiveProject(), isTrue);
|
||||
tabs.remove(second.id);
|
||||
final closed = container.read(projectsProvider).requireValue;
|
||||
expect(closed.activeProject, isNull);
|
||||
expect(closed.timeline, isNull);
|
||||
expect(closed.assets, isEmpty);
|
||||
expect(closed.recent.length, 2);
|
||||
expect(await File('${second.path}/manifest.json').exists(), isTrue);
|
||||
expect(await projects.open(first.activeProject!.path), isTrue);
|
||||
final reopened = await projects.openTimelineSession(
|
||||
first.activeProject!.id,
|
||||
first.timeline!.id,
|
||||
);
|
||||
expect(reopened, same(session));
|
||||
expect(reopened.view(reopened.activeSequenceId!), same(view));
|
||||
expect(view.playheadTick, 100);
|
||||
expect(
|
||||
container.read(projectTabsProvider).map((project) => project.id),
|
||||
[first.activeProject!.id],
|
||||
);
|
||||
} finally {
|
||||
await projects.prepareToQuit();
|
||||
container.dispose();
|
||||
await root.delete(recursive: true);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cutdex/errors/app_failure.dart';
|
||||
import 'package:cutdex/integrations/platform/device_experience.dart';
|
||||
import 'package:cutdex/persistence/app_settings_repositories.dart';
|
||||
import 'package:cutdex/workspace/persistence/recent_projects.dart';
|
||||
import 'package:cutdex/workspace/projects.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../support/memory_app_settings.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
group('project creation collisions', () {
|
||||
late Directory root;
|
||||
late ProviderContainer container;
|
||||
late Projects projects;
|
||||
|
||||
setUp(() async {
|
||||
root = await Directory.systemTemp.createTemp('cutdex-name-conflict-');
|
||||
container = ProviderContainer(
|
||||
overrides: [
|
||||
deviceExperienceProvider.overrideWithValue(DeviceExperience.desktop),
|
||||
recentProjectsProvider.overrideWithValue(
|
||||
MemoryRecentProjectsRepository(),
|
||||
),
|
||||
projectLocationSettingsRepositoryProvider.overrideWithValue(
|
||||
DefaultingProjectLocationSettingsRepository(
|
||||
MemoryProjectLocationSettingsRepository(root.path),
|
||||
),
|
||||
),
|
||||
resourceLocationSettingsRepositoryProvider.overrideWithValue(
|
||||
MemoryResourceLocationSettingsRepository(root.path),
|
||||
),
|
||||
],
|
||||
);
|
||||
projects = container.read(projectsProvider.notifier);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await projects.prepareToQuit();
|
||||
container.dispose();
|
||||
await root.delete(recursive: true);
|
||||
});
|
||||
|
||||
test(
|
||||
'duplicate creation preserves the existing project and session',
|
||||
() async {
|
||||
expect(
|
||||
await projects.createProject('One', initialTimelineName: 'Timeline'),
|
||||
isTrue,
|
||||
);
|
||||
final before = container.read(projectsProvider).requireValue;
|
||||
final project = before.activeProject!;
|
||||
final session = await projects.openTimelineSession(
|
||||
project.id,
|
||||
before.timeline!.id,
|
||||
);
|
||||
final manifest = File('${project.path}/manifest.json');
|
||||
final contents = await manifest.readAsString();
|
||||
expect(
|
||||
(await projects.validateNewProjectName(' One '))?.code,
|
||||
AppErrorCode.projectAlreadyExists,
|
||||
);
|
||||
expect(container.read(projectsProvider).requireValue.error, isNull);
|
||||
|
||||
expect(
|
||||
await projects.createProject(
|
||||
' One ',
|
||||
initialTimelineName: 'Replacement',
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
final after = container.read(projectsProvider).requireValue;
|
||||
expect(after.error?.code, AppErrorCode.projectAlreadyExists);
|
||||
expect(after.activeProject?.id, project.id);
|
||||
expect(after.timeline?.id, before.timeline?.id);
|
||||
expect(after.recent, before.recent);
|
||||
expect(await manifest.readAsString(), contents);
|
||||
expect(
|
||||
await projects.openTimelineSession(project.id, before.timeline!.id),
|
||||
same(session),
|
||||
);
|
||||
|
||||
expect(await projects.validateNewProjectName('Two'), isNull);
|
||||
expect(
|
||||
await projects.createProject('Two', initialTimelineName: 'Timeline'),
|
||||
isTrue,
|
||||
);
|
||||
expect(container.read(projectsProvider).requireValue.error, isNull);
|
||||
expect(
|
||||
container.read(projectsProvider).requireValue.activeProject?.name,
|
||||
'Two',
|
||||
);
|
||||
expect(await manifest.readAsString(), contents);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'creation detects a destination occupied after name validation',
|
||||
() async {
|
||||
expect(await projects.validateNewProjectName('Racing'), isNull);
|
||||
final destination = File('${root.path}/Racing.cutdex');
|
||||
await destination.writeAsString('created by another operation');
|
||||
expect(
|
||||
await projects.createProject(
|
||||
'Racing',
|
||||
initialTimelineName: 'Timeline',
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
container.read(projectsProvider).requireValue.error?.code,
|
||||
AppErrorCode.projectAlreadyExists,
|
||||
);
|
||||
expect(
|
||||
await destination.readAsString(),
|
||||
'created by another operation',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
for (final type in ['file', 'directory', 'broken link']) {
|
||||
test('occupied $type is reported without replacing it', () async {
|
||||
final destination = '${root.path}/Occupied.cutdex';
|
||||
switch (type) {
|
||||
case 'file':
|
||||
await File(destination).writeAsString('keep this file');
|
||||
case 'directory':
|
||||
await Directory(destination).create();
|
||||
await File('$destination/keep.txt')
|
||||
.writeAsString('keep this directory');
|
||||
case 'broken link':
|
||||
await Link(destination).create('${root.path}/missing-target');
|
||||
}
|
||||
final before = await FileSystemEntity.type(
|
||||
destination,
|
||||
followLinks: false,
|
||||
);
|
||||
expect(
|
||||
(await projects.validateNewProjectName('Occupied'))?.code,
|
||||
AppErrorCode.projectAlreadyExists,
|
||||
);
|
||||
expect(
|
||||
await projects.createProject(
|
||||
'Occupied',
|
||||
initialTimelineName: 'Timeline',
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
final state = container.read(projectsProvider).requireValue;
|
||||
expect(state.error?.code, AppErrorCode.projectAlreadyExists);
|
||||
expect(state.activeProject, isNull);
|
||||
expect(state.recent, isEmpty);
|
||||
expect(
|
||||
await FileSystemEntity.type(destination, followLinks: false),
|
||||
before,
|
||||
);
|
||||
switch (type) {
|
||||
case 'file':
|
||||
expect(await File(destination).readAsString(), 'keep this file');
|
||||
case 'directory':
|
||||
expect(
|
||||
await File('$destination/keep.txt').readAsString(),
|
||||
'keep this directory',
|
||||
);
|
||||
case 'broken link':
|
||||
expect(
|
||||
await Link(destination).target(),
|
||||
'${root.path}/missing-target',
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:cutdex/workspace/timeline_session.dart';
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
@@ -209,7 +211,13 @@ void main() {
|
||||
|
||||
testWidgets('pending tabs accept a newer real click', (tester) async {
|
||||
final widgetContainer = ProviderContainer(
|
||||
overrides: [projectsProvider.overrideWith(_PendingProjects.new)],
|
||||
overrides: [
|
||||
projectsProvider.overrideWith(_PendingProjects.new),
|
||||
editorTimelineProvider(
|
||||
'project',
|
||||
'a',
|
||||
).overrideWith((ref) => Completer<EditorTimelineSession>().future),
|
||||
],
|
||||
);
|
||||
addTearDown(widgetContainer.dispose);
|
||||
await tester.pumpWidget(
|
||||
@@ -226,7 +234,7 @@ void main() {
|
||||
if (state == null) return const SizedBox();
|
||||
return EditorWorkspace(
|
||||
projectId: 'project',
|
||||
timelineId: state.visibleTimelineId!,
|
||||
timelineId: state.timeline!.id,
|
||||
projectName: 'Project',
|
||||
integratedTitlebar: false,
|
||||
headerLeading: const SizedBox(),
|
||||
@@ -247,7 +255,7 @@ void main() {
|
||||
final panel = tester.widget<EditorTimelinePanel>(
|
||||
find.byType(EditorTimelinePanel),
|
||||
);
|
||||
expect(panel.timelineId, 'b');
|
||||
expect(panel.timelineId, 'a');
|
||||
await tester.tap(find.byKey(const ValueKey('timeline-tab-c')));
|
||||
await tester.pump();
|
||||
expect(
|
||||
@@ -258,7 +266,7 @@ void main() {
|
||||
tester
|
||||
.widget<EditorTimelinePanel>(find.byType(EditorTimelinePanel))
|
||||
.timelineId,
|
||||
'c',
|
||||
'a',
|
||||
);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user