Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of unittest; | 5 part of unittest; |
| 6 | 6 |
| 7 /// Represents the state for an individual unit test. | 7 /// Represents the state for an individual unit test. |
| 8 /// | 8 /// |
| 9 /// Create by calling [test] or [solo_test]. | 9 /// Create by calling [test] or [solo_test]. |
| 10 class TestCase { | 10 class TestCase { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 // Avoid calling [new Future] to avoid issue 11911. | 92 // Avoid calling [new Future] to avoid issue 11911. |
| 93 return new Future.value().then((_) { | 93 return new Future.value().then((_) { |
| 94 if (_setUp != null) return _setUp(); | 94 if (_setUp != null) return _setUp(); |
| 95 }).catchError(_errorHandler('Setup')).then((_) { | 95 }).catchError(_errorHandler('Setup')).then((_) { |
| 96 // Skip the test if setup failed. | 96 // Skip the test if setup failed. |
| 97 if (result != null) return new Future.value(); | 97 if (result != null) return new Future.value(); |
| 98 _config.onTestStart(this); | 98 _config.onTestStart(this); |
| 99 _startTime = new DateTime.now(); | 99 _startTime = new DateTime.now(); |
| 100 _runningTime = null; | 100 _runningTime = null; |
| 101 ++_callbackFunctionsOutstanding; | 101 ++_callbackFunctionsOutstanding; |
| 102 return _testFunction(); | 102 var testReturn = _testFunction(); |
| 103 if (testReturn is Future) { | |
| 104 ++_callbackFunctionsOutstanding; | |
| 105 testReturn.catchError(_errorHandler('Test')).whenComplete(_markCallbackC omplete); | |
|
kevmoo
2014/07/29 19:59:01
long line
Also, would you add a note explaining t
Paul Berry
2014/07/29 21:54:38
Done.
| |
| 106 } | |
| 103 }).catchError(_errorHandler('Test')).then((_) { | 107 }).catchError(_errorHandler('Test')).then((_) { |
| 104 _markCallbackComplete(); | 108 _markCallbackComplete(); |
| 105 if (result == null) { | 109 if (result == null) { |
| 106 // Outstanding callbacks exist; we need to return a Future. | 110 // Outstanding callbacks exist; we need to return a Future. |
| 107 _testComplete = new Completer(); | 111 _testComplete = new Completer(); |
| 108 return _testComplete.future.whenComplete(() { | 112 return _testComplete.future.whenComplete(() { |
| 109 if (_tearDown != null) { | 113 if (_tearDown != null) { |
| 110 return _tearDown(); | 114 return _tearDown(); |
| 111 } | 115 } |
| 112 }).catchError(_errorHandler('Teardown')); | 116 }).catchError(_errorHandler('Teardown')); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 } | 175 } |
| 172 | 176 |
| 173 void _markCallbackComplete() { | 177 void _markCallbackComplete() { |
| 174 if (--_callbackFunctionsOutstanding == 0 && !isComplete) { | 178 if (--_callbackFunctionsOutstanding == 0 && !isComplete) { |
| 175 _pass(); | 179 _pass(); |
| 176 } | 180 } |
| 177 } | 181 } |
| 178 | 182 |
| 179 String toString() => _result != null ? "$description: $result" : description; | 183 String toString() => _result != null ? "$description: $result" : description; |
| 180 } | 184 } |
| OLD | NEW |