OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 | 7 |
8 @Timeout(const Duration(seconds: 60)) | 8 @Timeout(const Duration(seconds: 60)) |
9 import 'package:test/test.dart'; | 9 import 'package:test/test.dart'; |
10 import 'package:webdriver/webdriver.dart' show By, Capabilities, WebDriver; | 10 import 'package:webdriver/webdriver.dart' show By, Capabilities, WebDriver; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 var body = await webdriver.findElement(const By.tagName('body')); | 63 var body = await webdriver.findElement(const By.tagName('body')); |
64 expect(await body.text, "'Hello, World!'"); | 64 expect(await body.text, "'Hello, World!'"); |
65 }); | 65 }); |
66 }); | 66 }); |
67 } | 67 } |
68 | 68 |
69 Future<ChildServerProcess> _startPubServe(String directory, | 69 Future<ChildServerProcess> _startPubServe(String directory, |
70 [List<String> args = const []]) async { | 70 [List<String> args = const []]) async { |
71 assert(new Directory(directory).existsSync()); | 71 assert(new Directory(directory).existsSync()); |
72 var result = await Process.run('pub', ['upgrade'], workingDirectory: directory
); | 72 var result = |
| 73 await Process.run('pub', ['upgrade'], workingDirectory: directory); |
73 if (result.exitCode != 0) { | 74 if (result.exitCode != 0) { |
74 throw new StateError('Pub get failed: ${result.stderr}'); | 75 throw new StateError('Pub get failed: ${result.stderr}'); |
75 } | 76 } |
76 return ChildServerProcess.build( | 77 return ChildServerProcess.build( |
77 (host, port) => Process.start( | 78 (host, port) => Process.start( |
78 'pub', ['serve', '--hostname=$host', '--port=$port']..addAll(args), | 79 'pub', ['serve', '--hostname=$host', '--port=$port']..addAll(args), |
79 mode: ProcessStartMode.DETACHED_WITH_STDIO, | 80 mode: ProcessStartMode.DETACHED_WITH_STDIO, |
80 workingDirectory: directory), | 81 workingDirectory: directory), |
81 defaultPort: 8080); | 82 defaultPort: 8080); |
82 } | 83 } |
83 | 84 |
84 const _webDriverManagerPath = './node_modules/.bin/webdriver-manager'; | 85 const _webDriverManagerPath = './node_modules/.bin/webdriver-manager'; |
85 Future<ChildServerProcess> _startSelenium() async { | 86 Future<ChildServerProcess> _startSelenium() async { |
86 var result = await Process.run(_webDriverManagerPath, ['update']); | 87 var result = await Process.run(_webDriverManagerPath, ['update']); |
87 if (result.exitCode != 0) { | 88 if (result.exitCode != 0) { |
88 throw new StateError('Webdriver update failed: ${result.stderr}'); | 89 throw new StateError('Webdriver update failed: ${result.stderr}'); |
89 } | 90 } |
90 return ChildServerProcess.build( | 91 return ChildServerProcess.build( |
91 (host, port) => Process.start( | 92 (host, port) => Process.start( |
92 _webDriverManagerPath, ['start', '--seleniumPort=$port'], | 93 _webDriverManagerPath, ['start', '--seleniumPort=$port'], |
93 mode: ProcessStartMode.DETACHED_WITH_STDIO), | 94 mode: ProcessStartMode.DETACHED_WITH_STDIO), |
94 defaultPort: 4444); | 95 defaultPort: 4444); |
95 } | 96 } |
OLD | NEW |