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

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

Issue 1726773002: Refactor service tests in preparation of running on sky_shell (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
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 --verbose_debug --trac e_service 4 // VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug --trac e_service
5 5
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:developer'; 7 import 'dart:developer';
8 8
9 import 'test_helper.dart'; 9 import 'test_helper.dart';
10 import 'service_test_common.dart';
10 11
11 import 'package:observatory/service_io.dart'; 12 import 'package:observatory/service_io.dart';
12 import 'package:unittest/unittest.dart'; 13 import 'package:unittest/unittest.dart';
13 14
15 const int LINE_A = 24;
16 const int LINE_B = 26;
17 const int LINE_C = 28;
18 const int LINE_D = 29;
19
14 // This tests the low level synthetic breakpoint added / paused / removed 20 // This tests the low level synthetic breakpoint added / paused / removed
15 // machinery triggered by the step OverAwait command. 21 // machinery triggered by the step OverAwait command.
16 asyncWithoutAwait() async { 22 asyncWithoutAwait() async {
17 debugger(); 23 debugger();
18 print('a'); 24 print('a'); // LINE_A
19 await new Future.delayed(new Duration(seconds: 2)); 25 await new Future.delayed(new Duration(seconds: 2));
20 print('b'); 26 print('b'); // LINE_B
21 debugger(); 27 debugger(); // LINE_C
22 debugger(); 28 debugger(); // LINE_D
23 } 29 }
24 30
25 testMain() { 31 testMain() {
26 asyncWithoutAwait(); 32 asyncWithoutAwait();
27 } 33 }
28 34
29 Breakpoint syntheticBreakpoint; 35 Breakpoint syntheticBreakpoint;
30 36
31 Future<Isolate> testLowLevelAwaitOver( 37 Future<Isolate> testLowLevelAwaitOver(
32 Isolate isolate) { 38 Isolate isolate) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 handleResume(event); 124 handleResume(event);
119 expect(state, 2); 125 expect(state, 2);
120 } else { 126 } else {
121 handleResume(event); 127 handleResume(event);
122 expect(state, 4); 128 expect(state, 4);
123 } 129 }
124 } else if (event.kind == ServiceEvent.kPauseBreakpoint) { 130 } else if (event.kind == ServiceEvent.kPauseBreakpoint) {
125 handlePauseBreakpoint(event); 131 handlePauseBreakpoint(event);
126 expect(state, 3); 132 expect(state, 3);
127 // Check that we are paused after the await statement. 133 // Check that we are paused after the await statement.
128 await (stoppedAtLine(20)(isolate)); 134 await (stoppedAtLine(LINE_B)(isolate));
129 // Resume the isolate so that we trigger the breakpoint removal. 135 // Resume the isolate so that we trigger the breakpoint removal.
130 print('!!!! Triggering synthetic breakpoint removal.'); 136 print('!!!! Triggering synthetic breakpoint removal.');
131 isolate.resume(); 137 isolate.resume();
132 } else if (event.kind == ServiceEvent.kBreakpointRemoved) { 138 } else if (event.kind == ServiceEvent.kBreakpointRemoved) {
133 handleBreakpointRemoved(event); 139 handleBreakpointRemoved(event);
134 expect(state, 5); 140 expect(state, 5);
135 subscription.cancel(); 141 subscription.cancel();
136 if (completer != null) { 142 if (completer != null) {
137 // Reload to update isolate.pauseEvent. 143 // Reload to update isolate.pauseEvent.
138 completer.complete(isolate.reload()); 144 completer.complete(isolate.reload());
139 completer = null; 145 completer = null;
140 } 146 }
141 } 147 }
142 }); 148 });
143 }); 149 });
144 150
145 isolate.stepOverAsyncSuspension(); 151 isolate.stepOverAsyncSuspension();
146 152
147 return completer.future; // Will complete when breakpoint added. 153 return completer.future; // Will complete when breakpoint added.
148 } 154 }
149 155
150 156
151 var tests = [ 157 var tests = [
152 hasStoppedAtBreakpoint, 158 hasStoppedAtBreakpoint,
153 stoppedAtLine(18), 159 stoppedAtLine(LINE_A),
154 stepOver, 160 stepOver,
155 stepOver, 161 stepOver,
156 stepOver, 162 stepOver,
157 (Isolate isolate) async { 163 (Isolate isolate) async {
158 expect(isolate.pauseEvent.atAsyncSuspension, isTrue); 164 expect(isolate.pauseEvent.atAsyncSuspension, isTrue);
159 expect(syntheticBreakpoint, isNull); 165 expect(syntheticBreakpoint, isNull);
160 }, 166 },
161 testLowLevelAwaitOver, 167 testLowLevelAwaitOver,
162 hasStoppedAtBreakpoint, 168 hasStoppedAtBreakpoint,
163 stoppedAtLine(22), 169 stoppedAtLine(LINE_C),
164 resumeIsolate, 170 resumeIsolate,
165 hasStoppedAtBreakpoint, 171 hasStoppedAtBreakpoint,
166 stoppedAtLine(23), 172 stoppedAtLine(LINE_D),
167 resumeIsolate, 173 resumeIsolate,
168 ]; 174 ];
169 175
170 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain); 176 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698