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

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

Issue 13863012: Refactor List.setRange function. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Created 7 years, 8 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";
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 SecureServerSocket.bind(SERVER_ADDRESS, 0, 5, CERTIFICATE).then((server) { 161 SecureServerSocket.bind(SERVER_ADDRESS, 0, 5, CERTIFICATE).then((server) {
162 server.listen((client) { 162 server.listen((client) {
163 int bytesRead = 0; 163 int bytesRead = 0;
164 int bytesWritten = 0; 164 int bytesWritten = 0;
165 List<int> data = new List<int>(messageSize); 165 List<int> data = new List<int>(messageSize);
166 166
167 client.listen( 167 client.listen(
168 (buffer) { 168 (buffer) {
169 Expect.isTrue(bytesWritten == 0); 169 Expect.isTrue(bytesWritten == 0);
170 data.setRange(bytesRead, buffer.length, buffer); 170 data.setRange(bytesRead, bytesRead + buffer.length, buffer);
171 bytesRead += buffer.length; 171 bytesRead += buffer.length;
172 if (bytesRead == data.length) { 172 if (bytesRead == data.length) {
173 verifyTestData(data); 173 verifyTestData(data);
174 client.add(data); 174 client.add(data);
175 client.close(); 175 client.close();
176 } 176 }
177 }, 177 },
178 onDone: () { 178 onDone: () {
179 server.close(); 179 server.close();
180 }); 180 });
181 }); 181 });
182 182
183 SecureSocket.connect(HOST_NAME, server.port).then((socket) { 183 SecureSocket.connect(HOST_NAME, server.port).then((socket) {
184 int bytesRead = 0; 184 int bytesRead = 0;
185 int bytesWritten = 0; 185 int bytesWritten = 0;
186 List<int> dataSent = createTestData(); 186 List<int> dataSent = createTestData();
187 List<int> dataReceived = new List<int>(dataSent.length); 187 List<int> dataReceived = new List<int>(dataSent.length);
188 socket.add(dataSent); 188 socket.add(dataSent);
189 socket.close(); // Can also be delayed. 189 socket.close(); // Can also be delayed.
190 socket.listen( 190 socket.listen(
191 (List<int> buffer) { 191 (List<int> buffer) {
192 dataReceived.setRange(bytesRead, buffer.length, buffer); 192 dataReceived.setRange(bytesRead, bytesRead + buffer.length, buffer);
193 bytesRead += buffer.length; 193 bytesRead += buffer.length;
194 }, 194 },
195 onDone: () { 195 onDone: () {
196 verifyTestData(dataReceived); 196 verifyTestData(dataReceived);
197 socket.close(); 197 socket.close();
198 port.close(); 198 port.close();
199 }); 199 });
200 }); 200 });
201 }); 201 });
202 } 202 }
203 203
204 main() { 204 main() {
205 Path scriptDir = new Path(new Options().script).directoryPath; 205 Path scriptDir = new Path(new Options().script).directoryPath;
206 Path certificateDatabase = scriptDir.append('pkcert'); 206 Path certificateDatabase = scriptDir.append('pkcert');
207 SecureSocket.initialize(database: certificateDatabase.toNativePath(), 207 SecureSocket.initialize(database: certificateDatabase.toNativePath(),
208 password: 'dartdart', 208 password: 'dartdart',
209 useBuiltinRoots: false); 209 useBuiltinRoots: false);
210 testArguments(); 210 testArguments();
211 testSimpleBind(); 211 testSimpleBind();
212 testInvalidBind(); 212 testInvalidBind();
213 testSimpleConnect(CERTIFICATE); 213 testSimpleConnect(CERTIFICATE);
214 testSimpleConnect("CN=localhost"); 214 testSimpleConnect("CN=localhost");
215 testSimpleConnectFail("not_a_nickname"); 215 testSimpleConnectFail("not_a_nickname");
216 testSimpleConnectFail("CN=notARealDistinguishedName"); 216 testSimpleConnectFail("CN=notARealDistinguishedName");
217 testServerListenAfterConnect(); 217 testServerListenAfterConnect();
218 testSimpleReadWrite(); 218 testSimpleReadWrite();
219 } 219 }
OLDNEW
« no previous file with comments | « tests/standalone/io/raw_socket_test.dart ('k') | tests/standalone/io/web_socket_protocol_processor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698