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

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

Issue 93973002: Add test of Zones for HttpServer and RawSocketServer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Stay in zone in raw socket/serversocket. Created 7 years 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 | « runtime/bin/socket_patch.dart ('k') | tests/standalone/io/raw_socket_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import "dart:async"; 5 import "dart:async";
6 import "dart:io"; 6 import "dart:io";
7 7
8 import "package:async_helper/async_helper.dart"; 8 import "package:async_helper/async_helper.dart";
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 server.close(); 53 server.close();
54 Expect.throws(() => server.port); 54 Expect.throws(() => server.port);
55 Expect.throws(() => server.address); 55 Expect.throws(() => server.address);
56 socket.close(); 56 socket.close();
57 asyncEnd(); 57 asyncEnd();
58 }); 58 });
59 }); 59 });
60 }); 60 });
61 } 61 }
62 62
63
64 void testHttpServerZone() {
65 asyncStart();
66 Expect.equals(Zone.ROOT, Zone.current);
67 runZoned(() {
68 Expect.notEquals(Zone.ROOT, Zone.current);
69 HttpServer.bind("127.0.0.1", 0).then((server) {
70 Expect.notEquals(Zone.ROOT, Zone.current);
71 server.listen((request) {
72 Expect.notEquals(Zone.ROOT, Zone.current);
73 request.response.close();
74 server.close();
75 });
76 new HttpClient().get("127.0.0.1", server.port, '/')
77 .then((request) => request.close())
78 .then((response) => response.drain())
79 .then((_) => asyncEnd());
80 });
81 });
82 }
83
84
85 void testHttpServerZoneError() {
86 asyncStart();
87 Expect.equals(Zone.ROOT, Zone.current);
88 runZoned(() {
89 Expect.notEquals(Zone.ROOT, Zone.current);
90 HttpServer.bind("127.0.0.1", 0).then((server) {
91 Expect.notEquals(Zone.ROOT, Zone.current);
92 server.listen((request) {
93 Expect.notEquals(Zone.ROOT, Zone.current);
94 request.listen((_) {}, onError: (error) {
95 Expect.notEquals(Zone.ROOT, Zone.current);
96 server.close();
97 throw error;
98 });
99 });
100 Socket.connect("127.0.0.1", server.port).then((socket) {
101 socket.write('GET / HTTP/1.1\r\nContent-Length: 100\r\n\r\n');
102 socket.write('some body');
103 socket.close();
104 });
105 });
106 }, onError: (e) {
107 asyncEnd();
108 });
109 }
110
111
63 void main() { 112 void main() {
64 testListenOn(); 113 testListenOn();
114 testHttpServerZone();
115 testHttpServerZoneError();
65 } 116 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | tests/standalone/io/raw_socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698