catch IOSDeviceNotFoundError in IOSDevice.startApp() (#45011)
This commit is contained in:
committed by
GitHub
parent
01b0a62974
commit
ff84b3e66d
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user