Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: test/stream_channel_test.dart

Issue 2048473002: Fix transformer tests. (Closed) Base URL: git@github.com:dart-lang/stream_channel.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 7
8 import 'package:async/async.dart'; 8 import 'package:async/async.dart';
9 import 'package:stream_channel/stream_channel.dart'; 9 import 'package:stream_channel/stream_channel.dart';
10 import 'package:test/test.dart'; 10 import 'package:test/test.dart';
(...skipping 23 matching lines...) Expand all
34 streamController.close(); 34 streamController.close();
35 expect(otherSinkController.stream.toList(), completion(equals([1, 2, 3]))); 35 expect(otherSinkController.stream.toList(), completion(equals([1, 2, 3])));
36 36
37 otherStreamController.add(4); 37 otherStreamController.add(4);
38 otherStreamController.add(5); 38 otherStreamController.add(5);
39 otherStreamController.add(6); 39 otherStreamController.add(6);
40 otherStreamController.close(); 40 otherStreamController.close();
41 expect(sinkController.stream.toList(), completion(equals([4, 5, 6]))); 41 expect(sinkController.stream.toList(), completion(equals([4, 5, 6])));
42 }); 42 });
43 43
44 test("transform() transforms the channel", () { 44 test("transform() transforms the channel", () async {
45 var transformed = channel.transform( 45 var transformed = channel.transform(
46 new StreamChannelTransformer.fromCodec(UTF8)); 46 new StreamChannelTransformer.fromCodec(UTF8));
47 47
48 streamController.add([102, 111, 111, 98, 97, 114]); 48 streamController.add([102, 111, 111, 98, 97, 114]);
49 streamController.close(); 49 streamController.close();
50 expect(transformed.stream.toList(), completion(equals(["foobar"]))); 50 expect(await transformed.stream.toList(), equals(["foobar"]));
51 51
52 transformed.sink.add("fblthp"); 52 transformed.sink.add("fblthp");
53 transformed.sink.close(); 53 transformed.sink.close();
54 expect(sinkController.stream.toList(), 54 expect(sinkController.stream.toList(),
55 completion(equals([[102, 98, 108, 116, 104, 112]]))); 55 completion(equals([[102, 98, 108, 116, 104, 112]])));
56 }); 56 });
57 57
58 test("transformStream() transforms only the stream", () { 58 test("transformStream() transforms only the stream", () async {
59 var transformed = channel.transformStream(UTF8.decoder); 59 var transformed = channel.transformStream(UTF8.decoder);
60 60
61 streamController.add([102, 111, 111, 98, 97, 114]); 61 streamController.add([102, 111, 111, 98, 97, 114]);
62 streamController.close(); 62 streamController.close();
63 expect(transformed.stream.toList(), completion(equals(["foobar"]))); 63 expect(await transformed.stream.toList(), equals(["foobar"]));
64 64
65 transformed.sink.add("fblthp"); 65 transformed.sink.add("fblthp");
66 transformed.sink.close(); 66 transformed.sink.close();
67 expect(sinkController.stream.toList(), 67 expect(sinkController.stream.toList(),
68 completion(equals(["fblthp"]))); 68 completion(equals(["fblthp"])));
69 }); 69 });
70 70
71 test("transformSink() transforms only the sink", () { 71 test("transformSink() transforms only the sink", () async {
72 var transformed = channel.transformSink( 72 var transformed = channel.transformSink(
73 new StreamSinkTransformer.fromStreamTransformer(UTF8.encoder)); 73 new StreamSinkTransformer.fromStreamTransformer(UTF8.encoder));
74 74
75 streamController.add([102, 111, 111, 98, 97, 114]); 75 streamController.add([102, 111, 111, 98, 97, 114]);
76 streamController.close(); 76 streamController.close();
77 expect(transformed.stream.toList(), 77 expect(await transformed.stream.toList(),
78 completion(equals([[102, 111, 111, 98, 97, 114]]))); 78 equals([[102, 111, 111, 98, 97, 114]]));
79 79
80 transformed.sink.add("fblthp"); 80 transformed.sink.add("fblthp");
81 transformed.sink.close(); 81 transformed.sink.close();
82 expect(sinkController.stream.toList(), 82 expect(sinkController.stream.toList(),
83 completion(equals([[102, 98, 108, 116, 104, 112]]))); 83 completion(equals([[102, 98, 108, 116, 104, 112]])));
84 }); 84 });
85 85
86 test("changeStream() changes the stream", () { 86 test("changeStream() changes the stream", () {
87 var newController = new StreamController(); 87 var newController = new StreamController();
88 var changed = channel.changeStream((stream) { 88 var changed = channel.changeStream((stream) {
(...skipping 17 matching lines...) Expand all
106 return newController.sink; 106 return newController.sink;
107 }); 107 });
108 108
109 expect(newController.stream.toList(), completion(equals([10]))); 109 expect(newController.stream.toList(), completion(equals([10])));
110 streamController.stream.listen(expectAsync((_) {}, count: 0)); 110 streamController.stream.listen(expectAsync((_) {}, count: 0));
111 111
112 changed.sink.add(10); 112 changed.sink.add(10);
113 changed.sink.close(); 113 changed.sink.close();
114 }); 114 });
115 } 115 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698