Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 library async_periodictimer; | |
| 2 | |
| 3 import 'dart:async'; | |
| 4 import 'package:unittest/unittest.dart'; | |
| 5 | |
| 6 main(message, replyTo) { | |
| 7 var command = message[0]; | |
|
terry
2015/03/04 15:26:48
ditto message.first?
| |
| 8 expect(command, 'START'); | |
| 9 int counter = 0; | |
| 10 new Timer.periodic(const Duration(milliseconds: 10), (timer) { | |
| 11 if (counter == 3) { | |
| 12 counter = 1024; | |
| 13 timer.cancel(); | |
| 14 // Wait some more time to be sure callback won't be invoked any | |
| 15 // more. | |
| 16 new Timer(const Duration(milliseconds: 30), () { | |
| 17 replyTo.send('DONE'); | |
| 18 }); | |
| 19 return; | |
| 20 } | |
| 21 assert(counter < 3); | |
| 22 counter++; | |
| 23 }); | |
| 24 } | |
| OLD | NEW |