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

Side by Side Diff: runtime/bin/vmservice/observatory/test/graph_test.dart

Issue 773573005: vmservice: basic object graph serialization. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
(Empty)
1 // Copyright (c) 2014, 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 import 'dart:async';
6 import 'package:observatory/object_graph.dart';
7 import 'package:observatory/service_io.dart';
8 import 'package:unittest/unittest.dart';
9 import 'test_helper.dart';
10
11 class Foo {
12 Object left;
13 Object right;
14 }
15 Foo root;
16
17 void script() {
18 // Create 3 instances of Foo, with out-degrees 0 (for b), 1 (for a), and 2 (fo r root).
19 root = new Foo();
20 var a = new Foo();
21 var b = new Foo();
22 root.left = a;
23 root.right = b;
24 a.left = b;
25 }
26
27 int fooId;
28
29 var tests = [
30
31 (Isolate isolate) {
32 Completer completer = new Completer();
33 isolate.vm.events.stream.listen((ServiceEvent event) {
34 if (event.eventType == '_Graph') {
35 ReadStream reader = new ReadStream(event.data);
36 ObjectGraph graph = new ObjectGraph(reader);
37 List<ObjectVertex> foos = graph.vertices.where((ObjectVertex obj) => obj.c lassId == fooId);
Cutch 2014/12/02 16:46:26 assert that fooId != null before?
koda 2014/12/02 18:47:12 Done.
38 expect(foos.length, equals(3));
39 expect(foos.where((ObjectVertex obj) => obj.succ.length == 0).length, equa ls(1));
40 expect(foos.where((ObjectVertex obj) => obj.succ.length == 1).length, equa ls(1));
41 expect(foos.where((ObjectVertex obj) => obj.succ.length == 2).length, equa ls(1));
42 completer.complete();
43 }
44 });
45 return isolate.rootLib.load().then((Library lib) {
46 expect(lib.classes.length, equals(1));
47 // Extract the numerical class id of 'Foo', used in the event listener above .
48 Class fooClass = lib.classes.first;
49 String prefix = "classes/";
50 fooId = int.parse(fooClass.id.substring(prefix.length));
Cutch 2014/12/02 16:46:26 Not necessarily for your change- it might make sen
koda 2014/12/02 18:47:12 Agreed, I've added a TODO.
51 isolate.get('graph');
52 return completer.future;
53 });
54 },
55
56 ];
57
58 main(args) => runIsolateTests(args, tests, testeeBefore: script);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698