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

Unified Diff: tests/standalone/src/StreamPipeTest.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 | « tests/standalone/src/FileTest.dart ('k') | tests/standalone/src/TimerCancelTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/StreamPipeTest.dart
diff --git a/tests/standalone/src/StreamPipeTest.dart b/tests/standalone/src/StreamPipeTest.dart
index 0a313d721c7516ae60b2c37531c2308fe7fe931b..26d5ec2b618e839af41ac2947badd00b563c2c28 100644
--- a/tests/standalone/src/StreamPipeTest.dart
+++ b/tests/standalone/src/StreamPipeTest.dart
@@ -159,6 +159,11 @@ class PipeServer extends TestingServer {
// Test piping from one file to another and closing both streams
// after wards.
testFileToFilePipe1() {
+ // Force test to timeout if one of the handlers is
+ // not called.
+ ReceivePort donePort = new ReceivePort.singleShot();
+ donePort.receive((message, ignore) {});
+
String srcFileName =
getDataFilename("tests/standalone/src/readline_test1.dat");
var srcStream = new File(srcFileName).openInputStreamSync();
@@ -169,11 +174,12 @@ testFileToFilePipe1() {
new File(dstFileName).createSync();
var dstStream = new File(dstFileName).openOutputStreamSync();
- srcStream.closeHandler = () {
+ dstStream.closeHandler = () {
bool result = compareFileContent(srcFileName, dstFileName);
new File(dstFileName).deleteSync();
tempDir.deleteSync();
Expect.isTrue(result);
+ donePort.toSendPort().send(null);
};
srcStream.pipe(dstStream);
@@ -183,6 +189,11 @@ testFileToFilePipe1() {
// Test piping from one file to another and write additional data to
// the output stream after piping finished.
testFileToFilePipe2() {
+ // Force test to timeout if one of the handlers is
+ // not called.
+ ReceivePort donePort = new ReceivePort.singleShot();
+ donePort.receive((message, ignore) {});
+
String srcFileName =
getDataFilename("tests/standalone/src/readline_test1.dat");
var srcFile = new File(srcFileName);
@@ -198,22 +209,25 @@ testFileToFilePipe2() {
srcStream.closeHandler = () {
dstStream.write([32]);
dstStream.close();
- var src = srcFile.openSync();
- var dst = dstFile.openSync();
- var srcLength = src.lengthSync();
- var dstLength = dst.lengthSync();
- Expect.equals(srcLength + 1, dstLength);
- Expect.isTrue(compareFileContent(srcFileName,
- dstFileName,
- count: srcLength));
- dst.setPositionSync(srcLength);
- var data = new List<int>(1);
- var read2 = dst.readListSync(data, 0, 1);
- Expect.equals(32, data[0]);
- src.closeSync();
- dst.closeSync();
- dstFile.deleteSync();
- tempDir.deleteSync();
+ dstStream.closeHandler = () {
+ var src = srcFile.openSync();
+ var dst = dstFile.openSync();
+ var srcLength = src.lengthSync();
+ var dstLength = dst.lengthSync();
+ Expect.equals(srcLength + 1, dstLength);
+ Expect.isTrue(compareFileContent(srcFileName,
+ dstFileName,
+ count: srcLength));
+ dst.setPositionSync(srcLength);
+ var data = new List<int>(1);
+ var read2 = dst.readListSync(data, 0, 1);
+ Expect.equals(32, data[0]);
+ src.closeSync();
+ dst.closeSync();
+ dstFile.deleteSync();
+ tempDir.deleteSync();
+ donePort.toSendPort().send(null);
+ };
};
srcStream.pipe(dstStream, close: false);
@@ -222,6 +236,11 @@ testFileToFilePipe2() {
// Test piping two copies of one file to another.
testFileToFilePipe3() {
+ // Force test to timeout if one of the handlers is
+ // not called.
+ ReceivePort donePort = new ReceivePort.singleShot();
+ donePort.receive((message, ignore) {});
+
String srcFileName =
getDataFilename("tests/standalone/src/readline_test1.dat");
var srcFile = new File(srcFileName);
@@ -237,7 +256,7 @@ testFileToFilePipe3() {
srcStream.closeHandler = () {
var srcStream2 = srcFile.openInputStreamSync();
- srcStream2.closeHandler = () {
+ dstStream.closeHandler = () {
var src = srcFile.openSync();
var dst = dstFile.openSync();
var srcLength = src.lengthSync();
@@ -254,6 +273,7 @@ testFileToFilePipe3() {
dst.closeSync();
dstFile.deleteSync();
tempDir.deleteSync();
+ donePort.toSendPort().send(null);
};
// Pipe another copy of the source file.
« no previous file with comments | « tests/standalone/src/FileTest.dart ('k') | tests/standalone/src/TimerCancelTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698