feat(player): 未就绪改由进度条展示加载态
This commit is contained in:
1 parent
76cc52ad66
commit
cf4b07aa69
12 files changed
+359
-167
No files matched your search
@@ -0,0 +1,53 @@
|
||||
// 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<ColoredBox>(find.byKey(const Key('progress-loading-track')))
|
||||
.color,
|
||||
Colors.white24,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<ColoredBox>(
|
||||
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);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user