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

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

Issue 9474004: Make FileInputStream and FileOutputStream actually asynchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 10 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/timer_impl.dart ('k') | tests/standalone/src/FileInvalidArgumentsTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/FileInputStreamTest.dart
diff --git a/tests/standalone/src/FileInputStreamTest.dart b/tests/standalone/src/FileInputStreamTest.dart
index c2d2aad8b0e60ae628bb2d32a7f5a1f11d9353a1..f8a08e16897b91fb1c6986c30577ee6c67e61b4f 100644
--- a/tests/standalone/src/FileInputStreamTest.dart
+++ b/tests/standalone/src/FileInputStreamTest.dart
@@ -32,7 +32,7 @@ void testInputStreamAsync() {
InputStream x = (new File(fileName)).openInputStreamSync();
var byteCount = 0;
x.dataHandler = () {
- Expect.equals(expected[byteCount], x.read(1)[0]);
+ Expect.equals(expected[byteCount], x.read(1)[0]);
byteCount++;
};
x.closeHandler = () {
@@ -63,29 +63,38 @@ void testStringInputStreamAsync(String name, int length) {
void testChunkedInputStream() {
+ // Force the test to timeout if it does not finish.
+ ReceivePort done = new ReceivePort.singleShot();
+ done.receive((message, replyTo) {});
+
String fileName = getFilename("tests/standalone/src/readuntil_test.dat");
// File contains 19 bytes ("Hello Dart\nwassup!")
File file = new File(fileName);
ChunkedInputStream x = new ChunkedInputStream(file.openInputStreamSync());
x.chunkSize = 9;
- List<int> chunk = x.read();
- Expect.equals(9, chunk.length);
- x.chunkSize = 5;
- chunk = x.read();
- Expect.equals(5, chunk.length);
- chunk = x.read();
- Expect.equals(5, chunk.length);
- chunk = x.read();
- Expect.equals(null, chunk);
+ x.dataHandler = () {
+ List<int> chunk = x.read();
+ Expect.equals(9, chunk.length);
+ x.chunkSize = 5;
+ x.dataHandler = () {
+ chunk = x.read();
+ Expect.equals(5, chunk.length);
+ x.dataHandler = () {
+ chunk = x.read();
+ Expect.equals(5, chunk.length);
+ chunk = x.read();
+ Expect.equals(null, chunk);
+ done.toSendPort().send(null);
+ };
+ };
+ };
}
void testOpenInputStreamAsync() {
// Create a port for waiting on the final result of this test.
- ReceivePort done = new ReceivePort();
- done.receive((message, replyTo) {
- done.close();
- });
+ ReceivePort done = new ReceivePort.singleShot();
+ done.receive((message, replyTo) {});
// Test using the asynchronous way of opening an input stream.
String fileName = getFilename("tests/standalone/src/readuntil_test.dat");
« no previous file with comments | « runtime/bin/timer_impl.dart ('k') | tests/standalone/src/FileInvalidArgumentsTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698