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

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

Issue 8413034: New OutputStream interface (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@ 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/ProcessStdoutTest.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 // Tests socket exceptions. 5 // Tests socket exceptions.
6 6
7 class SocketExceptionTest { 7 class SocketExceptionTest {
8 8
9 static final PORT = 0; 9 static final PORT = 0;
10 static final HOST = "127.0.0.1"; 10 static final HOST = "127.0.0.1";
11 11
12 static void serverSocketExceptionTest() { 12 static void serverSocketExceptionTest() {
13 bool exceptionCaught = false; 13 bool exceptionCaught = false;
14 bool wrongExceptionCaught = false; 14 bool wrongExceptionCaught = false;
15 15
16 ServerSocket server = new ServerSocket(HOST, PORT, 10); 16 ServerSocket server = new ServerSocket(HOST, PORT, 10);
17 Expect.equals(true, server !== null); 17 Expect.equals(true, server !== null);
18 server.close(); 18 server.close();
19 try { 19 try {
20 server.close(); 20 server.close();
21 } catch (SocketIOException ex) { 21 } catch (SocketIOException ex) {
22 exceptionCaught = true; 22 exceptionCaught = true;
23 } catch (Exception ex) { 23 } catch (Exception ex) {
24 wrongExceptionCaught = true; 24 wrongExceptionCaught = true;
25 } 25 }
26 Expect.equals(true, exceptionCaught); 26 Expect.equals(false, exceptionCaught);
27 Expect.equals(true, !wrongExceptionCaught); 27 Expect.equals(true, !wrongExceptionCaught);
28 exceptionCaught = false; 28 exceptionCaught = false;
29 try { 29 try {
30 server.accept(); 30 server.accept();
31 } catch (SocketIOException ex) { 31 } catch (SocketIOException ex) {
32 exceptionCaught = true; 32 exceptionCaught = true;
33 } catch (Exception ex) { 33 } catch (Exception ex) {
34 wrongExceptionCaught = true; 34 wrongExceptionCaught = true;
35 } 35 }
36 Expect.equals(true, exceptionCaught); 36 Expect.equals(true, exceptionCaught);
(...skipping 12 matching lines...) Expand all
49 InputStream input = client.inputStream; 49 InputStream input = client.inputStream;
50 OutputStream output = client.outputStream; 50 OutputStream output = client.outputStream;
51 client.close(); 51 client.close();
52 try { 52 try {
53 client.close(); 53 client.close();
54 } catch (SocketIOException ex) { 54 } catch (SocketIOException ex) {
55 exceptionCaught = true; 55 exceptionCaught = true;
56 } catch (Exception ex) { 56 } catch (Exception ex) {
57 wrongExceptionCaught = true; 57 wrongExceptionCaught = true;
58 } 58 }
59 Expect.equals(true, exceptionCaught); 59 Expect.equals(false, exceptionCaught);
60 Expect.equals(true, !wrongExceptionCaught); 60 Expect.equals(true, !wrongExceptionCaught);
61 exceptionCaught = false; 61 exceptionCaught = false;
62 try { 62 try {
63 client.available(); 63 client.available();
64 } catch (SocketIOException ex) { 64 } catch (SocketIOException ex) {
65 exceptionCaught = true; 65 exceptionCaught = true;
66 } catch (Exception ex) { 66 } catch (Exception ex) {
67 wrongExceptionCaught = true; 67 wrongExceptionCaught = true;
68 } 68 }
69 Expect.equals(true, exceptionCaught); 69 Expect.equals(true, exceptionCaught);
(...skipping 27 matching lines...) Expand all
97 } catch (SocketIOException ex) { 97 } catch (SocketIOException ex) {
98 exceptionCaught = true; 98 exceptionCaught = true;
99 } catch (Exception ex) { 99 } catch (Exception ex) {
100 wrongExceptionCaught = true; 100 wrongExceptionCaught = true;
101 } 101 }
102 Expect.equals(true, exceptionCaught); 102 Expect.equals(true, exceptionCaught);
103 Expect.equals(true, !wrongExceptionCaught); 103 Expect.equals(true, !wrongExceptionCaught);
104 exceptionCaught = false; 104 exceptionCaught = false;
105 try { 105 try {
106 List<int> buffer = new List<int>(42); 106 List<int> buffer = new List<int>(42);
107 bool readDone = output.write(buffer, 0, 12, null); 107 output.writeFrom(buffer, 0, 12);
108 } catch (SocketIOException ex) { 108 } catch (SocketIOException ex) {
109 exceptionCaught = true; 109 exceptionCaught = true;
110 } catch (Exception ex) { 110 } catch (Exception ex) {
111 wrongExceptionCaught = true; 111 wrongExceptionCaught = true;
112 } 112 }
113 Expect.equals(true, exceptionCaught); 113 Expect.equals(true, exceptionCaught);
114 Expect.equals(true, !wrongExceptionCaught); 114 Expect.equals(true, !wrongExceptionCaught);
115 115
116 server.close(); 116 server.close();
117 } 117 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 static void testMain() { 179 static void testMain() {
180 serverSocketExceptionTest(); 180 serverSocketExceptionTest();
181 clientSocketExceptionTest(); 181 clientSocketExceptionTest();
182 indexOutOfRangeExceptionTest(); 182 indexOutOfRangeExceptionTest();
183 } 183 }
184 } 184 }
185 185
186 main() { 186 main() {
187 SocketExceptionTest.testMain(); 187 SocketExceptionTest.testMain();
188 } 188 }
OLDNEW
« no previous file with comments | « tests/standalone/src/ProcessStdoutTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698