OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:io' as io; | 7 import 'dart:io' as io; |
8 import 'package:observatory/service_io.dart'; | 8 import 'package:observatory/service_io.dart'; |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 import 'test_helper.dart'; | 10 import 'test_helper.dart'; |
(...skipping 30 matching lines...) Expand all Loading... |
41 // The second will have a name like 127.0.0.1:Y | 41 // The second will have a name like 127.0.0.1:Y |
42 // The third will have a name like 127.0.0.1:X | 42 // The third will have a name like 127.0.0.1:X |
43 expect(result['data'][0]['name'].startsWith('listening:127.0.0.1'), isTrue); | 43 expect(result['data'][0]['name'].startsWith('listening:127.0.0.1'), isTrue); |
44 expect(result['data'][1]['name'].startsWith('127.0.0.1:'), isTrue); | 44 expect(result['data'][1]['name'].startsWith('127.0.0.1:'), isTrue); |
45 expect(result['data'][2]['name'].startsWith('127.0.0.1:'), isTrue); | 45 expect(result['data'][2]['name'].startsWith('127.0.0.1:'), isTrue); |
46 | 46 |
47 var listening = await isolate.invokeRpcNoUpgrade( | 47 var listening = await isolate.invokeRpcNoUpgrade( |
48 '__getSocketByID', { 'id' : result['data'][0]['id'] }); | 48 '__getSocketByID', { 'id' : result['data'][0]['id'] }); |
49 expect(listening['id'], equals(result['data'][0]['id'])); | 49 expect(listening['id'], equals(result['data'][0]['id'])); |
50 expect(listening['listening'], isTrue); | 50 expect(listening['listening'], isTrue); |
51 expect(listening['socket_type'], equals('TCP')); | 51 expect(listening['socketType'], equals('TCP')); |
52 expect(listening['port'], greaterThanOrEqualTo(1024)); | 52 expect(listening['port'], greaterThanOrEqualTo(1024)); |
53 expect(listening['last_read'], greaterThan(0)); | 53 expect(listening['lastRead'], greaterThan(0)); |
54 | 54 |
55 expect(listening['total_read'], equals(2)); | 55 expect(listening['totalRead'], equals(2)); |
56 expect(listening['last_write'], equals(0)); | 56 expect(listening['lastWrite'], equals(0)); |
57 expect(listening['total_written'], equals(0)); | 57 expect(listening['totalWritten'], equals(0)); |
58 expect(listening['write_count'], equals(0)); | 58 expect(listening['writeCount'], equals(0)); |
59 expect(listening['read_count'], equals(2)); | 59 expect(listening['readCount'], equals(2)); |
60 expect(listening['remote_host'], equals('NA')); | 60 expect(listening['remoteHost'], equals('NA')); |
61 expect(listening['remote_port'], equals('NA')); | 61 expect(listening['remotePort'], equals('NA')); |
62 | 62 |
63 var client = await isolate.invokeRpcNoUpgrade( | 63 var client = await isolate.invokeRpcNoUpgrade( |
64 '__getSocketByID', { 'id' : result['data'][1]['id'] }); | 64 '__getSocketByID', { 'id' : result['data'][1]['id'] }); |
65 expect(client['id'], equals(result['data'][1]['id'])); | 65 expect(client['id'], equals(result['data'][1]['id'])); |
66 | 66 |
67 var server = await isolate.invokeRpcNoUpgrade( | 67 var server = await isolate.invokeRpcNoUpgrade( |
68 '__getSocketByID', { 'id' : result['data'][2]['id'] }); | 68 '__getSocketByID', { 'id' : result['data'][2]['id'] }); |
69 expect(server['id'], equals(result['data'][2]['id'])); | 69 expect(server['id'], equals(result['data'][2]['id'])); |
70 | 70 |
71 // We expect the client to be connected on the port and | 71 // We expect the client to be connected on the port and |
72 // host of the listening socket. | 72 // host of the listening socket. |
73 expect(client['remote_port'], equals(listening['port'])); | 73 expect(client['remotePort'], equals(listening['port'])); |
74 expect(client['remote_host'], equals(listening['host'])); | 74 expect(client['remoteHost'], equals(listening['host'])); |
75 // We expect the third socket (accepted server) to be connected to the | 75 // We expect the third socket (accepted server) to be connected to the |
76 // same port and host as the listening socket (the listening one). | 76 // same port and host as the listening socket (the listening one). |
77 expect(server['port'], equals(listening['port'])); | 77 expect(server['port'], equals(listening['port'])); |
78 expect(server['host'], equals(listening['host'])); | 78 expect(server['host'], equals(listening['host'])); |
79 | 79 |
80 expect(client['listening'], isFalse); | 80 expect(client['listening'], isFalse); |
81 expect(server['listening'], isFalse); | 81 expect(server['listening'], isFalse); |
82 | 82 |
83 expect(client['socket_type'], equals('TCP')); | 83 expect(client['socketType'], equals('TCP')); |
84 expect(server['socket_type'], equals('TCP')); | 84 expect(server['socketType'], equals('TCP')); |
85 | 85 |
86 // We are using no reserved ports. | 86 // We are using no reserved ports. |
87 expect(client['port'], greaterThanOrEqualTo(1024)); | 87 expect(client['port'], greaterThanOrEqualTo(1024)); |
88 expect(server['port'], greaterThanOrEqualTo(1024)); | 88 expect(server['port'], greaterThanOrEqualTo(1024)); |
89 | 89 |
90 // The client and server "mirror" each other in reads and writes, and the | 90 // The client and server "mirror" each other in reads and writes, and the |
91 // timestamps are in correct order. | 91 // timestamps are in correct order. |
92 expect(client['last_read'], equals(0)); | 92 expect(client['lastRead'], equals(0)); |
93 expect(server['last_read'], greaterThan(0)); | 93 expect(server['lastRead'], greaterThan(0)); |
94 expect(client['total_read'], equals(0)); | 94 expect(client['totalRead'], equals(0)); |
95 expect(server['total_read'], equals(12)); | 95 expect(server['totalRead'], equals(12)); |
96 expect(client['read_count'], equals(0)); | 96 expect(client['readCount'], equals(0)); |
97 expect(server['read_count'], greaterThanOrEqualTo(1)); | 97 expect(server['readCount'], greaterThanOrEqualTo(1)); |
98 | 98 |
99 expect(client['last_write'], greaterThan(0)); | 99 expect(client['lastWrite'], greaterThan(0)); |
100 expect(server['last_write'], equals(0)); | 100 expect(server['lastWrite'], equals(0)); |
101 expect(client['total_written'], equals(12)); | 101 expect(client['totalWritten'], equals(12)); |
102 expect(server['total_written'], equals(0)); | 102 expect(server['totalWritten'], equals(0)); |
103 expect(client['write_count'], greaterThanOrEqualTo(2)); | 103 expect(client['writeCount'], greaterThanOrEqualTo(2)); |
104 expect(server['write_count'], equals(0)); | 104 expect(server['writeCount'], equals(0)); |
105 | 105 |
106 // Order | 106 // Order |
107 // Stopwatch resolution on windows can make us have the same timestamp. | 107 // Stopwatch resolution on windows can make us have the same timestamp. |
108 if (io.Platform.isWindows) { | 108 if (io.Platform.isWindows) { |
109 expect(server['last_read'], greaterThanOrEqualTo(client['last_write'])); | 109 expect(server['lastRead'], greaterThanOrEqualTo(client['lastWrite'])); |
110 } else { | 110 } else { |
111 expect(server['last_read'], greaterThan(client['last_write'])); | 111 expect(server['lastRead'], greaterThan(client['lastWrite'])); |
112 } | 112 } |
113 | 113 |
114 var second_client = await isolate.invokeRpcNoUpgrade( | 114 var secondClient = await isolate.invokeRpcNoUpgrade( |
115 '__getSocketByID', { 'id' : result['data'][3]['id'] }); | 115 '__getSocketByID', { 'id' : result['data'][3]['id'] }); |
116 expect(second_client['id'], equals(result['data'][3]['id'])); | 116 expect(secondClient['id'], equals(result['data'][3]['id'])); |
117 var second_server = await isolate.invokeRpcNoUpgrade( | 117 var secondServer = await isolate.invokeRpcNoUpgrade( |
118 '__getSocketByID', { 'id' : result['data'][4]['id'] }); | 118 '__getSocketByID', { 'id' : result['data'][4]['id'] }); |
119 expect(second_server['id'], equals(result['data'][4]['id'])); | 119 expect(secondServer['id'], equals(result['data'][4]['id'])); |
120 | 120 |
121 // We expect the client to be connected on the port and | 121 // We expect the client to be connected on the port and |
122 // host of the listening socket. | 122 // host of the listening socket. |
123 expect(second_client['remote_port'], equals(listening['port'])); | 123 expect(secondClient['remotePort'], equals(listening['port'])); |
124 expect(second_client['remote_host'], equals(listening['host'])); | 124 expect(secondClient['remoteHost'], equals(listening['host'])); |
125 // We expect the third socket (accepted server) to be connected to the | 125 // We expect the third socket (accepted server) to be connected to the |
126 // same port and host as the listening socket (the listening one). | 126 // same port and host as the listening socket (the listening one). |
127 expect(second_server['port'], equals(listening['port'])); | 127 expect(secondServer['port'], equals(listening['port'])); |
128 expect(second_server['host'], equals(listening['host'])); | 128 expect(secondServer['host'], equals(listening['host'])); |
129 | 129 |
130 expect(second_client['listening'], isFalse); | 130 expect(secondClient['listening'], isFalse); |
131 expect(second_server['listening'], isFalse); | 131 expect(secondServer['listening'], isFalse); |
132 | 132 |
133 expect(second_client['socket_type'], equals('TCP')); | 133 expect(secondClient['socketType'], equals('TCP')); |
134 expect(second_server['socket_type'], equals('TCP')); | 134 expect(secondServer['socketType'], equals('TCP')); |
135 | 135 |
136 // We are using no reserved ports. | 136 // We are using no reserved ports. |
137 expect(second_client['port'], greaterThanOrEqualTo(1024)); | 137 expect(secondClient['port'], greaterThanOrEqualTo(1024)); |
138 expect(second_server['port'], greaterThanOrEqualTo(1024)); | 138 expect(secondServer['port'], greaterThanOrEqualTo(1024)); |
139 | 139 |
140 // The client and server "mirror" each other in reads and writes, and the | 140 // The client and server "mirror" each other in reads and writes, and the |
141 // timestamps are in correct order. | 141 // timestamps are in correct order. |
142 expect(second_client['last_read'], equals(0)); | 142 expect(secondClient['lastRead'], equals(0)); |
143 expect(second_server['last_read'], greaterThan(0)); | 143 expect(secondServer['lastRead'], greaterThan(0)); |
144 expect(second_client['total_read'], equals(0)); | 144 expect(secondClient['totalRead'], equals(0)); |
145 expect(second_server['total_read'], equals(12)); | 145 expect(secondServer['totalRead'], equals(12)); |
146 expect(second_client['read_count'], equals(0)); | 146 expect(secondClient['readCount'], equals(0)); |
147 expect(second_server['read_count'], greaterThanOrEqualTo(1)); | 147 expect(secondServer['readCount'], greaterThanOrEqualTo(1)); |
148 | 148 |
149 expect(second_client['last_write'], greaterThan(0)); | 149 expect(secondClient['lastWrite'], greaterThan(0)); |
150 expect(second_server['last_write'], equals(0)); | 150 expect(secondServer['lastWrite'], equals(0)); |
151 expect(second_client['total_written'], equals(12)); | 151 expect(secondClient['totalWritten'], equals(12)); |
152 expect(second_server['total_written'], equals(0)); | 152 expect(secondServer['totalWritten'], equals(0)); |
153 expect(second_client['write_count'], greaterThanOrEqualTo(1)); | 153 expect(secondClient['writeCount'], greaterThanOrEqualTo(1)); |
154 expect(second_server['write_count'], equals(0)); | 154 expect(secondServer['writeCount'], equals(0)); |
155 | 155 |
156 // Order | 156 // Order |
157 // Stopwatch resolution on windows make us sometimes report the same value. | 157 // Stopwatch resolution on windows make us sometimes report the same value. |
158 if (io.Platform.isWindows) { | 158 if (io.Platform.isWindows) { |
159 expect(server['last_read'], greaterThanOrEqualTo(client['last_write'])); | 159 expect(server['lastRead'], greaterThanOrEqualTo(client['lastWrite'])); |
160 } else { | 160 } else { |
161 expect(server['last_read'], greaterThan(client['last_write'])); | 161 expect(server['lastRead'], greaterThan(client['lastWrite'])); |
162 } | 162 } |
163 }, | 163 }, |
164 ]; | 164 ]; |
165 | 165 |
166 main(args) async => runIsolateTests(args, tcpTests, testeeBefore:setupTCP); | 166 main(args) async => runIsolateTests(args, tcpTests, testeeBefore:setupTCP); |
OLD | NEW |