2dcd56ef43
There are far too many files here to review everyone carefully. Spot checking most of the diffs look good as test code is generally written with less care than application code so lots of ugly formatting get through. If people notice files where the automated formatting bothers them feel free to comment indicating file names and I'll move spaces within comments to make the formatting cleaner and use comments to force block formatting as I have done for other case where formatting looked bad. BUG= R=efortuna@google.com Review-Url: https://codereview.chromium.org/2771453003 .
32 lines
1012 B
Dart
32 lines
1012 B
Dart
library async_cancellingisolate;
|
|
|
|
import 'dart:async';
|
|
import 'package:unittest/unittest.dart';
|
|
|
|
main(message, replyTo) {
|
|
var command = message.first;
|
|
expect(command, 'START');
|
|
var shot = false;
|
|
var oneshot;
|
|
var periodic;
|
|
periodic = new Timer.periodic(const Duration(milliseconds: 10), (timer) {
|
|
expect(shot, isFalse);
|
|
shot = true;
|
|
expect(timer, same(periodic));
|
|
periodic.cancel();
|
|
oneshot.cancel();
|
|
// Wait some more time to be sure callbacks won't be invoked any
|
|
// more.
|
|
new Timer(const Duration(milliseconds: 50), () {
|
|
replyTo.send('DONE');
|
|
});
|
|
});
|
|
// We launch the oneshot timer after the periodic timer. Otherwise a
|
|
// (very long) context switch could make this test flaky: assume the
|
|
// oneshot timer is created first and then there is a 30ms context switch.
|
|
// when the periodic timer is scheduled it would execute after the oneshot.
|
|
oneshot = new Timer(const Duration(milliseconds: 30), () {
|
|
fail('Should never be invoked');
|
|
});
|
|
}
|