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

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

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

Powered by Google App Engine
This is Rietveld 408576698