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

Unified Diff: tests/standalone/io/file_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 | « tests/standalone/io/file_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/file_test.dart
diff --git a/tests/standalone/io/file_test.dart b/tests/standalone/io/file_test.dart
index 852b2534ac83f341aa7db9267f5020591ac5bca8..3411f8891f4d9c6a8c08d989e4bf11db6a53a3a7 100644
--- a/tests/standalone/io/file_test.dart
+++ b/tests/standalone/io/file_test.dart
@@ -78,41 +78,54 @@ class FileTest {
int bytesRead;
// Test reading all using readInto.
- file = new File(inFilename);
- input = file.openInputStream();
- input.onData = () {
- List<int> buffer1 = new List<int>(42);
- bytesRead = input.readInto(buffer1, 0, 42);
+ var file1 = new File(inFilename);
+ var input1 = file1.openInputStream();
+ List<int> buffer1;
+ input1.onData = () {
+ buffer1 = new List<int>(42);
+ bytesRead = input1.readInto(buffer1, 0, 42);
Expect.equals(42, bytesRead);
- Expect.isTrue(input.closed);
+ };
+ input1.onError = (e) { throw e; };
+ input1.onClosed = () {
+ Expect.isTrue(input1.closed);
// Test reading all using readInto and read.
- file = new File(inFilename);
- input = file.openInputStream();
- input.onData = () {
- bytesRead = input.readInto(buffer1, 0, 21);
+ var file2 = new File(inFilename);
+ var input2 = file2.openInputStream();
+ input2.onData = () {
+ bytesRead = input2.readInto(buffer1, 0, 21);
Expect.equals(21, bytesRead);
- buffer1 = input.read();
+ buffer1 = input2.read();
Expect.equals(21, buffer1.length);
- Expect.isTrue(input.closed);
+ };
+ input2.onError = (e) { throw e; };
+ input2.onClosed = () {
+ Expect.isTrue(input2.closed);
// Test reading all using read and readInto.
- file = new File(inFilename);
- input = file.openInputStream();
- input.onData = () {
- buffer1 = input.read(21);
+ var file3 = new File(inFilename);
+ var input3 = file3.openInputStream();
+ input3.onData = () {
+ buffer1 = input3.read(21);
Expect.equals(21, buffer1.length);
- bytesRead = input.readInto(buffer1, 0, 21);
+ bytesRead = input3.readInto(buffer1, 0, 21);
Expect.equals(21, bytesRead);
- Expect.isTrue(input.closed);
+ };
+ input3.onError = (e) { throw e; };
+ input3.onClosed = () {
+ Expect.isTrue(input3.closed);
// Test reading all using read.
- file = new File(inFilename);
- input = file.openInputStream();
- input.onData = () {
- buffer1 = input.read();
+ var file4 = new File(inFilename);
+ var input4 = file4.openInputStream();
+ input4.onData = () {
+ buffer1 = input4.read();
Expect.equals(42, buffer1.length);
- Expect.isTrue(input.closed);
+ };
+ input4.onError = (e) { throw e; };
+ input4.onClosed = () {
+ Expect.isTrue(input4.closed);
// Write the contents of the file just read into another file.
String outFilename =
@@ -126,20 +139,21 @@ class FileTest {
output.onClosed = () {
// Now read the contents of the file just written.
List<int> buffer2 = new List<int>(42);
- file = new File(outFilename);
- input = file.openInputStream();
- input.onData = () {
- bytesRead = input.readInto(buffer2, 0, 42);
+ var file6 = new File(outFilename);
+ var input6 = file6.openInputStream();
+ input6.onData = () {
+ bytesRead = input6.readInto(buffer2, 0, 42);
Expect.equals(42, bytesRead);
// Now compare the two buffers to check if they are identical.
for (int i = 0; i < buffer1.length; i++) {
Expect.equals(buffer1[i], buffer2[i]);
}
};
- input.onClosed = () {
+ input6.onError = (e) { throw e; };
+ input6.onClosed = () {
// Delete the output file.
- file.deleteSync();
- Expect.isFalse(file.existsSync());
+ file6.deleteSync();
+ Expect.isFalse(file6.existsSync());
asyncTestDone("testReadWriteStream");
};
};
« no previous file with comments | « tests/standalone/io/file_input_stream_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698