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

Side by Side Diff: tests/standalone/src/io/HttpServerEarlyClientCloseTest.dart

Issue 10073006: Update test to hopefully help detect flanky results on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #import("dart:io"); 1 #import("dart:io");
2 #import("dart:isolate"); 2 #import("dart:isolate");
3 3
4 void sendData(List<int> data, int port) { 4 void sendData(List<int> data, int port) {
5 Socket socket = new Socket("127.0.0.1", port); 5 Socket socket = new Socket("127.0.0.1", port);
6 socket.onConnect = () { 6 socket.onConnect = () {
7 socket.onData = () { 7 socket.onData = () {
8 Expect.fail("No data response was expected"); 8 Expect.fail("No data response was expected");
9 }; 9 };
10 socket.outputStream.onNoPendingWrites = () { 10 socket.outputStream.onNoPendingWrites = () {
11 socket.close(false); 11 socket.close(false);
12 }; 12 };
13 socket.outputStream.write(data); 13 socket.outputStream.write(data);
14 }; 14 };
15 } 15 }
16 16
17 class EarlyCloseTest { 17 class EarlyCloseTest {
18 EarlyCloseTest(Object this.data, 18 EarlyCloseTest(Object this.data,
19 String this.exception, 19 String this.exception,
20 [bool this.expectRequest = false]); 20 [bool this.expectRequest = false]);
21 21
22 Future execute(HttpServer server) { 22 Future execute(HttpServer server) {
23 Completer c = new Completer(); 23 Completer c = new Completer();
24 24
25 bool calledOnRequest = false; 25 bool calledOnRequest = false;
26 bool calledOnError = false;
26 server.onRequest = (HttpRequest request, HttpResponse response) { 27 server.onRequest = (HttpRequest request, HttpResponse response) {
27 Expect.isTrue(expectRequest); 28 Expect.isTrue(expectRequest);
29 Expect.isFalse(calledOnError);
28 Expect.isFalse(calledOnRequest, "onRequest called multiple times"); 30 Expect.isFalse(calledOnRequest, "onRequest called multiple times");
29 calledOnRequest = true; 31 calledOnRequest = true;
30 }; 32 };
31 ReceivePort port = new ReceivePort(); 33 ReceivePort port = new ReceivePort();
32 server.onError = (Exception error) { 34 server.onError = (Exception error) {
35 Expect.isFalse(calledOnError);
33 Expect.equals(exception, error.message); 36 Expect.equals(exception, error.message);
34 calledOnRequest = true; // onRequest is not allowed after onError. 37 Expect.equals(expectRequest, calledOnRequest);
38 calledOnError = true;
35 port.close(); 39 port.close();
36 c.complete(null); 40 c.complete(null);
37 }; 41 };
38 42
39 List<int> d; 43 List<int> d;
40 if (data is List<int>) d = data; 44 if (data is List<int>) d = data;
41 if (data is String) d = data.charCodes(); 45 if (data is String) d = data.charCodes();
42 if (d == null) Expect.fail("Invalid data"); 46 if (d == null) Expect.fail("Invalid data");
43 sendData(d, server.port); 47 sendData(d, server.port);
44 48
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } else { 84 } else {
81 server.close(); 85 server.close();
82 } 86 }
83 } 87 }
84 runTest(tests.iterator()); 88 runTest(tests.iterator());
85 } 89 }
86 90
87 void main() { 91 void main() {
88 testEarlyClose(); 92 testEarlyClose();
89 } 93 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698