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
85b54d4c
Unverified
Commit
85b54d4c
authored
Feb 20, 2020
by
Jenn Magder
Committed by
GitHub
Feb 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change DeviceManager.getAllConnectedDevices() return value from Stream to List (#51015)
parent
6815e720
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
43 deletions
+36
-43
devices.dart
packages/flutter_tools/lib/src/commands/devices.dart
+1
-1
device.dart
packages/flutter_tools/lib/src/device.dart
+13
-15
doctor.dart
packages/flutter_tools/lib/src/doctor.dart
+1
-1
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+3
-3
run_test.dart
.../flutter_tools/test/commands.shard/hermetic/run_test.dart
+11
-13
device_test.dart
packages/flutter_tools/test/general.shard/device_test.dart
+3
-5
context.dart
packages/flutter_tools/test/src/context.dart
+4
-5
No files found.
packages/flutter_tools/lib/src/commands/devices.dart
View file @
85b54d4c
...
...
@@ -27,7 +27,7 @@ class DevicesCommand extends FlutterCommand {
exitCode:
1
);
}
final
List
<
Device
>
devices
=
await
deviceManager
.
getAllConnectedDevices
()
.
toList
()
;
final
List
<
Device
>
devices
=
await
deviceManager
.
getAllConnectedDevices
();
if
(
devices
.
isEmpty
)
{
globals
.
printStatus
(
...
...
packages/flutter_tools/lib/src/device.dart
View file @
85b54d4c
...
...
@@ -100,8 +100,8 @@ class DeviceManager {
/// specifiedDeviceId = 'all'.
bool
get
hasSpecifiedAllDevices
=>
_specifiedDeviceId
==
'all'
;
Stream
<
Device
>
getDevicesById
(
String
deviceId
)
async
*
{
final
List
<
Device
>
devices
=
await
getAllConnectedDevices
()
.
toList
()
;
Future
<
List
<
Device
>>
getDevicesById
(
String
deviceId
)
async
{
final
List
<
Device
>
devices
=
await
getAllConnectedDevices
();
deviceId
=
deviceId
.
toLowerCase
();
bool
exactlyMatchesDeviceId
(
Device
device
)
=>
device
.
id
.
toLowerCase
()
==
deviceId
||
...
...
@@ -113,18 +113,15 @@ class DeviceManager {
final
Device
exactMatch
=
devices
.
firstWhere
(
exactlyMatchesDeviceId
,
orElse:
()
=>
null
);
if
(
exactMatch
!=
null
)
{
yield
exactMatch
;
return
;
return
<
Device
>[
exactMatch
];
}
// Match on a id or name starting with [deviceId].
for
(
final
Device
device
in
devices
.
where
(
startsWithDeviceId
))
{
yield
device
;
}
return
devices
.
where
(
startsWithDeviceId
).
toList
();
}
/// Return the list of connected devices, filtered by any user-specified device id.
Stream
<
Device
>
getDevices
()
{
Future
<
List
<
Device
>
>
getDevices
()
{
return
hasSpecifiedDeviceId
?
getDevicesById
(
specifiedDeviceId
)
:
getAllConnectedDevices
();
...
...
@@ -135,12 +132,13 @@ class DeviceManager {
}
/// Return the list of all connected devices.
Stream
<
Device
>
getAllConnectedDevices
()
async
*
{
for
(
final
DeviceDiscovery
discoverer
in
_platformDiscoverers
)
{
for
(
final
Device
device
in
await
discoverer
.
devices
)
{
yield
device
;
}
}
Future
<
List
<
Device
>>
getAllConnectedDevices
()
async
{
final
List
<
List
<
Device
>>
devices
=
await
Future
.
wait
<
List
<
Device
>>(<
Future
<
List
<
Device
>>>[
for
(
final
DeviceDiscovery
discoverer
in
_platformDiscoverers
)
discoverer
.
devices
,
]);
return
devices
.
expand
<
Device
>((
List
<
Device
>
deviceList
)
=>
deviceList
).
toList
();
}
/// Whether we're capable of listing any devices given the current environment configuration.
...
...
@@ -170,7 +168,7 @@ class DeviceManager {
/// device connected, then filter out unsupported devices and prioritize
/// ephemeral devices.
Future
<
List
<
Device
>>
findTargetDevices
(
FlutterProject
flutterProject
)
async
{
List
<
Device
>
devices
=
await
getDevices
()
.
toList
()
;
List
<
Device
>
devices
=
await
getDevices
();
// Always remove web and fuchsia devices from `--all`. This setting
// currently requires devices to share a frontend_server and resident
...
...
packages/flutter_tools/lib/src/doctor.dart
View file @
85b54d4c
...
...
@@ -878,7 +878,7 @@ class DeviceValidator extends DoctorValidator {
@override
Future
<
ValidationResult
>
validate
()
async
{
final
List
<
Device
>
devices
=
await
deviceManager
.
getAllConnectedDevices
()
.
toList
()
;
final
List
<
Device
>
devices
=
await
deviceManager
.
getAllConnectedDevices
();
List
<
ValidationMessage
>
messages
;
if
(
devices
.
isEmpty
)
{
final
List
<
String
>
diagnostics
=
await
deviceManager
.
getDeviceDiagnostics
();
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
85b54d4c
...
...
@@ -718,7 +718,7 @@ abstract class FlutterCommand extends Command<void> {
globals
.
printStatus
(
userMessages
.
flutterFoundSpecifiedDevices
(
devices
.
length
,
deviceManager
.
specifiedDeviceId
));
}
else
{
globals
.
printStatus
(
userMessages
.
flutterSpecifyDeviceWithAllOption
);
devices
=
await
deviceManager
.
getAllConnectedDevices
()
.
toList
()
;
devices
=
await
deviceManager
.
getAllConnectedDevices
();
}
globals
.
printStatus
(
''
);
await
Device
.
printDevices
(
devices
);
...
...
@@ -738,7 +738,7 @@ abstract class FlutterCommand extends Command<void> {
}
if
(
deviceList
.
length
>
1
)
{
globals
.
printStatus
(
userMessages
.
flutterSpecifyDevice
);
deviceList
=
await
deviceManager
.
getAllConnectedDevices
()
.
toList
()
;
deviceList
=
await
deviceManager
.
getAllConnectedDevices
();
globals
.
printStatus
(
''
);
await
Device
.
printDevices
(
deviceList
);
return
null
;
...
...
@@ -804,7 +804,7 @@ mixin DeviceBasedDevelopmentArtifacts on FlutterCommand {
// If there are no attached devices, use the default configuration.
// Otherwise, only add development artifacts which correspond to a
// connected device.
final
List
<
Device
>
devices
=
await
deviceManager
.
getDevices
()
.
toList
()
;
final
List
<
Device
>
devices
=
await
deviceManager
.
getDevices
();
if
(
devices
.
isEmpty
)
{
return
super
.
requiredArtifacts
;
}
...
...
packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
View file @
85b54d4c
...
...
@@ -95,7 +95,7 @@ void main() {
return
Future
<
List
<
Device
>>.
value
(<
Device
>[
mockDevice
]);
});
when
(
deviceManager
.
getDevices
()).
thenAnswer
((
Invocation
invocation
)
{
return
Stream
<
Device
>.
value
(
mockDevice
);
return
Future
<
List
<
Device
>>.
value
(<
Device
>[
mockDevice
]
);
});
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
'pubspec.yaml'
).
createSync
();
...
...
@@ -215,7 +215,7 @@ void main() {
const
List
<
Device
>
noDevices
=
<
Device
>[];
when
(
mockDeviceManager
.
getDevices
()).
thenAnswer
(
(
Invocation
invocation
)
=>
Stream
<
Device
>.
fromIterabl
e
(
noDevices
)
(
Invocation
invocation
)
=>
Future
<
List
<
Device
>>.
valu
e
(
noDevices
)
);
when
(
mockDeviceManager
.
findTargetDevices
(
any
)).
thenAnswer
(
(
Invocation
invocation
)
=>
Future
<
List
<
Device
>>.
value
(
noDevices
)
...
...
@@ -245,7 +245,7 @@ void main() {
// Called as part of requiredArtifacts()
when
(
mockDeviceManager
.
getDevices
()).
thenAnswer
(
(
Invocation
invocation
)
=>
Stream
<
Device
>.
fromIterabl
e
(<
Device
>[])
(
Invocation
invocation
)
=>
Future
<
List
<
Device
>>.
valu
e
(<
Device
>[])
);
// No devices are attached, we just want to verify update the cache
// BEFORE checking for devices
...
...
@@ -308,7 +308,7 @@ void main() {
)).
thenReturn
(
'/path/to/sdk'
);
when
(
mockDeviceManager
.
getDevices
()).
thenAnswer
(
(
Invocation
invocation
)
=>
Stream
<
Device
>.
fromIterable
(<
Device
>[
mockDevice
]),
(
Invocation
invocation
)
=>
Future
<
List
<
Device
>>.
value
(<
Device
>[
mockDevice
])
);
when
(
mockDeviceManager
.
findTargetDevices
(
any
)).
thenAnswer
(
...
...
@@ -366,9 +366,7 @@ void main() {
setUpAll
(()
{
final
FakeDevice
fakeDevice
=
FakeDevice
();
when
(
mockDeviceManager
.
getDevices
()).
thenAnswer
((
Invocation
invocation
)
{
return
Stream
<
Device
>.
fromIterable
(<
Device
>[
fakeDevice
,
]);
return
Future
<
List
<
Device
>>.
value
(<
Device
>[
fakeDevice
]);
});
when
(
mockDeviceManager
.
findTargetDevices
(
any
)).
thenAnswer
(
(
Invocation
invocation
)
=>
Future
<
List
<
Device
>>.
value
(<
Device
>[
fakeDevice
])
...
...
@@ -454,7 +452,7 @@ void main() {
testUsingContext
(
'should only request artifacts corresponding to connected devices'
,
()
async
{
when
(
mockDeviceManager
.
getDevices
()).
thenAnswer
((
Invocation
invocation
)
{
return
Stream
<
Device
>.
fromIterabl
e
(<
Device
>[
return
Future
<
List
<
Device
>>.
valu
e
(<
Device
>[
MockDevice
(
TargetPlatform
.
android_arm
),
]);
});
...
...
@@ -465,7 +463,7 @@ void main() {
}));
when
(
mockDeviceManager
.
getDevices
()).
thenAnswer
((
Invocation
invocation
)
{
return
Stream
<
Device
>.
fromIterabl
e
(<
Device
>[
return
Future
<
List
<
Device
>>.
valu
e
(<
Device
>[
MockDevice
(
TargetPlatform
.
ios
),
]);
});
...
...
@@ -476,7 +474,7 @@ void main() {
}));
when
(
mockDeviceManager
.
getDevices
()).
thenAnswer
((
Invocation
invocation
)
{
return
Stream
<
Device
>.
fromIterabl
e
(<
Device
>[
return
Future
<
List
<
Device
>>.
valu
e
(<
Device
>[
MockDevice
(
TargetPlatform
.
ios
),
MockDevice
(
TargetPlatform
.
android_arm
),
]);
...
...
@@ -489,7 +487,7 @@ void main() {
}));
when
(
mockDeviceManager
.
getDevices
()).
thenAnswer
((
Invocation
invocation
)
{
return
Stream
<
Device
>.
fromIterabl
e
(<
Device
>[
return
Future
<
List
<
Device
>>.
valu
e
(<
Device
>[
MockDevice
(
TargetPlatform
.
web_javascript
),
]);
});
...
...
@@ -510,7 +508,7 @@ void main() {
setUpAll
(()
{
final
FakeDevice
fakeDevice
=
FakeDevice
()..
_targetPlatform
=
TargetPlatform
.
web_javascript
;
when
(
mockDeviceManager
.
getDevices
()).
thenAnswer
(
(
Invocation
invocation
)
=>
Stream
<
Device
>.
fromIterabl
e
(<
Device
>[
fakeDevice
])
(
Invocation
invocation
)
=>
Future
<
List
<
Device
>>.
valu
e
(<
Device
>[
fakeDevice
])
);
when
(
mockDeviceManager
.
findTargetDevices
(
any
)).
thenAnswer
(
(
Invocation
invocation
)
=>
Future
<
List
<
Device
>>.
value
(<
Device
>[
fakeDevice
])
...
...
@@ -612,7 +610,7 @@ class TestRunCommand extends RunCommand {
@override
// ignore: must_call_super
Future
<
void
>
validateCommand
()
async
{
devices
=
await
deviceManager
.
getDevices
()
.
toList
()
;
devices
=
await
deviceManager
.
getDevices
();
}
}
...
...
packages/flutter_tools/test/general.shard/device_test.dart
View file @
85b54d4c
...
...
@@ -18,7 +18,7 @@ void main() {
testUsingContext
(
'getDevices'
,
()
async
{
// Test that DeviceManager.getDevices() doesn't throw.
final
DeviceManager
deviceManager
=
DeviceManager
();
final
List
<
Device
>
devices
=
await
deviceManager
.
getDevices
()
.
toList
()
;
final
List
<
Device
>
devices
=
await
deviceManager
.
getDevices
();
expect
(
devices
,
isList
);
});
...
...
@@ -30,7 +30,7 @@ void main() {
final
DeviceManager
deviceManager
=
TestDeviceManager
(
devices
);
Future
<
void
>
expectDevice
(
String
id
,
List
<
Device
>
expected
)
async
{
expect
(
await
deviceManager
.
getDevicesById
(
id
)
.
toList
()
,
expected
);
expect
(
await
deviceManager
.
getDevicesById
(
id
),
expected
);
}
await
expectDevice
(
'01abfc49119c410e'
,
<
Device
>[
device2
]);
await
expectDevice
(
'Nexus 5X'
,
<
Device
>[
device2
]);
...
...
@@ -170,9 +170,7 @@ class TestDeviceManager extends DeviceManager {
bool
isAlwaysSupportedOverride
;
@override
Stream
<
Device
>
getAllConnectedDevices
()
{
return
Stream
<
Device
>.
fromIterable
(
allDevices
);
}
Future
<
List
<
Device
>>
getAllConnectedDevices
()
async
=>
allDevices
;
@override
bool
isDeviceSupportedForProject
(
Device
device
,
FlutterProject
flutterProject
)
{
...
...
packages/flutter_tools/test/src/context.dart
View file @
85b54d4c
...
...
@@ -201,16 +201,15 @@ class FakeDeviceManager implements DeviceManager {
}
@override
Stream
<
Device
>
getAllConnectedDevices
()
=>
Stream
<
Device
>.
fromIterable
(
devices
)
;
Future
<
List
<
Device
>>
getAllConnectedDevices
()
async
=>
devices
;
@override
Stream
<
Device
>
getDevicesById
(
String
deviceId
)
{
return
Stream
<
Device
>.
fromIterable
(
devices
.
where
((
Device
device
)
=>
device
.
id
==
deviceId
));
Future
<
List
<
Device
>>
getDevicesById
(
String
deviceId
)
async
{
return
devices
.
where
((
Device
device
)
=>
device
.
id
==
deviceId
).
toList
();
}
@override
Stream
<
Device
>
getDevices
()
{
Future
<
List
<
Device
>
>
getDevices
()
{
return
hasSpecifiedDeviceId
?
getDevicesById
(
specifiedDeviceId
)
:
getAllConnectedDevices
();
...
...
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