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

Side by Side Diff: tests/standalone/src/SocketManyConnectionsTest.dart

Issue 8386029: Consistently use setters to set event handlers in native APIs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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/src/SocketCloseTest.dart ('k') | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Test creating a large number of socket connections. 5 // Test creating a large number of socket connections.
6 6
7 final SERVERINIT = 0; 7 final SERVERINIT = 0;
8 final SERVERSHUTDOWN = -1; 8 final SERVERSHUTDOWN = -1;
9 final CONNECTIONS = 200; 9 final CONNECTIONS = 200;
10 final HOST = "127.0.0.1"; 10 final HOST = "127.0.0.1";
(...skipping 19 matching lines...) Expand all
30 for (int i = 0; i < CONNECTIONS; i++) { 30 for (int i = 0; i < CONNECTIONS; i++) {
31 _sockets[i].close(); 31 _sockets[i].close();
32 } 32 }
33 shutdown(); 33 shutdown();
34 } 34 }
35 } 35 }
36 36
37 for (int i = 0; i < CONNECTIONS; i++) { 37 for (int i = 0; i < CONNECTIONS; i++) {
38 _sockets[i] = new Socket(HOST, _port); 38 _sockets[i] = new Socket(HOST, _port);
39 if (_sockets[i] !== null) { 39 if (_sockets[i] !== null) {
40 _sockets[i].setConnectHandler(connectHandler); 40 _sockets[i].connectHandler = connectHandler;
41 } else { 41 } else {
42 Expect.fail("socket creation failed"); 42 Expect.fail("socket creation failed");
43 } 43 }
44 } 44 }
45 } 45 }
46 46
47 void start() { 47 void start() {
48 _receivePort.receive((var message, SendPort replyTo) { 48 _receivePort.receive((var message, SendPort replyTo) {
49 _port = message; 49 _port = message;
50 run(); 50 run();
(...skipping 24 matching lines...) Expand all
75 _client.close(); 75 _client.close();
76 } 76 }
77 77
78 void errorHandler() { 78 void errorHandler() {
79 print("Socket error"); 79 print("Socket error");
80 _client.close(); 80 _client.close();
81 } 81 }
82 82
83 _client = _server.accept(); 83 _client = _server.accept();
84 _connections++; 84 _connections++;
85 _client.setCloseHandler(closeHandler); 85 _client.closeHandler = closeHandler;
86 _client.setErrorHandler(errorHandler); 86 _client.errorHandler = errorHandler;
87 } 87 }
88 88
89 void errorHandlerServer() { 89 void errorHandlerServer() {
90 print("Server socket error"); 90 print("Server socket error");
91 _server.close(); 91 _server.close();
92 } 92 }
93 93
94 this.port.receive((message, SendPort replyTo) { 94 this.port.receive((message, SendPort replyTo) {
95 if (message == SERVERINIT) { 95 if (message == SERVERINIT) {
96 _server = new ServerSocket(HOST, 0, 10); 96 _server = new ServerSocket(HOST, 0, 10);
97 Expect.equals(true, _server !== null); 97 Expect.equals(true, _server !== null);
98 _server.setConnectionHandler(connectionHandler); 98 _server.connectionHandler = connectionHandler;
99 _server.setErrorHandler(errorHandlerServer); 99 _server.errorHandler = errorHandlerServer;
100 replyTo.send(_server.port, null); 100 replyTo.send(_server.port, null);
101 } else if (message == SERVERSHUTDOWN) { 101 } else if (message == SERVERSHUTDOWN) {
102 _server.close(); 102 _server.close();
103 this.port.close(); 103 this.port.close();
104 } 104 }
105 }); 105 });
106 } 106 }
107 107
108 ServerSocket _server; 108 ServerSocket _server;
109 int _connections = 0; 109 int _connections = 0;
110 } 110 }
111 111
112 main() { 112 main() {
113 SocketManyConnectionsTest test = new SocketManyConnectionsTest.start(); 113 SocketManyConnectionsTest test = new SocketManyConnectionsTest.start();
114 } 114 }
OLDNEW
« no previous file with comments | « tests/standalone/src/SocketCloseTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698