|
6 | 6 | @Timeout(Duration(minutes: 2)) |
7 | 7 |
|
8 | 8 | import 'dart:async'; |
| 9 | +import 'dart:io'; |
9 | 10 |
|
10 | 11 | import 'package:dwds/shared/batched_stream.dart'; |
11 | 12 | import 'package:test/expect.dart'; |
12 | 13 | import 'package:test/scaffolding.dart'; |
13 | 14 |
|
14 | 15 | void main() { |
15 | 16 | group('Batched stream controller', () { |
16 | | - test('emits batches', () async { |
17 | | - const size = 100; |
18 | | - const delay = Duration(milliseconds: 1000); |
19 | | - |
20 | | - final batchOne = List<int>.generate(size, (index) => index); |
21 | | - final batchTwo = List<int>.generate(size, (index) => size + index); |
22 | | - |
23 | | - // Setup controller. |
24 | | - final controller = BatchedStreamController<int>(delay: 500); |
25 | | - |
26 | | - // Verify the output. |
27 | | - expect( |
28 | | - controller.stream, |
29 | | - emitsInOrder([ |
30 | | - batchOne, |
31 | | - batchTwo, |
32 | | - ]), |
33 | | - ); |
34 | | - |
35 | | - // Add input. |
36 | | - final inputController = StreamController<int>(); |
37 | | - final inputAdded = controller.sink.addStream(inputController.stream); |
38 | | - |
39 | | - batchOne.forEach(inputController.sink.add); |
40 | | - await Future.delayed(delay); |
41 | | - batchTwo.forEach(inputController.sink.add); |
42 | | - |
43 | | - await inputController.close(); |
44 | | - await inputAdded; |
45 | | - await controller.close(); |
46 | | - }); |
| 17 | + test( |
| 18 | + 'emits batches', |
| 19 | + () async { |
| 20 | + const size = 100; |
| 21 | + const delay = Duration(milliseconds: 1000); |
| 22 | + |
| 23 | + final batchOne = List<int>.generate(size, (index) => index); |
| 24 | + final batchTwo = List<int>.generate(size, (index) => size + index); |
| 25 | + |
| 26 | + // Setup controller. |
| 27 | + final controller = BatchedStreamController<int>(delay: 500); |
| 28 | + |
| 29 | + // Verify the output. |
| 30 | + expect( |
| 31 | + controller.stream, |
| 32 | + emitsInOrder([ |
| 33 | + batchOne, |
| 34 | + batchTwo, |
| 35 | + ]), |
| 36 | + ); |
| 37 | + |
| 38 | + // Add input. |
| 39 | + final inputController = StreamController<int>(); |
| 40 | + final inputAdded = controller.sink.addStream(inputController.stream); |
| 41 | + |
| 42 | + batchOne.forEach(inputController.sink.add); |
| 43 | + await Future.delayed(delay); |
| 44 | + batchTwo.forEach(inputController.sink.add); |
| 45 | + |
| 46 | + await inputController.close(); |
| 47 | + await inputAdded; |
| 48 | + await controller.close(); |
| 49 | + }, |
| 50 | + // https://github.com/dart-lang/webdev/issues/2126 |
| 51 | + skip: Platform.isWindows, |
| 52 | + ); |
47 | 53 |
|
48 | 54 | test('emits all inputs in order', () async { |
49 | 55 | const size = 10; |
|
0 commit comments