Give video clips a dedicated color tab with immediate input interpretation, automatic detection, and reset controls. Clarify project output color space, source-stream scope, and unavailable metadata across localized UI text. Share unknown-source color defaults with the SDK and retain independent property tab scroll state. Include localized resources and control previews. Validation: full application analysis, 1261 Flutter tests passed (9 skipped), generated-code verification, and 171 tool tests.
135 lines
5.0 KiB
Dart
135 lines
5.0 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 independently and keep color controls visible',
|
|
(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.byKey(const ValueKey('property-tab-color')));
|
|
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-color')));
|
|
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);
|
|
await tester.tap(find.byKey(const ValueKey('property-tab-picture')));
|
|
await tester.pumpAndSettle();
|
|
expect(find.byKey(const Key('media-color-menu')), findsNothing);
|
|
expect(find.text('素材色彩解释'), findsNothing);
|
|
position().jumpTo(55);
|
|
await tester.pumpAndSettle();
|
|
expect(position().pixels, 55);
|
|
await tester.tap(find.byKey(const ValueKey('property-tab-color')));
|
|
await tester.pumpAndSettle();
|
|
expect(position().pixels, 0);
|
|
expect(find.byKey(const Key('media-color-menu')), findsOneWidget);
|
|
await tester.tap(find.byKey(const ValueKey('property-tab-picture')));
|
|
await tester.pumpAndSettle();
|
|
expect(position().pixels, 55);
|
|
await tester.tap(find.byKey(const ValueKey('property-tab-color')));
|
|
await tester.pumpAndSettle();
|
|
|
|
position().jumpTo(0);
|
|
await tester.pumpAndSettle();
|
|
await switchBack();
|
|
expect(find.byKey(const Key('media-color-menu')), findsOneWidget);
|
|
expect(position().pixels, 0);
|
|
await tester.pumpWidget(const SizedBox());
|
|
},
|
|
);
|
|
}
|