2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
- // @dart = 2.9
6
-
7
5
@TestOn ('vm' )
8
6
import 'dart:async' ;
9
7
@@ -38,88 +36,92 @@ void main() {
38
36
39
37
group ('breakpoint' , () {
40
38
VM vm;
41
- Isolate isolate;
39
+ late Isolate isolate;
40
+ late String isolateId;
42
41
ScriptList scripts;
43
- ScriptRef mainScript;
44
- Stream <Event > stream;
42
+ late ScriptRef mainScript;
43
+ late String mainScriptUri;
44
+ late Stream <Event > stream;
45
45
46
46
setUp (() async {
47
47
vm = await service.getVM ();
48
- isolate = await service.getIsolate (vm.isolates.first.id);
49
- scripts = await service.getScripts (isolate.id);
48
+ isolate = await service.getIsolate (vm.isolates! .first.id! );
49
+ isolateId = isolate.id! ;
50
+ scripts = await service.getScripts (isolateId);
50
51
51
52
await service.streamListen ('Debug' );
52
53
stream = service.onEvent ('Debug' );
53
54
54
- mainScript = scripts.scripts
55
- .firstWhere ((each) => each.uri.contains ('main.dart' ));
55
+ mainScript = scripts.scripts!
56
+ .firstWhere ((each) => each.uri! .contains ('main.dart' ));
57
+ mainScriptUri = mainScript.uri! ;
56
58
});
57
59
58
60
tearDown (() async {
59
- await service.resume (isolate.id );
61
+ await service.resume (isolateId );
60
62
});
61
63
62
64
test ('set breakpoint' , () async {
63
65
final line = await context.findBreakpointLine (
64
- 'printLocal' , isolate.id , mainScript);
66
+ 'printLocal' , isolateId , mainScript);
65
67
final bp = await service.addBreakpointWithScriptUri (
66
- isolate.id, mainScript.uri , line);
68
+ isolateId, mainScriptUri , line);
67
69
68
70
await stream.firstWhere (
69
71
(Event event) => event.kind == EventKind .kPauseBreakpoint);
70
72
71
73
expect (bp, isNotNull);
72
74
73
75
// Remove breakpoint so it doesn't impact other tests.
74
- await service.removeBreakpoint (isolate.id , bp.id);
76
+ await service.removeBreakpoint (isolateId , bp.id! );
75
77
});
76
78
77
79
test ('set breakpoint again' , () async {
78
80
final line = await context.findBreakpointLine (
79
- 'printLocal' , isolate.id , mainScript);
81
+ 'printLocal' , isolateId , mainScript);
80
82
final bp = await service.addBreakpointWithScriptUri (
81
- isolate.id, mainScript.uri , line);
83
+ isolateId, mainScriptUri , line);
82
84
83
85
await stream.firstWhere (
84
86
(Event event) => event.kind == EventKind .kPauseBreakpoint);
85
87
86
88
expect (bp, isNotNull);
87
89
88
90
// Remove breakpoint so it doesn't impact other tests.
89
- await service.removeBreakpoint (isolate.id , bp.id);
91
+ await service.removeBreakpoint (isolateId , bp.id! );
90
92
});
91
93
92
94
test ('set existing breakpoint succeeds' , () async {
93
95
final line = await context.findBreakpointLine (
94
- 'printLocal' , isolate.id , mainScript);
96
+ 'printLocal' , isolateId , mainScript);
95
97
final bp1 = await service.addBreakpointWithScriptUri (
96
- isolate.id, mainScript.uri , line);
98
+ isolateId, mainScriptUri , line);
97
99
final bp2 = await service.addBreakpointWithScriptUri (
98
- isolate.id, mainScript.uri , line);
100
+ isolateId, mainScriptUri , line);
99
101
100
102
expect (bp1, equals (bp2));
101
103
expect (bp1, isNotNull);
102
104
103
105
await stream.firstWhere (
104
106
(Event event) => event.kind == EventKind .kPauseBreakpoint);
105
107
106
- var currentIsolate = await service.getIsolate (isolate.id );
108
+ var currentIsolate = await service.getIsolate (isolateId );
107
109
expect (currentIsolate.breakpoints, containsAll ([bp1]));
108
110
109
111
// Remove breakpoints so they don't impact other tests.
110
- await service.removeBreakpoint (isolate.id , bp1.id);
112
+ await service.removeBreakpoint (isolateId , bp1.id! );
111
113
112
- currentIsolate = await service.getIsolate (isolate.id );
114
+ currentIsolate = await service.getIsolate (isolateId );
113
115
expect (currentIsolate.breakpoints, isEmpty);
114
116
});
115
117
116
118
test ('set breakpoints at the same line simultaneously succeeds' ,
117
119
() async {
118
120
final line = await context.findBreakpointLine (
119
- 'printLocal' , isolate.id , mainScript);
121
+ 'printLocal' , isolateId , mainScript);
120
122
final futures = [
121
- service.addBreakpointWithScriptUri (isolate.id, mainScript.uri , line),
122
- service.addBreakpointWithScriptUri (isolate.id, mainScript.uri , line),
123
+ service.addBreakpointWithScriptUri (isolateId, mainScriptUri , line),
124
+ service.addBreakpointWithScriptUri (isolateId, mainScriptUri , line),
123
125
];
124
126
125
127
final breakpoints = await Future .wait (futures);
@@ -129,34 +131,34 @@ void main() {
129
131
await stream.firstWhere (
130
132
(Event event) => event.kind == EventKind .kPauseBreakpoint);
131
133
132
- var currentIsolate = await service.getIsolate (isolate.id );
134
+ var currentIsolate = await service.getIsolate (isolateId );
133
135
expect (currentIsolate.breakpoints, containsAll ([breakpoints[0 ]]));
134
136
135
137
// Remove breakpoints so they don't impact other tests.
136
- await service.removeBreakpoint (isolate.id , breakpoints[0 ].id);
138
+ await service.removeBreakpoint (isolateId , breakpoints[0 ].id! );
137
139
138
- currentIsolate = await service.getIsolate (isolate.id );
140
+ currentIsolate = await service.getIsolate (isolateId );
139
141
expect (currentIsolate.breakpoints, isEmpty);
140
142
});
141
143
142
144
test ('remove non-existing breakpoint fails' , () async {
143
145
final line = await context.findBreakpointLine (
144
- 'printLocal' , isolate.id , mainScript);
146
+ 'printLocal' , isolateId , mainScript);
145
147
final bp = await service.addBreakpointWithScriptUri (
146
- isolate.id, mainScript.uri , line);
148
+ isolateId, mainScriptUri , line);
147
149
148
150
await stream.firstWhere (
149
151
(Event event) => event.kind == EventKind .kPauseBreakpoint);
150
152
151
- var currentIsolate = await service.getIsolate (isolate.id );
153
+ var currentIsolate = await service.getIsolate (isolateId );
152
154
expect (currentIsolate.breakpoints, containsAll ([bp]));
153
155
154
156
// Remove breakpoints so they don't impact other tests.
155
- await service.removeBreakpoint (isolate.id , bp.id);
157
+ await service.removeBreakpoint (isolateId , bp.id! );
156
158
await expectLater (
157
- service.removeBreakpoint (isolate.id , bp.id), throwsRPCError);
159
+ service.removeBreakpoint (isolateId , bp.id! ), throwsRPCError);
158
160
159
- currentIsolate = await service.getIsolate (isolate.id );
161
+ currentIsolate = await service.getIsolate (isolateId );
160
162
expect (currentIsolate.breakpoints, isEmpty);
161
163
});
162
164
});
0 commit comments