// Author: fruit.com.cn import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:fruitshorts/core/theme/app_colors.dart'; import 'package:fruitshorts/pages/player/widgets/loading_progress_track.dart'; void main() { testWidgets('should_move_highlight_while_loading', (tester) async { tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed); addTearDown( () => tester.binding.handleAppLifecycleStateChanged( AppLifecycleState.paused, ), ); await tester.pumpWidget( const MaterialApp( home: Scaffold( body: Center( child: SizedBox(width: 240, child: LoadingProgressTrack(height: 4)), ), ), ), ); expect(find.byKey(const Key('progress-loading')), findsOneWidget); expect( tester .widget(find.byKey(const Key('progress-loading-track'))) .color, Colors.white24, ); expect( tester .widget( find.byKey(const Key('progress-loading-highlight')), ) .color, AppColors.blue, ); final initialLeft = tester .getTopLeft(find.byKey(const Key('progress-loading-highlight'))) .dx; await tester.pump(const Duration(milliseconds: 300)); final movedLeft = tester .getTopLeft(find.byKey(const Key('progress-loading-highlight'))) .dx; expect(movedLeft, greaterThan(initialLeft)); expect(tester.getSize(find.byKey(const Key('progress-loading'))).height, 4); }); }