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
5976c370
Unverified
Commit
5976c370
authored
Jul 14, 2022
by
Lau Ching Jun
Committed by
GitHub
Jul 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check device type using platformType instead of type check to support proxied devices. (#107618)
parent
902b0124
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
10 deletions
+43
-10
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+1
-1
run_test.dart
.../flutter_tools/test/commands.shard/hermetic/run_test.dart
+42
-9
No files found.
packages/flutter_tools/lib/src/commands/run.dart
View file @
5976c370
...
...
@@ -495,7 +495,7 @@ class RunCommand extends RunCommandBase {
}
if
(
userIdentifier
!=
null
&&
devices
!.
every
((
Device
device
)
=>
device
is
!
AndroidDevice
))
{
&&
devices
!.
every
((
Device
device
)
=>
device
.
platformType
!=
PlatformType
.
android
))
{
throwToolExit
(
'--
${FlutterOptions.kDeviceUser}
is only supported for Android. At least one Android device is required.'
);
...
...
packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
View file @
5976c370
...
...
@@ -221,16 +221,13 @@ void main() {
});
testUsingContext
(
'fails when targeted device is not Android with --device-user'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
writeAsStringSync
(
'
\n
'
);
fs
.
file
(
'lib/main.dart'
).
createSync
(
recursive:
true
);
final
FakeDevice
device
=
FakeDevice
(
isLocalEmulator:
true
);
mockDeviceManager
..
devices
=
<
Device
>[
device
]
..
targetDevices
=
<
Device
>[
device
];
final
RunCommand
command
=
RunCommand
();
final
TestRunCommandThatOnlyValidates
command
=
TestRunCommandThatOnlyValidates
();
await
expectLater
(
createTestCommandRunner
(
command
).
run
(<
String
>[
'run'
,
'--no-pub'
,
...
...
@@ -245,6 +242,29 @@ void main() {
Cache:
()
=>
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()),
});
testUsingContext
(
'succeeds when targeted device is an Android device with --device-user'
,
()
async
{
final
FakeDevice
device
=
FakeDevice
(
isLocalEmulator:
true
,
platformType:
PlatformType
.
android
);
mockDeviceManager
..
devices
=
<
Device
>[
device
]
..
targetDevices
=
<
Device
>[
device
];
final
TestRunCommandThatOnlyValidates
command
=
TestRunCommandThatOnlyValidates
();
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'run'
,
'--no-pub'
,
'--device-user'
,
'10'
,
]);
// Finishes normally without error.
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
DeviceManager:
()
=>
mockDeviceManager
,
Stdio:
()
=>
FakeStdio
(),
Cache:
()
=>
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()),
});
testUsingContext
(
'fails when v1 FlutterApplication is detected'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'android/AndroidManifest.xml'
)
...
...
@@ -876,16 +896,22 @@ class FakeAndroidSdk extends Fake implements AndroidSdk {
// Until we fix that, we have to also ignore related lints here.
// ignore: avoid_implementing_value_types
class
FakeDevice
extends
Fake
implements
Device
{
FakeDevice
({
bool
isLocalEmulator
=
false
,
TargetPlatform
targetPlatform
=
TargetPlatform
.
ios
,
String
sdkNameAndVersion
=
''
})
:
_isLocalEmulator
=
isLocalEmulator
,
_targetPlatform
=
targetPlatform
,
_sdkNameAndVersion
=
sdkNameAndVersion
;
FakeDevice
({
bool
isLocalEmulator
=
false
,
TargetPlatform
targetPlatform
=
TargetPlatform
.
ios
,
String
sdkNameAndVersion
=
''
,
PlatformType
platformType
=
PlatformType
.
ios
,
}):
_isLocalEmulator
=
isLocalEmulator
,
_targetPlatform
=
targetPlatform
,
_sdkNameAndVersion
=
sdkNameAndVersion
,
_platformType
=
platformType
;
static
const
int
kSuccess
=
1
;
static
const
int
kFailure
=
-
1
;
final
TargetPlatform
_targetPlatform
;
final
bool
_isLocalEmulator
;
final
String
_sdkNameAndVersion
;
final
PlatformType
_platformType
;
@override
Category
get
category
=>
Category
.
mobile
;
...
...
@@ -943,7 +969,7 @@ class FakeDevice extends Fake implements Device {
Future
<
TargetPlatform
>
get
targetPlatform
async
=>
_targetPlatform
;
@override
final
PlatformType
platformType
=
PlatformType
.
ios
;
PlatformType
get
platformType
=>
_platformType
;
bool
startAppSuccess
;
...
...
@@ -1012,6 +1038,13 @@ class TestRunCommandWithFakeResidentRunner extends RunCommand {
}
}
class
TestRunCommandThatOnlyValidates
extends
RunCommand
{
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
return
FlutterCommandResult
.
success
();
}
}
class
FakeResidentRunner
extends
Fake
implements
ResidentRunner
{
RPCError
rpcError
;
...
...
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