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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 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
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 "dart:async"; 10 import "dart:async";
(...skipping 19 matching lines...) Expand all
30 // Be sure to close as subscription.cancel may not be called, if 30 // Be sure to close as subscription.cancel may not be called, if
31 // backlog prevents acceptCount to grow to socketCount / 2. 31 // backlog prevents acceptCount to grow to socketCount / 2.
32 server.close(); 32 server.close();
33 } 33 }
34 } 34 }
35 35
36 var subscription; 36 var subscription;
37 subscription = server.listen((client) { 37 subscription = server.listen((client) {
38 client.writeEventsEnabled = false; 38 client.writeEventsEnabled = false;
39 client.listen((event) { 39 client.listen((event) {
40 switch(event) { 40 switch (event) {
41 case RawSocketEvent.READ: 41 case RawSocketEvent.READ:
42 client.read(); 42 client.read();
43 break; 43 break;
44 case RawSocketEvent.READ_CLOSED: 44 case RawSocketEvent.READ_CLOSED:
45 client.shutdown(SocketDirection.SEND); 45 client.shutdown(SocketDirection.SEND);
46 break; 46 break;
47 case RawSocketEvent.WRITE: 47 case RawSocketEvent.WRITE:
48 Expect.fail("No write event expected"); 48 Expect.fail("No write event expected");
49 break; 49 break;
50 } 50 }
(...skipping 12 matching lines...) Expand all
63 }); 63 });
64 } 64 }
65 }); 65 });
66 66
67 // Connect a number of sockets. 67 // Connect a number of sockets.
68 for (int i = 0; i < socketCount; i++) { 68 for (int i = 0; i < socketCount; i++) {
69 RawSocket.connect("127.0.0.1", server.port).then((socket) { 69 RawSocket.connect("127.0.0.1", server.port).then((socket) {
70 bool done = false; 70 bool done = false;
71 var subscription; 71 var subscription;
72 subscription = socket.listen((event) { 72 subscription = socket.listen((event) {
73 switch(event) { 73 switch (event) {
74 case RawSocketEvent.READ: 74 case RawSocketEvent.READ:
75 Expect.fail("No read event expected"); 75 Expect.fail("No read event expected");
76 break; 76 break;
77 case RawSocketEvent.READ_CLOSED: 77 case RawSocketEvent.READ_CLOSED:
78 done = true; 78 done = true;
79 doneCount++; 79 doneCount++;
80 checkDone(); 80 checkDone();
81 break; 81 break;
82 case RawSocketEvent.WRITE: 82 case RawSocketEvent.WRITE:
83 // We don't care if this write succeeds, so we don't check 83 // We don't care if this write succeeds, so we don't check
84 // the return value (number of bytes written). 84 // the return value (number of bytes written).
85 socket.write([1,2,3]); 85 socket.write([1, 2, 3]);
86 socket.shutdown(SocketDirection.SEND); 86 socket.shutdown(SocketDirection.SEND);
87 break; 87 break;
88 } 88 }
89 }, 89 }, onDone: () {
90 onDone: () {
91 if (!done) { 90 if (!done) {
92 doneCount++; 91 doneCount++;
93 checkDone(); 92 checkDone();
94 } 93 }
95 }, 94 }, onError: (e) {
96 onError: (e) {
97 // "Connection reset by peer" errors are handled here. 95 // "Connection reset by peer" errors are handled here.
98 errorCount++; 96 errorCount++;
99 checkDone(); 97 checkDone();
100 }, cancelOnError: true); 98 }, cancelOnError: true);
101 }).catchError((e) { 99 }).catchError((e) {
102 // "Connection actively refused by host" errors are handled here. 100 // "Connection actively refused by host" errors are handled here.
103 earlyErrorCount++; 101 earlyErrorCount++;
104 checkDone(); 102 checkDone();
105 }); 103 });
106 } 104 }
107 }); 105 });
108 } 106 }
109 107
110 void main() { 108 void main() {
111 testCancelResubscribeServerSocket(10, 20); 109 testCancelResubscribeServerSocket(10, 20);
112 testCancelResubscribeServerSocket(20, 5); 110 testCancelResubscribeServerSocket(20, 5);
113 } 111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698