Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: runtime/observatory/tests/service/code_test.dart

Issue 2759973004: Fix observatory tests broken by running dartfmt. Temporarily reverted formatting for evaluate_activ… (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 import 'test_helper.dart'; 8 import 'test_helper.dart';
9 import 'dart:async'; 9 import 'dart:async';
10 10
11 int counter = 0; 11 int counter = 0;
12 12
13 void funcB() { 13 void funcB() {
14 counter++; // line 13 14 counter++; // line 13
15 if (counter % 100000000 == 0) { 15 if (counter % 100000000 == 0) {
16 print(counter); 16 print(counter);
17 } 17 }
18 } 18 }
19 19
20 void funcA() { 20 void funcA() {
21 funcB(); 21 funcB();
22 } 22 }
23 23
24 void testFunction() { 24 void testFunction() {
25 while (true) { 25 while (true) {
26 funcA(); 26 funcA();
27 } 27 }
28 } 28 }
29 29
30 var tests = [ 30 var tests = [
31
32 // Go to breakpoint at line 13. 31 // Go to breakpoint at line 13.
33 (Isolate isolate) { 32 (Isolate isolate) {
34 return isolate.rootLibrary.load().then((_) { 33 return isolate.rootLibrary.load().then((_) {
35 // Set up a listener to wait for breakpoint events. 34 // Set up a listener to wait for breakpoint events.
36 Completer completer = new Completer(); 35 Completer completer = new Completer();
37 isolate.vm.getEventStream(VM.kDebugStream).then((stream) { 36 isolate.vm.getEventStream(VM.kDebugStream).then((stream) {
38 var subscription; 37 var subscription;
39 subscription = stream.listen((ServiceEvent event) { 38 subscription = stream.listen((ServiceEvent event) {
40 if (event.kind == ServiceEvent.kPauseBreakpoint) { 39 if (event.kind == ServiceEvent.kPauseBreakpoint) {
41 print('Breakpoint reached'); 40 print('Breakpoint reached');
42 subscription.cancel(); 41 subscription.cancel();
43 completer.complete(); 42 completer.complete();
44 } 43 }
45 }); 44 });
46 }); 45 });
47 46
48 // Add the breakpoint. 47 // Add the breakpoint.
49 var script = isolate.rootLibrary.scripts[0]; 48 var script = isolate.rootLibrary.scripts[0];
50 var line = 13; 49 var line = 13;
51 return isolate.addBreakpoint(script, line).then((ServiceObject bpt) { 50 return isolate.addBreakpoint(script, line).then((ServiceObject bpt) {
52 return completer.future; // Wait for breakpoint reached. 51 return completer.future; // Wait for breakpoint reached.
53 }); 52 });
54 }); 53 });
55 }, 54 },
56 55
57 // Inspect code objects for top two frames. 56 // Inspect code objects for top two frames.
58 (Isolate isolate) { 57 (Isolate isolate) {
59 return isolate.getStack().then((ServiceMap stack) { 58 return isolate.getStack().then((ServiceMap stack) {
60 // Make sure we are in the right place. 59 // Make sure we are in the right place.
61 expect(stack.type, equals('Stack')); 60 expect(stack.type, equals('Stack'));
62 expect(stack['frames'].length, greaterThanOrEqualTo(3)); 61 expect(stack['frames'].length, greaterThanOrEqualTo(3));
63 var frame0 = stack['frames'][0]; 62 var frame0 = stack['frames'][0];
64 var frame1 = stack['frames'][1]; 63 var frame1 = stack['frames'][1];
65 print(frame0); 64 print(frame0);
66 expect(frame0.function.name, equals('funcB')); 65 expect(frame0.function.name, equals('funcB'));
67 expect(frame1.function.name, equals('funcA')); 66 expect(frame1.function.name, equals('funcA'));
68 var codeId0 = frame0.code.id; 67 var codeId0 = frame0.code.id;
69 var codeId1 = frame1.code.id; 68 var codeId1 = frame1.code.id;
70 69
71 List tests = []; 70 List tests = [];
72 // Load code from frame 0. 71 // Load code from frame 0.
73 tests.add(isolate.getObject(codeId0)..then((Code code) { 72 tests.add(isolate.getObject(codeId0)
74 expect(code.type, equals('Code')); 73 ..then((Code code) {
75 expect(code.function.name, equals('funcB')); 74 expect(code.type, equals('Code'));
76 expect(code.hasDisassembly, equals(true)); 75 expect(code.function.name, equals('funcB'));
77 })); 76 expect(code.hasDisassembly, equals(true));
77 }));
78 // Load code from frame 0. 78 // Load code from frame 0.
79 tests.add(isolate.getObject(codeId1)..then((Code code) { 79 tests.add(isolate.getObject(codeId1)
80 expect(code.type, equals('Code')); 80 ..then((Code code) {
81 expect(code.function.name, equals('funcA')); 81 expect(code.type, equals('Code'));
82 expect(code.hasDisassembly, equals(true)); 82 expect(code.function.name, equals('funcA'));
83 })); 83 expect(code.hasDisassembly, equals(true));
84 }));
84 return Future.wait(tests); 85 return Future.wait(tests);
85 }); 86 });
86 }, 87 },
87
88 ]; 88 ];
89 89
90 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); 90 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698