OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library set_library_debuggable_test; | 6 library set_library_debuggable_test; |
7 | 7 |
8 import 'dart:developer'; | 8 import 'dart:developer'; |
9 import 'package:observatory/service_io.dart'; | 9 import 'package:observatory/service_io.dart'; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
11 import 'service_test_common.dart'; | 11 import 'service_test_common.dart'; |
12 import 'test_helper.dart'; | 12 import 'test_helper.dart'; |
13 | 13 |
14 const LINE_A = 20; | 14 const LINE_A = 20; |
15 const LINE_B = 21; | 15 const LINE_B = 21; |
16 const LINE_C = 22; | 16 const LINE_C = 22; |
17 | 17 |
18 testMain() async { | 18 testMain() async { |
19 debugger(); | 19 debugger(); |
20 print('hi'); // LINE_A. | 20 print('hi'); // LINE_A. |
21 print('yep'); // LINE_B. | 21 print('yep'); // LINE_B. |
22 print('zoo'); // LINE_C. | 22 print('zoo'); // LINE_C. |
23 } | 23 } |
24 | 24 |
25 var tests = [ | 25 var tests = [ |
26 hasStoppedAtBreakpoint, | 26 hasStoppedAtBreakpoint, |
27 markDartColonLibrariesDebuggable, | 27 markDartColonLibrariesDebuggable, |
28 (Isolate isolate) async { | 28 (Isolate isolate) async { |
29 await isolate.reload(); | 29 await isolate.reload(); |
30 Library dartCore = isolate.libraries.firstWhere( | 30 Library dartCore = isolate.libraries |
31 (Library library) => library.uri == 'dart:core'); | 31 .firstWhere((Library library) => library.uri == 'dart:core'); |
32 await dartCore.reload(); | 32 await dartCore.reload(); |
33 expect(dartCore.debuggable, equals(true)); | 33 expect(dartCore.debuggable, equals(true)); |
34 }, | 34 }, |
35 stoppedInFunction('testMain', contains:true), | 35 stoppedInFunction('testMain', contains: true), |
36 stoppedAtLine(LINE_A), | 36 stoppedAtLine(LINE_A), |
37 stepInto, | 37 stepInto, |
38 stoppedInFunction('print'), | 38 stoppedInFunction('print'), |
39 stepOut, | 39 stepOut, |
40 stoppedInFunction('testMain', contains:true), | 40 stoppedInFunction('testMain', contains: true), |
41 stoppedAtLine(LINE_B), | 41 stoppedAtLine(LINE_B), |
42 (Isolate isolate) async { | 42 (Isolate isolate) async { |
43 // Mark 'dart:core' as not debuggable. | 43 // Mark 'dart:core' as not debuggable. |
44 await isolate.reload(); | 44 await isolate.reload(); |
45 Library dartCore = isolate.libraries.firstWhere( | 45 Library dartCore = isolate.libraries |
46 (Library library) => library.uri == 'dart:core'); | 46 .firstWhere((Library library) => library.uri == 'dart:core'); |
47 await dartCore.load(); | 47 await dartCore.load(); |
48 expect(dartCore.debuggable, equals(true)); | 48 expect(dartCore.debuggable, equals(true)); |
49 var setDebugParams = { | 49 var setDebugParams = { |
50 'libraryId': dartCore.id, | 50 'libraryId': dartCore.id, |
51 'isDebuggable': false, | 51 'isDebuggable': false, |
52 }; | 52 }; |
53 Map<String, dynamic> result = | 53 Map<String, dynamic> result = await isolate.invokeRpcNoUpgrade( |
54 await isolate.invokeRpcNoUpgrade('setLibraryDebuggable', | 54 'setLibraryDebuggable', setDebugParams); |
55 setDebugParams); | |
56 expect(result['type'], equals('Success')); | 55 expect(result['type'], equals('Success')); |
57 await dartCore.reload(); | 56 await dartCore.reload(); |
58 expect(dartCore.debuggable, equals(false)); | 57 expect(dartCore.debuggable, equals(false)); |
59 }, | 58 }, |
60 stoppedInFunction('testMain', contains:true), | 59 stoppedInFunction('testMain', contains: true), |
61 stoppedAtLine(LINE_B), | 60 stoppedAtLine(LINE_B), |
62 stepInto, | 61 stepInto, |
63 stoppedInFunction('testMain', contains:true), | 62 stoppedInFunction('testMain', contains: true), |
64 stoppedAtLine(LINE_C), | 63 stoppedAtLine(LINE_C), |
65 ]; | 64 ]; |
66 | 65 |
67 main(args) async => runIsolateTests(args, tests, testeeConcurrent: testMain); | 66 main(args) async => runIsolateTests(args, tests, testeeConcurrent: testMain); |
OLD | NEW |