OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library async.test.stream_group_test; | 5 library async.test.stream_group_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:async/async.dart'; | 9 import 'package:async/async.dart'; |
10 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 streamGroup.add(controller.stream); | 465 streamGroup.add(controller.stream); |
466 streamGroup.add(controller.stream); | 466 streamGroup.add(controller.stream); |
467 | 467 |
468 // If the stream was actually listened to multiple times, this would | 468 // If the stream was actually listened to multiple times, this would |
469 // throw a StateError. | 469 // throw a StateError. |
470 streamGroup.stream.listen(null); | 470 streamGroup.stream.listen(null); |
471 }); | 471 }); |
472 }); | 472 }); |
473 | 473 |
474 group("while active", () { | 474 group("while active", () { |
475 var subscription; | |
476 setUp(() async { | 475 setUp(() async { |
477 subscription = streamGroup.stream.listen(null); | 476 streamGroup.stream.listen(null); |
478 await flushMicrotasks(); | 477 await flushMicrotasks(); |
479 }); | 478 }); |
480 | 479 |
481 test("listens to the stream immediately", () async { | 480 test("listens to the stream immediately", () async { |
482 var controller = new StreamController<String>(); | 481 var controller = new StreamController<String>(); |
483 | 482 |
484 expect(streamGroup.add(controller.stream), isNull); | 483 expect(streamGroup.add(controller.stream), isNull); |
485 await flushMicrotasks(); | 484 await flushMicrotasks(); |
486 expect(controller.hasListener, isTrue); | 485 expect(controller.hasListener, isTrue); |
487 }); | 486 }); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 controller.close(); | 714 controller.close(); |
716 | 715 |
717 await streamGroup.close(); | 716 await streamGroup.close(); |
718 expect(events, equals(["one", "two", "three", "four", "five", "six"])); | 717 expect(events, equals(["one", "two", "three", "four", "five", "six"])); |
719 }); | 718 }); |
720 }); | 719 }); |
721 } | 720 } |
722 | 721 |
723 /// Wait for all microtasks to complete. | 722 /// Wait for all microtasks to complete. |
724 Future flushMicrotasks() => new Future.delayed(Duration.ZERO); | 723 Future flushMicrotasks() => new Future.delayed(Duration.ZERO); |
OLD | NEW |