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

Non-periodic Timers are not active while executing callback() #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
21 changes: 21 additions & 0 deletions test/testing/fake_async_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -598,5 +598,26 @@ 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");
});
});
});
});
}