Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
942de678
Unverified
Commit
942de678
authored
Jan 27, 2022
by
Danny Tuppeny
Committed by
GitHub
Jan 27, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make remaining DAP tests null-safe (#97368)
parent
dcce0db1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
25 deletions
+21
-25
flutter_adapter_test.dart
...integration.shard/debug_adapter/flutter_adapter_test.dart
+16
-18
test_adapter_test.dart
...st/integration.shard/debug_adapter/test_adapter_test.dart
+5
-7
No files found.
packages/flutter_tools/test/integration.shard/debug_adapter/flutter_adapter_test.dart
View file @
942de678
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'package:dds/src/dap/protocol_generated.dart'
;
...
...
@@ -18,8 +16,8 @@ import 'test_client.dart';
import
'test_support.dart'
;
void
main
(
)
{
Directory
tempDir
;
/*late*/
DapTestSession
dap
;
late
Directory
tempDir
;
late
DapTestSession
dap
;
final
String
relativeMainPath
=
'lib
${fileSystem.path.separator}
main.dart'
;
setUpAll
(()
{
...
...
@@ -119,7 +117,7 @@ void main() {
await
project
.
setUpIn
(
tempDir
);
// Launch the app and wait for it to print "topLevelFunction".
await
Future
.
wait
(<
Future
<
Object
>>[
await
Future
.
wait
(<
Future
<
void
>>[
dap
.
client
.
outputEvents
.
firstWhere
((
OutputEventBody
output
)
=>
output
.
output
.
startsWith
(
'topLevelFunction'
)),
dap
.
client
.
start
(
launch:
()
=>
dap
.
client
.
launch
(
...
...
@@ -156,7 +154,7 @@ void main() {
await
project
.
setUpIn
(
tempDir
);
// Launch the app and wait for it to print "topLevelFunction".
await
Future
.
wait
(<
Future
<
Object
>>[
await
Future
.
wait
(<
Future
<
void
>>[
dap
.
client
.
outputEvents
.
firstWhere
((
OutputEventBody
output
)
=>
output
.
output
.
startsWith
(
'topLevelFunction'
)),
dap
.
client
.
start
(
launch:
()
=>
dap
.
client
.
launch
(
...
...
@@ -193,10 +191,10 @@ void main() {
await
project
.
setUpIn
(
tempDir
);
// Launch the app and wait for it to stop at an exception.
int
originalThreadId
,
newThreadId
;
await
Future
.
wait
(<
Future
<
Object
>>[
late
int
originalThreadId
,
newThreadId
;
await
Future
.
wait
(<
Future
<
void
>>[
// Capture the thread ID of the stopped thread.
dap
.
client
.
stoppedEvents
.
first
.
then
((
StoppedEventBody
event
)
=>
originalThreadId
=
event
.
threadId
),
dap
.
client
.
stoppedEvents
.
first
.
then
((
StoppedEventBody
event
)
=>
originalThreadId
=
event
.
threadId
!
),
dap
.
client
.
start
(
exceptionPauseMode:
'All'
,
// Ensure we stop on all exceptions
launch:
()
=>
dap
.
client
.
launch
(
...
...
@@ -208,9 +206,9 @@ void main() {
// Hot restart, ensuring it completes and capturing the ID of the new thread
// to pause.
await
Future
.
wait
(<
Future
<
Object
>>[
await
Future
.
wait
(<
Future
<
void
>>[
// Capture the thread ID of the newly stopped thread.
dap
.
client
.
stoppedEvents
.
first
.
then
((
StoppedEventBody
event
)
=>
newThreadId
=
event
.
threadId
),
dap
.
client
.
stoppedEvents
.
first
.
then
((
StoppedEventBody
event
)
=>
newThreadId
=
event
.
threadId
!
),
dap
.
client
.
hotRestart
(),
],
eagerError:
true
);
...
...
@@ -230,11 +228,11 @@ void main() {
// extension loads, as we'll need that to call it later.
final
Future
<
String
>
isolateIdForDebugPaint
=
dap
.
client
.
serviceExtensionAdded
(
debugPaintRpc
)
.
then
((
Map
<
String
,
Object
/*?*/
>
body
)
=>
body
[
'isolateId'
]
as
String
);
.
then
((
Map
<
String
,
Object
?>
body
)
=>
body
[
'isolateId'
]!
as
String
);
// Launch the app and wait for it to print "topLevelFunction" so we know
// it's up and running.
await
Future
.
wait
(<
Future
<
Object
>>[
await
Future
.
wait
(<
Future
<
void
>>[
dap
.
client
.
outputEvents
.
firstWhere
((
OutputEventBody
output
)
=>
output
.
output
.
startsWith
(
'topLevelFunction'
)),
dap
.
client
.
start
(
...
...
@@ -247,15 +245,15 @@ void main() {
// Capture the next relevant state-change event (which should occur as a
// result of the call below).
final
Future
<
Map
<
String
,
Object
/*?*/
>>
stateChangeEventFuture
=
final
Future
<
Map
<
String
,
Object
?
>>
stateChangeEventFuture
=
dap
.
client
.
serviceExtensionStateChanged
(
debugPaintRpc
);
// Enable debug paint to trigger the state change.
await
dap
.
client
.
custom
(
'callService'
,
<
String
,
Object
/*?*/
>{
<
String
,
Object
?
>{
'method'
:
debugPaintRpc
,
'params'
:
<
String
,
Object
/*?*/
>{
'params'
:
<
String
,
Object
?
>{
'enabled'
:
true
,
'isolateId'
:
await
isolateIdForDebugPaint
,
},
...
...
@@ -263,7 +261,7 @@ void main() {
);
// Ensure the event occurred, and its value was as expected.
final
Map
<
String
,
Object
/*?*/
>
stateChangeEvent
=
await
stateChangeEventFuture
;
final
Map
<
String
,
Object
?
>
stateChangeEvent
=
await
stateChangeEventFuture
;
expect
(
stateChangeEvent
[
'value'
],
'true'
);
// extension state change values are always strings
await
dap
.
client
.
terminate
();
...
...
@@ -273,7 +271,7 @@ void main() {
/// Extracts the output from a set of [OutputEventBody], removing any
/// adjacent duplicates and combining into a single string.
String
_uniqueOutputLines
(
List
<
OutputEventBody
>
outputEvents
)
{
String
/*?*/
lastItem
;
String
?
lastItem
;
return
outputEvents
.
map
((
OutputEventBody
e
)
=>
e
.
output
)
.
where
((
String
output
)
{
...
...
packages/flutter_tools/test/integration.shard/debug_adapter/test_adapter_test.dart
View file @
942de678
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:dds/src/dap/protocol_generated.dart'
;
import
'package:file/file.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
...
...
@@ -15,8 +13,8 @@ import 'test_client.dart';
import
'test_support.dart'
;
void
main
(
)
{
Directory
tempDir
;
/*late*/
DapTestSession
dap
;
late
Directory
tempDir
;
late
DapTestSession
dap
;
setUpAll
(()
{
Cache
.
flutterRoot
=
getFlutterRoot
();
...
...
@@ -107,8 +105,8 @@ void main() {
);
final
List
<
Object
>
testsNames
=
outputEvents
.
testNotifications
.
where
((
Map
<
String
,
Object
>
/*?*/
e
)
=>
e
[
'type'
]
==
'testStart'
)
.
map
((
Map
<
String
,
Object
>
/*?*/
e
)
=>
(
e
[
'test'
]
as
Map
<
String
,
Object
/*?*/
>)[
'name'
]
)
.
where
((
Map
<
String
,
Object
?>
e
)
=>
e
[
'type'
]
==
'testStart'
)
.
map
((
Map
<
String
,
Object
?>
e
)
=>
(
e
[
'test'
]!
as
Map
<
String
,
Object
?>)[
'name'
]!
)
.
toList
();
expect
(
testsNames
,
contains
(
'Flutter tests can pass'
));
...
...
@@ -140,7 +138,7 @@ void _expectStandardTestsProjectResults(TestEvents events) {
// Check we recieved all expected test events passed through from
// package:test.
final
List
<
Object
>
eventNames
=
events
.
testNotifications
.
map
((
Map
<
String
,
Object
/*?*/
>
e
)
=>
e
[
'type'
]
).
toList
();
events
.
testNotifications
.
map
((
Map
<
String
,
Object
?>
e
)
=>
e
[
'type'
]!
).
toList
();
// start/done should always be first/last.
expect
(
eventNames
.
first
,
equals
(
'start'
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment