OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Test merging streams. | 5 // Test merging streams. |
6 library dart.test.stream_from_iterable; | 6 library dart.test.stream_from_iterable; |
7 | 7 |
8 import "dart:async"; | 8 import "dart:async"; |
9 import '../../../pkg/unittest/lib/unittest.dart'; | 9 import '../../../pkg/unittest/lib/unittest.dart'; |
10 import 'event_helper.dart'; | 10 import 'event_helper.dart'; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 })); | 55 })); |
56 }); | 56 }); |
57 | 57 |
58 test("iterable-paused", () { | 58 test("iterable-paused", () { |
59 Stream stream = new Stream.fromIterable(iter); | 59 Stream stream = new Stream.fromIterable(iter); |
60 Events actual = new Events(); | 60 Events actual = new Events(); |
61 StreamSubscription subscription; | 61 StreamSubscription subscription; |
62 subscription = stream.listen((int value) { | 62 subscription = stream.listen((int value) { |
63 actual.add(value); | 63 actual.add(value); |
64 // Do a 10 ms pause during the playback of the iterable. | 64 // Do a 10 ms pause during the playback of the iterable. |
65 if (value == 20) { subscription.pause(new Future.delayed(10, () {})); } | 65 Duration duration = const Duration(milliseconds: 10); |
| 66 if (value == 20) { |
| 67 subscription.pause(new Future.delayed(duration, () {})); |
| 68 } |
66 }, onDone: expectAsync0(() { | 69 }, onDone: expectAsync0(() { |
67 actual.close(); | 70 actual.close(); |
68 Events expected = new Events.fromIterable(iter); | 71 Events expected = new Events.fromIterable(iter); |
69 Expect.listEquals(expected.events, actual.events); | 72 Expect.listEquals(expected.events, actual.events); |
70 })); | 73 })); |
71 }); | 74 }); |
72 } | 75 } |
OLD | NEW |