| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'package:observatory/object_graph.dart'; | 6 import 'package:observatory/object_graph.dart'; |
| 7 import 'package:observatory/service_io.dart'; | 7 import 'package:observatory/service_io.dart'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 import 'test_helper.dart'; | 9 import 'test_helper.dart'; |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 var tests = [ | 29 var tests = [ |
| 30 | 30 |
| 31 (Isolate isolate) { | 31 (Isolate isolate) { |
| 32 Completer completer = new Completer(); | 32 Completer completer = new Completer(); |
| 33 isolate.vm.events.stream.listen((ServiceEvent event) { | 33 isolate.vm.events.stream.listen((ServiceEvent event) { |
| 34 if (event.eventType == '_Graph') { | 34 if (event.eventType == '_Graph') { |
| 35 ReadStream reader = new ReadStream(event.data); | 35 ReadStream reader = new ReadStream(event.data); |
| 36 ObjectGraph graph = new ObjectGraph(reader); | 36 ObjectGraph graph = new ObjectGraph(reader); |
| 37 expect(fooId, isNotNull); | 37 expect(fooId, isNotNull); |
| 38 List<ObjectVertex> foos = graph.vertices.where((ObjectVertex obj) => obj.c
lassId == fooId); | 38 Iterable<ObjectVertex> foos = graph.vertices.where((ObjectVertex obj) => o
bj.classId == fooId); |
| 39 expect(foos.length, equals(3)); | 39 expect(foos.length, equals(3)); |
| 40 expect(foos.where((ObjectVertex obj) => obj.succ.length == 0).length, equa
ls(1)); | 40 expect(foos.where((ObjectVertex obj) => obj.succ.length == 0).length, equa
ls(1)); |
| 41 expect(foos.where((ObjectVertex obj) => obj.succ.length == 1).length, equa
ls(1)); | 41 expect(foos.where((ObjectVertex obj) => obj.succ.length == 1).length, equa
ls(1)); |
| 42 expect(foos.where((ObjectVertex obj) => obj.succ.length == 2).length, equa
ls(1)); | 42 expect(foos.where((ObjectVertex obj) => obj.succ.length == 2).length, equa
ls(1)); |
| 43 completer.complete(); | 43 completer.complete(); |
| 44 } | 44 } |
| 45 }); | 45 }); |
| 46 return isolate.rootLib.load().then((Library lib) { | 46 return isolate.rootLib.load().then((Library lib) { |
| 47 expect(lib.classes.length, equals(1)); | 47 expect(lib.classes.length, equals(1)); |
| 48 // Extract the numerical class id of 'Foo', used in the event listener above
. | 48 // Extract the numerical class id of 'Foo', used in the event listener above
. |
| 49 Class fooClass = lib.classes.first; | 49 Class fooClass = lib.classes.first; |
| 50 String prefix = "classes/"; | 50 String prefix = "classes/"; |
| 51 // TODO(koda): Add method on Class to get numerical id. | 51 // TODO(koda): Add method on Class to get numerical id. |
| 52 fooId = int.parse(fooClass.id.substring(prefix.length)); | 52 fooId = int.parse(fooClass.id.substring(prefix.length)); |
| 53 isolate.get('graph'); | 53 isolate.get('graph'); |
| 54 return completer.future; | 54 return completer.future; |
| 55 }); | 55 }); |
| 56 }, | 56 }, |
| 57 | 57 |
| 58 ]; | 58 ]; |
| 59 | 59 |
| 60 main(args) => runIsolateTests(args, tests, testeeBefore: script); | 60 main(args) => runIsolateTests(args, tests, testeeBefore: script); |
| OLD | NEW |