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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/tests/service/step_over_await_test.dart
diff --git a/runtime/observatory/tests/service/step_over_await_test.dart b/runtime/observatory/tests/service/step_over_await_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5a176e7bb4e8d2ceaf3fbb2f7a10904c018c770c
--- /dev/null
+++ b/runtime/observatory/tests/service/step_over_await_test.dart
@@ -0,0 +1,90 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug --trace_service
+
+import 'dart:async';
+import 'dart:developer';
+
+import 'test_helper.dart';
+
+import 'package:observatory/service_io.dart';
+import 'package:unittest/unittest.dart';
+
+// This tests the low level synthetic breakpoint added / removed machinery
+// triggered by the step OverAwait command.
+asyncWithoutAwait() async {
+ debugger();
+ await new Future.delayed(new Duration(seconds: 2));
+ debugger();
+}
+
+testMain() {
+ asyncWithoutAwait(); // Line 22
+}
+
+Future<Isolate> stepOverAwaitAndWaitForAddedSyntheticBreakpoint(
+ Isolate isolate) {
+ assert(isolate.pauseEvent.atAwait);
+
+ // Set up a listener to wait for breakpoint events.
+ Completer completer = new Completer();
+ isolate.vm.getEventStream(VM.kDebugStream).then((stream) {
+ var subscription;
+ subscription = stream.listen((ServiceEvent event) {
+ if (event.kind == ServiceEvent.kBreakpointAdded) {
rmacnak 2016/02/16 21:21:58 over-idented
Cutch 2016/02/17 18:24:21 Done.
+ if (!event.breakpoint.isSyntheticAsync) {
+ return;
+ }
+ print('Synthetic async breakpoint added ${event.breakpoint}');
+ subscription.cancel();
+ if (completer != null) {
+ // Reload to update isolate.pauseEvent.
+ completer.complete(isolate.reload());
+ completer = null;
+ }
+ }
+ });
+ });
+
+ isolate.stepOverAwait();
+
+ return completer.future; // Will complete when breakpoint added.
+}
+
+Future<Isolate> waitForRemovedSyntheticBreakpoint(Isolate isolate) {
+ Completer completer = new Completer();
+ isolate.vm.getEventStream(VM.kDebugStream).then((stream) {
+ var subscription;
+ subscription = stream.listen((ServiceEvent event) {
+ if (event.kind == ServiceEvent.kBreakpointRemoved) {
rmacnak 2016/02/16 21:21:58 over-idented
Cutch 2016/02/17 18:24:21 Done.
+ if (!event.breakpoint.isSyntheticAsync) {
+ return;
+ }
+ print('Synthetic async breakpoint removed ${event.breakpoint}');
+ subscription.cancel();
+ if (completer != null) {
+ // Reload to update isolate.pauseEvent.
+ completer.complete(isolate.reload());
+ completer = null;
+ }
+ }
+ });
+ });
+
+ return completer.future; // Will complete when breakpoint removed.
+}
+
+var tests = [
+ hasStoppedAtBreakpoint,
+ stoppedAtLine(18),
+ (Isolate isolate) {
+ expect(isolate.pauseEvent.atAwait, isTrue);
rmacnak 2016/02/16 21:21:58 Something's not right. There're at least two const
+ },
+ stepOverAwaitAndWaitForAddedSyntheticBreakpoint,
+ waitForRemovedSyntheticBreakpoint,
+ hasStoppedAtBreakpoint,
+ stoppedAtLine(19),
+];
+
+main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain);

Powered by Google App Engine
This is Rietveld 408576698