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 '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 | 8 |
9 import 'test_helper.dart'; | 9 import 'test_helper.dart'; |
10 | 10 |
11 fib(n) { | 11 fib(n) { |
12 if (n < 0) return 0; | 12 if (n < 0) return 0; |
13 if (n == 0) return 1; | 13 if (n == 0) return 1; |
14 return fib(n - 1) + fib(n - 2); | 14 return fib(n - 1) + fib(n - 2); |
15 } | 15 } |
16 | 16 |
17 testeeDo() { | 17 testeeDo() { |
18 print("Testee doing something."); | 18 print("Testee doing something."); |
19 fib(25); | 19 fib(25); |
20 print("Testee did something."); | 20 print("Testee did something."); |
21 } | 21 } |
22 | 22 |
23 var tests = [ | 23 var tests = [ |
24 (Isolate isolate) async { | 24 (Isolate isolate) async { |
25 var params = {'tags': 'VMUser'}; | 25 var params = { |
26 var result = | 26 'tags': 'VMUser' |
27 await isolate.invokeRpcNoUpgrade('_getCpuProfileTimeline', params); | 27 }; |
| 28 var result = await isolate.invokeRpcNoUpgrade( |
| 29 '_getCpuProfileTimeline', params); |
28 print(result); | 30 print(result); |
29 expect(result['type'], equals('_CpuProfileTimeline')); | 31 expect(result['type'], equals('_CpuProfileTimeline')); |
30 | 32 |
31 var isString = new isInstanceOf<String>(); | 33 var isString = new isInstanceOf<String>(); |
32 var isInt = new isInstanceOf<int>(); | 34 var isInt = new isInstanceOf<int>(); |
33 | 35 |
34 Map frames = result['stackFrames']; | 36 Map frames = result['stackFrames']; |
35 for (Map frame in frames.values) { | 37 for (Map frame in frames.values) { |
36 expect(frame['category'], isString); | 38 expect(frame['category'], isString); |
37 expect(frame['name'], isString); | 39 expect(frame['name'], isString); |
38 if (frame['parent'] != null) { | 40 if (frame['parent'] != null) { |
39 expect(frames.containsKey(frame['parent']), isTrue); | 41 expect(frames.containsKey(frame['parent']), isTrue); |
40 } | 42 } |
41 } | 43 } |
42 | 44 |
43 List events = result['traceEvents']; | 45 List events = result['traceEvents']; |
44 for (Map event in events) { | 46 for (Map event in events) { |
45 expect(event['ph'], equals('P')); | 47 expect(event['ph'], equals('P')); |
46 expect(event['pid'], isInt); | 48 expect(event['pid'], isInt); |
47 expect(event['tid'], isInt); | 49 expect(event['tid'], isInt); |
48 expect(event['ts'], isInt); | 50 expect(event['ts'], isInt); |
49 expect(event['cat'], equals("Dart")); | 51 expect(event['cat'], equals("Dart")); |
50 expect(frames.containsKey(event['sf']), isTrue); | 52 expect(frames.containsKey(event['sf']), isTrue); |
51 } | 53 } |
52 }, | 54 }, |
53 ]; | 55 ]; |
54 | 56 |
55 main(args) async => runIsolateTests(args, tests, testeeBefore: testeeDo); | 57 main(args) async => runIsolateTests(args, tests, testeeBefore: testeeDo); |
OLD | NEW |