OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'package:expect/expect.dart'; |
| 6 import 'package:async_helper/async_helper.dart'; |
| 7 import 'dart:async'; |
| 8 |
| 9 testEmptyZoneSpecification() { |
| 10 Expect.identical(Zone.ROOT, Zone.current); |
| 11 Zone forked = Zone.current.fork(); |
| 12 Expect.isFalse(identical(Zone.ROOT, forked)); |
| 13 |
| 14 asyncStart(); |
| 15 bool timerDidRun = false; |
| 16 forked.createTimer(const Duration(milliseconds: 20), () { |
| 17 // The createTimer function on the Zone binds the closures. |
| 18 Expect.identical(forked, Zone.current); |
| 19 timerDidRun = true; |
| 20 asyncEnd(); |
| 21 }); |
| 22 Expect.identical(Zone.ROOT, Zone.current); |
| 23 |
| 24 asyncStart(); |
| 25 int periodicTimerCount = 0; |
| 26 forked.createPeriodicTimer(const Duration(milliseconds: 20), (Timer timer) { |
| 27 periodicTimerCount++; |
| 28 if (periodicTimerCount == 4) { |
| 29 timer.cancel(); |
| 30 asyncEnd(); |
| 31 } |
| 32 // The createPeriodicTimer function on the Zone binds the closures. |
| 33 Expect.identical(forked, Zone.current); |
| 34 }); |
| 35 Expect.identical(Zone.ROOT, Zone.current); |
| 36 } |
| 37 |
| 38 main() { |
| 39 testEmptyZoneSpecification(); |
| 40 } |
OLD | NEW |