| 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 unittest.backend.invoker; | 5 library test.backend.invoker; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:stack_trace/stack_trace.dart'; | 9 import 'package:stack_trace/stack_trace.dart'; |
| 10 | 10 |
| 11 import '../frontend/expect.dart'; | 11 import '../frontend/expect.dart'; |
| 12 import '../utils.dart'; | 12 import '../utils.dart'; |
| 13 import 'live_test.dart'; | 13 import 'live_test.dart'; |
| 14 import 'live_test_controller.dart'; | 14 import 'live_test_controller.dart'; |
| 15 import 'metadata.dart'; | 15 import 'metadata.dart'; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 /// | 65 /// |
| 66 /// This is distinct from [_controller.completer] because a tear-down may need | 66 /// This is distinct from [_controller.completer] because a tear-down may need |
| 67 /// to run before the test is truly finished. | 67 /// to run before the test is truly finished. |
| 68 final _completer = new Completer(); | 68 final _completer = new Completer(); |
| 69 | 69 |
| 70 /// The current invoker, or `null` if none is defined. | 70 /// The current invoker, or `null` if none is defined. |
| 71 /// | 71 /// |
| 72 /// An invoker is only set within the zone scope of a running test. | 72 /// An invoker is only set within the zone scope of a running test. |
| 73 static Invoker get current { | 73 static Invoker get current { |
| 74 // TODO(nweiz): Use a private symbol when dart2js supports it (issue 17526). | 74 // TODO(nweiz): Use a private symbol when dart2js supports it (issue 17526). |
| 75 return Zone.current[#unittest.invoker]; | 75 return Zone.current[#test.invoker]; |
| 76 } | 76 } |
| 77 | 77 |
| 78 Invoker._(Suite suite, LocalTest test) { | 78 Invoker._(Suite suite, LocalTest test) { |
| 79 _controller = new LiveTestController(suite, test, _onRun); | 79 _controller = new LiveTestController(suite, test, _onRun); |
| 80 } | 80 } |
| 81 | 81 |
| 82 /// Tells the invoker that there's a callback running that it should wait for | 82 /// Tells the invoker that there's a callback running that it should wait for |
| 83 /// before considering the test successful. | 83 /// before considering the test successful. |
| 84 /// | 84 /// |
| 85 /// Each call to [addOutstandingCallback] should be followed by a call to | 85 /// Each call to [addOutstandingCallback] should be followed by a call to |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 _controller.setState( | 174 _controller.setState( |
| 175 new State(Status.complete, liveTest.state.result)); | 175 new State(Status.complete, liveTest.state.result)); |
| 176 | 176 |
| 177 // Use [Timer.run] here to avoid starving the DOM or other | 177 // Use [Timer.run] here to avoid starving the DOM or other |
| 178 // non-microtask events. | 178 // non-microtask events. |
| 179 Timer.run(_controller.completer.complete); | 179 Timer.run(_controller.completer.complete); |
| 180 }); | 180 }); |
| 181 }, | 181 }, |
| 182 zoneSpecification: new ZoneSpecification( | 182 zoneSpecification: new ZoneSpecification( |
| 183 print: (self, parent, zone, line) => _controller.print(line)), | 183 print: (self, parent, zone, line) => _controller.print(line)), |
| 184 zoneValues: {#unittest.invoker: this}, | 184 zoneValues: {#test.invoker: this}, |
| 185 onError: handleError); | 185 onError: handleError); |
| 186 }); | 186 }); |
| 187 } | 187 } |
| 188 } | 188 } |
| OLD | NEW |