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

Side by Side Diff: tests/standalone/io/http_detach_socket_test.dart

Issue 14640008: Change the signature for all network bind calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments by whesse@ Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 import "dart:io"; 11 import "dart:io";
12 import "dart:isolate"; 12 import "dart:isolate";
13 13
14 void testServerDetachSocket() { 14 void testServerDetachSocket() {
15 HttpServer.bind().then((server) { 15 HttpServer.bind("127.0.0.1", 0).then((server) {
16 server.listen((request) { 16 server.listen((request) {
17 var response = request.response; 17 var response = request.response;
18 response.contentLength = 0; 18 response.contentLength = 0;
19 response.detachSocket().then((socket) { 19 response.detachSocket().then((socket) {
20 Expect.isNotNull(socket); 20 Expect.isNotNull(socket);
21 var body = new StringBuffer(); 21 var body = new StringBuffer();
22 socket.listen( 22 socket.listen(
23 (data) => body.write(new String.fromCharCodes(data)), 23 (data) => body.write(new String.fromCharCodes(data)),
24 onDone: () => Expect.equals("Some data", body.toString())); 24 onDone: () => Expect.equals("Some data", body.toString()));
25 socket.write("Test!"); 25 socket.write("Test!");
(...skipping 15 matching lines...) Expand all
41 "\r\n" 41 "\r\n"
42 "Test!", 42 "Test!",
43 body.toString()); 43 body.toString());
44 socket.close(); 44 socket.close();
45 }); 45 });
46 }); 46 });
47 }); 47 });
48 } 48 }
49 49
50 void testBadServerDetachSocket() { 50 void testBadServerDetachSocket() {
51 HttpServer.bind().then((server) { 51 HttpServer.bind("127.0.0.1", 0).then((server) {
52 server.listen((request) { 52 server.listen((request) {
53 var response = request.response; 53 var response = request.response;
54 response.contentLength = 0; 54 response.contentLength = 0;
55 response.close(); 55 response.close();
56 Expect.throws(response.detachSocket); 56 Expect.throws(response.detachSocket);
57 server.close(); 57 server.close();
58 }); 58 });
59 59
60 Socket.connect("127.0.0.1", server.port).then((socket) { 60 Socket.connect("127.0.0.1", server.port).then((socket) {
61 socket.write("GET / HTTP/1.1\r\n" 61 socket.write("GET / HTTP/1.1\r\n"
62 "content-length: 0\r\n\r\n"); 62 "content-length: 0\r\n\r\n");
63 socket.listen((_) {}, onDone: () { 63 socket.listen((_) {}, onDone: () {
64 socket.close(); 64 socket.close();
65 }); 65 });
66 }); 66 });
67 }); 67 });
68 } 68 }
69 69
70 void testClientDetachSocket() { 70 void testClientDetachSocket() {
71 ServerSocket.bind().then((server) { 71 ServerSocket.bind("127.0.0.1", 0).then((server) {
72 server.listen((socket) { 72 server.listen((socket) {
73 socket.write("HTTP/1.1 200 OK\r\n" 73 socket.write("HTTP/1.1 200 OK\r\n"
74 "\r\n" 74 "\r\n"
75 "Test!"); 75 "Test!");
76 var body = new StringBuffer(); 76 var body = new StringBuffer();
77 socket.listen( 77 socket.listen(
78 (data) => body.write(new String.fromCharCodes(data)), 78 (data) => body.write(new String.fromCharCodes(data)),
79 onDone: () { 79 onDone: () {
80 Expect.equals("GET / HTTP/1.1\r\n" 80 Expect.equals("GET / HTTP/1.1\r\n"
81 "accept-encoding: gzip\r\n" 81 "accept-encoding: gzip\r\n"
(...skipping 24 matching lines...) Expand all
106 }); 106 });
107 }); 107 });
108 }); 108 });
109 } 109 }
110 110
111 void main() { 111 void main() {
112 testServerDetachSocket(); 112 testServerDetachSocket();
113 testBadServerDetachSocket(); 113 testBadServerDetachSocket();
114 testClientDetachSocket(); 114 testClientDetachSocket();
115 } 115 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_content_length_test.dart ('k') | tests/standalone/io/http_head_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698