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

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: Starting implementation 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
Index: tests/standalone/src/ProcessStdoutTest.dart
diff --git a/tests/standalone/src/ProcessStdoutTest.dart b/tests/standalone/src/ProcessStdoutTest.dart
index 9ef5e4c83c62e200438a9359fecc44eabfaf2fae..5c7208229a8e4c06694deb04783dc47bdc33ba81 100644
--- a/tests/standalone/src/ProcessStdoutTest.dart
+++ b/tests/standalone/src/ProcessStdoutTest.dart
@@ -11,45 +11,53 @@
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;
- SocketInputStream input = process.stdoutStream;
- SocketOutputStream output = process.stdinStream;
+ InputStream2 input = process.stdoutStream;
+ OutputStream output = process.stdinStream;
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();
+ print(buffer.length);
+ 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();
}
}

Powered by Google App Engine
This is Rietveld 408576698