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

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

Issue 1278803005: Minor observatory test cleanups. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 'test_helper.dart'; 9 import 'test_helper.dart';
10 import 'dart:async'; 10 import 'dart:async';
11 import 'dart:developer';
11 12
12 void testFunction() { 13 void testFunction() {
13 int i = 0; 14 int i = 0;
14 while (true) { 15 while (true) {
15 if (++i % 100000000 == 0) { // line 15 16 debugger();
16 print(i); 17 print('loop');
17 } 18 print('loop');
18 } 19 }
19 } 20 }
20 21
21 class TestDebugger extends Debugger { 22 class TestDebugger extends Debugger {
22 TestDebugger(this.isolate, this.stack); 23 TestDebugger(this.isolate, this.stack);
23 24
24 VM get vm => isolate.vm; 25 VM get vm => isolate.vm;
25 Isolate isolate; 26 Isolate isolate;
26 ServiceMap stack; 27 ServiceMap stack;
27 int currentFrame = 0; 28 int currentFrame = 0;
(...skipping 16 matching lines...) Expand all
44 } 45 }
45 46
46 Future<Debugger> initDebugger(Isolate isolate) { 47 Future<Debugger> initDebugger(Isolate isolate) {
47 return isolate.getStack().then((stack) { 48 return isolate.getStack().then((stack) {
48 return new TestDebugger(isolate, stack); 49 return new TestDebugger(isolate, stack);
49 }); 50 });
50 } 51 }
51 52
52 var tests = [ 53 var tests = [
53 54
54 // Bring the isolate to a breakpoint at line 15. 55 hasStoppedAtBreakpoint,
55 (Isolate isolate) {
56 return isolate.rootLibrary.load().then((_) {
57 // Listen for breakpoint event.
58 Completer completer = new Completer();
59 isolate.vm.getEventStream(VM.kDebugStream).then((stream) {
60 var subscription;
61 subscription = stream.listen((ServiceEvent event) {
62 if (event.kind == ServiceEvent.kPauseBreakpoint) {
63 subscription.cancel();
64 completer.complete();
65 }
66 });
67 });
68
69 // Add the breakpoint.
70 var script = isolate.rootLibrary.scripts[0];
71 return isolate.addBreakpoint(script, 15).then((ServiceObject bpt) {
72 return completer.future; // Wait for breakpoint events.
73 });
74 });
75 },
76 56
77 // Parse '' => current position 57 // Parse '' => current position
78 (Isolate isolate) { 58 (Isolate isolate) {
79 return initDebugger(isolate).then((debugger) { 59 return initDebugger(isolate).then((debugger) {
80 return DebuggerLocation.parse(debugger, '').then((DebuggerLocation loc) { 60 return DebuggerLocation.parse(debugger, '').then((DebuggerLocation loc) {
81 expect(loc.valid, isTrue); 61 expect(loc.valid, isTrue);
82 expect(loc.toString(), equals('debugger_location_test.dart:15')); 62 expect(loc.toString(), equals('debugger_location_test.dart:17'));
83 }); 63 });
84 }); 64 });
85 }, 65 },
86 66
87 // Parse line 67 // Parse line
88 (Isolate isolate) { 68 (Isolate isolate) {
89 return initDebugger(isolate).then((debugger) { 69 return initDebugger(isolate).then((debugger) {
90 return DebuggerLocation.parse(debugger, '16').then((DebuggerLocation loc) { 70 return DebuggerLocation.parse(debugger, '18').then((DebuggerLocation loc) {
91 expect(loc.valid, isTrue); 71 expect(loc.valid, isTrue);
92 expect(loc.toString(), equals('debugger_location_test.dart:16')); 72 expect(loc.toString(), equals('debugger_location_test.dart:18'));
93 }); 73 });
94 }); 74 });
95 }, 75 },
96 76
97 // Parse line + col 77 // Parse line + col
98 (Isolate isolate) { 78 (Isolate isolate) {
99 return initDebugger(isolate).then((debugger) { 79 return initDebugger(isolate).then((debugger) {
100 return DebuggerLocation.parse(debugger, '16:11').then((DebuggerLocation loc) { 80 return DebuggerLocation.parse(debugger, '16:11').then((DebuggerLocation loc) {
101 expect(loc.valid, isTrue); 81 expect(loc.valid, isTrue);
102 expect(loc.toString(), equals('debugger_location_test.dart:16:11')); 82 expect(loc.toString(), equals('debugger_location_test.dart:16:11'));
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 return DebuggerLocation.complete(debugger, 'DebuggerLocationTestFoo.q') 256 return DebuggerLocation.complete(debugger, 'DebuggerLocationTestFoo.q')
277 .then((List<String> completions) { 257 .then((List<String> completions) {
278 expect(completions.toString(), equals('[]')); 258 expect(completions.toString(), equals('[]'));
279 }); 259 });
280 }); 260 });
281 }, 261 },
282 262
283 ]; 263 ];
284 264
285 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); 265 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698