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

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

Issue 10542102: Add buffering to _FileInputStream implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase to current bleeding-edge Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | tests/standalone/io/file_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/file_input_stream_test.dart
diff --git a/tests/standalone/io/file_input_stream_test.dart b/tests/standalone/io/file_input_stream_test.dart
index dc112d0250b7726ed084478172092b78caf40b87..31733b06b97f615b4edc135d506a80c6b98e161e 100644
--- a/tests/standalone/io/file_input_stream_test.dart
+++ b/tests/standalone/io/file_input_stream_test.dart
@@ -15,14 +15,18 @@ void testStringInputStreamSync() {
String fileName = getFilename("tests/standalone/io/readuntil_test.dat");
// File contains "Hello Dart\nwassup!\n"
File file = new File(fileName);
+ int linesRead = 0;
StringInputStream x = new StringInputStream(file.openInputStream());
x.onLine = () {
- // The file input stream is known (for now) to have read the whole
- // file when the data handler is called.
String line = x.readLine();
- Expect.equals("Hello Dart", line);
- line = x.readLine();
- Expect.equals("wassup!", line);
+ linesRead++;
+ if (linesRead == 1) {
+ Expect.equals("Hello Dart", line);
+ } else if (linesRead == 2) {
+ Expect.equals("wassup!", line);
+ } else {
+ Expect.fail("More or less than 2 lines read ($linesRead lines read).");
+ }
};
}
@@ -41,7 +45,6 @@ void testInputStreamAsync() {
};
}
-
void testStringInputStreamAsync(String name, int length) {
String fileName = getFilename("tests/standalone/io/$name");
// File contains 10 lines.
@@ -62,7 +65,6 @@ void testStringInputStreamAsync(String name, int length) {
};
}
-
void testChunkedInputStream() {
// Force the test to timeout if it does not finish.
ReceivePort done = new ReceivePort();
@@ -91,6 +93,26 @@ void testChunkedInputStream() {
};
}
+void testUnreadyInputStream() {
+ String fileName = getFilename("tests/standalone/io/readuntil_test.dat");
+ var expected = "Hello Dart\nwassup!\n".charCodes();
+ InputStream x = (new File(fileName)).openInputStream();
+ List<int> buffer = new List<int>(100);
+
+ x.onData = () {
+ Expect.fail("Input stream closed before opening called onData handler.");
+ };
+
+ x.onClosed = () { };
+
+ // Called before stream is ready.
+ int read = x.readInto(buffer);
+ Expect.equals(0, read);
+
+ // Called before stream is ready.
+ x.close();
+}
+
main() {
testStringInputStreamSync();
@@ -101,4 +123,5 @@ main() {
testStringInputStreamAsync("readline_test1.dat", 111);
testStringInputStreamAsync("readline_test2.dat", 114);
testChunkedInputStream();
+ testUnreadyInputStream();
}
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | tests/standalone/io/file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698