OLD | NEW |
1 // Copyright 2013 Google Inc. All Rights Reserved. | 1 // Copyright 2013 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 expect(e, 'baz'); | 53 expect(e, 'baz'); |
54 }); | 54 }); |
55 controller.add('baz'); | 55 controller.add('baz'); |
56 return controller.close(); | 56 return controller.close(); |
57 }); | 57 }); |
58 | 58 |
59 test('should close child streams', () { | 59 test('should close child streams', () { |
60 var controller = new StreamController<int>(sync: true); | 60 var controller = new StreamController<int>(sync: true); |
61 var router = new StreamRouter<int>(controller.stream); | 61 var router = new StreamRouter<int>(controller.stream); |
62 // toList() will only complete when the child streams are closed | 62 // toList() will only complete when the child streams are closed |
63 var future = Future | 63 var future = Future.wait([ |
64 .wait([ | |
65 router.route((e) => e % 2 == 0).toList(), | 64 router.route((e) => e % 2 == 0).toList(), |
66 router.route((e) => e % 2 == 1).toList(), | 65 router.route((e) => e % 2 == 1).toList(), |
67 ]) | 66 ]).then((l) { |
68 .then((l) { | 67 expect(l, [ |
69 expect(l, [[4], [5]]); | 68 [4], |
| 69 [5] |
| 70 ]); |
70 }); | 71 }); |
71 controller | 72 controller..add(4)..add(5); |
72 ..add(4) | |
73 ..add(5); | |
74 router.close(); | 73 router.close(); |
75 return future; | 74 return future; |
76 }); | 75 }); |
77 }); | 76 }); |
78 } | 77 } |
OLD | NEW |