| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 test.runner.browser.browser_manager; | 5 library test.runner.browser.browser_manager; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:async/async.dart'; | 10 import 'package:async/async.dart'; |
| 11 import 'package:http_parser/http_parser.dart'; | 11 import 'package:http_parser/http_parser.dart'; |
| 12 import 'package:pool/pool.dart'; | 12 import 'package:pool/pool.dart'; |
| 13 | 13 |
| 14 import '../../backend/group.dart'; | 14 import '../../backend/group.dart'; |
| 15 import '../../backend/metadata.dart'; | 15 import '../../backend/metadata.dart'; |
| 16 import '../../backend/suite_entry.dart'; | |
| 17 import '../../backend/test_platform.dart'; | 16 import '../../backend/test_platform.dart'; |
| 18 import '../../util/cancelable_future.dart'; | 17 import '../../util/cancelable_future.dart'; |
| 19 import '../../util/multi_channel.dart'; | 18 import '../../util/multi_channel.dart'; |
| 20 import '../../util/remote_exception.dart'; | 19 import '../../util/remote_exception.dart'; |
| 21 import '../../util/stack_trace_mapper.dart'; | 20 import '../../util/stack_trace_mapper.dart'; |
| 22 import '../../utils.dart'; | 21 import '../../utils.dart'; |
| 23 import '../application_exception.dart'; | 22 import '../application_exception.dart'; |
| 24 import '../environment.dart'; | 23 import '../environment.dart'; |
| 25 import '../load_exception.dart'; | 24 import '../load_exception.dart'; |
| 26 import '../runner_suite.dart'; | 25 import '../runner_suite.dart'; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 if (response["type"] == "error") { | 237 if (response["type"] == "error") { |
| 239 closeIframe(); | 238 closeIframe(); |
| 240 var asyncError = RemoteException.deserialize(response["error"]); | 239 var asyncError = RemoteException.deserialize(response["error"]); |
| 241 await new Future.error( | 240 await new Future.error( |
| 242 new LoadException(path, asyncError.error), | 241 new LoadException(path, asyncError.error), |
| 243 asyncError.stackTrace); | 242 asyncError.stackTrace); |
| 244 } | 243 } |
| 245 | 244 |
| 246 return new RunnerSuite( | 245 return new RunnerSuite( |
| 247 await _environment, | 246 await _environment, |
| 248 _deserializeEntries(suiteChannel, mapper, response["entries"]), | 247 _deserializeGroup(suiteChannel, mapper, response["root"]), |
| 249 platform: _platform, | 248 platform: _platform, |
| 250 metadata: metadata, | |
| 251 path: path, | 249 path: path, |
| 252 onClose: () => closeIframe()); | 250 onClose: () => closeIframe()); |
| 253 } | 251 } |
| 254 | 252 |
| 255 /// Deserializes [entries] into concrete [SuiteEntry] subclasses. | 253 /// Deserializes [group] into a concrete [Group] class. |
| 256 Iterable<SuiteEntry> _deserializeEntries(MultiChannel suiteChannel, | 254 Group _deserializeGroup(MultiChannel suiteChannel, |
| 257 StackTraceMapper mapper, List<Map> entries) { | 255 StackTraceMapper mapper, Map group) { |
| 258 return entries.map((entry) { | 256 var metadata = new Metadata.deserialize(group['metadata']); |
| 259 var metadata = new Metadata.deserialize(entry['metadata']); | 257 return new Group(group['name'], group['entries'].map((entry) { |
| 260 if (entry['type'] == 'group') { | 258 if (entry['type'] == 'group') { |
| 261 return new Group( | 259 return _deserializeGroup(suiteChannel, mapper, entry); |
| 262 entry['name'], | |
| 263 metadata, | |
| 264 _deserializeEntries(suiteChannel, mapper, entry['entries'])); | |
| 265 } else { | |
| 266 var testChannel = suiteChannel.virtualChannel(entry['channel']); | |
| 267 return new IframeTest(entry['name'], metadata, testChannel, | |
| 268 mapper: mapper); | |
| 269 } | 260 } |
| 270 }); | 261 |
| 262 var testMetadata = new Metadata.deserialize(entry['metadata']); |
| 263 var testChannel = suiteChannel.virtualChannel(entry['channel']); |
| 264 return new IframeTest(entry['name'], testMetadata, testChannel, |
| 265 mapper: mapper); |
| 266 }), metadata: metadata); |
| 271 } | 267 } |
| 272 | 268 |
| 273 /// An implementation of [Environment.displayPause]. | 269 /// An implementation of [Environment.displayPause]. |
| 274 CancelableFuture _displayPause() { | 270 CancelableFuture _displayPause() { |
| 275 if (_pauseCompleter != null) return _pauseCompleter.future; | 271 if (_pauseCompleter != null) return _pauseCompleter.future; |
| 276 | 272 |
| 277 _pauseCompleter = new CancelableCompleter(() { | 273 _pauseCompleter = new CancelableCompleter(() { |
| 278 _channel.sink.add({"command": "resume"}); | 274 _channel.sink.add({"command": "resume"}); |
| 279 _pauseCompleter = null; | 275 _pauseCompleter = null; |
| 280 }); | 276 }); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 311 | 307 |
| 312 final Uri observatoryUrl; | 308 final Uri observatoryUrl; |
| 313 | 309 |
| 314 final Uri remoteDebuggerUrl; | 310 final Uri remoteDebuggerUrl; |
| 315 | 311 |
| 316 _BrowserEnvironment(this._manager, this.observatoryUrl, | 312 _BrowserEnvironment(this._manager, this.observatoryUrl, |
| 317 this.remoteDebuggerUrl); | 313 this.remoteDebuggerUrl); |
| 318 | 314 |
| 319 CancelableFuture displayPause() => _manager._displayPause(); | 315 CancelableFuture displayPause() => _manager._displayPause(); |
| 320 } | 316 } |
| OLD | NEW |