| 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:developer'; | 7 import 'dart:developer'; |
| 8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
| 9 import 'package:observatory/service_io.dart'; | 9 import 'package:observatory/service_io.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 var result = await readTemp.readAsString(); | 57 var result = await readTemp.readAsString(); |
| 58 expect(result, equals('foobar')); | 58 expect(result, equals('foobar')); |
| 59 | 59 |
| 60 } catch (e) { | 60 } catch (e) { |
| 61 closeDown(); | 61 closeDown(); |
| 62 throw e; | 62 throw e; |
| 63 } | 63 } |
| 64 var result = JSON.encode({'type' : 'foobar'}); | 64 var result = JSON.encode({'type' : 'foobar'}); |
| 65 return new Future.value(new ServiceExtensionResponse.result(result)); | 65 return new Future.value(new ServiceExtensionResponse.result(result)); |
| 66 } | 66 } |
| 67 registerExtension('__cleanup', cleanup); | 67 registerExtension('ext.dart.io.cleanup', cleanup); |
| 68 registerExtension('__setup', setup); | 68 registerExtension('ext.dart.io.setup', setup); |
| 69 } | 69 } |
| 70 | 70 |
| 71 var fileTests = [ | 71 var fileTests = [ |
| 72 (Isolate isolate) async { | 72 (Isolate isolate) async { |
| 73 await isolate.invokeRpcNoUpgrade('__setup', {}); | 73 await isolate.invokeRpcNoUpgrade('ext.dart.io.setup', {}); |
| 74 try { | 74 try { |
| 75 var result = await isolate.invokeRpcNoUpgrade('__getOpenFiles', {}); | 75 var result = |
| 76 await isolate.invokeRpcNoUpgrade('ext.dart.io.getOpenFiles', {}); |
| 76 expect(result['type'], equals('_openfiles')); | 77 expect(result['type'], equals('_openfiles')); |
| 77 | 78 |
| 78 expect(result['data'].length, equals(2)); | 79 expect(result['data'].length, equals(2)); |
| 79 var writing = await isolate.invokeRpcNoUpgrade( | 80 var writing = await isolate.invokeRpcNoUpgrade( |
| 80 '__getFileByID', { 'id' : result['data'][0]['id'] }); | 81 'ext.dart.io.getFileByID', { 'id' : result['data'][0]['id'] }); |
| 81 | 82 |
| 82 expect(writing['totalRead'], equals(0)); | 83 expect(writing['totalRead'], equals(0)); |
| 83 expect(writing['readCount'], equals(0)); | 84 expect(writing['readCount'], equals(0)); |
| 84 expect(writing['writeCount'], equals(3)); | 85 expect(writing['writeCount'], equals(3)); |
| 85 expect(writing['totalWritten'], equals(3)); | 86 expect(writing['totalWritten'], equals(3)); |
| 86 expect(writing['lastWrite'], greaterThan(0)); | 87 expect(writing['lastWrite'], greaterThan(0)); |
| 87 expect(writing['lastRead'], equals(0)); | 88 expect(writing['lastRead'], equals(0)); |
| 88 | 89 |
| 89 var reading = await isolate.invokeRpcNoUpgrade( | 90 var reading = await isolate.invokeRpcNoUpgrade( |
| 90 '__getFileByID', { 'id' : result['data'][1]['id'] }); | 91 'ext.dart.io.getFileByID', { 'id' : result['data'][1]['id'] }); |
| 91 | 92 |
| 92 expect(reading['totalRead'], equals(5)); | 93 expect(reading['totalRead'], equals(5)); |
| 93 expect(reading['readCount'], equals(5)); | 94 expect(reading['readCount'], equals(5)); |
| 94 expect(reading['writeCount'], equals(0)); | 95 expect(reading['writeCount'], equals(0)); |
| 95 expect(reading['totalWritten'], equals(0)); | 96 expect(reading['totalWritten'], equals(0)); |
| 96 expect(reading['lastWrite'], equals(0)); | 97 expect(reading['lastWrite'], equals(0)); |
| 97 expect(reading['lastRead'], greaterThan(0)); | 98 expect(reading['lastRead'], greaterThan(0)); |
| 98 | 99 |
| 99 } finally { | 100 } finally { |
| 100 await isolate.invokeRpcNoUpgrade('__cleanup', {}); | 101 await isolate.invokeRpcNoUpgrade('ext.dart.io.cleanup', {}); |
| 101 } | 102 } |
| 102 }, | 103 }, |
| 103 ]; | 104 ]; |
| 104 | 105 |
| 105 main(args) async => runIsolateTests(args, fileTests, testeeBefore:setupFiles); | 106 main(args) async => runIsolateTests(args, fileTests, testeeBefore:setupFiles); |
| OLD | NEW |