Preview quick switch styles with the real local workspace
This commit is contained in:
@@ -187,7 +187,7 @@ void main() {
|
||||
selected,
|
||||
reason: '$destination: $rowKey after opening $key',
|
||||
);
|
||||
// Every list uses the shared row and its highlight.
|
||||
// Every list retains shared row semantics; features may supply their own fill.
|
||||
final context = tester.element(row);
|
||||
expect(tester.widget<AppListRow>(row).selected, selected);
|
||||
final surface = find.descendant(
|
||||
@@ -199,10 +199,11 @@ void main() {
|
||||
? tester.widget<ColoredBox>(surface).color
|
||||
: tester.widget<Material>(surface).color,
|
||||
selected
|
||||
? AppListRow.selectedColor(
|
||||
context,
|
||||
cupertino: cupertino,
|
||||
)
|
||||
? tester.widget<AppListRow>(row).selectedFill ??
|
||||
AppListRow.selectedColor(
|
||||
context,
|
||||
cupertino: cupertino,
|
||||
)
|
||||
: const Color(0x00000000),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/settings/quick_switch_preview.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
|
||||
import 'package:pipelines_app/ui/motion/quick_switch_animation.dart';
|
||||
|
||||
Widget _host(QuickSwitchAnimation style, {bool reduced = false}) => MaterialApp(
|
||||
home: Scaffold(
|
||||
body: MediaQuery(
|
||||
data: MediaQueryData(disableAnimations: reduced),
|
||||
child: SingleChildScrollView(child: QuickSwitchPreview(animation: style)),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
void main() {
|
||||
testWidgets('preview replays the real local workspace with chosen style', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(_host(QuickSwitchAnimation.cardStack));
|
||||
await tester.pumpAndSettle();
|
||||
final workspace = tester.widget<ChatWorkspace>(find.byType(ChatWorkspace));
|
||||
expect(workspace.animationStyle, QuickSwitchAnimation.cardStack);
|
||||
expect(workspace.controller.paneCount, 2);
|
||||
final active = workspace.controller.activePaneId;
|
||||
await tester.tap(find.text('Replay animation'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(workspace.controller.activePaneId, isNot(active));
|
||||
expect(tester.binding.transientCallbackCount, 0);
|
||||
await tester.pumpWidget(_host(QuickSwitchAnimation.swap));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.widget<ChatWorkspace>(find.byType(ChatWorkspace)).controller,
|
||||
same(workspace.controller),
|
||||
);
|
||||
expect(
|
||||
tester.widget<ChatWorkspace>(find.byType(ChatWorkspace)).animationStyle,
|
||||
QuickSwitchAnimation.swap,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('reduced-motion preview remains still and disables replay', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
_host(QuickSwitchAnimation.cardStack, reduced: true),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text('Reduced motion is enabled. Preview stays still.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
final button = tester.widget<TextButton>(
|
||||
find.widgetWithText(TextButton, 'Replay animation'),
|
||||
);
|
||||
expect(button.onPressed, isNull);
|
||||
expect(tester.binding.transientCallbackCount, 0);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
@@ -27,8 +27,14 @@ void main() {
|
||||
final section = SettingsAnimationSection(controller: controller);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: section))
|
||||
: MaterialApp(home: Scaffold(body: section)),
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
child: SingleChildScrollView(child: section),
|
||||
),
|
||||
)
|
||||
: MaterialApp(
|
||||
home: Scaffold(body: SingleChildScrollView(child: section)),
|
||||
),
|
||||
);
|
||||
if (cupertino) {
|
||||
final slider = tester.widget<CupertinoSlider>(
|
||||
|
||||
@@ -31,8 +31,14 @@ void main() {
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: child))
|
||||
: MaterialApp(home: Scaffold(body: child)),
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
child: SingleChildScrollView(child: child),
|
||||
),
|
||||
)
|
||||
: MaterialApp(
|
||||
home: Scaffold(body: SingleChildScrollView(child: child)),
|
||||
),
|
||||
);
|
||||
expect(find.text('Quick switch animation'), findsOneWidget);
|
||||
expect(
|
||||
@@ -41,7 +47,7 @@ void main() {
|
||||
);
|
||||
await tester.tap(find.text('Tape'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Card stack').last);
|
||||
await tester.tap(find.text('Card deck').last);
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.value, QuickSwitchAnimation.cardStack);
|
||||
expect(store.saved, 'cardStack');
|
||||
@@ -50,7 +56,7 @@ void main() {
|
||||
findsOneWidget,
|
||||
);
|
||||
store.success = false;
|
||||
await tester.tap(find.text('Card stack'));
|
||||
await tester.tap(find.text('Card deck'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Swap').last);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
Reference in New Issue
Block a user