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:http_parser/http_parser.dart'; | 10 import 'package:http_parser/http_parser.dart'; |
11 import 'package:pool/pool.dart'; | 11 import 'package:pool/pool.dart'; |
12 | 12 |
13 import '../../backend/metadata.dart'; | 13 import '../../backend/metadata.dart'; |
14 import '../../backend/suite.dart'; | |
15 import '../../backend/test_platform.dart'; | 14 import '../../backend/test_platform.dart'; |
16 import '../../util/multi_channel.dart'; | 15 import '../../util/multi_channel.dart'; |
17 import '../../util/remote_exception.dart'; | 16 import '../../util/remote_exception.dart'; |
18 import '../../util/stack_trace_mapper.dart'; | 17 import '../../util/stack_trace_mapper.dart'; |
19 import '../../utils.dart'; | 18 import '../../utils.dart'; |
20 import '../load_exception.dart'; | 19 import '../load_exception.dart'; |
| 20 import '../runner_suite.dart'; |
21 import 'iframe_test.dart'; | 21 import 'iframe_test.dart'; |
22 | 22 |
23 /// A class that manages the connection to a single running browser. | 23 /// A class that manages the connection to a single running browser. |
24 /// | 24 /// |
25 /// This is in charge of telling the browser which test suites to load and | 25 /// This is in charge of telling the browser which test suites to load and |
26 /// converting its responses into [Suite] objects. | 26 /// converting its responses into [Suite] objects. |
27 class BrowserManager { | 27 class BrowserManager { |
28 /// The browser that this is managing. | 28 /// The browser that this is managing. |
29 final TestPlatform browser; | 29 final TestPlatform browser; |
30 | 30 |
(...skipping 30 matching lines...) Expand all Loading... |
61 } | 61 } |
62 | 62 |
63 /// Tells the browser the load a test suite from the URL [url]. | 63 /// Tells the browser the load a test suite from the URL [url]. |
64 /// | 64 /// |
65 /// [url] should be an HTML page with a reference to the JS-compiled test | 65 /// [url] should be an HTML page with a reference to the JS-compiled test |
66 /// suite. [path] is the path of the original test suite file, which is used | 66 /// suite. [path] is the path of the original test suite file, which is used |
67 /// for reporting. [metadata] is the parsed metadata for the test suite. | 67 /// for reporting. [metadata] is the parsed metadata for the test suite. |
68 /// | 68 /// |
69 /// If [mapper] is passed, it's used to map stack traces for errors coming | 69 /// If [mapper] is passed, it's used to map stack traces for errors coming |
70 /// from this test suite. | 70 /// from this test suite. |
71 Future<Suite> loadSuite(String path, Uri url, Metadata metadata, | 71 Future<RunnerSuite> loadSuite(String path, Uri url, Metadata metadata, |
72 {StackTraceMapper mapper}) async { | 72 {StackTraceMapper mapper}) async { |
73 url = url.replace(fragment: Uri.encodeFull(JSON.encode({ | 73 url = url.replace(fragment: Uri.encodeFull(JSON.encode({ |
74 "metadata": metadata.serialize(), | 74 "metadata": metadata.serialize(), |
75 "browser": browser.identifier | 75 "browser": browser.identifier |
76 }))); | 76 }))); |
77 | 77 |
78 // The stream may close before emitting a value if the browser is killed | 78 // The stream may close before emitting a value if the browser is killed |
79 // prematurely (e.g. via Control-C). | 79 // prematurely (e.g. via Control-C). |
80 var suiteVirtualChannel = _channel.virtualChannel(); | 80 var suiteVirtualChannel = _channel.virtualChannel(); |
81 var suiteId = _suiteId++; | 81 var suiteId = _suiteId++; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 133 } |
134 | 134 |
135 if (response["type"] == "error") { | 135 if (response["type"] == "error") { |
136 closeIframe(); | 136 closeIframe(); |
137 var asyncError = RemoteException.deserialize(response["error"]); | 137 var asyncError = RemoteException.deserialize(response["error"]); |
138 await new Future.error( | 138 await new Future.error( |
139 new LoadException(path, asyncError.error), | 139 new LoadException(path, asyncError.error), |
140 asyncError.stackTrace); | 140 asyncError.stackTrace); |
141 } | 141 } |
142 | 142 |
143 return new Suite(response["tests"].map((test) { | 143 return new RunnerSuite(response["tests"].map((test) { |
144 var testMetadata = new Metadata.deserialize(test['metadata']); | 144 var testMetadata = new Metadata.deserialize(test['metadata']); |
145 var testChannel = suiteChannel.virtualChannel(test['channel']); | 145 var testChannel = suiteChannel.virtualChannel(test['channel']); |
146 return new IframeTest(test['name'], testMetadata, testChannel, | 146 return new IframeTest(test['name'], testMetadata, testChannel, |
147 mapper: mapper); | 147 mapper: mapper); |
148 }), platform: browser, metadata: metadata, path: path, | 148 }), platform: browser, metadata: metadata, path: path, |
149 onClose: () => closeIframe()); | 149 onClose: () => closeIframe()); |
150 } | 150 } |
151 } | 151 } |
OLD | NEW |