@@ -6,9 +6,6 @@ import 'package:test/test.dart';
6
6
7
7
void main () {
8
8
group ('Full app' , () {
9
- final styledPageScaffold = find.byValueKey ('StyledPageScaffold' );
10
- final authSubmitButton = find.byValueKey ('auth_submit_button' );
11
-
12
9
late FlutterDriver driver;
13
10
14
11
// Connect to the Flutter driver before running any tests.
@@ -21,26 +18,91 @@ void main() {
21
18
driver.close ();
22
19
});
23
20
24
- test ('StyledPageScaffold appears after login and scrolls' , () async {
21
+ test (
22
+ 'homepage scrolling up and down' ,
23
+ () async {
24
+ await _ensureLoggedIn (driver);
25
+
26
+ await driver.startTracing (streams: [TimelineStream .embedder]);
27
+ for (var i = 0 ; i < 10 ; i++ ) {
28
+ // Scroll about 6 pages down ...
29
+ await driver.scroll (
30
+ styledPageScaffold, 0 , - 6000 , const Duration (seconds: 1 ));
31
+ await driver.tap (styledPageScaffold);
32
+ // ... and about 5 pages up.
33
+ await driver.scroll (
34
+ styledPageScaffold, 0 , 5000 , const Duration (seconds: 2 ));
35
+ await driver.tap (styledPageScaffold);
36
+ }
37
+ final timeline = await driver.stopTracingAndDownloadTimeline ();
38
+ await _saveTimeline ('homepage-scrolling' , timeline);
39
+ },
40
+ timeout: _increasedTimeout,
41
+ skip: 'currently only have one folio, so no scrolling' ,
42
+ );
43
+
44
+ test ('going from login screen to homepage and back' , () async {
45
+ await _ensureLoggedIn (driver);
46
+
25
47
await driver.startTracing (streams: [TimelineStream .embedder]);
26
- await driver.waitFor (authSubmitButton);
27
- await driver.tap (authSubmitButton);
28
- await driver.waitFor (styledPageScaffold);
29
- for (var i = 0 ; i < 10 ; i++ ) {
30
- await driver.scroll (
31
- styledPageScaffold, 0 , - 6000 , const Duration (seconds: 1 ));
32
- await driver.tap (styledPageScaffold);
33
- await driver.scroll (
34
- styledPageScaffold, 0 , 5000 , const Duration (seconds: 2 ));
35
- await driver.tap (styledPageScaffold);
48
+ for (var i = 0 ; i < 50 ; i++ ) {
49
+ // Log out ...
50
+ await driver.tap (roundedProfileButton);
51
+ await driver.tap (logoutButton);
52
+ // ... then log in again.
53
+ await driver.tap (authSubmitButton);
36
54
}
37
55
final timeline = await driver.stopTracingAndDownloadTimeline ();
38
56
39
- final now = DateTime .now ();
40
- final nowString = now.toIso8601String ().replaceAll (':' , '-' );
41
- final file = File ('benchmark/timeline-$nowString .json' );
42
- await file.writeAsString (json.encode (timeline.json));
57
+ await _saveTimeline ('login-to-homepage' , timeline);
58
+ }, timeout: _increasedTimeout);
59
+
60
+ test ('opening and closing the "create new" sheet' , () async {
61
+ await _ensureLoggedIn (driver);
62
+
63
+ await driver.startTracing (streams: [TimelineStream .embedder]);
64
+ for (var i = 0 ; i < 50 ; i++ ) {
65
+ // Open ...
66
+ await driver.tap (newFolioFab);
67
+ // ... and close.
68
+ await driver.scroll (
69
+ newFolioCard, 0 , 5000 , const Duration (milliseconds: 200 ));
70
+ }
71
+ final timeline = await driver.stopTracingAndDownloadTimeline ();
43
72
44
- }, timeout: Timeout (const Duration (minutes: 3 )));
73
+ await _saveTimeline ('create-new-sheet' , timeline);
74
+ }, timeout: _increasedTimeout);
45
75
});
46
76
}
77
+
78
+ final authSubmitButton = find.byValueKey ('auth_submit_button' );
79
+ final logoutButton = find.byValueKey ('logout_button' );
80
+ final materialApp = find.byType ('MaterialApp' );
81
+ final newFolioFab = find.byType ('_NewFolioFab' );
82
+ final newFolioCard = find.byType ('_NewFolioCard' );
83
+ final roundedProfileButton = find.byValueKey ('rounded_profile_button' );
84
+ final styledPageScaffold = find.byValueKey ('StyledPageScaffold' );
85
+
86
+ final Timeout _increasedTimeout = Timeout (const Duration (minutes: 5 ));
87
+
88
+ Future <void > _ensureLoggedIn (FlutterDriver driver) async {
89
+ // await driver.waitFor(find.byType('MainAppScaffold'));
90
+
91
+ // XXX: The following currently always returns an empty string.
92
+ // We basically have no way of programmatically learning if we're
93
+ // logged in or out.
94
+ // final renderTree = await driver.getRenderTree();
95
+ // print('render tree:');
96
+ // print(renderTree.tree);
97
+
98
+ if (false ) {
99
+ await driver.tap (authSubmitButton);
100
+ }
101
+ }
102
+
103
+ Future <void > _saveTimeline (String label, Timeline timeline) async {
104
+ final now = DateTime .now ();
105
+ final nowString = now.toIso8601String ().replaceAll (':' , '-' );
106
+ final file = File ('benchmark/$label -$nowString .json' );
107
+ await file.writeAsString (json.encode (timeline.json));
108
+ }
0 commit comments