| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // VMOptions=--error_on_bad_type --error_on_bad_override | 4 // VMOptions=--error_on_bad_type --error_on_bad_override |
| 5 | 5 |
| 6 import 'dart:developer'; | 6 import 'dart:developer'; |
| 7 import 'package:observatory/models.dart' as M; |
| 7 import 'package:observatory/service_io.dart'; | 8 import 'package:observatory/service_io.dart'; |
| 8 import 'package:observatory/cpu_profile.dart'; | 9 import 'package:observatory/cpu_profile.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 10 import 'service_test_common.dart'; | 11 import 'service_test_common.dart'; |
| 11 import 'test_helper.dart'; | 12 import 'test_helper.dart'; |
| 12 | 13 |
| 13 class Foo { | 14 class Foo { |
| 14 Foo() { | 15 Foo() { |
| 15 print('new Foo'); | 16 print('new Foo'); |
| 16 } | 17 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 var fooClass = await getClassFromRootLib(isolate, 'Foo'); | 55 var fooClass = await getClassFromRootLib(isolate, 'Foo'); |
| 55 await fooClass.reload(); | 56 await fooClass.reload(); |
| 56 expect(fooClass.traceAllocations, isTrue); | 57 expect(fooClass.traceAllocations, isTrue); |
| 57 var profileResponse = await fooClass.getAllocationSamples(); | 58 var profileResponse = await fooClass.getAllocationSamples(); |
| 58 expect(profileResponse, isNotNull); | 59 expect(profileResponse, isNotNull); |
| 59 expect(profileResponse['type'], equals('_CpuProfile')); | 60 expect(profileResponse['type'], equals('_CpuProfile')); |
| 60 await fooClass.setTraceAllocations(false); | 61 await fooClass.setTraceAllocations(false); |
| 61 await fooClass.reload(); | 62 await fooClass.reload(); |
| 62 expect(fooClass.traceAllocations, isFalse); | 63 expect(fooClass.traceAllocations, isFalse); |
| 63 CpuProfile cpuProfile = new CpuProfile(); | 64 CpuProfile cpuProfile = new CpuProfile(); |
| 64 cpuProfile.load(isolate, profileResponse); | 65 await cpuProfile.load(isolate, profileResponse); |
| 65 cpuProfile.buildCodeCallerAndCallees(); | 66 cpuProfile.buildCodeCallerAndCallees(); |
| 66 cpuProfile.buildFunctionCallerAndCallees(); | 67 cpuProfile.buildFunctionCallerAndCallees(); |
| 67 var tree = cpuProfile.loadCodeTree('exclusive'); | 68 var tree = cpuProfile.loadCodeTree(M.ProfileTreeDirection.exclusive); |
| 68 var node = tree.root; | 69 var node = tree.root; |
| 69 var expected = | 70 var expected = |
| 70 ['Root', 'DRT_AllocateObject', 'test', 'test', '_Closure.call']; | 71 ['Root', 'DRT_AllocateObject', 'test', 'test', '_Closure.call']; |
| 71 for (var i = 0; i < expected.length; i++) { | 72 for (var i = 0; i < expected.length; i++) { |
| 72 expect(node.profileCode.code.name, equals(expected[i])); | 73 expect(node.profileCode.code.name, equals(expected[i])); |
| 73 // Depth first traversal. | 74 // Depth first traversal. |
| 74 if (node.children.length == 0) { | 75 if (node.children.length == 0) { |
| 75 node = null; | 76 node = null; |
| 76 } else { | 77 } else { |
| 77 node = node.children[0]; | 78 node = node.children[0]; |
| 78 } | 79 } |
| 79 expect(node, isNotNull); | 80 expect(node, isNotNull); |
| 80 } | 81 } |
| 81 }, | 82 }, |
| 82 resumeIsolate, | 83 resumeIsolate, |
| 83 ]; | 84 ]; |
| 84 | 85 |
| 85 main(args) async => runIsolateTests(args, tests, testeeConcurrent:test); | 86 main(args) async => runIsolateTests(args, tests, testeeConcurrent:test); |
| OLD | NEW |