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
25a3121d
Unverified
Commit
25a3121d
authored
Jun 20, 2019
by
Jonah Williams
Committed by
GitHub
Jun 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer ephemeral devices from command line run (#34802)
parent
4c56b66f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
5 deletions
+73
-5
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+22
-5
flutter_command_test.dart
packages/flutter_tools/test/runner/flutter_command_test.dart
+51
-0
No files found.
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
25a3121d
...
...
@@ -517,12 +517,8 @@ abstract class FlutterCommand extends Command<void> {
}
devices
=
devices
.
where
((
Device
device
)
=>
device
.
isSupported
()).
toList
();
// If the user has not specified all devices and has multiple connected
// then filter then list by those supported in the current project. If
// this ends up with a single device we can proceed as normal.
if
(
devices
.
length
>
1
&&
!
deviceManager
.
hasSpecifiedAllDevices
&&
!
deviceManager
.
hasSpecifiedDeviceId
)
{
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
devices
.
removeWhere
((
Device
device
)
=>
!
device
.
isSupportedForProject
(
flutterProject
));
devices
=
filterDevices
(
devices
);
}
if
(
devices
.
isEmpty
)
{
...
...
@@ -698,3 +694,24 @@ abstract class FastFlutterCommand extends FlutterCommand {
);
}
}
// 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. If this ends up with a single
// device we can proceed as normal.
@visibleForTesting
List
<
Device
>
filterDevices
(
List
<
Device
>
devices
)
{
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
devices
=
devices
.
where
((
Device
device
)
=>
device
.
isSupportedForProject
(
flutterProject
))
.
toList
();
// Note: ephemeral is nullable for device types where this is not well
// defined.
if
(
devices
.
any
((
Device
device
)
=>
device
.
ephemeral
==
true
))
{
devices
=
devices
.
where
((
Device
device
)
=>
device
.
ephemeral
==
true
)
.
toList
();
}
return
devices
;
}
packages/flutter_tools/test/runner/flutter_command_test.dart
View file @
25a3121d
...
...
@@ -4,6 +4,8 @@
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/base/time.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/usage.dart'
;
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
...
...
@@ -289,6 +291,43 @@ void main() {
FlutterVersion:
()
=>
betaVersion
,
});
});
group
(
'Filter devices'
,
()
{
MockDevice
ephemeral
;
MockDevice
nonEphemeralOne
;
MockDevice
nonEphemeralTwo
;
MockDevice
unsupported
;
setUp
(()
{
ephemeral
=
MockDevice
(
true
);
nonEphemeralOne
=
MockDevice
(
false
);
nonEphemeralTwo
=
MockDevice
(
false
);
unsupported
=
MockDevice
(
true
,
false
);
});
test
(
'chooses ephemeral device'
,
()
{
final
List
<
Device
>
filtered
=
filterDevices
(<
Device
>[
ephemeral
,
nonEphemeralOne
,
nonEphemeralTwo
,
unsupported
,
]);
expect
(
filtered
.
single
,
ephemeral
);
});
test
(
'does not remove all non-ephemeral'
,
()
{
final
List
<
Device
>
filtered
=
filterDevices
(<
Device
>[
nonEphemeralOne
,
nonEphemeralTwo
,
]);
expect
(
filtered
,
<
Device
>[
nonEphemeralOne
,
nonEphemeralTwo
,
]);
});
});
}
...
...
@@ -309,3 +348,15 @@ class FakeCommand extends FlutterCommand {
}
class
MockVersion
extends
Mock
implements
FlutterVersion
{}
class
MockDevice
extends
Mock
implements
Device
{
MockDevice
(
this
.
ephemeral
,
[
this
.
_isSupported
=
true
]);
@override
final
bool
ephemeral
;
bool
_isSupported
;
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
=>
_isSupported
;
}
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