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

Side by Side Diff: runtime/observatory/tests/service/issue_25465_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 4 // VMOptions=--error_on_bad_type --error_on_bad_override
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 import 'service_test_common.dart';
9 import 'dart:async'; 10 import 'dart:async';
10 11
12 const int LINE_A = 16;
13 const int LINE_B = 17;
14
11 testMain() { 15 testMain() {
12 var foo; // line 11 16 var foo; // line A
13 foo = 42; // line 12 17 foo = 42; // line B
14 print(foo); 18 print(foo);
15 } 19 }
16 20
17 var tests = [ 21 var tests = [
18 hasPausedAtStart, 22 hasPausedAtStart,
19 23
20 // Add breakpoints at line 11 and line 12. 24 // Add breakpoints at line 11 and line 12.
21 (Isolate isolate) async { 25 (Isolate isolate) async {
22 var rootLib = isolate.rootLibrary; 26 var rootLib = isolate.rootLibrary;
23 await rootLib.load(); 27 await rootLib.load();
24 var script = rootLib.scripts[0]; 28 var script = rootLib.scripts[0];
25 29
26 var bpt1 = await isolate.addBreakpoint(script, 11); 30 var bpt1 = await isolate.addBreakpoint(script, LINE_A);
27 var bpt2 = await isolate.addBreakpoint(script, 12); 31 var bpt2 = await isolate.addBreakpoint(script, LINE_B);
28 expect(await bpt1.location.getLine(), equals(11)); 32 expect(await bpt1.location.getLine(), equals(LINE_A));
29 expect(await bpt2.location.getLine(), equals(12)); 33 expect(await bpt2.location.getLine(), equals(LINE_B));
30 34
31 var stream = await isolate.vm.getEventStream(VM.kDebugStream); 35 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
32 Completer completer = new Completer(); 36 Completer completer = new Completer();
33 var subscription; 37 var subscription;
34 var breakCount = 0; 38 var breakCount = 0;
35 subscription = stream.listen((ServiceEvent event) async { 39 subscription = stream.listen((ServiceEvent event) async {
36 if (event.kind == ServiceEvent.kPauseBreakpoint) { 40 if (event.kind == ServiceEvent.kPauseBreakpoint) {
37 breakCount++; 41 breakCount++;
38 print('break count is $breakCount'); 42 print('break count is $breakCount');
39 if (breakCount == 1) { 43 if (breakCount == 1) {
40 // We are stopped at breakpoint 1. 44 // We are stopped at breakpoint 1.
41 expect(event.breakpoint.number, equals(bpt1.number)); 45 expect(event.breakpoint.number, equals(bpt1.number));
42 46
43 // Remove both breakpoints 47 // Remove both breakpoints
44 var result = await isolate.removeBreakpoint(bpt1); 48 var result = await isolate.removeBreakpoint(bpt1);
45 expect(result.type, equals("Success")); 49 expect(result.type, equals("Success"));
46 50
47 result = await isolate.removeBreakpoint(bpt2); 51 result = await isolate.removeBreakpoint(bpt2);
48 expect(result.type, equals("Success")); 52 expect(result.type, equals("Success"));
49 53
50 isolate.stepOver(); 54 isolate.stepOver();
51 } else { 55 } else {
52 // No breakpoint. 56 // No breakpoint.
53 expect(event.breakpoint, isNull); 57 expect(event.breakpoint, isNull);
54 58
55 // We expect the next step to take us to line 12. 59 // We expect the next step to take us to line B.
56 var stack = await isolate.getStack(); 60 var stack = await isolate.getStack();
57 expect(await stack['frames'][0].location.getLine(), equals(12)); 61 expect(await stack['frames'][0].location.getLine(), equals(LINE_B));
58 62
59 subscription.cancel(); 63 subscription.cancel();
60 completer.complete(null); 64 completer.complete(null);
61 } 65 }
62 } 66 }
63 }); 67 });
64 isolate.resume(); 68 isolate.resume();
65 await completer.future; 69 await completer.future;
66 }, 70 },
67 ]; 71 ];
68 72
69 main(args) => runIsolateTests(args, tests, 73 main(args) => runIsolateTests(args, tests,
70 testeeConcurrent: testMain, 74 testeeConcurrent: testMain,
71 pause_on_start: true); 75 pause_on_start: true);
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/isolate_lifecycle_test.dart ('k') | runtime/observatory/tests/service/logging_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698