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

Side by Side Diff: runtime/observatory/tests/service/tcp_socket_service_test.dart

Issue 2759973004: Fix observatory tests broken by running dartfmt. Temporarily reverted formatting for evaluate_activ… (Closed)
Patch Set: Created 3 years, 9 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) 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 13 matching lines...) Expand all
24 24
25 var socket2 = await io.Socket.connect("127.0.0.1", serverSocket.port); 25 var socket2 = await io.Socket.connect("127.0.0.1", serverSocket.port);
26 socket2.write("foobarfoobar"); 26 socket2.write("foobarfoobar");
27 await socket2.flush(); 27 await socket2.flush();
28 } 28 }
29 29
30 var tcpTests = [ 30 var tcpTests = [
31 // Initial. 31 // Initial.
32 (Isolate isolate) async { 32 (Isolate isolate) async {
33 var result = 33 var result =
34 await isolate.invokeRpcNoUpgrade('ext.dart.io.getOpenSockets', {}); 34 await isolate.invokeRpcNoUpgrade('ext.dart.io.getOpenSockets', {});
35 expect(result['type'], equals('_opensockets')); 35 expect(result['type'], equals('_opensockets'));
36 // We expect 3 sockets to be open (in this order): 36 // We expect 3 sockets to be open (in this order):
37 // The server socket accepting connections, on port X 37 // The server socket accepting connections, on port X
38 // The accepted connection on the client, on port Y 38 // The accepted connection on the client, on port Y
39 // The client connection, on port X 39 // The client connection, on port X
40 if (result['data'].length != 5) { 40 if (result['data'].length != 5) {
41 print(result['data']); 41 print(result['data']);
42 } 42 }
43 expect(result['data'].length, equals(5)); 43 expect(result['data'].length, equals(5));
44 // The first socket will have a name like listening:127.0.0.1:X 44 // The first socket will have a name like listening:127.0.0.1:X
45 // The second will have a name like 127.0.0.1:Y 45 // The second will have a name like 127.0.0.1:Y
46 // The third will have a name like 127.0.0.1:X 46 // The third will have a name like 127.0.0.1:X
47 expect(result['data'][0]['name'].startsWith('listening:127.0.0.1'), isTrue); 47 expect(result['data'][0]['name'].startsWith('listening:127.0.0.1'), isTrue);
48 expect(result['data'][1]['name'].startsWith('127.0.0.1:'), isTrue); 48 expect(result['data'][1]['name'].startsWith('127.0.0.1:'), isTrue);
49 expect(result['data'][2]['name'].startsWith('127.0.0.1:'), isTrue); 49 expect(result['data'][2]['name'].startsWith('127.0.0.1:'), isTrue);
50 50
51 var listening = await isolate.invokeRpcNoUpgrade( 51 var listening = await isolate.invokeRpcNoUpgrade(
52 'ext.dart.io.getSocketByID', { 'id' : result['data'][0]['id'] }); 52 'ext.dart.io.getSocketByID', {'id': result['data'][0]['id']});
53 expect(listening['id'], equals(result['data'][0]['id'])); 53 expect(listening['id'], equals(result['data'][0]['id']));
54 expect(listening['listening'], isTrue); 54 expect(listening['listening'], isTrue);
55 expect(listening['socketType'], equals('TCP')); 55 expect(listening['socketType'], equals('TCP'));
56 expect(listening['port'], greaterThanOrEqualTo(1024)); 56 expect(listening['port'], greaterThanOrEqualTo(1024));
57 expect(listening['lastRead'], greaterThan(0)); 57 expect(listening['lastRead'], greaterThan(0));
58 58
59 expect(listening['totalRead'], equals(2)); 59 expect(listening['totalRead'], equals(2));
60 expect(listening['lastWrite'], equals(0)); 60 expect(listening['lastWrite'], equals(0));
61 expect(listening['totalWritten'], equals(0)); 61 expect(listening['totalWritten'], equals(0));
62 expect(listening['writeCount'], equals(0)); 62 expect(listening['writeCount'], equals(0));
63 expect(listening['readCount'], equals(2)); 63 expect(listening['readCount'], equals(2));
64 expect(listening['remoteHost'], equals('NA')); 64 expect(listening['remoteHost'], equals('NA'));
65 expect(listening['remotePort'], equals('NA')); 65 expect(listening['remotePort'], equals('NA'));
66 66
67 var client = await isolate.invokeRpcNoUpgrade( 67 var client = await isolate.invokeRpcNoUpgrade(
68 'ext.dart.io.getSocketByID', { 'id' : result['data'][1]['id'] }); 68 'ext.dart.io.getSocketByID', {'id': result['data'][1]['id']});
69 expect(client['id'], equals(result['data'][1]['id'])); 69 expect(client['id'], equals(result['data'][1]['id']));
70 70
71 var server = await isolate.invokeRpcNoUpgrade( 71 var server = await isolate.invokeRpcNoUpgrade(
72 'ext.dart.io.getSocketByID', { 'id' : result['data'][2]['id'] }); 72 'ext.dart.io.getSocketByID', {'id': result['data'][2]['id']});
73 expect(server['id'], equals(result['data'][2]['id'])); 73 expect(server['id'], equals(result['data'][2]['id']));
74 74
75 // We expect the client to be connected on the port and 75 // We expect the client to be connected on the port and
76 // host of the listening socket. 76 // host of the listening socket.
77 expect(client['remotePort'], equals(listening['port'])); 77 expect(client['remotePort'], equals(listening['port']));
78 expect(client['remoteHost'], equals(listening['host'])); 78 expect(client['remoteHost'], equals(listening['host']));
79 // We expect the third socket (accepted server) to be connected to the 79 // We expect the third socket (accepted server) to be connected to the
80 // same port and host as the listening socket (the listening one). 80 // same port and host as the listening socket (the listening one).
81 expect(server['port'], equals(listening['port'])); 81 expect(server['port'], equals(listening['port']));
82 expect(server['host'], equals(listening['host'])); 82 expect(server['host'], equals(listening['host']));
(...skipping 26 matching lines...) Expand all
109 109
110 // Order 110 // Order
111 // Stopwatch resolution on windows can make us have the same timestamp. 111 // Stopwatch resolution on windows can make us have the same timestamp.
112 if (io.Platform.isWindows) { 112 if (io.Platform.isWindows) {
113 expect(server['lastRead'], greaterThanOrEqualTo(client['lastWrite'])); 113 expect(server['lastRead'], greaterThanOrEqualTo(client['lastWrite']));
114 } else { 114 } else {
115 expect(server['lastRead'], greaterThan(client['lastWrite'])); 115 expect(server['lastRead'], greaterThan(client['lastWrite']));
116 } 116 }
117 117
118 var secondClient = await isolate.invokeRpcNoUpgrade( 118 var secondClient = await isolate.invokeRpcNoUpgrade(
119 'ext.dart.io.getSocketByID', { 'id' : result['data'][3]['id'] }); 119 'ext.dart.io.getSocketByID', {'id': result['data'][3]['id']});
120 expect(secondClient['id'], equals(result['data'][3]['id'])); 120 expect(secondClient['id'], equals(result['data'][3]['id']));
121 var secondServer = await isolate.invokeRpcNoUpgrade( 121 var secondServer = await isolate.invokeRpcNoUpgrade(
122 'ext.dart.io.getSocketByID', { 'id' : result['data'][4]['id'] }); 122 'ext.dart.io.getSocketByID', {'id': result['data'][4]['id']});
123 expect(secondServer['id'], equals(result['data'][4]['id'])); 123 expect(secondServer['id'], equals(result['data'][4]['id']));
124 124
125 // We expect the client to be connected on the port and 125 // We expect the client to be connected on the port and
126 // host of the listening socket. 126 // host of the listening socket.
127 expect(secondClient['remotePort'], equals(listening['port'])); 127 expect(secondClient['remotePort'], equals(listening['port']));
128 expect(secondClient['remoteHost'], equals(listening['host'])); 128 expect(secondClient['remoteHost'], equals(listening['host']));
129 // We expect the third socket (accepted server) to be connected to the 129 // We expect the third socket (accepted server) to be connected to the
130 // same port and host as the listening socket (the listening one). 130 // same port and host as the listening socket (the listening one).
131 expect(secondServer['port'], equals(listening['port'])); 131 expect(secondServer['port'], equals(listening['port']));
132 expect(secondServer['host'], equals(listening['host'])); 132 expect(secondServer['host'], equals(listening['host']));
(...skipping 27 matching lines...) Expand all
160 // Order 160 // Order
161 // Stopwatch resolution on windows make us sometimes report the same value. 161 // Stopwatch resolution on windows make us sometimes report the same value.
162 if (io.Platform.isWindows) { 162 if (io.Platform.isWindows) {
163 expect(server['lastRead'], greaterThanOrEqualTo(client['lastWrite'])); 163 expect(server['lastRead'], greaterThanOrEqualTo(client['lastWrite']));
164 } else { 164 } else {
165 expect(server['lastRead'], greaterThan(client['lastWrite'])); 165 expect(server['lastRead'], greaterThan(client['lastWrite']));
166 } 166 }
167 }, 167 },
168 ]; 168 ];
169 169
170 main(args) async => runIsolateTests(args, tcpTests, testeeBefore:setupTCP); 170 main(args) async => runIsolateTests(args, tcpTests, testeeBefore: setupTCP);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698