| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 new io.InternetAddress('127.0.0.1'), server.port); | 47 new io.InternetAddress('127.0.0.1'), server.port); |
| 48 client.close(); | 48 client.close(); |
| 49 | 49 |
| 50 // The one socket to expect. | 50 // The one socket to expect. |
| 51 await io.ServerSocket.bind('127.0.0.1', 0); | 51 await io.ServerSocket.bind('127.0.0.1', 0); |
| 52 } | 52 } |
| 53 | 53 |
| 54 var tests = [ | 54 var tests = [ |
| 55 // Initial. | 55 // Initial. |
| 56 (Isolate isolate) async { | 56 (Isolate isolate) async { |
| 57 var result = await isolate.invokeRpcNoUpgrade('__getOpenSockets', {}); | 57 var result = |
| 58 await isolate.invokeRpcNoUpgrade('ext.dart.io.getOpenSockets', {}); |
| 58 expect(result['type'], equals('_opensockets')); | 59 expect(result['type'], equals('_opensockets')); |
| 59 // We expect only one socket to be open, the server socket create at the | 60 // We expect only one socket to be open, the server socket create at the |
| 60 // end of test. | 61 // end of test. |
| 61 expect(result['data'].length, equals(1)); | 62 expect(result['data'].length, equals(1)); |
| 62 var server = await isolate.invokeRpcNoUpgrade( | 63 var server = await isolate.invokeRpcNoUpgrade( |
| 63 '__getSocketByID', { 'id' : result['data'][0]['id'] }); | 64 'ext.dart.io.getSocketByID', { 'id' : result['data'][0]['id'] }); |
| 64 expect(server['listening'], isTrue); | 65 expect(server['listening'], isTrue); |
| 65 expect(server['lastRead'], equals(0)); | 66 expect(server['lastRead'], equals(0)); |
| 66 expect(server['totalRead'], equals(0)); | 67 expect(server['totalRead'], equals(0)); |
| 67 expect(server['lastWrite'], equals(0)); | 68 expect(server['lastWrite'], equals(0)); |
| 68 expect(server['totalWritten'], equals(0)); | 69 expect(server['totalWritten'], equals(0)); |
| 69 expect(server['writeCount'], equals(0)); | 70 expect(server['writeCount'], equals(0)); |
| 70 expect(server['readCount'], equals(0)); | 71 expect(server['readCount'], equals(0)); |
| 71 }, | 72 }, |
| 72 ]; | 73 ]; |
| 73 | 74 |
| 74 main(args) async => runIsolateTests(args, tests, testeeBefore:setup); | 75 main(args) async => runIsolateTests(args, tests, testeeBefore:setup); |
| OLD | NEW |