Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Non-periodic Timers are not active while executing callback()
Browse files Browse the repository at this point in the history
Copied from google/quiver-dart #282
  • Loading branch information
jtmcdole committed Feb 25, 2016
1 parent 309c549 commit a7a2f72
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/testing/src/fake_async.dart
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ class _FakeAsync extends FakeAsync {
timer._callback(timer);
timer._nextCall += timer._duration;
} else {
timer._callback();
_timers.remove(timer);
timer._callback();
}
}

Expand Down
22 changes: 22 additions & 0 deletions test/testing/fake_async_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -598,5 +598,27 @@ main() {
});
});
});

group('timers', () {
test('should behave like real timers', () {
return new FakeAsync().run((async) {
var timeout = const Duration(minutes: 1);
int counter = 0;
var timer;
timer = new Timer(timeout, () {
counter++;
expect(timer.isActive, isFalse,
reason: "is not active while executing callback");
});
expect(timer.isActive, isTrue,
reason: "is active before executing callback");
async.elapse(timeout);
expect(counter, equals(1), reason: "timer executed");
expect(timer.isActive, isFalse,
reason: "is not active after executing callback");
});
});
;

This comment has been minimized.

Copy link
@jtmcdole

jtmcdole Feb 25, 2016

Author Contributor

well, that didn't merge right...

});
});
}

0 comments on commit a7a2f72

Please sign in to comment.