Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(808)

Side by Side Diff: tests/standalone/vmservice/isolate_class_field_test.dart

Issue 895093002: Add getClassList RPC (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 library isolate_class_list_test;
6
7 import 'dart:async';
8 import 'test_helper.dart';
9 import 'package:expect/expect.dart';
10
11 class BananaClassTest {
12 int port;
13 String isolate_id;
14 String class_id;
15 BananaClassTest(this.port, this.isolate_id, this.class_id);
16
17 _testFieldA(Map field) {
18 Expect.equals('Field', field['type']);
19 Expect.equals('a', field['name']);
20 Expect.equals(false, field['final']);
21 Expect.equals(false, field['static']);
22 Expect.equals(false, field['const']);
23 Expect.equals('dynamic', field['guardClass']);
24 Expect.equals(true, field['guardNullable']);
25 Expect.equals('variable', field['guardLength']);
26 }
27
28 _testFieldFinalFixedLengthList(Map field) {
29 Expect.equals('Field', field['type']);
30 Expect.equals('final_fixed_length_list', field['name']);
31 Expect.equals('_Float32Array', field['guardClass']['name']);
32 Expect.equals(true, field['final']);
33 Expect.equals(false, field['static']);
34 Expect.equals(false, field['const']);
35 Expect.equals(4, field['guardLength']);
36 }
37
38 _testFieldFixedLengthList(Map field) {
39 Expect.equals('Field', field['type']);
40 Expect.equals('fixed_length_list', field['name']);
41 Expect.equals(false, field['final']);
42 Expect.equals(false, field['static']);
43 Expect.equals(false, field['const']);
44 Expect.equals('_Float32Array', field['guardClass']['name']);
45 Expect.equals('variable', field['guardLength']);
46 }
47
48 _testFieldName(Map field) {
49 Expect.equals('Field', field['type']);
50 Expect.equals('name', field['name']);
51 Expect.equals(false, field['final']);
52 Expect.equals(false, field['static']);
53 Expect.equals(false, field['const']);
54 Expect.equals('_OneByteString', field['guardClass']['name']);
55 Expect.equals(false, field['guardNullable']);
56 Expect.equals('variable', field['guardLength']);
57 }
58
59 Future makeRequest() {
60 var fields = ['final_fixed_length_list', 'fixed_length_list', 'name', 'a'];
61 var helper =
62 new ClassFieldRequestHelper(port, isolate_id, class_id, fields);
63 return helper.makeRequest().then((_) {
64 _testFieldA(helper.fields['a']);
65 _testFieldFinalFixedLengthList(helper.fields['final_fixed_length_list']);
66 _testFieldFixedLengthList(helper.fields['fixed_length_list']);
67 _testFieldName(helper.fields['name']);
68 });
69 }
70 }
71
72 class BadBananaClassTest {
73 int port;
74 String isolate_id;
75 String class_id;
76 BadBananaClassTest(this.port, this.isolate_id, this.class_id);
77
78 _testFieldV(Map field) {
79 Expect.equals('Field', field['type']);
80 Expect.equals('v', field['name']);
81 Expect.equals(false, field['final']);
82 Expect.equals(false, field['static']);
83 Expect.equals(false, field['const']);
84 Expect.equals('_Double', field['guardClass']['name']);
85 Expect.equals(true, field['guardNullable']);
86 Expect.equals('variable', field['guardLength']);
87 }
88
89 _testFieldC(Map field) {
90 Expect.equals('Field', field['type']);
91 Expect.equals('c', field['name']);
92 Expect.equals(true, field['final']);
93 Expect.equals(false, field['static']);
94 Expect.equals(true, field['final']);
95 Expect.equals('_Smi', field['guardClass']['name']);
96 Expect.equals(false, field['guardNullable']);
97 Expect.equals('variable', field['guardLength']);
98 }
99
100 _testFieldFinalFixedLengthList(Map field) {
101 Expect.equals('Field', field['type']);
102 Expect.equals('final_fixed_length_list', field['name']);
103 Expect.equals('_Float32Array', field['guardClass']['name']);
104 Expect.equals(true, field['final']);
105 Expect.equals(false, field['static']);
106 Expect.equals(false, field['const']);
107 Expect.equals('variable', field['guardLength']);
108 }
109
110 _testFieldFixedLengthArray(Map field) {
111 Expect.equals('Field', field['type']);
112 Expect.equals('fixed_length_array', field['name']);
113 Expect.equals('_List', field['guardClass']['name']);
114 Expect.equals(true, field['final']);
115 Expect.equals(false, field['static']);
116 Expect.equals(false, field['const']);
117 Expect.equals(3, field['guardLength']);
118 }
119
120 Future makeRequest() {
121 var fields = ['final_fixed_length_list', 'fixed_length_array', 'v', 'c'];
122 var helper =
123 new ClassFieldRequestHelper(port, isolate_id, class_id, fields);
124 return helper.makeRequest().then((_) {
125 _testFieldV(helper.fields['v']);
126 _testFieldC(helper.fields['c']);
127 _testFieldFinalFixedLengthList(helper.fields['final_fixed_length_list']);
128 _testFieldFixedLengthArray(helper.fields['fixed_length_array']);
129 });
130 }
131 }
132
133 class ClassTableTest extends VmServiceRequestHelper {
134 ClassTableTest(port, id) :
135 super('http://127.0.0.1:$port/$id/classes/');
136
137 String banana_class_id;
138 String bad_banana_class_id;
139
140 onRequestCompleted(Map reply) {
141 ClassTableHelper helper = new ClassTableHelper(reply);
142 Expect.isTrue(helper.classExists('Banana'));
143 banana_class_id = helper.classId('Banana');
144 Expect.isTrue(helper.classExists('BadBanana'));
145 bad_banana_class_id = helper.classId('BadBanana');
146 }
147 }
148
149 class VMTest extends VmServiceRequestHelper {
150 VMTest(port) : super('http://127.0.0.1:$port/vm');
151
152 String _isolateId;
153 onRequestCompleted(Map reply) {
154 VMTester tester = new VMTester(reply);
155 tester.checkIsolateCount(1);
156 _isolateId = tester.getIsolateId(0);
157 }
158 }
159
160 main() {
161 var process = new TestLauncher('field_script.dart');
162 process.launch().then((port) {
163 var test = new VMTest(port);
164 test.makeRequest().then((_) {
165 var classTableTest = new ClassTableTest(port, test._isolateId);
166 classTableTest.makeRequest().then((_) {
167 var bananaClassTest =
168 new BananaClassTest(port, test._isolateId,
169 classTableTest.banana_class_id);
170 var badBananaClassTest =
171 new BadBananaClassTest(port, test._isolateId,
172 classTableTest.bad_banana_class_id);
173 Future.wait([bananaClassTest.makeRequest(),
174 badBananaClassTest.makeRequest()]).then((_) {
175 process.requestExit();
176 });
177 });
178 });
179 });
180 }
OLDNEW
« no previous file with comments | « tests/standalone/vmservice/isolate_bad_object_test.dart ('k') | tests/standalone/vmservice/isolate_echo_script.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698