| 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 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override | 4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override |
| 5 | 5 |
| 6 library get_object_rpc_test; | 6 library get_object_rpc_test; |
| 7 | 7 |
| 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 | 10 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 // library. | 117 // library. |
| 118 (Isolate isolate) async { | 118 (Isolate isolate) async { |
| 119 var params = { | 119 var params = { |
| 120 'objectId': isolate.rootLibrary.id, | 120 'objectId': isolate.rootLibrary.id, |
| 121 }; | 121 }; |
| 122 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 122 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
| 123 expect(result['type'], equals('Library')); | 123 expect(result['type'], equals('Library')); |
| 124 expect(result['id'], startsWith('libraries/')); | 124 expect(result['id'], startsWith('libraries/')); |
| 125 expect(result['name'], equals('get_object_rpc_test')); | 125 expect(result['name'], equals('get_object_rpc_test')); |
| 126 expect(result['url'], startsWith('file:')); | 126 expect(result['uri'], startsWith('file:')); |
| 127 expect(result['url'], endsWith('get_object_rpc_test.dart')); | 127 expect(result['uri'], endsWith('get_object_rpc_test.dart')); |
| 128 expect(result['imports'].length, isPositive); | 128 expect(result['imports'].length, isPositive); |
| 129 expect(result['imports'][0]['type'], equals('@Library')); | 129 expect(result['imports'][0]['type'], equals('@Library')); |
| 130 expect(result['scripts'].length, isPositive); | 130 expect(result['scripts'].length, isPositive); |
| 131 expect(result['scripts'][0]['type'], equals('@Script')); | 131 expect(result['scripts'][0]['type'], equals('@Script')); |
| 132 expect(result['variables'].length, isPositive); | 132 expect(result['variables'].length, isPositive); |
| 133 expect(result['variables'][0]['type'], equals('@Field')); | 133 expect(result['variables'][0]['type'], equals('@Field')); |
| 134 expect(result['functions'].length, isPositive); | 134 expect(result['functions'].length, isPositive); |
| 135 expect(result['functions'][0]['type'], equals('@Function')); | 135 expect(result['functions'][0]['type'], equals('@Function')); |
| 136 expect(result['classes'].length, isPositive); | 136 expect(result['classes'].length, isPositive); |
| 137 expect(result['classes'][0]['type'], equals('@Class')); | 137 expect(result['classes'][0]['type'], equals('@Class')); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 162 'objectId': isolate.rootLibrary.id, | 162 'objectId': isolate.rootLibrary.id, |
| 163 }; | 163 }; |
| 164 var libResult = await isolate.invokeRpcNoUpgrade('getObject', params); | 164 var libResult = await isolate.invokeRpcNoUpgrade('getObject', params); |
| 165 // Get the first script. | 165 // Get the first script. |
| 166 params = { | 166 params = { |
| 167 'objectId': libResult['scripts'][0]['id'], | 167 'objectId': libResult['scripts'][0]['id'], |
| 168 }; | 168 }; |
| 169 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 169 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
| 170 expect(result['type'], equals('Script')); | 170 expect(result['type'], equals('Script')); |
| 171 expect(result['id'], startsWith('libraries/')); | 171 expect(result['id'], startsWith('libraries/')); |
| 172 expect(result['name'], startsWith('file:')); | 172 expect(result['uri'], startsWith('file:')); |
| 173 expect(result['name'], endsWith('get_object_rpc_test.dart')); | 173 expect(result['uri'], endsWith('get_object_rpc_test.dart')); |
| 174 expect(result['kind'], equals('script')); | 174 expect(result['kind'], equals('script')); |
| 175 expect(result['library']['type'], equals('@Library')); | 175 expect(result['library']['type'], equals('@Library')); |
| 176 expect(result['source'], startsWith('// Copyright (c)')); | 176 expect(result['source'], startsWith('// Copyright (c)')); |
| 177 expect(result['tokenPosTable'].length, isPositive); | 177 expect(result['tokenPosTable'].length, isPositive); |
| 178 expect(result['tokenPosTable'][0], new isInstanceOf<List>()); | 178 expect(result['tokenPosTable'][0], new isInstanceOf<List>()); |
| 179 expect(result['tokenPosTable'][0].length, isPositive); | 179 expect(result['tokenPosTable'][0].length, isPositive); |
| 180 expect(result['tokenPosTable'][0][0], new isInstanceOf<int>()); | 180 expect(result['tokenPosTable'][0][0], new isInstanceOf<int>()); |
| 181 }, | 181 }, |
| 182 | 182 |
| 183 // invalid script. | 183 // invalid script. |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 caughtException = true; | 415 caughtException = true; |
| 416 expect(e.code, equals(ServerRpcException.kInvalidParams)); | 416 expect(e.code, equals(ServerRpcException.kInvalidParams)); |
| 417 expect(e.message, | 417 expect(e.message, |
| 418 "getObject: invalid 'objectId' parameter: code/0"); | 418 "getObject: invalid 'objectId' parameter: code/0"); |
| 419 } | 419 } |
| 420 expect(caughtException, isTrue); | 420 expect(caughtException, isTrue); |
| 421 }, | 421 }, |
| 422 ]; | 422 ]; |
| 423 | 423 |
| 424 main(args) async => runIsolateTests(args, tests, testeeBefore:warmup); | 424 main(args) async => runIsolateTests(args, tests, testeeBefore:warmup); |
| OLD | NEW |