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

Unified Diff: tests/standalone/io/list_output_stream_test.dart

Issue 10832145: Add a ListOutputStream.onData callback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/standalone/io/list_input_stream_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/list_output_stream_test.dart
diff --git a/tests/standalone/io/list_output_stream_test.dart b/tests/standalone/io/list_output_stream_test.dart
index 40b36bd16f45412ad5ada8b92cffec3102fa2072..812c4b3d3a3844b07e00347c682df4150abe2d19 100644
--- a/tests/standalone/io/list_output_stream_test.dart
+++ b/tests/standalone/io/list_output_stream_test.dart
@@ -7,9 +7,9 @@
void testEmptyListOutputStream1() {
ListOutputStream stream = new ListOutputStream();
- Expect.equals(null, stream.contents());
+ Expect.equals(null, stream.read());
stream.close();
- Expect.equals(null, stream.contents());
+ Expect.equals(null, stream.read());
Expect.throws(() { stream.write([0]); });
}
@@ -23,7 +23,7 @@ void testEmptyListOutputStream2() {
}
void onClosed() {
- Expect.equals(null, stream.contents());
+ Expect.equals(null, stream.read());
donePort.toSendPort().send(null);
}
@@ -36,15 +36,15 @@ void testEmptyListOutputStream2() {
void testListOutputStream1() {
ListOutputStream stream = new ListOutputStream();
- Expect.equals(null, stream.contents());
+ Expect.equals(null, stream.read());
stream.write([1, 2]);
stream.writeFrom([1, 2, 3, 4, 5], 2, 2);
stream.write([5]);
stream.close();
- var contents = stream.contents();
+ var contents = stream.read();
Expect.equals(5, contents.length);
for (var i = 0; i < contents.length; i++) Expect.equals(i + 1, contents[i]);
- Expect.equals(null, stream.contents());
+ Expect.equals(null, stream.read());
}
@@ -72,10 +72,10 @@ void testListOutputStream2() {
void onClosed() {
Expect.equals(4, stage);
- var contents = stream.contents();
+ var contents = stream.read();
Expect.equals(5, contents.length);
for (var i = 0; i < contents.length; i++) Expect.equals(i + 1, contents[i]);
- Expect.equals(null, stream.contents());
+ Expect.equals(null, stream.read());
donePort.toSendPort().send(null);
}
@@ -98,7 +98,7 @@ void testListOutputStream3() {
}
void onClosed() {
- var contents = stream.contents();
+ var contents = stream.read();
Expect.equals(38, contents.length);
donePort.toSendPort().send(null);
}
@@ -109,10 +109,41 @@ void testListOutputStream3() {
donePort.receive((x,y) => donePort.close());
}
+void testListOutputStream4() {
+ ListOutputStream stream = new ListOutputStream();
+ ReceivePort donePort = new ReceivePort();
+ List result = <int>[];
+
+ void onData() => result.addAll(stream.read());
+
+ void onClosed() {
+ Expect.equals(4, result.length);
+ for (var i = 0; i < result.length; i++) Expect.equals(i + 1, result[i]);
+ donePort.toSendPort().send(null);
+ }
+
+ stream.onData = onData;
+ stream.onClosed = onClosed;
+
+ new Timer(0, (_) {
+ result.add(1);
+ stream.write([2]);
+
+ new Timer(0, (_) {
+ result.add(3);
+ stream.write([4]);
+ stream.close();
+ });
+ });
+
+ donePort.receive((x,y) => donePort.close());
+}
+
main() {
testEmptyListOutputStream1();
testEmptyListOutputStream2();
testListOutputStream1();
testListOutputStream2();
testListOutputStream3();
+ testListOutputStream4();
}
« no previous file with comments | « tests/standalone/io/list_input_stream_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698