| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:async/async.dart'; | 7 import 'package:async/async.dart'; |
| 8 import 'package:stream_channel/stream_channel.dart'; |
| 8 | 9 |
| 9 import '../../backend/group.dart'; | 10 import '../../backend/group.dart'; |
| 10 import '../../backend/metadata.dart'; | 11 import '../../backend/metadata.dart'; |
| 11 import '../../backend/test.dart'; | 12 import '../../backend/test.dart'; |
| 12 import '../../backend/test_platform.dart'; | 13 import '../../backend/test_platform.dart'; |
| 13 import '../../util/multi_channel.dart'; | |
| 14 import '../../util/remote_exception.dart'; | 14 import '../../util/remote_exception.dart'; |
| 15 import '../../util/stack_trace_mapper.dart'; | 15 import '../../util/stack_trace_mapper.dart'; |
| 16 import '../../util/stream_channel.dart'; | |
| 17 import '../../utils.dart'; | 16 import '../../utils.dart'; |
| 18 import '../environment.dart'; | 17 import '../environment.dart'; |
| 19 import '../load_exception.dart'; | 18 import '../load_exception.dart'; |
| 20 import '../runner_suite.dart'; | 19 import '../runner_suite.dart'; |
| 21 import 'iframe_test.dart'; | 20 import 'iframe_test.dart'; |
| 22 | 21 |
| 23 /// Loads a [RunnerSuite] for a browser. | 22 /// Loads a [RunnerSuite] for a browser. |
| 24 /// | 23 /// |
| 25 /// [channel] should connect to the iframe containing the suite, which should | 24 /// [channel] should connect to the iframe containing the suite, which should |
| 26 /// eventually emit a message containing the suite's test information. | 25 /// eventually emit a message containing the suite's test information. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 44 // | 43 // |
| 45 // Start this canceled because we don't want it to start ticking until we get | 44 // Start this canceled because we don't want it to start ticking until we get |
| 46 // some response from the iframe. | 45 // some response from the iframe. |
| 47 var timer = new RestartableTimer(new Duration(seconds: 3), () { | 46 var timer = new RestartableTimer(new Duration(seconds: 3), () { |
| 48 controller.setDebugging(true); | 47 controller.setDebugging(true); |
| 49 })..cancel(); | 48 })..cancel(); |
| 50 | 49 |
| 51 // Even though [channel] is probably a [MultiChannel] already, create a | 50 // Even though [channel] is probably a [MultiChannel] already, create a |
| 52 // nested MultiChannel because the iframe will be using a channel wrapped | 51 // nested MultiChannel because the iframe will be using a channel wrapped |
| 53 // within the host's channel. | 52 // within the host's channel. |
| 54 var suiteChannel = new MultiChannel(channel.stream.map((message) { | 53 var suiteChannel = new MultiChannel(channel.changeStream((stream) { |
| 55 // Whenever we get a message, no matter which child channel it's for, we the | 54 return stream.map((message) { |
| 56 // browser is still running code which means the using isn't debugging. | 55 // Whenever we get a message, no matter which child channel it's for, we t
he |
| 57 if (controller != null) { | 56 // browser is still running code which means the using isn't debugging. |
| 58 timer.reset(); | 57 if (controller != null) { |
| 59 controller.setDebugging(false); | 58 timer.reset(); |
| 60 } | 59 controller.setDebugging(false); |
| 60 } |
| 61 | 61 |
| 62 return message; | 62 return message; |
| 63 }), channel.sink); | 63 }); |
| 64 })); |
| 64 | 65 |
| 65 var response = await _getResponse(suiteChannel.stream) | 66 var response = await _getResponse(suiteChannel.stream) |
| 66 .timeout(new Duration(minutes: 1), onTimeout: () { | 67 .timeout(new Duration(minutes: 1), onTimeout: () { |
| 67 suiteChannel.sink.close(); | 68 suiteChannel.sink.close(); |
| 68 throw new LoadException( | 69 throw new LoadException( |
| 69 path, | 70 path, |
| 70 "Timed out waiting for the test suite to connect."); | 71 "Timed out waiting for the test suite to connect."); |
| 71 }); | 72 }); |
| 72 | 73 |
| 73 try { | 74 try { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 /// Returns `null` if [test] is `null`. | 157 /// Returns `null` if [test] is `null`. |
| 157 Test _deserializeTest(MultiChannel suiteChannel, Map test, | 158 Test _deserializeTest(MultiChannel suiteChannel, Map test, |
| 158 [StackTraceMapper mapper]) { | 159 [StackTraceMapper mapper]) { |
| 159 if (test == null) return null; | 160 if (test == null) return null; |
| 160 | 161 |
| 161 var metadata = new Metadata.deserialize(test['metadata']); | 162 var metadata = new Metadata.deserialize(test['metadata']); |
| 162 var testChannel = suiteChannel.virtualChannel(test['channel']); | 163 var testChannel = suiteChannel.virtualChannel(test['channel']); |
| 163 return new IframeTest(test['name'], metadata, testChannel, | 164 return new IframeTest(test['name'], metadata, testChannel, |
| 164 mapper: mapper); | 165 mapper: mapper); |
| 165 } | 166 } |
| OLD | NEW |