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

Side by Side Diff: tests/standalone/io/raw_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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 int bytesWritten = 0; 159 int bytesWritten = 0;
160 List<int> data = new List<int>(messageSize); 160 List<int> data = new List<int>(messageSize);
161 161
162 client.writeEventsEnabled = false; 162 client.writeEventsEnabled = false;
163 client.listen((event) { 163 client.listen((event) {
164 switch (event) { 164 switch (event) {
165 case RawSocketEvent.READ: 165 case RawSocketEvent.READ:
166 Expect.isTrue(bytesWritten == 0); 166 Expect.isTrue(bytesWritten == 0);
167 Expect.isTrue(client.available() > 0); 167 Expect.isTrue(client.available() > 0);
168 var buffer = client.read(); 168 var buffer = client.read();
169 data.setRange(bytesRead, buffer.length, buffer); 169 data.setRange(bytesRead, bytesRead + buffer.length, buffer);
170 bytesRead += buffer.length; 170 bytesRead += buffer.length;
171 if (bytesRead == data.length) { 171 if (bytesRead == data.length) {
172 verifyTestData(data); 172 verifyTestData(data);
173 client.writeEventsEnabled = true; 173 client.writeEventsEnabled = true;
174 } 174 }
175 break; 175 break;
176 case RawSocketEvent.WRITE: 176 case RawSocketEvent.WRITE:
177 Expect.isFalse(client.writeEventsEnabled); 177 Expect.isFalse(client.writeEventsEnabled);
178 bytesWritten += client.write( 178 bytesWritten += client.write(
179 data, bytesWritten, data.length - bytesWritten); 179 data, bytesWritten, data.length - bytesWritten);
(...skipping 15 matching lines...) Expand all
195 RawSocket.connect("127.0.0.1", server.port).then((socket) { 195 RawSocket.connect("127.0.0.1", server.port).then((socket) {
196 int bytesRead = 0; 196 int bytesRead = 0;
197 int bytesWritten = 0; 197 int bytesWritten = 0;
198 List<int> data = createTestData(); 198 List<int> data = createTestData();
199 199
200 socket.listen((event) { 200 socket.listen((event) {
201 switch (event) { 201 switch (event) {
202 case RawSocketEvent.READ: 202 case RawSocketEvent.READ:
203 Expect.isTrue(socket.available() > 0); 203 Expect.isTrue(socket.available() > 0);
204 var buffer = socket.read(); 204 var buffer = socket.read();
205 data.setRange(bytesRead, buffer.length, buffer); 205 data.setRange(bytesRead, bytesRead + buffer.length, buffer);
206 bytesRead += buffer.length; 206 bytesRead += buffer.length;
207 break; 207 break;
208 case RawSocketEvent.WRITE: 208 case RawSocketEvent.WRITE:
209 Expect.isTrue(bytesRead == 0); 209 Expect.isTrue(bytesRead == 0);
210 Expect.isFalse(socket.writeEventsEnabled); 210 Expect.isFalse(socket.writeEventsEnabled);
211 bytesWritten += socket.write( 211 bytesWritten += socket.write(
212 data, bytesWritten, data.length - bytesWritten); 212 data, bytesWritten, data.length - bytesWritten);
213 if (bytesWritten < data.length) { 213 if (bytesWritten < data.length) {
214 socket.writeEventsEnabled = true; 214 socket.writeEventsEnabled = true;
215 } else { 215 } else {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 testSimpleBind(); 349 testSimpleBind();
350 testCloseOneEnd("client"); 350 testCloseOneEnd("client");
351 testCloseOneEnd("server"); 351 testCloseOneEnd("server");
352 testInvalidBind(); 352 testInvalidBind();
353 testSimpleConnect(); 353 testSimpleConnect();
354 testServerListenAfterConnect(); 354 testServerListenAfterConnect();
355 testSimpleReadWrite(); 355 testSimpleReadWrite();
356 testPauseServerSocket(); 356 testPauseServerSocket();
357 testPauseSocket(); 357 testPauseSocket();
358 } 358 }
OLDNEW
« no previous file with comments | « tests/standalone/io/raw_secure_server_socket_test.dart ('k') | tests/standalone/io/secure_server_socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698