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
24aa26a3
Unverified
Commit
24aa26a3
authored
Oct 14, 2022
by
Lau Ching Jun
Committed by
GitHub
Oct 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle null exception case in ProxiedDevice.stopApp. (#113317)
parent
0575faa3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
30 deletions
+70
-30
daemon.dart
packages/flutter_tools/lib/src/commands/daemon.dart
+5
-2
devices.dart
packages/flutter_tools/lib/src/proxied_devices/devices.dart
+6
-4
proxied_devices_test.dart
...t/general.shard/proxied_devices/proxied_devices_test.dart
+59
-24
No files found.
packages/flutter_tools/lib/src/commands/daemon.dart
View file @
24aa26a3
...
...
@@ -1025,8 +1025,11 @@ class DeviceDomain extends Domain {
if
(
device
==
null
)
{
throw
DaemonException
(
"device '
$deviceId
' not found"
);
}
final
String
?
applicationPackageId
=
_getStringArg
(
args
,
'applicationPackageId'
,
required:
true
);
final
ApplicationPackage
applicationPackage
=
_applicationPackages
[
applicationPackageId
!]!;
final
String
?
applicationPackageId
=
_getStringArg
(
args
,
'applicationPackageId'
);
ApplicationPackage
?
applicationPackage
;
if
(
applicationPackageId
!=
null
)
{
applicationPackage
=
_applicationPackages
[
applicationPackageId
];
}
return
device
.
stopApp
(
applicationPackage
,
userIdentifier:
_getStringArg
(
args
,
'userIdentifier'
),
...
...
packages/flutter_tools/lib/src/proxied_devices/devices.dart
View file @
24aa26a3
...
...
@@ -65,7 +65,7 @@ class ProxiedDevices extends DeviceDiscovery {
final
List
<
Map
<
String
,
Object
?>>
discoveredDevices
=
_cast
<
List
<
dynamic
>>(
await
connection
.
sendRequest
(
'device.discoverDevices'
)).
cast
<
Map
<
String
,
Object
?>>();
final
List
<
ProxiedDevice
>
devices
=
<
ProxiedDevice
>[
for
(
final
Map
<
String
,
Object
?>
device
in
discoveredDevices
)
_
deviceFromDaemonResult
(
device
),
deviceFromDaemonResult
(
device
),
];
_devices
=
devices
;
...
...
@@ -75,7 +75,8 @@ class ProxiedDevices extends DeviceDiscovery {
@override
List
<
String
>
get
wellKnownIds
=>
const
<
String
>[];
ProxiedDevice
_deviceFromDaemonResult
(
Map
<
String
,
Object
?>
device
)
{
@visibleForTesting
ProxiedDevice
deviceFromDaemonResult
(
Map
<
String
,
Object
?>
device
)
{
final
Map
<
String
,
Object
?>
capabilities
=
_cast
<
Map
<
String
,
Object
?>>(
device
[
'capabilities'
]);
return
ProxiedDevice
(
connection
,
_cast
<
String
>(
device
[
'id'
]),
...
...
@@ -275,12 +276,13 @@ class ProxiedDevice extends Device {
@override
Future
<
bool
>
stopApp
(
covariant
PrebuiltApplicationPackage
app
,
{
covariant
PrebuiltApplicationPackage
?
app
,
{
String
?
userIdentifier
,
})
async
{
return
_cast
<
bool
>(
await
connection
.
sendRequest
(
'device.stopApp'
,
<
String
,
Object
?>{
'deviceId'
:
id
,
'applicationPackageId'
:
await
applicationPackageId
(
app
),
if
(
app
!=
null
)
'applicationPackageId'
:
await
applicationPackageId
(
app
),
'userIdentifier'
:
userIdentifier
,
}));
}
...
...
packages/flutter_tools/test/general.shard/proxied_devices/proxied_devices_test.dart
View file @
24aa26a3
...
...
@@ -14,32 +14,32 @@ import 'package:test/fake.dart';
import
'../../src/common.dart'
;
void
main
(
)
{
group
(
'ProxiedPortForwarder'
,
()
{
late
BufferLogger
bufferLogger
;
late
DaemonConnection
serverDaemonConnection
;
late
DaemonConnection
clientDaemonConnection
;
setUp
(()
{
bufferLogger
=
BufferLogger
.
test
();
final
FakeDaemonStreams
serverDaemonStreams
=
FakeDaemonStreams
();
serverDaemonConnection
=
DaemonConnection
(
daemonStreams:
serverDaemonStreams
,
logger:
bufferLogger
,
);
final
FakeDaemonStreams
clientDaemonStreams
=
FakeDaemonStreams
();
clientDaemonConnection
=
DaemonConnection
(
daemonStreams:
clientDaemonStreams
,
logger:
bufferLogger
,
);
serverDaemonStreams
.
inputs
.
addStream
(
clientDaemonStreams
.
outputs
.
stream
);
clientDaemonStreams
.
inputs
.
addStream
(
serverDaemonStreams
.
outputs
.
stream
);
});
late
BufferLogger
bufferLogger
;
late
DaemonConnection
serverDaemonConnection
;
late
DaemonConnection
clientDaemonConnection
;
setUp
(()
{
bufferLogger
=
BufferLogger
.
test
();
final
FakeDaemonStreams
serverDaemonStreams
=
FakeDaemonStreams
();
serverDaemonConnection
=
DaemonConnection
(
daemonStreams:
serverDaemonStreams
,
logger:
bufferLogger
,
);
final
FakeDaemonStreams
clientDaemonStreams
=
FakeDaemonStreams
();
clientDaemonConnection
=
DaemonConnection
(
daemonStreams:
clientDaemonStreams
,
logger:
bufferLogger
,
);
serverDaemonStreams
.
inputs
.
addStream
(
clientDaemonStreams
.
outputs
.
stream
);
clientDaemonStreams
.
inputs
.
addStream
(
serverDaemonStreams
.
outputs
.
stream
);
});
tearDown
(()
async
{
await
serverDaemonConnection
.
dispose
();
await
clientDaemonConnection
.
dispose
();
});
tearDown
(()
async
{
await
serverDaemonConnection
.
dispose
();
await
clientDaemonConnection
.
dispose
();
});
group
(
'ProxiedPortForwarder'
,
()
{
testWithoutContext
(
'works correctly without device id'
,
()
async
{
final
FakeServerSocket
fakeServerSocket
=
FakeServerSocket
(
200
);
final
ProxiedPortForwarder
portForwarder
=
ProxiedPortForwarder
(
...
...
@@ -202,6 +202,41 @@ void main() {
});
});
});
group
(
'ProxiedDevice'
,
()
{
final
Map
<
String
,
Object
>
fakeDevice
=
<
String
,
Object
>{
'name'
:
'device-name'
,
'id'
:
'device-id'
,
'category'
:
'mobile'
,
'platformType'
:
'android'
,
'platform'
:
'android-arm'
,
'emulator'
:
true
,
'ephemeral'
:
false
,
'sdk'
:
'Test SDK (1.2.3)'
,
'capabilities'
:
<
String
,
Object
>{
'hotReload'
:
true
,
'hotRestart'
:
true
,
'screenshot'
:
false
,
'fastStart'
:
false
,
'flutterExit'
:
true
,
'hardwareRendering'
:
true
,
'startPaused'
:
true
,
},
};
testWithoutContext
(
'calls stopApp without application package if not passed'
,
()
async
{
bufferLogger
=
BufferLogger
.
test
();
final
ProxiedDevices
proxiedDevices
=
ProxiedDevices
(
clientDaemonConnection
,
logger:
bufferLogger
,
);
final
ProxiedDevice
device
=
proxiedDevices
.
deviceFromDaemonResult
(
fakeDevice
);
unawaited
(
device
.
stopApp
(
null
,
userIdentifier:
'user-id'
));
final
DaemonMessage
message
=
await
serverDaemonConnection
.
incomingCommands
.
first
;
expect
(
message
.
data
[
'id'
],
isNotNull
);
expect
(
message
.
data
[
'method'
],
'device.stopApp'
);
expect
(
message
.
data
[
'params'
],
<
String
,
Object
?>{
'deviceId'
:
'device-id'
,
'userIdentifier'
:
'user-id'
});
});
});
}
class
FakeDaemonStreams
implements
DaemonStreams
{
...
...
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