ClideMarquee honours reduced motion (MediaQuery.disableAnimations) (T-284)
The status-bar footer marquee drove a raw Ticker whenever its content overflowed, ignoring MediaQuery.disableAnimations — unlike the turn indicator (T-273), which stops on the same flag. Two costs: reduced-motion users still got the scrolling footer, and the perpetual ticker was the historical pumpAndSettle-hang culprit (its tests cope by only ever pump()-ing). Unify on the one mechanism: read disableAnimations in didChangeDependencies (as running_indicator does) and gate the ticker on it via _syncTicker(). Under reduced motion the marquee never starts the ticker (stops + resets if running) and renders the child statically (clipped, no looped copy). Toggling the flag at runtime starts/stops the scroll. Tests: reduced-motion marquee does not scroll and pumpAndSettle completes (no hang); flipping the flag off lets an overflowing marquee scroll again. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,11 @@ Widget _boxed(double width, Widget child) => Directionality(
|
||||
),
|
||||
);
|
||||
|
||||
Widget _reducedMotion(double width, Widget child) => MediaQuery(
|
||||
data: const MediaQueryData(disableAnimations: true),
|
||||
child: _boxed(width, child),
|
||||
);
|
||||
|
||||
void main() {
|
||||
testWidgets('shows the child statically when it fits', (tester) async {
|
||||
await tester.pumpWidget(_boxed(300, const ClideMarquee(child: Text('short'))));
|
||||
@@ -29,4 +34,29 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.pumpWidget(const SizedBox()); // dispose → stop ticker
|
||||
});
|
||||
|
||||
testWidgets('reduced motion (disableAnimations) does not scroll; pumpAndSettle completes (T-284)', (tester) async {
|
||||
await tester.pumpWidget(_reducedMotion(40, const ClideMarquee(child: Text('a long status line that overflows the slot'))));
|
||||
// The ticker must never start, so the frame queue is quiescent — if the
|
||||
// marquee still ran its ticker, this would hang for the 10-minute default.
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('a long status line that overflows the slot'), findsWidgets);
|
||||
// No looped second copy is built under reduced motion (single rendered copy).
|
||||
expect(find.text('a long status line that overflows the slot'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
});
|
||||
|
||||
testWidgets('toggling disableAnimations off lets an overflowing marquee scroll again (T-284)', (tester) async {
|
||||
const child = ClideMarquee(child: Text('a long status line that overflows the slot'));
|
||||
await tester.pumpWidget(_reducedMotion(40, child));
|
||||
await tester.pumpAndSettle(); // frozen, settles
|
||||
// Flip the flag off → ticker should start; the looped copy reappears.
|
||||
await tester.pumpWidget(_boxed(40, child));
|
||||
await tester.pump(); // measure
|
||||
await tester.pump(const Duration(milliseconds: 100)); // advance the ticker
|
||||
expect(find.text('a long status line that overflows the slot'), findsWidgets);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.pumpWidget(const SizedBox()); // dispose → stop ticker
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user