| 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.iframe_test; | 5 library test.runner.browser.iframe_test; |
| 6 | 6 |
| 7 import '../../backend/group.dart'; |
| 7 import '../../backend/live_test.dart'; | 8 import '../../backend/live_test.dart'; |
| 8 import '../../backend/live_test_controller.dart'; | 9 import '../../backend/live_test_controller.dart'; |
| 9 import '../../backend/metadata.dart'; | 10 import '../../backend/metadata.dart'; |
| 10 import '../../backend/operating_system.dart'; | 11 import '../../backend/operating_system.dart'; |
| 11 import '../../backend/state.dart'; | 12 import '../../backend/state.dart'; |
| 12 import '../../backend/suite.dart'; | 13 import '../../backend/suite.dart'; |
| 13 import '../../backend/test.dart'; | 14 import '../../backend/test.dart'; |
| 14 import '../../backend/test_platform.dart'; | 15 import '../../backend/test_platform.dart'; |
| 15 import '../../util/multi_channel.dart'; | 16 import '../../util/multi_channel.dart'; |
| 16 import '../../util/remote_exception.dart'; | 17 import '../../util/remote_exception.dart'; |
| 17 import '../../util/stack_trace_mapper.dart'; | 18 import '../../util/stack_trace_mapper.dart'; |
| 18 | 19 |
| 19 /// A test in a running iframe. | 20 /// A test in a running iframe. |
| 20 class IframeTest extends Test { | 21 class IframeTest extends Test { |
| 21 final String name; | 22 final String name; |
| 22 final Metadata metadata; | 23 final Metadata metadata; |
| 23 | 24 |
| 24 /// The mapper used to map stack traces for errors coming from this test, or | 25 /// The mapper used to map stack traces for errors coming from this test, or |
| 25 /// `null`. | 26 /// `null`. |
| 26 final StackTraceMapper _mapper; | 27 final StackTraceMapper _mapper; |
| 27 | 28 |
| 28 /// The channel used to communicate with the test's [IframeListener]. | 29 /// The channel used to communicate with the test's [IframeListener]. |
| 29 final MultiChannel _channel; | 30 final MultiChannel _channel; |
| 30 | 31 |
| 31 IframeTest(this.name, this.metadata, this._channel, {StackTraceMapper mapper}) | 32 IframeTest(this.name, this.metadata, this._channel, {StackTraceMapper mapper}) |
| 32 : _mapper = mapper; | 33 : _mapper = mapper; |
| 33 | 34 |
| 34 LiveTest load(Suite suite) { | 35 LiveTest load(Suite suite, {Iterable<Group> groups}) { |
| 35 var controller; | 36 var controller; |
| 36 var testChannel; | 37 var testChannel; |
| 37 controller = new LiveTestController(suite, this, () { | 38 controller = new LiveTestController(suite, this, () { |
| 38 controller.setState(const State(Status.running, Result.success)); | 39 controller.setState(const State(Status.running, Result.success)); |
| 39 | 40 |
| 40 testChannel = _channel.virtualChannel(); | 41 testChannel = _channel.virtualChannel(); |
| 41 _channel.sink.add({ | 42 _channel.sink.add({ |
| 42 'command': 'run', | 43 'command': 'run', |
| 43 'channel': testChannel.id | 44 'channel': testChannel.id |
| 44 }); | 45 }); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 62 assert(message['type'] == 'complete'); | 63 assert(message['type'] == 'complete'); |
| 63 controller.completer.complete(); | 64 controller.completer.complete(); |
| 64 } | 65 } |
| 65 }); | 66 }); |
| 66 }, () { | 67 }, () { |
| 67 // Ignore all future messages from the test and complete it immediately. | 68 // Ignore all future messages from the test and complete it immediately. |
| 68 // We don't need to tell it to run its tear-down because there's nothing a | 69 // We don't need to tell it to run its tear-down because there's nothing a |
| 69 // browser test needs to clean up on the file system anyway. | 70 // browser test needs to clean up on the file system anyway. |
| 70 testChannel.sink.close(); | 71 testChannel.sink.close(); |
| 71 if (!controller.completer.isCompleted) controller.completer.complete(); | 72 if (!controller.completer.isCompleted) controller.completer.complete(); |
| 72 }); | 73 }, groups: groups); |
| 73 return controller.liveTest; | 74 return controller.liveTest; |
| 74 } | 75 } |
| 75 | 76 |
| 76 Test forPlatform(TestPlatform platform, {OperatingSystem os}) { | 77 Test forPlatform(TestPlatform platform, {OperatingSystem os}) { |
| 77 if (!metadata.testOn.evaluate(platform, os: os)) return null; | 78 if (!metadata.testOn.evaluate(platform, os: os)) return null; |
| 78 return new IframeTest( | 79 return new IframeTest( |
| 79 name, metadata.forPlatform(platform, os: os), _channel, | 80 name, metadata.forPlatform(platform, os: os), _channel, |
| 80 mapper: _mapper); | 81 mapper: _mapper); |
| 81 } | 82 } |
| 82 } | 83 } |
| OLD | NEW |