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

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

Issue 2767533002: Revert "Fix observatory tests broken by running dartfmt." (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:observatory/debugger.dart'; 7 import 'package:observatory/debugger.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 import 'service_test_common.dart'; 9 import 'service_test_common.dart';
10 import 'test_helper.dart'; 10 import 'test_helper.dart';
11 import 'dart:async'; 11 import 'dart:async';
12 import 'dart:developer'; 12 import 'dart:developer';
13 13
14 const int LINE_A = 22; 14 const int LINE_A = 22;
15 const int LINE_B = 112; 15 const int LINE_B = 112;
16 const int LINE_C = 12; 16 const int LINE_C = 12;
17 17
18 void testFunction() { 18 void testFunction() {
19 int i = 0; 19 int i = 0;
20 while (i == 0) { 20 while (i == 0) {
21 debugger(); 21 debugger();
22 print('loop'); // Line A. 22 print('loop'); // Line A.
23 print('loop'); 23 print('loop');
24 } 24 }
25 } 25 }
26 26
27 class TestDebugger extends Debugger { 27 class TestDebugger extends Debugger {
28 TestDebugger(this.isolate, this.stack); 28 TestDebugger(this.isolate, this.stack);
29 29
30 VM get vm => isolate.vm; 30 VM get vm => isolate.vm;
31 Isolate isolate; 31 Isolate isolate;
32 ServiceMap stack; 32 ServiceMap stack;
33 int currentFrame = 0; 33 int currentFrame = 0;
34 } 34 }
35 35
36 void debugger_location_dummy_function() {} 36 void debugger_location_dummy_function() {
37 }
37 38
38 class DebuggerLocationTestFoo { 39 class DebuggerLocationTestFoo {
39 DebuggerLocationTestFoo(this.field); 40 DebuggerLocationTestFoo(this.field);
40 DebuggerLocationTestFoo.named(); 41 DebuggerLocationTestFoo.named();
41 42
42 void method() {} 43 void method() {}
43 void madness() {} 44 void madness() {}
44 45
45 int field; 46 int field;
46 } 47 }
47 48
48 class DebuggerLocationTestBar {} 49 class DebuggerLocationTestBar {
50 }
49 51
50 Future<Debugger> initDebugger(Isolate isolate) { 52 Future<Debugger> initDebugger(Isolate isolate) {
51 return isolate.getStack().then((stack) { 53 return isolate.getStack().then((stack) {
52 return new TestDebugger(isolate, stack); 54 return new TestDebugger(isolate, stack);
53 }); 55 });
54 } 56 }
55 57
56 var tests = [ 58 var tests = [
57 hasStoppedAtBreakpoint, 59
60 hasStoppedAtBreakpoint,
58 61
59 // Parse '' => current position 62 // Parse '' => current position
60 (Isolate isolate) async { 63 (Isolate isolate) async {
61 var debugger = await initDebugger(isolate); 64 var debugger = await initDebugger(isolate);
62 var loc = await DebuggerLocation.parse(debugger, ''); 65 var loc = await DebuggerLocation.parse(debugger, '');
63 expect(loc.valid, isTrue); 66 expect(loc.valid, isTrue);
64 expect(loc.toString(), equals('debugger_location_test.dart:$LINE_A:5')); 67 expect(loc.toString(), equals('debugger_location_test.dart:$LINE_A:5'));
65 }, 68 },
66 69
67 // Parse line 70 // Parse line
68 (Isolate isolate) async { 71 (Isolate isolate) async {
69 var debugger = await initDebugger(isolate); 72 var debugger = await initDebugger(isolate);
70 var loc = await DebuggerLocation.parse(debugger, '18'); 73 var loc = await DebuggerLocation.parse(debugger, '18');
71 expect(loc.valid, isTrue); 74 expect(loc.valid, isTrue);
72 expect(loc.toString(), equals('debugger_location_test.dart:18')); 75 expect(loc.toString(), equals('debugger_location_test.dart:18'));
73 }, 76 },
74 77
75 // Parse line + col 78 // Parse line + col
76 (Isolate isolate) async { 79 (Isolate isolate) async {
77 var debugger = await initDebugger(isolate); 80 var debugger = await initDebugger(isolate);
78 var loc = await DebuggerLocation.parse(debugger, '16:11'); 81 var loc = await DebuggerLocation.parse(debugger, '16:11');
79 expect(loc.valid, isTrue); 82 expect(loc.valid, isTrue);
80 expect(loc.toString(), equals('debugger_location_test.dart:16:11')); 83 expect(loc.toString(), equals('debugger_location_test.dart:16:11'));
81 }, 84 },
82 85
83 // Parse script + line 86 // Parse script + line
84 (Isolate isolate) async { 87 (Isolate isolate) async {
85 var debugger = await initDebugger(isolate); 88 var debugger = await initDebugger(isolate);
86 var loc = await DebuggerLocation.parse(debugger, 'unittest.dart:15'); 89 var loc = await DebuggerLocation.parse(debugger, 'unittest.dart:15');
87 expect(loc.valid, isTrue); 90 expect(loc.valid, isTrue);
88 expect(loc.toString(), equals('unittest.dart:15')); 91 expect(loc.toString(), equals('unittest.dart:15'));
89 }, 92 },
90 93
91 // Parse script + line + col 94 // Parse script + line + col
92 (Isolate isolate) async { 95 (Isolate isolate) async {
93 var debugger = await initDebugger(isolate); 96 var debugger = await initDebugger(isolate);
94 var loc = await DebuggerLocation.parse(debugger, 'unittest.dart:15:10'); 97 var loc = await DebuggerLocation.parse(debugger, 'unittest.dart:15:10');
95 expect(loc.valid, isTrue); 98 expect(loc.valid, isTrue);
96 expect(loc.toString(), equals('unittest.dart:15:10')); 99 expect(loc.toString(), equals('unittest.dart:15:10'));
97 }, 100 },
98 101
99 // Parse bad script 102 // Parse bad script
100 (Isolate isolate) async { 103 (Isolate isolate) async {
101 var debugger = await initDebugger(isolate); 104 var debugger = await initDebugger(isolate);
102 var loc = await DebuggerLocation.parse(debugger, 'bad.dart:15'); 105 var loc = await DebuggerLocation.parse(debugger, 'bad.dart:15');
103 expect(loc.valid, isFalse); 106 expect(loc.valid, isFalse);
104 expect(loc.toString(), 107 expect(loc.toString(), equals(
105 equals('invalid source location (Script \'bad.dart\' not found)')); 108 'invalid source location (Script \'bad.dart\' not found)'));
106 }, 109 },
107 110
108 // Parse function 111 // Parse function
109 (Isolate isolate) async { 112 (Isolate isolate) async {
110 var debugger = await initDebugger(isolate); 113 var debugger = await initDebugger(isolate);
111 var loc = await DebuggerLocation.parse(debugger, 'testFunction'); 114 var loc = await DebuggerLocation.parse(debugger, 'testFunction');
112 expect(loc.valid, isTrue); 115 expect(loc.valid, isTrue);
113 expect(loc.toString(), equals('testFunction')); 116 expect(loc.toString(), equals('testFunction'));
114 }, 117 },
115 118
116 // Parse bad function 119 // Parse bad function
117 (Isolate isolate) async { 120 (Isolate isolate) async {
118 var debugger = await initDebugger(isolate); 121 var debugger = await initDebugger(isolate);
119 var loc = await DebuggerLocation.parse(debugger, 'doesNotReallyExist'); 122 var loc = await DebuggerLocation.parse(debugger, 'doesNotReallyExist');
120 expect(loc.valid, isFalse); 123 expect(loc.valid, isFalse);
121 expect( 124 expect(loc.toString(), equals(
122 loc.toString(), 125 'invalid source location (Function \'doesNotReallyExist\' not found)'));
123 equals( 126 },
124 'invalid source location (Function \'doesNotReallyExist\' not found) '));
125 },
126 127
127 // Parse constructor 128 // Parse constructor
128 (Isolate isolate) async { 129 (Isolate isolate) async {
129 var debugger = await initDebugger(isolate); 130 var debugger = await initDebugger(isolate);
130 var loc = await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo'); 131 var loc = await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo');
131 expect(loc.valid, isTrue); 132 expect(loc.valid, isTrue);
132 // TODO(turnidge): Printing a constructor currently adds 133 // TODO(turnidge): Printing a constructor currently adds
133 // another class qualifier at the front. Do we want to change 134 // another class qualifier at the front. Do we want to change
134 // this to be more consistent? 135 // this to be more consistent?
135 expect(loc.toString(), 136 expect(loc.toString(), equals(
136 equals('DebuggerLocationTestFoo.DebuggerLocationTestFoo')); 137 'DebuggerLocationTestFoo.DebuggerLocationTestFoo'));
137 }, 138 },
138 139
139 // Parse named constructor 140 // Parse named constructor
140 (Isolate isolate) async { 141 (Isolate isolate) async {
141 var debugger = await initDebugger(isolate); 142 var debugger = await initDebugger(isolate);
142 var loc = 143 var loc =
143 await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.named'); 144 await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.named');
144 expect(loc.valid, isTrue); 145 expect(loc.valid, isTrue);
145 // TODO(turnidge): Printing a constructor currently adds 146 // TODO(turnidge): Printing a constructor currently adds
146 // another class qualifier at the front. Do we want to change 147 // another class qualifier at the front. Do we want to change
147 // this to be more consistent? 148 // this to be more consistent?
148 expect(loc.toString(), 149 expect(loc.toString(), equals(
149 equals('DebuggerLocationTestFoo.DebuggerLocationTestFoo.named')); 150 'DebuggerLocationTestFoo.DebuggerLocationTestFoo.named'));
150 }, 151 },
152
151 ]; 153 ];
152 154
153 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); 155 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698