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
1e26c41f
Unverified
Commit
1e26c41f
authored
Jul 08, 2019
by
Jonah Williams
Committed by
GitHub
Jul 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove web, fuchsia, and unsupported devices from all (#35709)
parent
34e18d38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
7 deletions
+79
-7
device.dart
packages/flutter_tools/lib/src/device.dart
+39
-7
device_test.dart
packages/flutter_tools/test/device_test.dart
+40
-0
No files found.
packages/flutter_tools/lib/src/device.dart
View file @
1e26c41f
...
...
@@ -169,17 +169,49 @@ class DeviceManager {
/// Find and return a list of devices based on the current project and environment.
///
/// Returns a list of deviecs specified by the user. If the user has not specified
/// all devices and has multiple connected then filter the list by those supported
/// in the current project and remove non-ephemeral device types.
/// Returns a list of deviecs specified by the user.
///
/// * If the user specified '-d all', then return all connected devices which
/// support the current project, except for fuchsia and web.
///
/// * If the user specified a device id, then do nothing as the list is already
/// filtered by [getDevices].
///
/// * If the user did not specify a device id and there is more than one
/// device connected, then filter out unsupported devices and prioritize
/// ephemeral devices.
Future
<
List
<
Device
>>
findTargetDevices
(
FlutterProject
flutterProject
)
async
{
List
<
Device
>
devices
=
await
getDevices
().
toList
();
if
(
devices
.
length
>
1
&&
!
deviceManager
.
hasSpecifiedAllDevices
&&
!
deviceManager
.
hasSpecifiedDeviceId
)
{
devices
=
devices
.
where
((
Device
device
)
=>
isDeviceSupportedForProject
(
device
,
flutterProject
))
.
toList
();
// Always remove web and fuchsia devices from `--all`. This setting
// currently requires devices to share a frontend_server and resident
// runnner instance. Both web and fuchsia require differently configured
// compilers, and web requires an entirely different resident runner.
if
(
hasSpecifiedAllDevices
)
{
devices
=
<
Device
>[
for
(
Device
device
in
devices
)
if
(
await
device
.
targetPlatform
!=
TargetPlatform
.
fuchsia
&&
await
device
.
targetPlatform
!=
TargetPlatform
.
web_javascript
)
device
];
}
// If there is no specified device, the remove all devices which are not
// supported by the current application. For example, if there was no
// 'android' folder then don't attempt to launch with an Android device.
if
(
devices
.
length
>
1
&&
!
hasSpecifiedDeviceId
)
{
devices
=
<
Device
>[
for
(
Device
device
in
devices
)
if
(
device
.
isSupportedForProject
(
flutterProject
))
device
];
}
// If there are still multiple devices and the user did not specify to run
// all, then attempt to prioritize ephemeral devices. For example, if the
// use only typed 'flutter run' and both an Android device and desktop
// device are availible, choose the Android device.
if
(
devices
.
length
>
1
&&
!
hasSpecifiedAllDevices
)
{
// Note: ephemeral is nullable for device types where this is not well
// defined.
if
(
devices
.
any
((
Device
device
)
=>
device
.
ephemeral
==
true
))
{
...
...
packages/flutter_tools/test/device_test.dart
View file @
1e26c41f
...
...
@@ -4,6 +4,7 @@
import
'dart:async'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/project.dart'
;
...
...
@@ -43,12 +44,18 @@ void main() {
_MockDevice
nonEphemeralOne
;
_MockDevice
nonEphemeralTwo
;
_MockDevice
unsupported
;
_MockDevice
webDevice
;
_MockDevice
fuchsiaDevice
;
setUp
(()
{
ephemeral
=
_MockDevice
(
'ephemeral'
,
'ephemeral'
,
true
);
nonEphemeralOne
=
_MockDevice
(
'nonEphemeralOne'
,
'nonEphemeralOne'
,
false
);
nonEphemeralTwo
=
_MockDevice
(
'nonEphemeralTwo'
,
'nonEphemeralTwo'
,
false
);
unsupported
=
_MockDevice
(
'unsupported'
,
'unsupported'
,
true
,
false
);
webDevice
=
_MockDevice
(
'webby'
,
'webby'
)
..
targetPlatform
=
Future
<
TargetPlatform
>.
value
(
TargetPlatform
.
web_javascript
);
fuchsiaDevice
=
_MockDevice
(
'fuchsiay'
,
'fuchsiay'
)
..
targetPlatform
=
Future
<
TargetPlatform
>.
value
(
TargetPlatform
.
fuchsia
);
});
testUsingContext
(
'chooses ephemeral device'
,
()
async
{
...
...
@@ -79,6 +86,36 @@ void main() {
nonEphemeralTwo
,
]);
});
testUsingContext
(
'Removes web and fuchsia from --all'
,
()
async
{
final
List
<
Device
>
devices
=
<
Device
>[
webDevice
,
fuchsiaDevice
,
];
final
DeviceManager
deviceManager
=
TestDeviceManager
(
devices
);
deviceManager
.
specifiedDeviceId
=
'all'
;
final
List
<
Device
>
filtered
=
await
deviceManager
.
findTargetDevices
(
FlutterProject
.
current
());
expect
(
filtered
,
<
Device
>[]);
});
testUsingContext
(
'Removes unsupported devices from --all'
,
()
async
{
final
List
<
Device
>
devices
=
<
Device
>[
nonEphemeralOne
,
nonEphemeralTwo
,
unsupported
,
];
final
DeviceManager
deviceManager
=
TestDeviceManager
(
devices
);
deviceManager
.
specifiedDeviceId
=
'all'
;
final
List
<
Device
>
filtered
=
await
deviceManager
.
findTargetDevices
(
FlutterProject
.
current
());
expect
(
filtered
,
<
Device
>[
nonEphemeralOne
,
nonEphemeralTwo
,
]);
});
});
}
...
...
@@ -106,6 +143,9 @@ class _MockDevice extends Device {
@override
final
String
name
;
@override
Future
<
TargetPlatform
>
targetPlatform
=
Future
<
TargetPlatform
>.
value
(
TargetPlatform
.
android_arm
);
@override
void
noSuchMethod
(
Invocation
invocation
)
=>
super
.
noSuchMethod
(
invocation
);
...
...
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