From ce05c3c5921b180e84a0adfbe6db77c4718c1ce7 Mon Sep 17 00:00:00 2001 From: Zhaotian Wang Date: Tue, 11 Jul 2017 04:53:21 +0800 Subject: [PATCH] Make _RelativeClock extends _SystemClock Make _RelativeClock extends _SystemClock so that it won't fail in test for DDC mode. Currently, clock.withClock will blow up if there is a stricter type detection. --- lib/src/relative_clock.dart | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/src/relative_clock.dart b/lib/src/relative_clock.dart index c8560ab..f204441 100644 --- a/lib/src/relative_clock.dart +++ b/lib/src/relative_clock.dart @@ -1,24 +1,20 @@ - part of clock; typedef Duration _Elapsed(); -class _RelativeClock implements Clock { - +class _RelativeClock implements _SystemClock { final DateTime _initialTime; final _Elapsed _elapsed; final int _frequency; - - _RelativeClock({ - DateTime initialTime, - Duration elapsed(), - int frequency: 1000000 - }) - : _initialTime = initialTime == null ? _zonedClock.value.now : initialTime, + + _RelativeClock( + {DateTime initialTime, Duration elapsed(), int frequency: 1000000}) + : _initialTime = + initialTime == null ? _zonedClock.value.now : initialTime, _elapsed = elapsed == null ? (() => Duration.ZERO) : elapsed, _frequency = frequency; - + DateTime get now => _initialTime.add(_elapsed()); - Stopwatch getStopwatch() => new FakeStopwatch(() => - _elapsed().inMicroseconds * _frequency ~/ 1000000, _frequency); + Stopwatch getStopwatch() => new FakeStopwatch( + () => _elapsed().inMicroseconds * _frequency ~/ 1000000, _frequency); }