| 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=--compile-all --error_on_bad_type --error_on_bad_override --checked | 4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override --checked |
| 5 | 5 |
| 6 import 'package:observatory/service_io.dart'; | 6 import 'package:observatory/service_io.dart'; |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'test_helper.dart'; | 8 import 'test_helper.dart'; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 return completer.future; | 77 return completer.future; |
| 78 }); | 78 }); |
| 79 }, | 79 }, |
| 80 | 80 |
| 81 // Get coverage for function, class, library, script, and isolate. | 81 // Get coverage for function, class, library, script, and isolate. |
| 82 (Isolate isolate) { | 82 (Isolate isolate) { |
| 83 return isolate.getStack().then((ServiceMap stack) { | 83 return isolate.getStack().then((ServiceMap stack) { |
| 84 // Make sure we are in the right place. | 84 // Make sure we are in the right place. |
| 85 expect(stack.type, equals('Stack')); | 85 expect(stack.type, equals('Stack')); |
| 86 expect(stack['frames'].length, greaterThanOrEqualTo(2)); | 86 expect(stack['frames'].length, greaterThanOrEqualTo(2)); |
| 87 expect(stack['frames'][0]['function'].owningClass.name, equals('MyClass'))
; | 87 expect(stack['frames'][0]['function'].name, equals('myFunction')); |
| 88 expect(stack['frames'][0]['function'].dartOwner.name, equals('MyClass')); |
| 88 | 89 |
| 89 var lib = isolate.rootLib; | 90 var lib = isolate.rootLib; |
| 90 var func = stack['frames'][0]['function']; | 91 var func = stack['frames'][0]['function']; |
| 91 expect(func.name, equals('myFunction')); | 92 expect(func.name, equals('myFunction')); |
| 92 var cls = stack['frames'][0]['function'].owningClass; | 93 var cls = stack['frames'][0]['function'].dartOwner; |
| 93 expect(cls.name, equals('MyClass')); | 94 expect(cls.name, equals('MyClass')); |
| 94 | 95 |
| 95 List tests = []; | 96 List tests = []; |
| 96 // Function | 97 // Function |
| 97 tests.add(isolate.invokeRpcNoUpgrade('getCoverage', | 98 tests.add(isolate.invokeRpcNoUpgrade('getCoverage', |
| 98 { 'targetId': func.id }) | 99 { 'targetId': func.id }) |
| 99 .then((Map coverage) { | 100 .then((Map coverage) { |
| 100 expect(coverage['type'], equals('CodeCoverage')); | 101 expect(coverage['type'], equals('CodeCoverage')); |
| 101 expect(coverage['coverage'].length, equals(1)); | 102 expect(coverage['coverage'].length, equals(1)); |
| 102 expect(normalize(coverage['coverage'][0]['hits']), | 103 expect(normalize(coverage['coverage'][0]['hits']), |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 expect(coverage['coverage'].length, greaterThan(100)); | 147 expect(coverage['coverage'].length, greaterThan(100)); |
| 147 }); | 148 }); |
| 148 })); | 149 })); |
| 149 return Future.wait(tests); | 150 return Future.wait(tests); |
| 150 }); | 151 }); |
| 151 }, | 152 }, |
| 152 | 153 |
| 153 ]; | 154 ]; |
| 154 | 155 |
| 155 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); | 156 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); |
| OLD | NEW |