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

Unified Diff: tests/standalone/src/ListInputStreamTest.dart

Issue 8989019: Implement list based output stream and add pipe to list based input streams (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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
Index: tests/standalone/src/ListInputStreamTest.dart
diff --git a/tests/standalone/src/ListInputStreamTest.dart b/tests/standalone/src/ListInputStreamTest.dart
index c90cc74d1ccf1b2657e7097bd02f57b5160661a4..d8a1b9033f42fd0a19d004877cf9014f13430a26 100644
--- a/tests/standalone/src/ListInputStreamTest.dart
+++ b/tests/standalone/src/ListInputStreamTest.dart
@@ -7,7 +7,7 @@ void testEmptyListInputStream() {
ReceivePort donePort = new ReceivePort();
void onData() {
- throw "On data expected";
+ throw "No data expected";
}
void onClose() {
@@ -25,7 +25,7 @@ void testEmptyDynamicListInputStream() {
ReceivePort donePort = new ReceivePort();
void onData() {
- throw "On data expected";
+ throw "No data expected";
}
void onClose() {
@@ -87,6 +87,55 @@ void testListInputStream2() {
donePort.receive((x,y) => donePort.close());
}
+void testListInputStreamPipe1() {
+ List<int> data = [0x00, 0x01, 0x10, 0x11, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff];
+ InputStream input = new ListInputStream(data);
+ OutputStream output = new ListOutputStream();
+ ReceivePort donePort = new ReceivePort();
+
+ void onClose() {
+ var content = output.content();
+ Expect.equals(data.length, content.length);
+ donePort.toSendPort().send(null);
+ }
+
+ input.closeHandler = onClose;
+ input.pipe(output);
+
+ donePort.receive((x,y) => donePort.close());
+}
+
+void testListInputStreamPipe2() {
+ List<int> data = [0x00, 0x01, 0x10, 0x11, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff];
+ OutputStream output = new ListOutputStream();
+ ReceivePort donePort = new ReceivePort();
+ int count = 0;
+
+ void onClose() {
+ if (count < 10) {
+ InputStream input = new ListInputStream(data);
+ input.closeHandler = onClose;
+ if (count < 9) {
+ input.pipe(output, close: false);
+ } else {
+ input.pipe(output);
+ }
+ count++;
+ } else {
+ var content = output.content();
+ Expect.equals(data.length * 10, content.length);
+ donePort.toSendPort().send(null);
+ }
+ }
+
+ InputStream input = new ListInputStream(data);
+ input.closeHandler = onClose;
+ input.pipe(output, close: false);
+ count++;
+
+ donePort.receive((x,y) => donePort.close());
+}
+
void testDynamicListInputStream1() {
List<int> data = [0x00, 0x01, 0x10, 0x11, 0x7e, 0x7f, 0x80, 0x81, 0xfe, 0xff];
InputStream stream = new DynamicListInputStream();
@@ -123,5 +172,7 @@ main() {
testEmptyDynamicListInputStream();
testListInputStream1();
testListInputStream2();
+ testListInputStreamPipe1();
+ testListInputStreamPipe2();
testDynamicListInputStream1();
}

Powered by Google App Engine
This is Rietveld 408576698