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

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

Issue 18684004: Fix error in standalone/io/secure_socket_bad_data_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | « no previous file | 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) 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 Expect.isTrue(e.toString().contains( 82 Expect.isTrue(e.toString().contains(
83 'received a record with an incorrect Message Authentication Code')); 83 'received a record with an incorrect Message Authentication Code'));
84 completer.complete(null); 84 completer.complete(null);
85 }); 85 });
86 return completer.future; 86 return completer.future;
87 } 87 }
88 88
89 Future<RawSocket> runClient(List sockets) { 89 Future<RawSocket> runClient(List sockets) {
90 RawSocket baseSocket = sockets[0]; 90 RawSocket baseSocket = sockets[0];
91 RawSecureSocket socket = sockets[1]; 91 RawSecureSocket socket = sockets[1];
92 final completer = new Completer(); 92 final completer = new Completer();
Anders Johnsen 2013/07/04 11:36:56 Make completer var and test for null?
93 bool completed = false;
94 void tryComplete() {
95 if (!completed) {
96 completed = true;
97 completer.complete(null);
98 }
99 }
93 final data = createTestData(); 100 final data = createTestData();
94 int bytesWritten = 0; 101 int bytesWritten = 0;
95 socket.listen((event) { 102 socket.listen((event) {
96 switch (event) { 103 switch (event) {
97 case RawSocketEvent.READ: 104 case RawSocketEvent.READ:
98 Expect.fail('READ event received'); 105 Expect.fail('READ event received');
99 break; 106 break;
100 case RawSocketEvent.WRITE: 107 case RawSocketEvent.WRITE:
101 if (bytesWritten < data.length) { 108 if (bytesWritten < data.length) {
102 bytesWritten += socket.write(data, bytesWritten); 109 bytesWritten += socket.write(data, bytesWritten);
103 } 110 }
104 if (bytesWritten < data.length) { 111 if (bytesWritten < data.length) {
105 socket.writeEventsEnabled = true; 112 socket.writeEventsEnabled = true;
106 } 113 }
107 if (bytesWritten == data.length) { 114 if (bytesWritten == data.length) {
108 baseSocket.write(data, 0, 300); 115 baseSocket.write(data, 0, 300);
109 socket.shutdown(SocketDirection.SEND); 116 socket.shutdown(SocketDirection.SEND);
110 } 117 }
111 break; 118 break;
112 case RawSocketEvent.READ_CLOSED: 119 case RawSocketEvent.READ_CLOSED:
113 completer.complete(null); 120 tryComplete();
114 break; 121 break;
115 default: throw "Unexpected event $event"; 122 default: throw "Unexpected event $event";
116 } 123 }
117 }, 124 },
118 onError: (e) { 125 onError: (e) {
119 Expect.isTrue(e is IOException); 126 Expect.isTrue(e is IOException);
120 completer.complete(null); 127 tryComplete();
121 }); 128 });
122 return completer.future; 129 return completer.future;
123 } 130 }
124 131
125 132
126 Future<List> connectClient(int port) => 133 Future<List> connectClient(int port) =>
127 RawSocket.connect(HOST_NAME, port) 134 RawSocket.connect(HOST_NAME, port)
128 .then((socket) => 135 .then((socket) =>
129 (hostnameInConnect ? RawSecureSocket.secure(socket) 136 (hostnameInConnect ? RawSecureSocket.secure(socket)
130 : RawSecureSocket.secure(socket, host: HOST_NAME)) 137 : RawSecureSocket.secure(socket, host: HOST_NAME))
(...skipping 18 matching lines...) Expand all
149 156
150 main() { 157 main() {
151 Path scriptDir = new Path(Platform.script).directoryPath; 158 Path scriptDir = new Path(Platform.script).directoryPath;
152 Path certificateDatabase = scriptDir.append('pkcert'); 159 Path certificateDatabase = scriptDir.append('pkcert');
153 SecureSocket.initialize(database: certificateDatabase.toNativePath(), 160 SecureSocket.initialize(database: certificateDatabase.toNativePath(),
154 password: 'dartdart', 161 password: 'dartdart',
155 useBuiltinRoots: false); 162 useBuiltinRoots: false);
156 test(false); 163 test(false);
157 test(true); 164 test(true);
158 } 165 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698