feat(workspace): 桌面工作区、主题与交互更新,发布 0.1.2
Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s

This commit was merged in pull request #13.
This commit is contained in:
lingjhf committed 2026-10-08 18:17:12 +00:00
1 parent aa5255d1e4
commit abc1868550
260 files changed
+43964 -5591

No files matched your search

+249
View File
@@ -0,0 +1,249 @@
import 'dart:async';
import 'package:cutdex/app/app.dart';
import 'package:cutdex/features/editor/editor_panel_defaults.dart';
import 'package:cutdex/features/preview/preview_panel.dart';
import 'package:cutdex/features/properties/project_properties.dart';
import 'package:cutdex/integrations/agent/conversation_repository.dart';
import 'package:cutdex/integrations/platform/device_experience.dart';
import 'package:cutdex/persistence/app_database.dart';
import 'package:cutdex/persistence/app_settings_repositories.dart';
import 'package:cutdex/workspace/media_availability.dart';
import 'package:cutdex/workspace/project_state.dart';
import 'package:cutdex/workspace/projects.dart';
import 'package:cutdex/workspace/timeline_provider.dart';
import 'package:cutdex/workspace/view_settings.dart';
import 'package:cutdex/workspace/workspace_navigation.dart';
import 'package:cutdex_sdk/project.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:drift/native.dart';
import 'support/empty_conversation_repository.dart';
import 'support/memory_app_settings.dart';
import 'support/preview_fixture.dart';
void main() {
testWidgets(
'project navigation retains panels and rebinds only prepared values',
(tester) async {
tester.view.physicalSize = const Size(1800, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final first = (await tester.runAsync(
() => createPreviewFixture(
Uri.file('/test/first.png'),
mediaType: 'image',
),
))!;
final second = (await tester.runAsync(
() => createPreviewFixture(
Uri.file('/test/second.png'),
mediaType: 'image',
renderSize: {'width': 1920, 'height': 1080},
),
))!;
final projects = _DelayedProjects();
final database = AppDatabase(NativeDatabase.memory());
final container = ProviderContainer(
overrides: [
deviceExperienceProvider.overrideWithValue(DeviceExperience.desktop),
appDatabaseProvider.overrideWithValue(database),
appearanceSettingsRepositoryProvider.overrideWithValue(
MemoryAppearanceSettingsRepository(),
),
paletteSettingsRepositoryProvider.overrideWithValue(
MemoryPaletteSettingsRepository(),
),
projectsProvider.overrideWith(() => projects),
conversationRepositoryProvider.overrideWith(
(ref) async => EmptyConversationRepository(),
),
editorTimelineProvider(
'project',
'first',
).overrideWith((ref) => first.timeline),
editorTimelineProvider(
'other',
'second',
).overrideWith((ref) => second.timeline),
editorPreviewProvider.overrideWith((ref, ids) => null),
mediaAvailabilityProvider.overrideWith(
(ref, ids) async => MediaAvailability.missing,
),
],
);
addTearDown(() async {
await tester.pumpWidget(const SizedBox());
container.dispose();
await tester.runAsync(() async {
await first.workspace.close();
await second.workspace.close();
await first.directory.delete(recursive: true);
await second.directory.delete(recursive: true);
await database.close();
});
});
await tester.pumpWidget(
UncontrolledProviderScope(
container: container,
child: const CutdexApp(),
),
);
await tester.pumpAndSettle();
await tester.runAsync(() async {
for (final id in ['project', 'other']) {
await container.read(projectViewSettingsProvider(id).future);
container
.read(projectViewSettingsProvider(id).notifier)
.setPropertiesOpen(true);
}
});
await tester.pumpAndSettle();
final properties = tester.element(find.byType(ProjectProperties));
final preview = tester.element(find.byType(EditorPreviewPanel));
final timeline = tester.element(
find.byKey(const Key('editor-timeline-surface')),
);
final propertyRect = tester.getRect(find.byType(ProjectProperties));
final canvasValue = tester.element(find.text('1080 × 1920 px'));
for (final success in [false, true]) {
await tester.tap(find.byKey(const Key('project-tabs-projects')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('project-menu-other')));
await tester.pump();
await tester.pump();
expect(
container.read(workspaceNavigationProvider).selectedProjectId,
'other',
);
final tab = find.byKey(const ValueKey('project-tab-other'));
expect(tab, findsOneWidget);
expect(tester.widget<TextButton>(tab).onPressed, isNotNull);
expect(
tester
.widgetList<Semantics>(
find.ancestor(of: tab, matching: find.byType(Semantics)),
)
.any((widget) => widget.properties.selected == true),
isTrue,
);
expect(
find.descendant(
of: find.byKey(const Key('window-project-tabs')),
matching: find.byType(CircularProgressIndicator),
),
findsNothing,
);
await tester.pump(const Duration(seconds: 2));
expect(
tester.element(find.byType(ProjectProperties)),
same(properties),
);
expect(tester.element(find.byType(EditorPreviewPanel)), same(preview));
expect(
tester.element(find.byKey(const Key('editor-timeline-surface'))),
same(timeline),
);
expect(tester.getRect(find.byType(ProjectProperties)), propertyRect);
expect(find.byType(EditorEmptyPanel), findsNothing);
expect(find.byKey(const Key('properties-pending')), findsNothing);
expect(find.byKey(const Key('timeline-default-tracks')), findsNothing);
expect(find.text('1080 × 1920 px'), findsOneWidget);
await tester.tap(
find.byKey(const ValueKey('project-settings-edit')),
warnIfMissed: false,
);
await tester.pump();
expect(find.byKey(const ValueKey('project-width')), findsNothing);
projects.finish(success);
await tester.pumpAndSettle();
expect(
container.read(workspaceNavigationProvider).selectedProjectId,
isNull,
);
expect(
projects.state.requireValue.activeProject?.id,
success ? 'other' : 'project',
);
expect(
find.byKey(const ValueKey('project-tab-other')),
success ? findsOneWidget : findsNothing,
);
expect(
tester.element(find.byType(ProjectProperties)),
same(properties),
);
expect(tester.getRect(find.byType(ProjectProperties)), propertyRect);
expect(tester.element(find.byType(EditorPreviewPanel)), same(preview));
expect(
find.text(success ? '1920 × 1080 px' : '1080 × 1920 px'),
findsOneWidget,
);
expect(
tester.element(
find.text(success ? '1920 × 1080 px' : '1080 × 1920 px'),
),
same(canvasValue),
);
expect(tester.takeException(), isNull);
}
await tester.tap(find.byKey(const ValueKey('project-settings-edit')));
await tester.pumpAndSettle();
expect(find.byKey(const ValueKey('project-width')), findsOneWidget);
},
);
}
class _DelayedProjects extends Projects {
Completer<bool>? _pending;
static const recent = [
RecentProject(
id: 'project',
name: 'First project',
path: '/test/First.cutdex',
),
RecentProject(
id: 'other',
name: 'Second project',
path: '/test/Second.cutdex',
),
];
TimelineDocument _document(String id) =>
TimelineDocument(id: id, name: id, sequences: []);
@override
Future<ProjectState> build() async => ProjectState(
activeProject: recent.first,
recent: recent,
timelines: const [TimelineSummary(id: 'first', name: 'First', revision: 1)],
timeline: _document('first'),
);
@override
Future<bool> open(
String directory, {
String? name,
String? expectedId,
String? timelineId,
String? initialTimelineName,
bool Function()? isCurrent,
}) async {
_pending = Completer<bool>();
state = AsyncData(state.requireValue.copyWith(projectBusy: true));
final success = await _pending!.future && (isCurrent?.call() ?? true);
state = AsyncData(
state.requireValue.copyWith(
projectBusy: false,
activeProject: success ? recent.last : state.requireValue.activeProject,
timelines: success
? const [TimelineSummary(id: 'second', name: 'Second', revision: 1)]
: state.requireValue.timelines,
timeline: success ? _document('second') : state.requireValue.timeline,
),
);
return success;
}
void finish(bool success) => _pending!.complete(success);
}