| Index: runtime/observatory/tests/service/graph_test.dart
|
| diff --git a/runtime/observatory/tests/service/graph_test.dart b/runtime/observatory/tests/service/graph_test.dart
|
| index 907dcd40c4b97d79bdb88a8b77eac4928a0a1241..9b0b937f2136fe788c222fc1d316ff6842b6749a 100644
|
| --- a/runtime/observatory/tests/service/graph_test.dart
|
| +++ b/runtime/observatory/tests/service/graph_test.dart
|
| @@ -37,61 +37,55 @@ int fooId;
|
|
|
| var tests = [
|
|
|
| -(Isolate isolate) {
|
| - Completer completer = new Completer();
|
| - isolate.vm.getEventStream('_Graph').listen((ServiceEvent event) {
|
| - if (event.eventType == ServiceEvent.kGraph) {
|
| - ReadStream reader = new ReadStream(event.data);
|
| - ObjectGraph graph = new ObjectGraph(reader);
|
| - expect(fooId, isNotNull);
|
| - Iterable<ObjectVertex> foos = graph.vertices.where(
|
| - (ObjectVertex obj) => obj.classId == fooId);
|
| - expect(foos.length, equals(3));
|
| - expect(foos.where(
|
| - (ObjectVertex obj) => obj.succ.length == 0).length, equals(1));
|
| - expect(foos.where(
|
| - (ObjectVertex obj) => obj.succ.length == 1).length, equals(1));
|
| - expect(foos.where(
|
| - (ObjectVertex obj) => obj.succ.length == 2).length, equals(1));
|
| -
|
| - ObjectVertex bVertex = foos.where(
|
| - (ObjectVertex obj) => obj.succ.length == 0).first;
|
| - ObjectVertex aVertex = foos.where(
|
| - (ObjectVertex obj) => obj.succ.length == 1).first;
|
| - ObjectVertex rVertex = foos.where(
|
| - (ObjectVertex obj) => obj.succ.length == 2).first;
|
| -
|
| - // TODO(koda): Check actual byte sizes.
|
| -
|
| - expect(aVertex.retainedSize, equals(aVertex.shallowSize));
|
| - expect(bVertex.retainedSize, equals(bVertex.shallowSize));
|
| - expect(rVertex.retainedSize, equals(aVertex.shallowSize +
|
| - bVertex.shallowSize +
|
| - rVertex.shallowSize));
|
| -
|
| - const int fixedSizeListCid = 61;
|
| - List<ObjectVertex> lists = new List.from(graph.vertices.where(
|
| - (ObjectVertex obj) => obj.classId == fixedSizeListCid));
|
| - expect(lists.length >= 2, isTrue);
|
| - // Order by decreasing retained size.
|
| - lists.sort((u, v) => v.retainedSize - u.retainedSize);
|
| - ObjectVertex first = lists[0];
|
| - ObjectVertex second = lists[1];
|
| - // Check that the short list retains more than the long list inside.
|
| - expect(first.succ.length, equals(2 + second.succ.length));
|
| - // ... and specifically, that it retains exactly itself + the long one.
|
| - expect(first.retainedSize,
|
| - equals(first.shallowSize + second.shallowSize));
|
| - completer.complete();
|
| - }
|
| - });
|
| - return isolate.rootLibrary.load().then((Library lib) {
|
| - expect(lib.classes.length, equals(1));
|
| - Class fooClass = lib.classes.first;
|
| - fooId = fooClass.vmCid;
|
| - isolate.invokeRpcNoUpgrade('requestHeapSnapshot', {});
|
| - return completer.future;
|
| - });
|
| +(Isolate isolate) async {
|
| + Library lib = await isolate.rootLibrary.load();
|
| + expect(lib.classes.length, equals(1));
|
| + Class fooClass = lib.classes.first;
|
| + fooId = fooClass.vmCid;
|
| +
|
| + HeapSnapshot snapshot = await isolate.fetchHeapSnapshot().last;
|
| + ObjectGraph graph = snapshot.graph;
|
| +
|
| + expect(fooId, isNotNull);
|
| + Iterable<ObjectVertex> foos = graph.vertices.where(
|
| + (ObjectVertex obj) => obj.vmCid == fooId);
|
| + expect(foos.length, equals(3));
|
| + expect(foos.where((obj) => obj.successors.length == 0).length,
|
| + equals(1));
|
| + expect(foos.where((obj) => obj.successors.length == 1).length,
|
| + equals(1));
|
| + expect(foos.where((obj) => obj.successors.length == 2).length,
|
| + equals(1));
|
| +
|
| + ObjectVertex bVertex = foos.where(
|
| + (ObjectVertex obj) => obj.successors.length == 0).first;
|
| + ObjectVertex aVertex = foos.where(
|
| + (ObjectVertex obj) => obj.successors.length == 1).first;
|
| + ObjectVertex rVertex = foos.where(
|
| + (ObjectVertex obj) => obj.successors.length == 2).first;
|
| +
|
| + // TODO(koda): Check actual byte sizes.
|
| +
|
| + expect(aVertex.retainedSize, equals(aVertex.shallowSize));
|
| + expect(bVertex.retainedSize, equals(bVertex.shallowSize));
|
| + expect(rVertex.retainedSize, equals(aVertex.shallowSize +
|
| + bVertex.shallowSize +
|
| + rVertex.shallowSize));
|
| +
|
| + const int fixedSizeListCid = 61;
|
| + List<ObjectVertex> lists = new List.from(graph.vertices.where(
|
| + (ObjectVertex obj) => obj.vmCid == fixedSizeListCid));
|
| + expect(lists.length >= 2, isTrue);
|
| + // Order by decreasing retained size.
|
| + lists.sort((u, v) => v.retainedSize - u.retainedSize);
|
| + ObjectVertex first = lists[0];
|
| + ObjectVertex second = lists[1];
|
| + // Check that the short list retains more than the long list inside.
|
| + expect(first.successors.length,
|
| + equals(2 + second.successors.length));
|
| + // ... and specifically, that it retains exactly itself + the long one.
|
| + expect(first.retainedSize,
|
| + equals(first.shallowSize + second.shallowSize));
|
| },
|
|
|
| ];
|
|
|