Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: lib/src/runner/browser/iframe_listener.dart

Issue 1400743002: Add support for setUpAll and tearDownAll. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/runner/browser/browser_manager.dart ('k') | lib/src/runner/engine.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_listener; 5 library test.runner.browser.iframe_listener;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:html' hide Metadata; 9 import 'dart:html' hide Metadata;
10 10
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 /// Send information about [_suite] across [channel] and start listening for 125 /// Send information about [_suite] across [channel] and start listening for
126 /// commands to run the tests. 126 /// commands to run the tests.
127 void _listen(MultiChannel channel) { 127 void _listen(MultiChannel channel) {
128 channel.sink.add({ 128 channel.sink.add({
129 "type": "success", 129 "type": "success",
130 "root": _serializeGroup(channel, _suite.group) 130 "root": _serializeGroup(channel, _suite.group)
131 }); 131 });
132 } 132 }
133 133
134 /// Serializes [entries] into a JSON-safe map. 134 /// Serializes [group] into a JSON-safe map.
135 Map _serializeGroup(MultiChannel channel, Group group) { 135 Map _serializeGroup(MultiChannel channel, Group group) {
136 return { 136 return {
137 "type": "group", 137 "type": "group",
138 "name": group.name, 138 "name": group.name,
139 "metadata": group.metadata.serialize(), 139 "metadata": group.metadata.serialize(),
140 "setUpAll": _serializeTest(channel, group.setUpAll),
141 "tearDownAll": _serializeTest(channel, group.tearDownAll),
140 "entries": group.entries.map((entry) { 142 "entries": group.entries.map((entry) {
141 if (entry is Group) return _serializeGroup(channel, entry); 143 return entry is Group
144 ? _serializeGroup(channel, entry)
145 : _serializeTest(channel, entry);
146 }).toList()
147 };
148 }
142 149
143 var test = entry as Test; 150 /// Serializes [test] into a JSON-safe map.
144 var testChannel = channel.virtualChannel(); 151 ///
145 testChannel.stream.listen((message) { 152 /// Returns `null` if [test] is `null`.
146 assert(message['command'] == 'run'); 153 Map _serializeTest(MultiChannel channel, Test test) {
147 _runTest(test, channel.virtualChannel(message['channel'])); 154 if (test == null) return null;
148 });
149 155
150 return { 156 var testChannel = channel.virtualChannel();
151 "type": "test", 157 testChannel.stream.listen((message) {
152 "name": test.name, 158 assert(message['command'] == 'run');
153 "metadata": test.metadata.serialize(), 159 _runTest(test, channel.virtualChannel(message['channel']));
154 "channel": testChannel.id 160 });
155 }; 161
156 }).toList() 162 return {
163 "type": "test",
164 "name": test.name,
165 "metadata": test.metadata.serialize(),
166 "channel": testChannel.id
157 }; 167 };
158 } 168 }
159 169
160 /// Runs [test] and sends the results across [channel]. 170 /// Runs [test] and sends the results across [channel].
161 void _runTest(Test test, MultiChannel channel) { 171 void _runTest(Test test, MultiChannel channel) {
162 var liveTest = test.load(_suite); 172 var liveTest = test.load(_suite);
163 173
164 channel.stream.listen((message) { 174 channel.stream.listen((message) {
165 assert(message['command'] == 'close'); 175 assert(message['command'] == 'close');
166 liveTest.close(); 176 liveTest.close();
(...skipping 16 matching lines...) Expand all
183 }); 193 });
184 194
185 liveTest.onPrint.listen((line) { 195 liveTest.onPrint.listen((line) {
186 print(line); 196 print(line);
187 channel.sink.add({"type": "print", "line": line}); 197 channel.sink.add({"type": "print", "line": line});
188 }); 198 });
189 199
190 liveTest.run().then((_) => channel.sink.add({"type": "complete"})); 200 liveTest.run().then((_) => channel.sink.add({"type": "complete"}));
191 } 201 }
192 } 202 }
OLDNEW
« no previous file with comments | « lib/src/runner/browser/browser_manager.dart ('k') | lib/src/runner/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698