Commit ff84b3e6 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

catch IOSDeviceNotFoundError in IOSDevice.startApp() (#45011)

parent 01b0a629
......@@ -282,7 +282,15 @@ class IOSDevice extends Device {
// TODO(chinmaygarde): Use mainPath, route.
printTrace('Building ${package.name} for $id');
final String cpuArchitecture = await iMobileDevice.getInfoForDevice(id, 'CPUArchitecture');
String cpuArchitecture;
try {
cpuArchitecture = await iMobileDevice.getInfoForDevice(id, 'CPUArchitecture');
} on IOSDeviceNotFoundError catch (e) {
printError(e.message);
return LaunchResult.failed();
}
final DarwinArch iosArch = getIOSArchForName(cpuArchitecture);
// Step 1: Build the precompiled/DBC application if necessary.
......
......@@ -249,6 +249,22 @@ void main() {
Cache.enableLocking();
});
testUsingContext('returns failed if the IOSDevice is not found', () async {
final IOSDevice device = IOSDevice('123');
when(mockIMobileDevice.getInfoForDevice(any, 'CPUArchitecture')).thenThrow(
const IOSDeviceNotFoundError(
'ideviceinfo could not find device:\n'
'No device found with udid 123, is it plugged in?\n'
'Try unlocking attached devices.'
)
);
final LaunchResult result = await device.startApp(mockApp);
expect(result.started, false);
}, overrides: <Type, Generator>{
IMobileDevice: () => mockIMobileDevice,
Platform: () => macPlatform,
});
testUsingContext(' succeeds in debug mode via mDNS', () async {
final IOSDevice device = IOSDevice('123');
device.portForwarder = mockPortForwarder;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment