2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
- @Skip ('https://github.com/dart-lang/webdev/issues/1845 - Move to cron job.' )
6
5
@Timeout (Duration (minutes: 5 ))
7
6
@TestOn ('vm' )
8
7
import 'dart:io' ;
@@ -19,7 +18,7 @@ Future<void> _waitForPageReady(TestContext context) async {
19
18
var attempt = 100 ;
20
19
while (attempt-- > 0 ) {
21
20
final content = await context.webDriver.pageSource;
22
- if (content.contains ('Hello World! ' )) return ;
21
+ if (content.contains ('hello_world ' )) return ;
23
22
await Future .delayed (const Duration (milliseconds: 100 ));
24
23
}
25
24
throw StateError ('Page never initialized' );
@@ -43,58 +42,48 @@ void main() {
43
42
test ('can launch devtools' , () async {
44
43
final windows = await context.webDriver.windows.toList ();
45
44
await context.webDriver.driver.switchTo.window (windows.last);
46
- // TODO(grouma): switch back to `fixture.webdriver.title` when
47
- // https://github.com/flutter/devtools/issues/2045 is fixed.
48
- expect (await context.webDriver.pageSource, contains ('Flutter' ));
45
+ expect (await context.webDriver.title, equals ('Dart DevTools' ));
49
46
expect (await context.webDriver.currentUrl, contains ('ide=Dwds' ));
50
- // TODO(elliette): Re-enable and fix flakes.
51
- }, skip: true );
52
-
53
- test (
54
- 'can not launch devtools for the same app in multiple tabs' ,
55
- () async {
56
- final appUrl = await context.webDriver.currentUrl;
57
- // Open a new tab, select it, and navigate to the app
58
- await context.webDriver.driver
59
- .execute ("window.open('$appUrl ', '_blank');" , []);
60
- await Future .delayed (const Duration (seconds: 2 ));
61
- var windows = await context.webDriver.windows.toList ();
62
- final oldAppWindow = windows[0 ];
63
- final newAppWindow = windows[1 ];
64
- var devToolsWindow = windows[2 ];
65
- await newAppWindow.setAsActive ();
66
-
67
- // Wait for the page to be ready before trying to open DevTools again.
68
- await _waitForPageReady (context);
69
-
70
- // Try to open devtools and check for the alert.
71
- await context.webDriver.driver.keyboard.sendChord ([Keyboard .alt, 'd' ]);
72
- await Future .delayed (const Duration (seconds: 2 ));
73
- final alert = context.webDriver.driver.switchTo.alert;
74
- expect (alert, isNotNull);
75
- expect (await alert.text,
76
- contains ('This app is already being debugged in a different tab' ));
77
- await alert.accept ();
78
-
79
- // Now close the old app and try to re-open devtools.
80
- await oldAppWindow.setAsActive ();
81
- await oldAppWindow.close ();
82
- await devToolsWindow.setAsActive ();
83
- await devToolsWindow.close ();
84
- await newAppWindow.setAsActive ();
85
- await context.webDriver.driver.keyboard.sendChord ([Keyboard .alt, 'd' ]);
86
- await Future .delayed (const Duration (seconds: 2 ));
87
- windows = await context.webDriver.windows.toList ();
88
- devToolsWindow = windows.firstWhere ((window) => window != newAppWindow);
89
- await devToolsWindow.setAsActive ();
90
- // TODO(grouma): switch back to `fixture.webdriver.title` when
91
- // https://github.com/flutter/devtools/issues/2045 is fixed.
92
- expect (await context.webDriver.pageSource, contains ('Flutter' ));
93
- },
94
- // TODO(elliette): Enable this test once
95
- // https://github.com/dart-lang/webdev/issues/1504 is resolved.
96
- skip: true ,
97
- );
47
+ });
48
+
49
+ test ('can not launch devtools for the same app in multiple tabs' , () async {
50
+ final appUrl = await context.webDriver.currentUrl;
51
+ // Open a new tab, select it, and navigate to the app
52
+ await context.webDriver.driver
53
+ .execute ("window.open('$appUrl ', '_blank');" , []);
54
+ await Future .delayed (const Duration (seconds: 2 ));
55
+ final newAppWindow = await context.webDriver.windows.last;
56
+ await newAppWindow.setAsActive ();
57
+
58
+ // Wait for the page to be ready before trying to open DevTools again.
59
+ await _waitForPageReady (context);
60
+
61
+ // Try to open devtools and check for the alert.
62
+ await context.webDriver.driver.keyboard.sendChord ([Keyboard .alt, 'd' ]);
63
+ await Future .delayed (const Duration (seconds: 2 ));
64
+ final alert = context.webDriver.driver.switchTo.alert;
65
+ expect (alert, isNotNull);
66
+ expect (await alert.text,
67
+ contains ('This app is already being debugged in a different tab' ));
68
+ await alert.accept ();
69
+
70
+ var windows = await context.webDriver.windows.toList ();
71
+ for (final window in windows) {
72
+ if (window.id != newAppWindow.id) {
73
+ await window.setAsActive ();
74
+ await window.close ();
75
+ }
76
+ }
77
+
78
+ await newAppWindow.setAsActive ();
79
+ await context.webDriver.driver.keyboard.sendChord ([Keyboard .alt, 'd' ]);
80
+ await Future .delayed (const Duration (seconds: 2 ));
81
+ windows = await context.webDriver.windows.toList ();
82
+ final devToolsWindow =
83
+ windows.firstWhere ((window) => window != newAppWindow);
84
+ await devToolsWindow.setAsActive ();
85
+ expect (await context.webDriver.title, equals ('Dart DevTools' ));
86
+ });
98
87
99
88
test ('destroys and recreates the isolate during a page refresh' , () async {
100
89
// This test is the same as one in reload_test, but runs here when there
@@ -124,7 +113,7 @@ void main() {
124
113
toReplace: 'Bonjour le monde!' ,
125
114
replaceWith: 'Hello World!' ,
126
115
);
127
- });
116
+ }, skip : 'https://github.com/dart-lang/webdev/issues/1888' );
128
117
});
129
118
130
119
group ('Injected client without DevTools' , () {
@@ -169,6 +158,8 @@ void main() {
169
158
expect (await alert.text, contains ('--debug' ));
170
159
await alert.accept ();
171
160
});
161
+ // TODO(https://github.com/dart-lang/webdev/issues/1724): Re-enable debug
162
+ // extension tests on Windows.
172
163
}, tags: ['extension' ], skip: Platform .isWindows);
173
164
}
174
165
0 commit comments