| 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 // TODO(nweiz): Add support for calling [schedule] while the schedule is already | 5 // TODO(nweiz): Add support for calling [schedule] while the schedule is already |
| 6 // running. | 6 // running. |
| 7 // TODO(nweiz): Port the non-Pub-specific scheduled test libraries from Pub. | 7 // TODO(nweiz): Port the non-Pub-specific scheduled test libraries from Pub. |
| 8 /// A package for writing readable tests of asynchronous behavior. | 8 /// A package for writing readable tests of asynchronous behavior. |
| 9 /// | 9 /// |
| 10 /// ## Installing ## | 10 /// ## Installing ## |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 /// expect(request.body, equals('payload')); | 167 /// expect(request.body, equals('payload')); |
| 168 /// expect(request.headers['content-type'], equals('text/plain')); | 168 /// expect(request.headers['content-type'], equals('text/plain')); |
| 169 /// })); | 169 /// })); |
| 170 /// | 170 /// |
| 171 /// schedule(() => sendRequest('payload')); | 171 /// schedule(() => sendRequest('payload')); |
| 172 /// }); | 172 /// }); |
| 173 /// } | 173 /// } |
| 174 /// | 174 /// |
| 175 /// ## Timeouts | 175 /// ## Timeouts |
| 176 /// | 176 /// |
| 177 /// `scheduled_test` has a built-in timeout of 30 seconds (configurable via | 177 /// `scheduled_test` has a built-in timeout of 5 seconds (configurable via |
| 178 /// [Schedule.timeout]). This timeout is aware of the structure of the schedule; | 178 /// [Schedule.timeout]). This timeout is aware of the structure of the schedule; |
| 179 /// this means that it will reset for each task in a queue, when moving between | 179 /// this means that it will reset for each task in a queue, when moving between |
| 180 /// queues, or almost any other sort of interaction with [currentSchedule]. As | 180 /// queues, or almost any other sort of interaction with [currentSchedule]. As |
| 181 /// long as the [Schedule] knows your test is making some sort of progress, it | 181 /// long as the [Schedule] knows your test is making some sort of progress, it |
| 182 /// won't time out. | 182 /// won't time out. |
| 183 /// | 183 /// |
| 184 /// If a single task might take a long time, you can also manually tell the | 184 /// If a single task might take a long time, you can also manually tell the |
| 185 /// [Schedule] that it's making progress by calling [Schedule.heartbeat], which | 185 /// [Schedule] that it's making progress by calling [Schedule.heartbeat], which |
| 186 /// will reset the timeout whenever it's called. | 186 /// will reset the timeout whenever it's called. |
| 187 /// | 187 /// |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 /// [description] provides an optional description of the future, which is | 370 /// [description] provides an optional description of the future, which is |
| 371 /// used when generating error messages. | 371 /// used when generating error messages. |
| 372 Future wrapFuture(Future future, [String description]) { | 372 Future wrapFuture(Future future, [String description]) { |
| 373 if (currentSchedule == null) { | 373 if (currentSchedule == null) { |
| 374 throw new StateError("Unexpected call to wrapFuture with no current " | 374 throw new StateError("Unexpected call to wrapFuture with no current " |
| 375 "schedule."); | 375 "schedule."); |
| 376 } | 376 } |
| 377 | 377 |
| 378 return currentSchedule.wrapFuture(future, description); | 378 return currentSchedule.wrapFuture(future, description); |
| 379 } | 379 } |
| OLD | NEW |