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

Unified Diff: tests/standalone/src/io/HttpServerEarlyClientCloseTest.dart

Issue 10252020: test rename overhaul: step 12 - standalone (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 side-by-side diff with in-line comments
Download patch
Index: tests/standalone/src/io/HttpServerEarlyClientCloseTest.dart
diff --git a/tests/standalone/src/io/HttpServerEarlyClientCloseTest.dart b/tests/standalone/src/io/HttpServerEarlyClientCloseTest.dart
deleted file mode 100644
index 9df075c510c7ce5fc5e74b1392d30cc9ced39b7a..0000000000000000000000000000000000000000
--- a/tests/standalone/src/io/HttpServerEarlyClientCloseTest.dart
+++ /dev/null
@@ -1,94 +0,0 @@
-#import("dart:io");
-#import("dart:isolate");
-
-void sendData(List<int> data, int port) {
- Socket socket = new Socket("127.0.0.1", port);
- socket.onConnect = () {
- socket.onData = () {
- Expect.fail("No data response was expected");
- };
- socket.outputStream.onNoPendingWrites = () {
- socket.close(true);
- };
- socket.outputStream.write(data);
- };
-}
-
-class EarlyCloseTest {
- EarlyCloseTest(Object this.data,
- String this.exception,
- [bool this.expectRequest = false]);
-
- Future execute(HttpServer server) {
- Completer c = new Completer();
-
- bool calledOnRequest = false;
- bool calledOnError = false;
- server.defaultRequestHandler =
- (HttpRequest request, HttpResponse response) {
- Expect.isTrue(expectRequest);
- Expect.isFalse(calledOnError);
- Expect.isFalse(calledOnRequest, "onRequest called multiple times");
- calledOnRequest = true;
- };
- ReceivePort port = new ReceivePort();
- server.onError = (Exception error) {
- Expect.isFalse(calledOnError);
- Expect.equals(exception, error.message);
- Expect.equals(expectRequest, calledOnRequest);
- calledOnError = true;
- port.close();
- c.complete(null);
- };
-
- List<int> d;
- if (data is List<int>) d = data;
- if (data is String) d = data.charCodes();
- if (d == null) Expect.fail("Invalid data");
- sendData(d, server.port);
-
- return c.future;
- }
-
- final Object data;
- final String exception;
- final bool expectRequest;
-}
-
-void testEarlyClose() {
- List<EarlyCloseTest> tests = new List<EarlyCloseTest>();
- void add(Object data, String exception, [bool expectRequest = false]) {
- tests.add(new EarlyCloseTest(data, exception, expectRequest));
- }
- // The empty packet is valid.
-
- // Close while sending header
- add("G", "Connection closed before full header was received");
- add("GET /", "Connection closed before full header was received");
- add("GET / HTTP/1.1", "Connection closed before full header was received");
- add("GET / HTTP/1.1\r\n", "Connection closed before full header was received");
-
- // Close while sending content
- add("GET / HTTP/1.1\r\nContent-Length: 100\r\n\r\n",
- "Connection closed before full body was received",
- expectRequest: true);
- add("GET / HTTP/1.1\r\nContent-Length: 100\r\n\r\n1",
- "Connection closed before full body was received",
- expectRequest: true);
-
-
- HttpServer server = new HttpServer();
- server.listen("127.0.0.1", 0);
- void runTest(Iterator it) {
- if (it.hasNext()) {
- it.next().execute(server).then((_) => runTest(it));
- } else {
- server.close();
- }
- }
- runTest(tests.iterator());
-}
-
-void main() {
- testEarlyClose();
-}
« no previous file with comments | « tests/standalone/src/io/HttpParserTest.dart ('k') | tests/standalone/src/io/HttpServerEarlyServerCloseTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698