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

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

Issue 1699153002: Add step OverAwait to service protocol (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug --trac e_service
5
6 import 'dart:async';
7 import 'dart:developer';
8
9 import 'test_helper.dart';
10
11 import 'package:observatory/service_io.dart';
12 import 'package:unittest/unittest.dart';
13
14 // This tests the low level synthetic breakpoint added / removed machinery
15 // triggered by the step OverAwait command.
16 asyncWithoutAwait() async {
17 debugger();
18 await new Future.delayed(new Duration(seconds: 2));
19 debugger();
20 }
21
22 testMain() {
23 asyncWithoutAwait(); // Line 22
24 }
25
26 Future<Isolate> stepOverAwaitAndWaitForAddedSyntheticBreakpoint(
27 Isolate isolate) {
28 assert(isolate.pauseEvent.atAwait);
29
30 // Set up a listener to wait for breakpoint events.
31 Completer completer = new Completer();
32 isolate.vm.getEventStream(VM.kDebugStream).then((stream) {
33 var subscription;
34 subscription = stream.listen((ServiceEvent event) {
35 if (event.kind == ServiceEvent.kBreakpointAdded) {
rmacnak 2016/02/16 21:21:58 over-idented
Cutch 2016/02/17 18:24:21 Done.
36 if (!event.breakpoint.isSyntheticAsync) {
37 return;
38 }
39 print('Synthetic async breakpoint added ${event.breakpoint}');
40 subscription.cancel();
41 if (completer != null) {
42 // Reload to update isolate.pauseEvent.
43 completer.complete(isolate.reload());
44 completer = null;
45 }
46 }
47 });
48 });
49
50 isolate.stepOverAwait();
51
52 return completer.future; // Will complete when breakpoint added.
53 }
54
55 Future<Isolate> waitForRemovedSyntheticBreakpoint(Isolate isolate) {
56 Completer completer = new Completer();
57 isolate.vm.getEventStream(VM.kDebugStream).then((stream) {
58 var subscription;
59 subscription = stream.listen((ServiceEvent event) {
60 if (event.kind == ServiceEvent.kBreakpointRemoved) {
rmacnak 2016/02/16 21:21:58 over-idented
Cutch 2016/02/17 18:24:21 Done.
61 if (!event.breakpoint.isSyntheticAsync) {
62 return;
63 }
64 print('Synthetic async breakpoint removed ${event.breakpoint}');
65 subscription.cancel();
66 if (completer != null) {
67 // Reload to update isolate.pauseEvent.
68 completer.complete(isolate.reload());
69 completer = null;
70 }
71 }
72 });
73 });
74
75 return completer.future; // Will complete when breakpoint removed.
76 }
77
78 var tests = [
79 hasStoppedAtBreakpoint,
80 stoppedAtLine(18),
81 (Isolate isolate) {
82 expect(isolate.pauseEvent.atAwait, isTrue);
rmacnak 2016/02/16 21:21:58 Something's not right. There're at least two const
83 },
84 stepOverAwaitAndWaitForAddedSyntheticBreakpoint,
85 waitForRemovedSyntheticBreakpoint,
86 hasStoppedAtBreakpoint,
87 stoppedAtLine(19),
88 ];
89
90 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698