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
54becbf3
Commit
54becbf3
authored
Nov 05, 2018
by
mattijsf
Committed by
Todd Volkert
Nov 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore unreachable iOS devices in IOSDevice.getAttachedDevices (#23776)
parent
b8c29a14
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
5 deletions
+51
-5
AUTHORS
AUTHORS
+1
-0
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+8
-3
mac.dart
packages/flutter_tools/lib/src/ios/mac.dart
+15
-2
devices_test.dart
packages/flutter_tools/test/ios/devices_test.dart
+19
-0
mac_test.dart
packages/flutter_tools/test/ios/mac_test.dart
+8
-0
No files found.
AUTHORS
View file @
54becbf3
...
...
@@ -29,3 +29,4 @@ Lukasz Piliszczuk <lukasz@intheloup.io>
Felix Schmidt <felix.free@gmx.de>
Artur Rymarz <artur.rymarz@gmail.com>
Stefan Mitev <mr.mitew@gmail.com>
Mattijs Fuijkschot <mattijs.fuijkschot@gmail.com>
packages/flutter_tools/lib/src/ios/devices.dart
View file @
54becbf3
...
...
@@ -149,9 +149,14 @@ class IOSDevice extends Device {
if
(
id
.
isEmpty
)
continue
;
final
String
deviceName
=
await
iMobileDevice
.
getInfoForDevice
(
id
,
'DeviceName'
);
final
String
sdkVersion
=
await
iMobileDevice
.
getInfoForDevice
(
id
,
'ProductVersion'
);
devices
.
add
(
IOSDevice
(
id
,
name:
deviceName
,
sdkVersion:
sdkVersion
));
try
{
final
String
deviceName
=
await
iMobileDevice
.
getInfoForDevice
(
id
,
'DeviceName'
);
final
String
sdkVersion
=
await
iMobileDevice
.
getInfoForDevice
(
id
,
'ProductVersion'
);
devices
.
add
(
IOSDevice
(
id
,
name:
deviceName
,
sdkVersion:
sdkVersion
));
}
on
IOSDeviceNotFoundError
catch
(
error
)
{
// Unable to find device with given udid. Possibly a network device.
printTrace
(
'Error getting attached iOS device:
$error
'
);
}
}
return
devices
;
}
...
...
packages/flutter_tools/lib/src/ios/mac.dart
View file @
54becbf3
...
...
@@ -83,6 +83,17 @@ class PropertyList {
}
}
/// Specialized exception for expected situations where the ideviceinfo
/// tool responds with exit code 255 / 'No device found' message
class
IOSDeviceNotFoundError
implements
Exception
{
IOSDeviceNotFoundError
(
this
.
message
);
final
String
message
;
@override
String
toString
()
=>
message
;
}
class
IMobileDevice
{
const
IMobileDevice
();
...
...
@@ -118,11 +129,13 @@ class IMobileDevice {
Future
<
String
>
getInfoForDevice
(
String
deviceID
,
String
key
)
async
{
try
{
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
'ideviceinfo'
,
'-u'
,
deviceID
,
'-k'
,
key
,
'--simple'
]);
if
(
result
.
exitCode
==
255
&&
result
.
stdout
!=
null
&&
result
.
stdout
.
contains
(
'No device found'
))
throw
IOSDeviceNotFoundError
(
'ideviceinfo could not find device:
\n
${result.stdout}
'
);
if
(
result
.
exitCode
!=
0
)
throw
ToolExit
(
'idevice
_id
returned an error:
\n
${result.stderr}
'
);
throw
ToolExit
(
'idevice
info
returned an error:
\n
${result.stderr}
'
);
return
result
.
stdout
.
trim
();
}
on
ProcessException
{
throw
ToolExit
(
'Failed to invoke idevice
_id
. Run flutter doctor.'
);
throw
ToolExit
(
'Failed to invoke idevice
info
. Run flutter doctor.'
);
}
}
...
...
packages/flutter_tools/test/ios/devices_test.dart
View file @
54becbf3
...
...
@@ -77,6 +77,25 @@ f577a7903cc54959be2e34bc4f7f80b7009efcf4
},
overrides:
<
Type
,
Generator
>{
IMobileDevice:
()
=>
mockIMobileDevice
,
});
testUsingContext
(
'returns attached devices and ignores devices that cannot be found by ideviceinfo'
,
()
async
{
when
(
iMobileDevice
.
isInstalled
).
thenReturn
(
true
);
when
(
iMobileDevice
.
getAvailableDeviceIDs
())
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
String
>.
value
(
'''
98206e7a4afd4aedaff06e687594e089dede3c44
f577a7903cc54959be2e34bc4f7f80b7009efcf4
'''
));
when
(
iMobileDevice
.
getInfoForDevice
(
'98206e7a4afd4aedaff06e687594e089dede3c44'
,
'DeviceName'
))
.
thenAnswer
((
_
)
=>
Future
<
String
>.
value
(
'La tele me regarde'
));
when
(
iMobileDevice
.
getInfoForDevice
(
'f577a7903cc54959be2e34bc4f7f80b7009efcf4'
,
'DeviceName'
))
.
thenThrow
(
IOSDeviceNotFoundError
(
'Device not found'
));
final
List
<
IOSDevice
>
devices
=
await
IOSDevice
.
getAttachedDevices
();
expect
(
devices
,
hasLength
(
1
));
expect
(
devices
[
0
].
id
,
'98206e7a4afd4aedaff06e687594e089dede3c44'
);
expect
(
devices
[
0
].
name
,
'La tele me regarde'
);
},
overrides:
<
Type
,
Generator
>{
IMobileDevice:
()
=>
mockIMobileDevice
,
});
});
group
(
'decodeSyslog'
,
()
{
...
...
packages/flutter_tools/test/ios/mac_test.dart
View file @
54becbf3
...
...
@@ -127,6 +127,14 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
});
testUsingContext
(
'getInfoForDevice throws IOSDeviceNotFoundError when ideviceinfo returns specific error code and message'
,
()
async
{
when
(
mockProcessManager
.
run
(<
String
>[
'ideviceinfo'
,
'-u'
,
'foo'
,
'-k'
,
'bar'
,
'--simple'
]))
.
thenAnswer
((
_
)
=>
Future
<
ProcessResult
>.
value
(
ProcessResult
(
1
,
255
,
'No device found with udid foo, is it plugged in?'
,
''
)));
expect
(()
async
=>
await
iMobileDevice
.
getInfoForDevice
(
'foo'
,
'bar'
),
throwsA
(
isInstanceOf
<
IOSDeviceNotFoundError
>()));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
});
group
(
'screenshot'
,
()
{
final
String
outputPath
=
fs
.
path
.
join
(
'some'
,
'test'
,
'path'
,
'image.png'
);
MockProcessManager
mockProcessManager
;
...
...
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