| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 Google Inc. All Rights Reserved. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 | |
| 15 part of quiver.testing.async; | |
| 16 | |
| 17 /** | |
| 18 * DEPRECATED: Use a much more feature-rich FakeAsync instead. | |
| 19 * | |
| 20 * A [Timer] implementation that stores its duration and callback for access | |
| 21 * in tests. | |
| 22 */ | |
| 23 @deprecated | |
| 24 class FakeTimer implements Timer { | |
| 25 Duration duration; | |
| 26 var callback; | |
| 27 var onCancel; | |
| 28 | |
| 29 /** | |
| 30 * Sets this timers [duration] and [callback] and returns [this]. | |
| 31 * | |
| 32 * This method is usable as a [CreateTimer] or [CreateTimerPeriodic] | |
| 33 * function. In tests, construct a FakeTimer so that you have a refernece to | |
| 34 * it, then pass [create] to the function or class under test. | |
| 35 */ | |
| 36 FakeTimer create(Duration duration, callback) { | |
| 37 if (this.duration != null) { | |
| 38 throw new StateError("FakeTimer.create already called"); | |
| 39 } | |
| 40 this.duration = duration; | |
| 41 this.callback = callback; | |
| 42 return this; | |
| 43 } | |
| 44 | |
| 45 void cancel() { | |
| 46 if (onCancel != null) onCancel(); | |
| 47 } | |
| 48 | |
| 49 bool isActive = true; | |
| 50 } | |
| OLD | NEW |