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 | |
7 import 'dart:io'; | 5 import 'dart:io'; |
8 import 'dart:convert'; | 6 import 'dart:convert'; |
9 | 7 |
10 import 'path.dart'; | 8 import 'path.dart'; |
11 | 9 |
12 // This is the maximum time we expect stdout/stderr of subprocesses to deliver | 10 // This is the maximum time we expect stdout/stderr of subprocesses to deliver |
13 // data after we've got the exitCode. | 11 // data after we've got the exitCode. |
14 const Duration MAX_STDIO_DELAY = const Duration(seconds: 30); | 12 const Duration MAX_STDIO_DELAY = const Duration(seconds: 30); |
15 | 13 |
16 String MAX_STDIO_DELAY_PASSED_MESSAGE = | 14 String MAX_STDIO_DELAY_PASSED_MESSAGE = |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 return UTF8.encode(string); | 169 return UTF8.encode(string); |
172 } | 170 } |
173 | 171 |
174 // TODO(kustermann,ricow): As soon we have a debug log we should log | 172 // TODO(kustermann,ricow): As soon we have a debug log we should log |
175 // invalid utf8-encoded input to the log. | 173 // invalid utf8-encoded input to the log. |
176 // Currently invalid bytes will be replaced by a replacement character. | 174 // Currently invalid bytes will be replaced by a replacement character. |
177 String decodeUtf8(List<int> bytes) { | 175 String decodeUtf8(List<int> bytes) { |
178 return UTF8.decode(bytes, allowMalformed: true); | 176 return UTF8.decode(bytes, allowMalformed: true); |
179 } | 177 } |
180 | 178 |
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 | |
235 // This function is pretty stupid and only puts quotes around an argument if | 179 // This function is pretty stupid and only puts quotes around an argument if |
236 // it the argument contains a space. | 180 // it the argument contains a space. |
237 String escapeCommandLineArgument(String argument) { | 181 String escapeCommandLineArgument(String argument) { |
238 if (argument.contains(' ')) { | 182 if (argument.contains(' ')) { |
239 return '"$argument"'; | 183 return '"$argument"'; |
240 } | 184 } |
241 return argument; | 185 return argument; |
242 } | 186 } |
243 | 187 |
244 class HashCodeBuilder { | 188 class HashCodeBuilder { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 class UniqueObject { | 248 class UniqueObject { |
305 static int _nextId = 1; | 249 static int _nextId = 1; |
306 final int _hashCode; | 250 final int _hashCode; |
307 | 251 |
308 int get hashCode => _hashCode; | 252 int get hashCode => _hashCode; |
309 operator ==(Object other) => | 253 operator ==(Object other) => |
310 other is UniqueObject && _hashCode == other._hashCode; | 254 other is UniqueObject && _hashCode == other._hashCode; |
311 | 255 |
312 UniqueObject() : _hashCode = ++_nextId; | 256 UniqueObject() : _hashCode = ++_nextId; |
313 } | 257 } |
OLD | NEW |