Chromium Code Reviews| 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.backend.live_test_controller; | 5 library test.backend.live_test_controller; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:stack_trace/stack_trace.dart'; | 10 import 'package:stack_trace/stack_trace.dart'; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 /// it's not different, this does nothing. | 144 /// it's not different, this does nothing. |
| 145 void setState(State newState) { | 145 void setState(State newState) { |
| 146 if (_isClosed) return; | 146 if (_isClosed) return; |
| 147 if (_state == newState) return; | 147 if (_state == newState) return; |
| 148 | 148 |
| 149 _state = newState; | 149 _state = newState; |
| 150 _onStateChangeController.add(newState); | 150 _onStateChangeController.add(newState); |
| 151 } | 151 } |
| 152 | 152 |
| 153 /// Emits a line printed by the test over [LiveTest.onPrint]. | 153 /// Emits a line printed by the test over [LiveTest.onPrint]. |
| 154 void print(String line) => _onPrintController.add(line); | 154 void print(String line) { |
| 155 if (_onPrintController.hasListener) { | |
|
kevmoo
2015/07/23 20:47:03
what's a case where the controller has no listener
nweiz
2015/07/23 21:23:00
After the test package has received a signal, it w
| |
| 156 _onPrintController.add(line); | |
| 157 } else { | |
| 158 // Make sure all prints get surfaced one way or another to aid in | |
| 159 // debugging. | |
| 160 Zone.ROOT.print(line); | |
| 161 } | |
| 162 } | |
| 155 | 163 |
| 156 /// A wrapper for [_onRun] that ensures that it follows the guarantees for | 164 /// A wrapper for [_onRun] that ensures that it follows the guarantees for |
| 157 /// [LiveTest.run]. | 165 /// [LiveTest.run]. |
| 158 Future _run() { | 166 Future _run() { |
| 159 if (_runCalled) { | 167 if (_runCalled) { |
| 160 throw new StateError("LiveTest.run() may not be called more than once."); | 168 throw new StateError("LiveTest.run() may not be called more than once."); |
| 161 } else if (_isClosed) { | 169 } else if (_isClosed) { |
| 162 throw new StateError("LiveTest.run() may not be called for a closed " | 170 throw new StateError("LiveTest.run() may not be called for a closed " |
| 163 "test."); | 171 "test."); |
| 164 } | 172 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 177 | 185 |
| 178 if (_runCalled) { | 186 if (_runCalled) { |
| 179 _onClose(); | 187 _onClose(); |
| 180 } else { | 188 } else { |
| 181 completer.complete(); | 189 completer.complete(); |
| 182 } | 190 } |
| 183 | 191 |
| 184 return completer.future; | 192 return completer.future; |
| 185 } | 193 } |
| 186 } | 194 } |
| OLD | NEW |