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

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

Issue 8318009: Update the streams interfaces (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@ Created 9 years, 2 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/src/ProcessStderrTest.dart ('k') | tests/standalone/src/SocketExceptionTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/ProcessStdoutTest.dart
diff --git a/tests/standalone/src/ProcessStdoutTest.dart b/tests/standalone/src/ProcessStdoutTest.dart
index 51250d1a2c41d0a7dfd55f79a111c45ea2351d8a..7177144e5db14bbd5c57a20739135d598731a795 100644
--- a/tests/standalone/src/ProcessStdoutTest.dart
+++ b/tests/standalone/src/ProcessStdoutTest.dart
@@ -11,45 +11,52 @@
class ProcessStdoutTest {
- static void testExit() {
+ static void testStdout() {
Process process = new Process("out/Debug_ia32//process_test",
const ["0", "1", "99", "0"]);
final int BUFFERSIZE = 10;
final int STARTCHAR = 65;
- List<int> buffer = new List<int>(BUFFERSIZE);
+ List<int> data = new List<int>(BUFFERSIZE);
for (int i = 0; (i < BUFFERSIZE - 1); i++) {
- buffer[i] = STARTCHAR + i;
+ data[i] = STARTCHAR + i;
}
- buffer[BUFFERSIZE - 1] = 10;
+ data[BUFFERSIZE - 1] = 10;
InputStream input = process.stdout;
OutputStream output = process.stdin;
process.start();
- List<int> readBuffer = new List<int>(BUFFERSIZE);
+ int received = 0;
void dataWritten() {
void readData() {
- for (int i = 0; i < BUFFERSIZE; i++) {
- Expect.equals(buffer[i], readBuffer[i]);
+ List<int> buffer = input.read();
+ for (int i = 0; i < buffer.length; i++) {
+ Expect.equals(data[received + i], buffer[i]);
+ }
+ received += buffer.length;
+ if (received == BUFFERSIZE) {
+ process.close();
}
- process.close();
}
- bool read = input.read(readBuffer, 0, BUFFERSIZE, readData);
- if (read) {
- readData();
+ void streamClosed() {
+ Expect.equals(BUFFERSIZE, received);
}
+
+ input.dataHandler = readData;
+ input.closeHandler = streamClosed;
}
- bool written = output.write(buffer, 0, BUFFERSIZE, dataWritten);
+
+ bool written = output.write(data, 0, BUFFERSIZE, dataWritten);
if (written) {
dataWritten();
}
}
static void testMain() {
- testExit();
+ testStdout();
}
}
« no previous file with comments | « tests/standalone/src/ProcessStderrTest.dart ('k') | tests/standalone/src/SocketExceptionTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698