Files
cutdex/test/properties_scroll_state_test.dart
T
lingjhf abc1868550
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
feat(workspace): 桌面工作区、主题与交互更新,发布 0.1.2
2026-10-08 18:17:12 +00:00

127 lines
4.4 KiB
Dart

import 'package:cutdex/app/editor_theme.dart';
import 'package:cutdex/features/preview/preview_panel.dart';
import 'package:cutdex/features/properties/properties_panel.dart';
import 'package:cutdex/l10n/app_localizations.dart';
import 'package:cutdex/workspace/timeline_provider.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'support/preview_fixture.dart';
void main() {
testWidgets(
'property categories restore scroll and expansion independently',
(tester) async {
final f = (await tester.runAsync(
() => createPreviewFixture(Uri.file('/test/video.mov'), hasAudio: true),
))!;
addTearDown(
() => tester.runAsync(() async {
await f.workspace.close();
await f.directory.delete(recursive: true);
}),
);
final project = f.workspace.project!.info.id;
final view = f.timeline.view(SequenceId('one'));
view.setSelection([
view.version.kernelVersion.query().elementById(ElementId('clip'))!,
]);
final container = ProviderContainer(
overrides: [
editorTimelineProvider(
project,
'project',
).overrideWith((_) => f.timeline),
editorPreviewProvider(project, 'project').overrideWith((_) => null),
],
);
addTearDown(container.dispose);
final bucket = PageStorageBucket();
Widget host(Widget child) => UncontrolledProviderScope(
container: container,
child: MaterialApp(
theme: EditorTheme.desktop(EditorTheme.penDark),
locale: const Locale('zh'),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: Scaffold(
body: Align(
alignment: Alignment.topLeft,
child: SizedBox(
width: 280,
height: 240,
child: PageStorage(bucket: bucket, child: child),
),
),
),
),
);
// A running app can still have the old bool saved when hot reloaded.
await tester.pumpWidget(
host(
Builder(
key: PageStorageKey((ElementId('clip'), PropertyCategory.picture)),
builder: (context) {
bucket.writeState(context, true);
return const SizedBox();
},
),
),
);
await tester.pumpWidget(
host(EditorPropertiesPanel(projectId: project, timelineId: 'project')),
);
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
expect(find.byKey(const Key('media-color-menu')), findsNothing);
await tester.tap(find.text('素材色彩解释'));
await tester.pumpAndSettle();
expect(find.byKey(const Key('media-color-menu')), findsOneWidget);
Future<void> switchBack() async {
await tester.tap(find.byKey(const ValueKey('property-tab-audio')));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
await tester.tap(find.byKey(const ValueKey('property-tab-picture')));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
}
ScrollPosition position() {
final scrollView = find.byWidgetPredicate(
(widget) =>
widget is SingleChildScrollView &&
widget.scrollDirection == Axis.vertical,
);
return tester
.state<ScrollableState>(
find
.descendant(of: scrollView, matching: find.byType(Scrollable))
.first,
)
.position;
}
await switchBack();
expect(find.byKey(const Key('media-color-menu')), findsOneWidget);
position().jumpTo(55);
await tester.pumpAndSettle();
expect(position().pixels, 55);
await switchBack();
expect(position().pixels, 55);
expect(find.byKey(const Key('media-color-menu')), findsOneWidget);
position().jumpTo(0);
await tester.pumpAndSettle();
await tester.tap(find.text('素材色彩解释'));
await tester.pumpAndSettle();
await switchBack();
expect(find.byKey(const Key('media-color-menu')), findsNothing);
expect(position().pixels, 0);
await tester.pumpWidget(const SizedBox());
},
);
}