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

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

Issue 1152283005: Revert "Add the streamListen and streamCancel rpcs to the vm service." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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=--compile-all --error_on_bad_type --error_on_bad_override --verbose -debug 4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override --verbose -debug
5 5
6 import 'package:observatory/service_io.dart'; 6 import 'package:observatory/service_io.dart';
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'dart:async';
9 import 'test_helper.dart'; 8 import 'test_helper.dart';
10 9
11 printSync() { // Line 11 10 printSync() { // Line 10
12 print('sync'); 11 print('sync');
13 } 12 }
14 printAsync() async { // Line 14 13 printAsync() async { // Line 13
15 print('async'); 14 print('async');
16 } 15 }
17 printAsyncStar() async* { // Line 17 16 printAsyncStar() async* { // Line 16
18 print('async*'); 17 print('async*');
19 } 18 }
20 printSyncStar() sync* { // Line 20 19 printSyncStar() sync* { // Line 19
21 print('sync*'); 20 print('sync*');
22 } 21 }
23 22
24 var testerReady = false; 23 var testerReady = false;
25 testeeDo() { 24 testeeDo() {
26 // We block here rather than allowing the isolate to enter the 25 // We block here rather than allowing the isolate to enter the
27 // paused-on-exit state before the tester gets a chance to set 26 // paused-on-exit state before the tester gets a chance to set
28 // the breakpoints because we need the event loop to remain 27 // the breakpoints because we need the event loop to remain
29 // operational for the async bodies to run. 28 // operational for the async bodies to run.
30 print('testee waiting'); 29 print('testee waiting');
31 while(!testerReady); 30 while(!testerReady);
32 31
33 printSync(); 32 printSync();
34 var future = printAsync(); 33 var future = printAsync();
35 var stream = printAsyncStar(); 34 var stream = printAsyncStar();
36 var iterator = printSyncStar(); 35 var iterator = printSyncStar();
37 36
38 print('middle'); // Line 38 37 print('middle'); // Line 37.
39 38
40 future.then((v) => print(v)); 39 future.then((v) => print(v));
41 stream.toList(); 40 stream.toList();
42 iterator.toList(); 41 iterator.toList();
43 } 42 }
44 43
45 testAsync(Isolate isolate) async { 44 testAsync(Isolate isolate) async {
46 await isolate.rootLibrary.load(); 45 await isolate.rootLibrary.load();
47 var script = isolate.rootLibrary.scripts[0]; 46 var script = isolate.rootLibrary.scripts[0];
48 47
49 var bp1 = await isolate.addBreakpoint(script, 11); 48 var bp1 = await isolate.addBreakpoint(script, 10);
50 expect(bp1, isNotNull); 49 expect(bp1, isNotNull);
51 expect(bp1 is Breakpoint, isTrue); 50 expect(bp1 is Breakpoint, isTrue);
52 var bp2 = await isolate.addBreakpoint(script, 14); 51 var bp2 = await isolate.addBreakpoint(script, 13);
53 expect(bp2, isNotNull); 52 expect(bp2, isNotNull);
54 expect(bp2 is Breakpoint, isTrue); 53 expect(bp2 is Breakpoint, isTrue);
55 var bp3 = await isolate.addBreakpoint(script, 17); 54 var bp3 = await isolate.addBreakpoint(script, 16);
56 expect(bp3, isNotNull); 55 expect(bp3, isNotNull);
57 expect(bp3 is Breakpoint, isTrue); 56 expect(bp3 is Breakpoint, isTrue);
58 var bp4 = await isolate.addBreakpoint(script, 20); 57 var bp4 = await isolate.addBreakpoint(script, 19);
59 expect(bp4, isNotNull); 58 expect(bp4, isNotNull);
60 expect(bp4 is Breakpoint, isTrue); 59 expect(bp4 is Breakpoint, isTrue);
61 var bp5 = await isolate.addBreakpoint(script, 38); 60 var bp5 = await isolate.addBreakpoint(script, 37);
62 print("BP5 - $bp5"); 61 print("BP5 - $bp5");
63 expect(bp5, isNotNull); 62 expect(bp5, isNotNull);
64 expect(bp5 is Breakpoint, isTrue); 63 expect(bp5 is Breakpoint, isTrue);
65 64
66 var hits = []; 65 var hits = [];
67 66
68 Completer completer = new Completer(); 67 isolate.rootLibrary.evaluate('testerReady = true;')
69 isolate.vm.debugEvents.listen((ServiceEvent event) { 68 .then((Instance result) {
69 expect(result.valueAsString, equals('true'));
70 });
71
72 await for (ServiceEvent event in isolate.vm.events.stream) {
70 if (event.eventType == ServiceEvent.kPauseBreakpoint) { 73 if (event.eventType == ServiceEvent.kPauseBreakpoint) {
71 var bp = event.breakpoint; 74 var bp = event.breakpoint;
72 print('Hit $bp'); 75 print('Hit $bp');
73 hits.add(bp); 76 hits.add(bp);
74 isolate.resume(); 77 isolate.resume();
75 78
76 if (hits.length == 5) { 79 if (hits.length == 5) break;
77 completer.complete();
78 }
79 } 80 }
80 }); 81 }
81 82
82 isolate.rootLibrary.evaluate('testerReady = true;')
83 .then((Instance result) {
84 expect(result.valueAsString, equals('true'));
85 });
86
87 await completer.future;
88 expect(hits, equals([bp1, bp5, bp4, bp2, bp3])); 83 expect(hits, equals([bp1, bp5, bp4, bp2, bp3]));
89 } 84 }
90 85
91 var tests = [testAsync]; 86 var tests = [testAsync];
92 87
93 main(args) => runIsolateTests(args, tests, testeeConcurrent: testeeDo); 88 main(args) => runIsolateTests(args, tests, testeeConcurrent: testeeDo);
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/service/object.dart ('k') | runtime/observatory/tests/service/code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698