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

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

Issue 98253009: Refactor VM service IDs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 -1;
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 int 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