5
5
// gestures. You can also use WidgetTester to find child widgets in the widget
6
6
// tree, read text, and verify that the values of widget properties are correct.
7
7
8
+ import 'package:app/material.dart' ;
8
9
import 'package:flutter/material.dart' ;
9
10
import 'package:flutter_test/flutter_test.dart' ;
10
11
@@ -15,7 +16,6 @@ void main() {
15
16
// Build our app and trigger a frame.
16
17
await tester.pumpWidget (const App ());
17
18
18
- // Verify that our counter starts at 0.
19
19
expect (find.byKey (materialPageKey), findsOneWidget);
20
20
expect (find.byKey (cupertinoPageKey), findsNothing);
21
21
@@ -26,4 +26,58 @@ void main() {
26
26
expect (find.byKey (cupertinoPageKey), findsOneWidget);
27
27
expect (find.byKey (materialPageKey), findsNothing);
28
28
});
29
+
30
+ testWidgets ('Test Material page pickers' , (WidgetTester tester) async {
31
+ // Build our app and trigger a frame.
32
+ await tester.pumpWidget (const App ());
33
+
34
+ expect (find.byKey (materialPageKey), findsOneWidget);
35
+ expect (find.byKey (cupertinoPageKey), findsNothing);
36
+
37
+ // TEST DATE BUTTON ONLY -----------
38
+ final dateButton = find.byKey (dateButtonKey);
39
+
40
+ // Tap on `Cupertino` key and page should change
41
+ await tester.tap (dateButton);
42
+ await tester.pumpAndSettle ();
43
+
44
+ // Tap on "OK"
45
+ await tester.tap (find.text ('OK' ));
46
+ await tester.pumpAndSettle ();
47
+
48
+ // Should show page again
49
+ expect (find.byKey (materialPageKey), findsOneWidget);
50
+
51
+ // TEST TIME BUTTON ONLY -----------
52
+ final timeButton = find.byKey (timeButtonKey);
53
+
54
+ // Tap on `Cupertino` key and page should change
55
+ await tester.tap (timeButton);
56
+ await tester.pumpAndSettle ();
57
+
58
+ // Tap on "OK"
59
+ await tester.tap (find.text ('OK' ));
60
+ await tester.pumpAndSettle ();
61
+
62
+ // Should show page again
63
+ expect (find.byKey (materialPageKey), findsOneWidget);
64
+
65
+ // TEST DATE AND TIME BUTTON -----------
66
+ final dateTimeButton = find.byKey (dateTimeButtonKey);
67
+
68
+ // Tap on `Cupertino` key and page should change
69
+ await tester.tap (dateTimeButton);
70
+ await tester.pumpAndSettle ();
71
+
72
+ // Tap on "OK" for date
73
+ await tester.tap (find.text ('OK' ));
74
+ await tester.pumpAndSettle ();
75
+
76
+ // Tap on "OK" for time
77
+ await tester.tap (find.text ('OK' ));
78
+ await tester.pumpAndSettle ();
79
+
80
+ // Should show page again
81
+ expect (find.byKey (materialPageKey), findsOneWidget);
82
+ });
29
83
}
0 commit comments