blob: fba21d4a6ef25d496d393c8f8346c325f22ae3fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Widget smoke tests for PlayerAndroidApp.
//
// These tests verify that the two named routes defined in main.dart render
// without errors and contain the expected key widgets. Navigation between
// HomeScreen and NowPlayingScreen is exercised end-to-end.
//
// Run with: flutter test test/widget_smoke_test.dart
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:player_android/main.dart';
void main() {
group('PlayerAndroidApp', () {
testWidgets('starts on HomeScreen showing Library title', (tester) async {
await tester.pumpWidget(const PlayerAndroidApp());
expect(find.text('Library'), findsOneWidget);
expect(find.text('Now Playing'), findsOneWidget);
});
testWidgets('navigates to NowPlayingScreen on button tap', (tester) async {
await tester.pumpWidget(const PlayerAndroidApp());
await tester.tap(find.widgetWithText(ElevatedButton, 'Now Playing'));
await tester.pumpAndSettle();
expect(find.text('Now Playing'), findsWidgets);
expect(find.text('No media selected'), findsOneWidget);
});
testWidgets('NowPlayingScreen back-navigates to HomeScreen', (tester) async {
await tester.pumpWidget(const PlayerAndroidApp());
// Navigate to NowPlayingScreen.
await tester.tap(find.widgetWithText(ElevatedButton, 'Now Playing'));
await tester.pumpAndSettle();
expect(find.text('No media selected'), findsOneWidget);
// Press the back button provided by Scaffold/AppBar.
final NavigatorState nav = tester.state(find.byType(Navigator));
nav.pop();
await tester.pumpAndSettle();
expect(find.text('Library'), findsOneWidget);
});
});
}
|