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

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

Issue 119673004: Version 1.1.0-dev.5.2 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 11 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
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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 library vmservice_test_helper; 5 library vmservice_test_helper;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'package:expect/expect.dart'; 10 import 'package:expect/expect.dart';
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 IsolateListTester(this.isolateList) { 180 IsolateListTester(this.isolateList) {
181 // The reply is an IsolateList. 181 // The reply is an IsolateList.
182 Expect.equals('IsolateList', isolateList['type'], 'Not an IsolateList.'); 182 Expect.equals('IsolateList', isolateList['type'], 'Not an IsolateList.');
183 } 183 }
184 184
185 void checkIsolateCount(int n) { 185 void checkIsolateCount(int n) {
186 Expect.equals(n, isolateList['members'].length, 'Isolate count not $n'); 186 Expect.equals(n, isolateList['members'].length, 'Isolate count not $n');
187 } 187 }
188 188
189 void checkIsolateIdExists(int id) { 189 void checkIsolateIdExists(String id) {
190 var exists = false; 190 var exists = false;
191 isolateList['members'].forEach((isolate) { 191 isolateList['members'].forEach((isolate) {
192 if (isolate['id'] == id) { 192 if (isolate['id'] == id) {
193 exists = true; 193 exists = true;
194 } 194 }
195 }); 195 });
196 Expect.isTrue(exists, 'No isolate with id: $id'); 196 Expect.isTrue(exists, 'No isolate with id: $id');
197 } 197 }
198 198
199 int checkIsolateNameContains(String name) { 199 String checkIsolateNameContains(String name) {
200 var exists = false; 200 var exists = false;
201 int id; 201 String id;
202 isolateList['members'].forEach((isolate) { 202 isolateList['members'].forEach((isolate) {
203 if (isolate['name'].contains(name)) { 203 if (isolate['name'].contains(name)) {
204 exists = true; 204 exists = true;
205 id = isolate['id']; 205 id = isolate['id'];
206 } 206 }
207 }); 207 });
208 Expect.isTrue(exists, 'No isolate with name: $name'); 208 Expect.isTrue(exists, 'No isolate with name: $name');
209 return id; 209 return id;
210 } 210 }
211 211
212 void checkIsolateNamePrefix(int id, String name) { 212 void checkIsolateNamePrefix(String id, String name) {
213 var exists = false; 213 var exists = false;
214 isolateList['members'].forEach((isolate) { 214 isolateList['members'].forEach((isolate) {
215 if (isolate['id'] == id) { 215 if (isolate['id'] == id) {
216 exists = true; 216 exists = true;
217 Expect.isTrue(isolate['name'].startsWith(name), 217 Expect.isTrue(isolate['name'].startsWith(name),
218 'Isolate $id does not have name prefix: $name' 218 'Isolate $id does not have name prefix: $name'
219 ' (was ${isolate['name']})'); 219 ' (was ${isolate['name']})');
220 } 220 }
221 }); 221 });
222 Expect.isTrue(exists, 'No isolate with id: $id'); 222 Expect.isTrue(exists, 'No isolate with id: $id');
(...skipping 11 matching lines...) Expand all
234 List members = classTable['members']; 234 List members = classTable['members'];
235 for (var i = 0; i < members.length; i++) { 235 for (var i = 0; i < members.length; i++) {
236 Map klass = members[i]; 236 Map klass = members[i];
237 if (klass['user_name'] == user_name) { 237 if (klass['user_name'] == user_name) {
238 return true; 238 return true;
239 } 239 }
240 } 240 }
241 return false; 241 return false;
242 } 242 }
243 243
244 int classId(String user_name) { 244 String classId(String user_name) {
245 List members = classTable['members']; 245 List members = classTable['members'];
246 for (var i = 0; i < members.length; i++) { 246 for (var i = 0; i < members.length; i++) {
247 Map klass = members[i]; 247 Map klass = members[i];
248 if (klass['user_name'] == user_name) { 248 if (klass['user_name'] == user_name) {
249 return klass['id']; 249 return klass['id'];
250 } 250 }
251 } 251 }
252 return -1; 252 return null;
253 } 253 }
254 } 254 }
255 255
256 class FieldRequestHelper extends VmServiceRequestHelper { 256 class FieldRequestHelper extends VmServiceRequestHelper {
257 FieldRequestHelper(port, isolate_id, field_id) : 257 FieldRequestHelper(port, isolate_id, field_id) :
258 super('http://127.0.0.1:$port/isolates/$isolate_id/objects/$field_id'); 258 super('http://127.0.0.1:$port/$isolate_id/$field_id');
259 Map field; 259 Map field;
260 onRequestCompleted(Map reply) { 260 onRequestCompleted(Map reply) {
261 Expect.equals('Field', reply['type']); 261 Expect.equals('Field', reply['type']);
262 field = reply; 262 field = reply;
263 return new Future.value(this); 263 return new Future.value(this);
264 } 264 }
265 } 265 }
266 266
267 class ClassFieldRequestHelper extends VmServiceRequestHelper { 267 class ClassFieldRequestHelper extends VmServiceRequestHelper {
268 final List<String> fieldNames; 268 final List<String> fieldNames;
269 int port_; 269 int port_;
270 int isolate_id_; 270 String isolate_id_;
271 ClassFieldRequestHelper(port, isolate_id, class_id, this.fieldNames) : 271 ClassFieldRequestHelper(port, isolate_id, class_id, this.fieldNames) :
272 super('http://127.0.0.1:$port/isolates/$isolate_id/classes/$class_id') { 272 super('http://127.0.0.1:$port/$isolate_id/$class_id') {
273 port_ = port; 273 port_ = port;
274 isolate_id_ = isolate_id; 274 isolate_id_ = isolate_id;
275 } 275 }
276 final Map<String, Map> fields = new Map<String, Map>(); 276 final Map<String, Map> fields = new Map<String, Map>();
277 277
278 onRequestCompleted(Map reply) { 278 onRequestCompleted(Map reply) {
279 Expect.equals('Class', reply['type']); 279 Expect.equals('Class', reply['type']);
280 List<Map> class_fields = reply['fields']; 280 List<Map> class_fields = reply['fields'];
281 List<Future> requests = new List<Future>(); 281 List<Future> requests = new List<Future>();
282 fieldNames.forEach((fn) { 282 fieldNames.forEach((fn) {
283 class_fields.forEach((f) { 283 class_fields.forEach((f) {
284 if (f['user_name'] == fn) { 284 if (f['user_name'] == fn) {
285 var request = new FieldRequestHelper(port_, isolate_id_, f['id']); 285 var request = new FieldRequestHelper(port_, isolate_id_, f['id']);
286 requests.add(request.makeRequest()); 286 requests.add(request.makeRequest());
287 } 287 }
288 }); 288 });
289 }); 289 });
290 return Future.wait(requests).then((a) { 290 return Future.wait(requests).then((a) {
291 a.forEach((FieldRequestHelper field) { 291 a.forEach((FieldRequestHelper field) {
292 fields[field.field['user_name']] = field.field; 292 fields[field.field['user_name']] = field.field;
293 }); 293 });
294 return this; 294 return this;
295 }); 295 });
296 } 296 }
297 } 297 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698