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 22 matching lines...) Expand all Loading... |
33 return await isolate.invokeRpcNoUpgrade('evaluate', params); | 33 return await isolate.invokeRpcNoUpgrade('evaluate', params); |
34 } | 34 } |
35 | 35 |
36 var tests = [ | 36 var tests = [ |
37 // null object. | 37 // null object. |
38 (Isolate isolate) async { | 38 (Isolate isolate) async { |
39 var params = { | 39 var params = { |
40 'objectId': 'objects/null', | 40 'objectId': 'objects/null', |
41 }; | 41 }; |
42 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 42 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
43 expect(result['type'], equals('null')); | 43 expect(result['type'], equals('Instance')); |
| 44 expect(result['kind'], equals('Null')); |
44 expect(result['id'], equals('objects/null')); | 45 expect(result['id'], equals('objects/null')); |
45 expect(result['valueAsString'], equals('null')); | 46 expect(result['valueAsString'], equals('null')); |
46 expect(result['class']['type'], equals('@Class')); | 47 expect(result['class']['type'], equals('@Class')); |
47 expect(result['class']['name'], equals('Null')); | 48 expect(result['class']['name'], equals('Null')); |
48 expect(result['size'], isPositive); | 49 expect(result['size'], isPositive); |
49 }, | 50 }, |
50 | 51 |
51 // bool object. | 52 // bool object. |
52 (Isolate isolate) async { | 53 (Isolate isolate) async { |
53 var params = { | 54 var params = { |
54 'objectId': 'objects/bool-true', | 55 'objectId': 'objects/bool-true', |
55 }; | 56 }; |
56 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 57 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
57 expect(result['type'], equals('bool')); | 58 expect(result['type'], equals('Instance')); |
| 59 expect(result['kind'], equals('Bool')); |
58 expect(result['id'], equals('objects/bool-true')); | 60 expect(result['id'], equals('objects/bool-true')); |
59 expect(result['valueAsString'], equals('true')); | 61 expect(result['valueAsString'], equals('true')); |
60 expect(result['class']['type'], equals('@Class')); | 62 expect(result['class']['type'], equals('@Class')); |
61 expect(result['class']['name'], equals('bool')); | 63 expect(result['class']['name'], equals('bool')); |
62 expect(result['size'], isPositive); | 64 expect(result['size'], isPositive); |
63 expect(result['fields'], isEmpty); | 65 expect(result['fields'], isEmpty); |
64 }, | 66 }, |
65 | 67 |
66 // int object. | 68 // int object. |
67 (Isolate isolate) async { | 69 (Isolate isolate) async { |
68 var params = { | 70 var params = { |
69 'objectId': 'objects/int-123', | 71 'objectId': 'objects/int-123', |
70 }; | 72 }; |
71 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 73 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
72 expect(result['type'], equals('int')); | 74 expect(result['type'], equals('Instance')); |
| 75 expect(result['kind'], equals('Int')); |
73 expect(result['_vmType'], equals('Smi')); | 76 expect(result['_vmType'], equals('Smi')); |
74 expect(result['id'], equals('objects/int-123')); | 77 expect(result['id'], equals('objects/int-123')); |
75 expect(result['valueAsString'], equals('123')); | 78 expect(result['valueAsString'], equals('123')); |
76 expect(result['class']['type'], equals('@Class')); | 79 expect(result['class']['type'], equals('@Class')); |
77 expect(result['class']['name'], equals('_Smi')); | 80 expect(result['class']['name'], equals('_Smi')); |
78 expect(result['size'], isZero); | 81 expect(result['size'], isZero); |
79 expect(result['fields'], isEmpty); | 82 expect(result['fields'], isEmpty); |
80 }, | 83 }, |
81 | 84 |
82 // A general Dart object. | 85 // A built-in List. |
83 (Isolate isolate) async { | 86 (Isolate isolate) async { |
84 // Call eval to get a Dart list. | 87 // Call eval to get a Dart list. |
85 var evalResult = await eval(isolate, '[3, 2, 1]'); | 88 var evalResult = await eval(isolate, '[3, 2, 1]'); |
86 var params = { | 89 var params = { |
87 'objectId': evalResult['id'], | 90 'objectId': evalResult['id'], |
88 }; | 91 }; |
89 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 92 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
90 expect(result['type'], equals('List')); | 93 expect(result['type'], equals('Instance')); |
| 94 expect(result['kind'], equals('List')); |
91 expect(result['_vmType'], equals('GrowableObjectArray')); | 95 expect(result['_vmType'], equals('GrowableObjectArray')); |
92 expect(result['id'], startsWith('objects/')); | 96 expect(result['id'], startsWith('objects/')); |
93 expect(result['valueAsString'], isNull); | 97 expect(result['valueAsString'], isNull); |
94 expect(result['class']['type'], equals('@Class')); | 98 expect(result['class']['type'], equals('@Class')); |
95 expect(result['class']['name'], equals('_GrowableList')); | 99 expect(result['class']['name'], equals('_GrowableList')); |
96 expect(result['size'], isPositive); | 100 expect(result['size'], isPositive); |
97 expect(result['fields'], isEmpty); | 101 expect(result['fields'], isEmpty); |
98 expect(result['elements'].length, equals(3)); | 102 expect(result['elements'].length, equals(3)); |
99 expect(result['elements'][0]['index'], equals(0)); | 103 expect(result['elements'][0]['index'], equals(0)); |
100 expect(result['elements'][0]['value']['type'], equals('@int')); | 104 expect(result['elements'][0]['value']['type'], equals('@Instance')); |
| 105 expect(result['elements'][0]['value']['kind'], equals('Int')); |
101 expect(result['elements'][0]['value']['valueAsString'], equals('3')); | 106 expect(result['elements'][0]['value']['valueAsString'], equals('3')); |
102 }, | 107 }, |
103 | 108 |
104 // An expired object. | 109 // An expired object. |
105 (Isolate isolate) async { | 110 (Isolate isolate) async { |
106 var params = { | 111 var params = { |
107 'objectId': 'objects/99999999', | 112 'objectId': 'objects/99999999', |
108 }; | 113 }; |
109 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 114 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
110 expect(result['type'], equals('Sentinel')); | 115 expect(result['type'], equals('Sentinel')); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 253 |
249 // type. | 254 // type. |
250 (Isolate isolate) async { | 255 (Isolate isolate) async { |
251 // Call eval to get a class id. | 256 // Call eval to get a class id. |
252 var evalResult = await eval(isolate, 'new _DummyClass()'); | 257 var evalResult = await eval(isolate, 'new _DummyClass()'); |
253 var id = "${evalResult['class']['id']}/types/0"; | 258 var id = "${evalResult['class']['id']}/types/0"; |
254 var params = { | 259 var params = { |
255 'objectId': id, | 260 'objectId': id, |
256 }; | 261 }; |
257 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 262 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
258 expect(result['type'], equals('Type')); | 263 expect(result['type'], equals('Instance')); |
| 264 expect(result['kind'], equals('Type')); |
259 expect(result['id'], equals(id)); | 265 expect(result['id'], equals(id)); |
260 expect(result['class']['type'], equals('@Class')); | 266 expect(result['class']['type'], equals('@Class')); |
261 expect(result['class']['name'], equals('_Type')); | 267 expect(result['class']['name'], equals('_Type')); |
262 expect(result['size'], isPositive); | 268 expect(result['size'], isPositive); |
263 expect(result['fields'], isEmpty); | 269 expect(result['fields'], isEmpty); |
264 expect(result['typeClass']['type'], equals('@Class')); | 270 expect(result['typeClass']['type'], equals('@Class')); |
265 expect(result['typeClass']['name'], equals('_DummyClass')); | 271 expect(result['typeClass']['name'], equals('_DummyClass')); |
266 }, | 272 }, |
267 | 273 |
268 // invalid type. | 274 // invalid type. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 caughtException = true; | 422 caughtException = true; |
417 expect(e.code, equals(ServerRpcException.kInvalidParams)); | 423 expect(e.code, equals(ServerRpcException.kInvalidParams)); |
418 expect(e.message, | 424 expect(e.message, |
419 "getObject: invalid 'objectId' parameter: code/0"); | 425 "getObject: invalid 'objectId' parameter: code/0"); |
420 } | 426 } |
421 expect(caughtException, isTrue); | 427 expect(caughtException, isTrue); |
422 }, | 428 }, |
423 ]; | 429 ]; |
424 | 430 |
425 main(args) async => runIsolateTests(args, tests, testeeBefore:warmup); | 431 main(args) async => runIsolateTests(args, tests, testeeBefore:warmup); |
OLD | NEW |