diff --git a/dwds/test/devtools_test.dart b/dwds/test/devtools_test.dart index 76dda874f..12f8e6fb8 100644 --- a/dwds/test/devtools_test.dart +++ b/dwds/test/devtools_test.dart @@ -2,7 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@Skip('https://github.com/dart-lang/webdev/issues/1845 - Move to cron job.') @Timeout(Duration(minutes: 5)) @TestOn('vm') import 'dart:io'; @@ -19,7 +18,7 @@ Future _waitForPageReady(TestContext context) async { var attempt = 100; while (attempt-- > 0) { final content = await context.webDriver.pageSource; - if (content.contains('Hello World!')) return; + if (content.contains('hello_world')) return; await Future.delayed(const Duration(milliseconds: 100)); } throw StateError('Page never initialized'); @@ -43,58 +42,48 @@ void main() { test('can launch devtools', () async { final windows = await context.webDriver.windows.toList(); await context.webDriver.driver.switchTo.window(windows.last); - // TODO(grouma): switch back to `fixture.webdriver.title` when - // https://github.com/flutter/devtools/issues/2045 is fixed. - expect(await context.webDriver.pageSource, contains('Flutter')); + expect(await context.webDriver.title, equals('Dart DevTools')); expect(await context.webDriver.currentUrl, contains('ide=Dwds')); - // TODO(elliette): Re-enable and fix flakes. - }, skip: true); - - test( - 'can not launch devtools for the same app in multiple tabs', - () async { - final appUrl = await context.webDriver.currentUrl; - // Open a new tab, select it, and navigate to the app - await context.webDriver.driver - .execute("window.open('$appUrl', '_blank');", []); - await Future.delayed(const Duration(seconds: 2)); - var windows = await context.webDriver.windows.toList(); - final oldAppWindow = windows[0]; - final newAppWindow = windows[1]; - var devToolsWindow = windows[2]; - await newAppWindow.setAsActive(); - - // Wait for the page to be ready before trying to open DevTools again. - await _waitForPageReady(context); - - // Try to open devtools and check for the alert. - await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']); - await Future.delayed(const Duration(seconds: 2)); - final alert = context.webDriver.driver.switchTo.alert; - expect(alert, isNotNull); - expect(await alert.text, - contains('This app is already being debugged in a different tab')); - await alert.accept(); - - // Now close the old app and try to re-open devtools. - await oldAppWindow.setAsActive(); - await oldAppWindow.close(); - await devToolsWindow.setAsActive(); - await devToolsWindow.close(); - await newAppWindow.setAsActive(); - await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']); - await Future.delayed(const Duration(seconds: 2)); - windows = await context.webDriver.windows.toList(); - devToolsWindow = windows.firstWhere((window) => window != newAppWindow); - await devToolsWindow.setAsActive(); - // TODO(grouma): switch back to `fixture.webdriver.title` when - // https://github.com/flutter/devtools/issues/2045 is fixed. - expect(await context.webDriver.pageSource, contains('Flutter')); - }, - // TODO(elliette): Enable this test once - // https://github.com/dart-lang/webdev/issues/1504 is resolved. - skip: true, - ); + }); + + test('can not launch devtools for the same app in multiple tabs', () async { + final appUrl = await context.webDriver.currentUrl; + // Open a new tab, select it, and navigate to the app + await context.webDriver.driver + .execute("window.open('$appUrl', '_blank');", []); + await Future.delayed(const Duration(seconds: 2)); + final newAppWindow = await context.webDriver.windows.last; + await newAppWindow.setAsActive(); + + // Wait for the page to be ready before trying to open DevTools again. + await _waitForPageReady(context); + + // Try to open devtools and check for the alert. + await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']); + await Future.delayed(const Duration(seconds: 2)); + final alert = context.webDriver.driver.switchTo.alert; + expect(alert, isNotNull); + expect(await alert.text, + contains('This app is already being debugged in a different tab')); + await alert.accept(); + + var windows = await context.webDriver.windows.toList(); + for (final window in windows) { + if (window.id != newAppWindow.id) { + await window.setAsActive(); + await window.close(); + } + } + + await newAppWindow.setAsActive(); + await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']); + await Future.delayed(const Duration(seconds: 2)); + windows = await context.webDriver.windows.toList(); + final devToolsWindow = + windows.firstWhere((window) => window != newAppWindow); + await devToolsWindow.setAsActive(); + expect(await context.webDriver.title, equals('Dart DevTools')); + }); test('destroys and recreates the isolate during a page refresh', () async { // This test is the same as one in reload_test, but runs here when there @@ -124,7 +113,7 @@ void main() { toReplace: 'Bonjour le monde!', replaceWith: 'Hello World!', ); - }); + }, skip: 'https://github.com/dart-lang/webdev/issues/1888'); }); group('Injected client without DevTools', () { @@ -169,6 +158,8 @@ void main() { expect(await alert.text, contains('--debug')); await alert.accept(); }); + // TODO(https://github.com/dart-lang/webdev/issues/1724): Re-enable debug + // extension tests on Windows. }, tags: ['extension'], skip: Platform.isWindows); }