fix(ui): skip size animation entirely under reduced motion
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/layout/collapsible_list_section.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'reduced-motion groups accept asynchronous row changes without layout animation ($cupertino)',
|
||||
(tester) async {
|
||||
tester.platformDispatcher.accessibilityFeaturesTestValue =
|
||||
const FakeAccessibilityFeatures(disableAnimations: true);
|
||||
addTearDown(
|
||||
tester.platformDispatcher.clearAccessibilityFeaturesTestValue,
|
||||
);
|
||||
final rows = ValueNotifier<int>(1);
|
||||
addTearDown(rows.dispose);
|
||||
final body = ValueListenableBuilder<int>(
|
||||
valueListenable: rows,
|
||||
builder: (context, count, _) => SingleChildScrollView(
|
||||
child: CollapsibleListSection(
|
||||
title: 'Group',
|
||||
count: count,
|
||||
children: [for (var i = 0; i < count; i++) Text('Row $i')],
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: body))
|
||||
: MaterialApp(home: Scaffold(body: body)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
rows.value = 3;
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Row 2'), findsOneWidget);
|
||||
expect(find.byType(AnimatedSize), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.tap(find.text('Group'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Row 0'), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user