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

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

Issue 24680005: Fix socket_exception_test, that had an asyncStart() too late. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add status file change. Created 7 years, 2 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 | tests/standalone/standalone.status » ('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 // Tests socket exceptions. 5 // Tests socket exceptions.
6 6
7 import "dart:async"; 7 import "dart:async";
8 import "dart:io"; 8 import "dart:io";
9 9
10 import "package:async_helper/async_helper.dart"; 10 import "package:async_helper/async_helper.dart";
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 }); 147 });
148 client.add(new List.filled(SIZE, 0)); 148 client.add(new List.filled(SIZE, 0));
149 client.close(); 149 client.close();
150 // Start piping now. 150 // Start piping now.
151 completer.complete(null); 151 completer.complete(null);
152 }); 152 });
153 }); 153 });
154 } 154 }
155 155
156 static void clientSocketAddCloseErrorTest() { 156 static void clientSocketAddCloseErrorTest() {
157 asyncStart();
157 ServerSocket.bind("127.0.0.1", 0).then((server) { 158 ServerSocket.bind("127.0.0.1", 0).then((server) {
158 var completer = new Completer(); 159 var completer = new Completer();
159 server.listen((socket) { 160 server.listen((socket) {
160 completer.future.then((_) => socket.destroy()); 161 completer.future.then((_) => socket.destroy());
161 }); 162 });
162 Socket.connect("127.0.0.1", server.port).then((client) { 163 Socket.connect("127.0.0.1", server.port).then((client) {
163 const int SIZE = 1024 * 1024; 164 const int SIZE = 1024 * 1024;
164 int errors = 0; 165 int errors = 0;
165 client.listen( 166 client.listen(
166 (data) => Expect.fail("Unexpected data"), 167 (data) => Expect.fail("Unexpected data"),
167 onError: (error) { 168 onError: (error) {
168 Expect.isTrue(error is SocketException); 169 Expect.isTrue(error is SocketException);
169 errors++; 170 errors++;
170 }, 171 },
171 onDone: () { 172 onDone: () {
172 // We get either a close or an error followed by a close 173 // We get either a close or an error followed by a close
173 // on the socket. Whether we get both depends on 174 // on the socket. Whether we get both depends on
174 // whether the system notices the error for the read 175 // whether the system notices the error for the read
175 // event or only for the write event. 176 // event or only for the write event.
176 Expect.isTrue(errors <= 1); 177 Expect.isTrue(errors <= 1);
177 server.close(); 178 server.close();
178 }); 179 });
179 client.add(new List.filled(SIZE, 0)); 180 client.add(new List.filled(SIZE, 0));
180 // Destroy other socket now. 181 // Destroy other socket now.
181 completer.complete(null); 182 completer.complete(null);
182 asyncStart();
183 client.done.then( 183 client.done.then(
184 (_) { 184 (_) {
185 Expect.fail("Expected error"); 185 Expect.fail("Expected error");
186 }, 186 },
187 onError: (error) { 187 onError: (error) {
188 Expect.isTrue(error is SocketException); 188 Expect.isTrue(error is SocketException);
189 asyncEnd(); 189 asyncEnd();
190 }); 190 });
191 }); 191 });
192 }); 192 });
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 unknownHostTest(); 233 unknownHostTest();
234 } 234 }
235 } 235 }
236 236
237 main() { 237 main() {
238 asyncStart(); 238 asyncStart();
239 SocketExceptionTest.testMain(); 239 SocketExceptionTest.testMain();
240 asyncEnd(); 240 asyncEnd();
241 } 241 }
242 242
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698