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

Side by Side Diff: tests/standalone/io/raw_socket_write_destroy_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
« no previous file with comments | « tests/standalone/io/raw_socket_test.dart ('k') | tests/standalone/io/regress_8828_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 // 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:async"; 11 import "dart:async";
12 import "dart:io"; 12 import "dart:io";
13 import "dart:isolate"; 13 import "dart:isolate";
14 const SERVER_ADDRESS = "127.0.0.1"; 14 const SERVER_ADDRESS = "127.0.0.1";
15 15
16 void testWriteDestroyServer() { 16 void testWriteDestroyServer() {
17 int WROTE = 100000; 17 int WROTE = 100000;
18 RawServerSocket.bind(SERVER_ADDRESS).then((server) { 18 RawServerSocket.bind(SERVER_ADDRESS, 0).then((server) {
19 server.listen((socket) { 19 server.listen((socket) {
20 socket.writeEventsEnabled = false; 20 socket.writeEventsEnabled = false;
21 21
22 var buffer = new List.filled(WROTE, 0); 22 var buffer = new List.filled(WROTE, 0);
23 int offset = 0; 23 int offset = 0;
24 void write() { 24 void write() {
25 int n = socket.write(buffer, offset, buffer.length - offset); 25 int n = socket.write(buffer, offset, buffer.length - offset);
26 offset += n; 26 offset += n;
27 socket.writeEventsEnabled = true; 27 socket.writeEventsEnabled = true;
28 } 28 }
(...skipping 18 matching lines...) Expand all
47 socket.close(); 47 socket.close();
48 server.close(); 48 server.close();
49 } 49 }
50 }); 50 });
51 }); 51 });
52 }); 52 });
53 } 53 }
54 54
55 void testWriteDestroyClient() { 55 void testWriteDestroyClient() {
56 int WROTE = 100000; 56 int WROTE = 100000;
57 RawServerSocket.bind(SERVER_ADDRESS).then((server) { 57 RawServerSocket.bind(SERVER_ADDRESS, 0).then((server) {
58 server.listen((socket) { 58 server.listen((socket) {
59 var bytes = 0; 59 var bytes = 0;
60 socket.listen((e) { 60 socket.listen((e) {
61 if (e == RawSocketEvent.READ) { 61 if (e == RawSocketEvent.READ) {
62 bytes += socket.read().length; 62 bytes += socket.read().length;
63 } else if (e == RawSocketEvent.READ_CLOSED) { 63 } else if (e == RawSocketEvent.READ_CLOSED) {
64 Expect.equals(WROTE, bytes); 64 Expect.equals(WROTE, bytes);
65 socket.close(); 65 socket.close();
66 server.close(); 66 server.close();
67 } 67 }
(...skipping 20 matching lines...) Expand all
88 }); 88 });
89 write(); 89 write();
90 }); 90 });
91 }); 91 });
92 } 92 }
93 93
94 void main() { 94 void main() {
95 testWriteDestroyServer(); 95 testWriteDestroyServer();
96 testWriteDestroyClient(); 96 testWriteDestroyClient();
97 } 97 }
OLDNEW
« no previous file with comments | « tests/standalone/io/raw_socket_test.dart ('k') | tests/standalone/io/regress_8828_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698