310 lines
11 KiB
Dart
310 lines
11 KiB
Dart
import 'package:cutdex/app/editor_theme.dart';
|
|
import 'package:cutdex/features/editor/layouts/bounded_editor_layout.dart';
|
|
import 'package:cutdex/features/editor/editor_presentation_controller.dart';
|
|
import 'package:cutdex/integrations/platform/device_experience.dart';
|
|
import 'package:cutdex/features/preview/preview_panel.dart';
|
|
import 'package:cutdex/features/properties/picture_properties.dart';
|
|
import 'package:cutdex/features/properties/audio_properties.dart';
|
|
import 'package:cutdex/features/properties/speed_properties.dart';
|
|
import 'package:cutdex_ui/widgets.dart';
|
|
import 'package:cutdex_ui/icons.dart';
|
|
import 'package:cutdex/l10n/app_localizations.dart';
|
|
import 'package:cutdex_sdk/timeline/model.dart';
|
|
import 'package:cutdex_ui/theme.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(
|
|
'floating desktop inspector keeps the UI3 width in narrow windows',
|
|
(tester) async {
|
|
for (final width in [200.0, 320.0, 800.0]) {
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
locale: const Locale('en'),
|
|
theme: EditorTheme.desktop(EditorTheme.penDark),
|
|
home: Scaffold(
|
|
body: Align(
|
|
alignment: Alignment.topRight,
|
|
child: SizedBox(
|
|
width: width,
|
|
height: 400,
|
|
child: BoundedEditorLayout(
|
|
experience: DeviceExperience.desktop,
|
|
editing: const SizedBox.expand(),
|
|
tool: EditorTool.properties,
|
|
media: const SizedBox.expand(),
|
|
properties: const SizedBox.expand(),
|
|
onCloseTool: () {},
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
tester.getSize(find.byKey(const Key('editor-tool-surface'))).width,
|
|
width < 240 ? width : 240,
|
|
);
|
|
final title = tester.widget<Text>(
|
|
find.byWidgetPredicate((w) => w is Text && w.style?.fontSize == 13),
|
|
);
|
|
expect(title.style!.fontSize, 13);
|
|
expect(title.style!.height, 22 / 13);
|
|
expect(tester.takeException(), isNull);
|
|
}
|
|
},
|
|
);
|
|
|
|
testWidgets(
|
|
'audio and speed controls fit desktop group headers at narrow widths',
|
|
(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 query = f.timeline
|
|
.view(SequenceId('one'))
|
|
.version
|
|
.kernelVersion
|
|
.query();
|
|
final clip = query.element(query.elementById(ElementId('clip'))!);
|
|
for (final width in [220.0, 280.0, 360.0]) {
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
locale: const Locale('zh'),
|
|
theme: AppTheme.propertiesPanelTheme(
|
|
EditorTheme.desktop(EditorTheme.penDark),
|
|
),
|
|
home: Scaffold(
|
|
body: Align(
|
|
alignment: Alignment.topLeft,
|
|
child: SizedBox(
|
|
width: width,
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
AudioProperties(
|
|
session: f.timeline,
|
|
sequence: SequenceId('one'),
|
|
clip: clip,
|
|
hasAudio: true,
|
|
),
|
|
SpeedProperties(
|
|
session: f.timeline,
|
|
sequence: SequenceId('one'),
|
|
clip: clip.id,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
final field = find.descendant(
|
|
of: find.byKey(const Key('audio-db')),
|
|
matching: find.byType(TextField),
|
|
);
|
|
expect(tester.getSize(field).height, 24);
|
|
expect(
|
|
tester.getRect(find.byKey(const Key('audio-key'))).center.dy,
|
|
tester.getRect(field).center.dy,
|
|
);
|
|
expect(find.byType(AppPropertyGroup), findsNWidgets(2));
|
|
expect(tester.takeException(), isNull);
|
|
}
|
|
await tester.pumpWidget(const SizedBox());
|
|
},
|
|
);
|
|
|
|
testWidgets('desktop transform grid fits narrow panels in all six themes', (
|
|
tester,
|
|
) async {
|
|
final f = (await tester.runAsync(
|
|
() =>
|
|
createPreviewFixture(Uri.file('/test/photo.png'), mediaType: 'image'),
|
|
))!;
|
|
addTearDown(
|
|
() => tester.runAsync(() async {
|
|
await f.workspace.close();
|
|
await f.directory.delete(recursive: true);
|
|
}),
|
|
);
|
|
final project = f.workspace.project!.info.id;
|
|
final query = f.timeline
|
|
.view(SequenceId('one'))
|
|
.version
|
|
.kernelVersion
|
|
.query();
|
|
final clip = query.element(query.elementById(ElementId('clip'))!);
|
|
final container = ProviderContainer(
|
|
overrides: [
|
|
editorPreviewProvider(project, 'project').overrideWith((ref) => null),
|
|
],
|
|
);
|
|
addTearDown(container.dispose);
|
|
Finder input(String name) => find.descendant(
|
|
of: find.byKey(ValueKey('picture-$name')),
|
|
matching: find.byType(TextField),
|
|
);
|
|
for (final palette in AppPalette.values) {
|
|
for (final brightness in Brightness.values) {
|
|
for (final (width, locale) in [
|
|
(220.0, 'de'),
|
|
(240.0, 'en'),
|
|
(280.0, 'zh'),
|
|
(360.0, 'en'),
|
|
]) {
|
|
await tester.pumpWidget(
|
|
UncontrolledProviderScope(
|
|
container: container,
|
|
child: MaterialApp(
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
locale: Locale(locale),
|
|
theme: AppTheme.propertiesPanelTheme(
|
|
EditorTheme.desktop(
|
|
EditorTheme.forPalette(palette, brightness),
|
|
),
|
|
),
|
|
home: Scaffold(
|
|
body: Align(
|
|
alignment: Alignment.topLeft,
|
|
child: SizedBox(
|
|
width: width,
|
|
child: SingleChildScrollView(
|
|
child: PictureProperties(
|
|
projectId: project,
|
|
timelineId: 'project',
|
|
session: f.timeline,
|
|
sequence: SequenceId('one'),
|
|
clip: clip,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
for (final name in ['x', 'y', 'scale-x', 'scale-y', 'rotation']) {
|
|
expect(tester.getSize(input(name)).height, 24);
|
|
}
|
|
expect(tester.getRect(input('x')).left, 16);
|
|
expect(tester.getRect(input('x')).width, (width - 64) / 2);
|
|
expect(tester.getRect(input('rotation')).width, (width - 64) / 2);
|
|
expect(find.byType(AppPropertyGroup), findsNWidgets(4));
|
|
expect(
|
|
tester.getRect(input('corner-radius')).width,
|
|
(width - 64) / 2,
|
|
);
|
|
expect(
|
|
tester.getSize(find.byType(AppPropertySection).first).height,
|
|
148,
|
|
);
|
|
final align = find.byKey(const ValueKey('picture-align-left'));
|
|
final verticalAlign = find.byKey(const ValueKey('picture-align-top'));
|
|
expect(
|
|
tester.getCenter(align).dy,
|
|
tester.getCenter(verticalAlign).dy,
|
|
);
|
|
for (final name in ['x', 'y', 'scale-x', 'scale-y', 'rotation']) {
|
|
final field = tester.widget<TextField>(input(name));
|
|
expect(field.decoration!.prefixIcon, isNotNull);
|
|
final handle = find.descendant(
|
|
of: find.byKey(ValueKey('picture-$name')),
|
|
matching: find.byType(AppScrubLabel),
|
|
);
|
|
expect(tester.getSize(handle).width, 24);
|
|
}
|
|
expect(
|
|
find.descendant(
|
|
of: find.byKey(const ValueKey('picture-rotation')),
|
|
matching: find.byIcon(AppIcons.angle),
|
|
),
|
|
findsOneWidget,
|
|
);
|
|
final xLabel = find.descendant(
|
|
of: find.byKey(const ValueKey('picture-x')),
|
|
matching: find.text('X'),
|
|
);
|
|
expect(
|
|
tester.getRect(xLabel).center.dy,
|
|
tester.getRect(input('x')).center.dy,
|
|
);
|
|
final right = tester
|
|
.getRect(find.byKey(const ValueKey('picture-key-position')))
|
|
.right;
|
|
for (final channel in ['position', 'scale', 'rotation']) {
|
|
final action = find.byKey(ValueKey('picture-key-$channel'));
|
|
expect(tester.getSize(action), const Size.square(24));
|
|
expect(tester.getRect(action).right, right);
|
|
final field = input(
|
|
channel == 'position'
|
|
? 'x'
|
|
: channel == 'scale'
|
|
? 'scale-x'
|
|
: 'rotation',
|
|
);
|
|
if (channel == 'scale') {
|
|
expect(
|
|
tester.getRect(action).bottom,
|
|
tester.getRect(field).top - 12,
|
|
);
|
|
} else {
|
|
expect(tester.getCenter(action).dy, tester.getCenter(field).dy);
|
|
}
|
|
}
|
|
expect(
|
|
tester.getCenter(find.byKey(const Key('picture-lock'))).dy,
|
|
tester.getCenter(input('scale-x')).dy,
|
|
);
|
|
expect(right, width - 8);
|
|
expect(
|
|
tester.getRect(input('x')).left,
|
|
tester.getRect(input('rotation')).left,
|
|
);
|
|
if (width >= 220) {
|
|
expect(
|
|
tester.getCenter(input('x')).dy,
|
|
tester.getCenter(input('y')).dy,
|
|
);
|
|
expect(
|
|
tester.getCenter(input('scale-x')).dy,
|
|
tester.getCenter(input('scale-y')).dy,
|
|
);
|
|
expect(
|
|
tester.getRect(input('rotation')).top -
|
|
tester.getRect(input('x')).bottom,
|
|
8,
|
|
);
|
|
}
|
|
expect(
|
|
tester.takeException(),
|
|
isNull,
|
|
reason: '$palette $brightness $locale $width',
|
|
);
|
|
}
|
|
}
|
|
}
|
|
await tester.pumpWidget(const SizedBox());
|
|
});
|
|
}
|