| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 var tcpTests = [ | 30 var tcpTests = [ |
| 31 // Initial. | 31 // Initial. |
| 32 (Isolate isolate) async { | 32 (Isolate isolate) async { |
| 33 var result = await isolate.invokeRpcNoUpgrade('__getOpenSockets', {}); | 33 var result = await isolate.invokeRpcNoUpgrade('__getOpenSockets', {}); |
| 34 expect(result['type'], equals('_opensockets')); | 34 expect(result['type'], equals('_opensockets')); |
| 35 // We expect 3 sockets to be open (in this order): | 35 // We expect 3 sockets to be open (in this order): |
| 36 // The server socket accepting connections, on port X | 36 // The server socket accepting connections, on port X |
| 37 // The accepted connection on the client, on port Y | 37 // The accepted connection on the client, on port Y |
| 38 // The client connection, on port X | 38 // The client connection, on port X |
| 39 if (result['data'].length != 5) { |
| 40 print(result['data']); |
| 41 } |
| 39 expect(result['data'].length, equals(5)); | 42 expect(result['data'].length, equals(5)); |
| 40 // The first socket will have a name like listening:127.0.0.1:X | 43 // The first socket will have a name like listening:127.0.0.1:X |
| 41 // The second will have a name like 127.0.0.1:Y | 44 // 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 | 45 // 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); | 46 expect(result['data'][0]['name'].startsWith('listening:127.0.0.1'), isTrue); |
| 44 expect(result['data'][1]['name'].startsWith('127.0.0.1:'), isTrue); | 47 expect(result['data'][1]['name'].startsWith('127.0.0.1:'), isTrue); |
| 45 expect(result['data'][2]['name'].startsWith('127.0.0.1:'), isTrue); | 48 expect(result['data'][2]['name'].startsWith('127.0.0.1:'), isTrue); |
| 46 | 49 |
| 47 var listening = await isolate.invokeRpcNoUpgrade( | 50 var listening = await isolate.invokeRpcNoUpgrade( |
| 48 '__getSocketByID', { 'id' : result['data'][0]['id'] }); | 51 '__getSocketByID', { 'id' : result['data'][0]['id'] }); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // Stopwatch resolution on windows make us sometimes report the same value. | 160 // Stopwatch resolution on windows make us sometimes report the same value. |
| 158 if (io.Platform.isWindows) { | 161 if (io.Platform.isWindows) { |
| 159 expect(server['lastRead'], greaterThanOrEqualTo(client['lastWrite'])); | 162 expect(server['lastRead'], greaterThanOrEqualTo(client['lastWrite'])); |
| 160 } else { | 163 } else { |
| 161 expect(server['lastRead'], greaterThan(client['lastWrite'])); | 164 expect(server['lastRead'], greaterThan(client['lastWrite'])); |
| 162 } | 165 } |
| 163 }, | 166 }, |
| 164 ]; | 167 ]; |
| 165 | 168 |
| 166 main(args) async => runIsolateTests(args, tcpTests, testeeBefore:setupTCP); | 169 main(args) async => runIsolateTests(args, tcpTests, testeeBefore:setupTCP); |
| OLD | NEW |