OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library utils; |
| 6 |
5 import 'dart:io'; | 7 import 'dart:io'; |
6 import 'dart:convert'; | 8 import 'dart:convert'; |
7 | 9 |
8 import 'path.dart'; | 10 import 'path.dart'; |
9 | 11 |
10 // This is the maximum time we expect stdout/stderr of subprocesses to deliver | 12 // This is the maximum time we expect stdout/stderr of subprocesses to deliver |
11 // data after we've got the exitCode. | 13 // data after we've got the exitCode. |
12 const Duration MAX_STDIO_DELAY = const Duration(seconds: 30); | 14 const Duration MAX_STDIO_DELAY = const Duration(seconds: 30); |
13 | 15 |
14 String MAX_STDIO_DELAY_PASSED_MESSAGE = | 16 String MAX_STDIO_DELAY_PASSED_MESSAGE = |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 return UTF8.encode(string); | 171 return UTF8.encode(string); |
170 } | 172 } |
171 | 173 |
172 // TODO(kustermann,ricow): As soon we have a debug log we should log | 174 // TODO(kustermann,ricow): As soon we have a debug log we should log |
173 // invalid utf8-encoded input to the log. | 175 // invalid utf8-encoded input to the log. |
174 // Currently invalid bytes will be replaced by a replacement character. | 176 // Currently invalid bytes will be replaced by a replacement character. |
175 String decodeUtf8(List<int> bytes) { | 177 String decodeUtf8(List<int> bytes) { |
176 return UTF8.decode(bytes, allowMalformed: true); | 178 return UTF8.decode(bytes, allowMalformed: true); |
177 } | 179 } |
178 | 180 |
| 181 class Locations { |
| 182 static String getBrowserLocation( |
| 183 String browserName, Map<String, dynamic> globalConfiguration) { |
| 184 var location = globalConfiguration[browserName] as String; |
| 185 if (location != null && location != '') { |
| 186 return location; |
| 187 } |
| 188 var browserLocations = { |
| 189 'firefox': const { |
| 190 'windows': 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe', |
| 191 'linux': 'firefox', |
| 192 'macos': '/Applications/Firefox.app/Contents/MacOS/firefox' |
| 193 }, |
| 194 'chrome': const { |
| 195 'windows': |
| 196 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe', |
| 197 'macos': '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', |
| 198 'linux': 'google-chrome' |
| 199 }, |
| 200 'dartium': const { |
| 201 'windows': 'client\\tests\\dartium\\chrome.exe', |
| 202 'macos': 'client/tests/dartium/Chromium.app/Contents/MacOS/Chromium', |
| 203 'linux': 'client/tests/dartium/chrome' |
| 204 }, |
| 205 'safari': const { |
| 206 'macos': '/Applications/Safari.app/Contents/MacOS/Safari' |
| 207 }, |
| 208 'safarimobilesim': const { |
| 209 'macos': '/Applications/Xcode.app/Contents/Developer/Platforms/' |
| 210 'iPhoneSimulator.platform/Developer/Applications/' |
| 211 'iPhone Simulator.app/Contents/MacOS/iPhone Simulator' |
| 212 }, |
| 213 'ie9': const { |
| 214 'windows': 'C:\\Program Files\\Internet Explorer\\iexplore.exe' |
| 215 }, |
| 216 'ie10': const { |
| 217 'windows': 'C:\\Program Files\\Internet Explorer\\iexplore.exe' |
| 218 }, |
| 219 'ie11': const { |
| 220 'windows': 'C:\\Program Files\\Internet Explorer\\iexplore.exe' |
| 221 } |
| 222 }; |
| 223 browserLocations['ff'] = browserLocations['firefox']; |
| 224 |
| 225 assert(browserLocations[browserName] != null); |
| 226 location = browserLocations[browserName][Platform.operatingSystem]; |
| 227 if (location != null) { |
| 228 return location; |
| 229 } else { |
| 230 throw '$browserName not supported on ${Platform.operatingSystem}'; |
| 231 } |
| 232 } |
| 233 } |
| 234 |
179 // This function is pretty stupid and only puts quotes around an argument if | 235 // This function is pretty stupid and only puts quotes around an argument if |
180 // it the argument contains a space. | 236 // it the argument contains a space. |
181 String escapeCommandLineArgument(String argument) { | 237 String escapeCommandLineArgument(String argument) { |
182 if (argument.contains(' ')) { | 238 if (argument.contains(' ')) { |
183 return '"$argument"'; | 239 return '"$argument"'; |
184 } | 240 } |
185 return argument; | 241 return argument; |
186 } | 242 } |
187 | 243 |
188 class HashCodeBuilder { | 244 class HashCodeBuilder { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 class UniqueObject { | 304 class UniqueObject { |
249 static int _nextId = 1; | 305 static int _nextId = 1; |
250 final int _hashCode; | 306 final int _hashCode; |
251 | 307 |
252 int get hashCode => _hashCode; | 308 int get hashCode => _hashCode; |
253 operator ==(Object other) => | 309 operator ==(Object other) => |
254 other is UniqueObject && _hashCode == other._hashCode; | 310 other is UniqueObject && _hashCode == other._hashCode; |
255 | 311 |
256 UniqueObject() : _hashCode = ++_nextId; | 312 UniqueObject() : _hashCode = ++_nextId; |
257 } | 313 } |
OLD | NEW |