22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- @Skip ('https://github.com/dart-lang/webdev/issues/1845 - Move to cron job.' )
65@Timeout (Duration (minutes: 5 ))
76@TestOn ('vm' )
87import 'dart:io' ;
@@ -19,7 +18,7 @@ Future<void> _waitForPageReady(TestContext context) async {
1918 var attempt = 100 ;
2019 while (attempt-- > 0 ) {
2120 final content = await context.webDriver.pageSource;
22- if (content.contains ('Hello World! ' )) return ;
21+ if (content.contains ('hello_world ' )) return ;
2322 await Future .delayed (const Duration (milliseconds: 100 ));
2423 }
2524 throw StateError ('Page never initialized' );
@@ -43,58 +42,48 @@ void main() {
4342 test ('can launch devtools' , () async {
4443 final windows = await context.webDriver.windows.toList ();
4544 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' ));
4946 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+ });
9887
9988 test ('destroys and recreates the isolate during a page refresh' , () async {
10089 // This test is the same as one in reload_test, but runs here when there
@@ -124,7 +113,7 @@ void main() {
124113 toReplace: 'Bonjour le monde!' ,
125114 replaceWith: 'Hello World!' ,
126115 );
127- });
116+ }, skip : 'https://github.com/dart-lang/webdev/issues/1888' );
128117 });
129118
130119 group ('Injected client without DevTools' , () {
@@ -169,6 +158,8 @@ void main() {
169158 expect (await alert.text, contains ('--debug' ));
170159 await alert.accept ();
171160 });
161+ // TODO(https://github.com/dart-lang/webdev/issues/1724): Re-enable debug
162+ // extension tests on Windows.
172163 }, tags: ['extension' ], skip: Platform .isWindows);
173164}
174165
0 commit comments