class IPadSimulatorPort(IOSSimulatorPort): port_name = 'ipad-simulator' DEVICE_TYPE = DeviceType(hardware_family='iPad') DEFAULT_DEVICE_TYPES = [DeviceType(hardware_family='iPad', hardware_type='(5th generation)')] def __init__(self, *args, **kwargs): super(IPadSimulatorPort, self).__init__(*args, **kwargs) self._config = Config(self._executive, self._filesystem, IOSSimulatorPort.port_name)
def test_generation_matching(self): self.assertEqual( DeviceType.from_string( 'iPhone SE (1st generation)').standardized_hardware_type, 'SE') self.assertTrue( DeviceType.from_string('iPhone SE') == DeviceType.from_string( 'iPhone SE (1st generation)')) self.assertTrue( DeviceType.from_string('iPhone SE') != DeviceType.from_string( 'iPhone SE (2nd generation)'))
class IPhoneSimulatorPort(IOSSimulatorPort): port_name = 'iphone-simulator' DEVICE_TYPE = DeviceType(hardware_family='iPhone') DEFAULT_DEVICE_TYPES = [ DeviceType(hardware_family='iPhone', hardware_type='SE'), DeviceType(hardware_family='iPhone', hardware_type='7'), ] def __init__(self, *args, **kwargs): super(IPhoneSimulatorPort, self).__init__(*args, **kwargs) self._config = Config(self._executive, self._filesystem, IOSSimulatorPort.port_name)
def test_iphone_initialization(self): type = DeviceType(hardware_family='iPhone') self.assertEquals('iPhone', type.hardware_family) self.assertEquals(None, type.hardware_type) self.assertEquals('iOS', type.software_variant) self.assertEquals(None, type.software_version) self.assertEqual('iPhone running iOS', str(type)) type = DeviceType('iPhone', '6s', Version(11)) self.assertEquals('iPhone', type.hardware_family) self.assertEquals('6s', type.hardware_type) self.assertEquals('iOS', type.software_variant) self.assertEquals(Version(11), type.software_version) self.assertEqual('iPhone 6s running iOS 11', str(type))
def test_ipad_initialization(self): type = DeviceType(hardware_family='iPad') self.assertEquals('iPad', type.hardware_family) self.assertEquals(None, type.hardware_type) self.assertEquals('iOS', type.software_variant) self.assertEquals(None, type.software_version) self.assertEqual('iPad running iOS', str(type)) type = DeviceType('iPad', 'Air 2', Version(11)) self.assertEquals('iPad', type.hardware_family) self.assertEquals('Air 2', type.hardware_type) self.assertEquals('iOS', type.software_variant) self.assertEquals(Version(11), type.software_version) self.assertEqual('iPad Air 2 running iOS 11', str(type))
def test_tv_initialization(self): type = DeviceType(hardware_family='TV') self.assertEquals('Apple TV', type.hardware_family) self.assertEquals(None, type.hardware_type) self.assertEquals('tvOS', type.software_variant) self.assertEquals(None, type.software_version) self.assertEqual('Apple TV running tvOS', str(type)) type = DeviceType('Apple TV', '4K', Version(11)) self.assertEquals('Apple TV', type.hardware_family) self.assertEquals('4K', type.hardware_type) self.assertEquals('tvOS', type.software_variant) self.assertEquals(Version(11), type.software_version) self.assertEqual('Apple TV 4K running tvOS 11', str(type))
def _disambiguate_device_type(device_type): # Copy by value since we do not want to modify the DeviceType passed in. full_device_type = DeviceType( hardware_family=device_type.hardware_family, hardware_type=device_type.hardware_type, software_version=device_type.software_version, software_variant=device_type.software_variant) runtime = SimulatedDeviceManager.get_runtime_for_device_type(full_device_type) assert runtime is not None full_device_type.software_version = runtime.version if full_device_type.hardware_family is None: # We use the existing devices to determine a legal family if no family is specified for device in SimulatedDeviceManager.AVAILABLE_DEVICES: if device.device_type == full_device_type: full_device_type.hardware_family = device.device_type.hardware_family break if full_device_type.hardware_type is None: # Again, we use the existing devices to determine a legal hardware type for name in SimulatedDeviceManager._device_identifier_to_name.itervalues(): type_from_name = DeviceType.from_string(name) if type_from_name == full_device_type: full_device_type.hardware_type = type_from_name.hardware_type break full_device_type.check_consistency() return full_device_type
def test_watch_initialization(self): type = DeviceType(hardware_family='Watch') self.assertEquals('Apple Watch', type.hardware_family) self.assertEquals(None, type.hardware_type) self.assertEquals('watchOS', type.software_variant) self.assertEquals(None, type.software_version) self.assertEqual('Apple Watch running watchOS', str(type)) type = DeviceType('Apple Watch', 'Series 2 - 42mm', Version(4)) self.assertEquals('Apple Watch', type.hardware_family) self.assertEquals('Series 2 - 42mm', type.hardware_type) self.assertEquals('watchOS', type.software_variant) self.assertEquals(Version(4), type.software_version) self.assertEqual('Apple Watch Series 2 - 42mm running watchOS 4', str(type))
def test_swapping_devices(self): SimulatedDeviceTest.reset_simulated_device_manager() host = SimulatedDeviceTest.mock_host_for_simctl() SimulatedDeviceManager.available_devices(host) # We won't test the creation and deletion of simulators, only managing existing sims SimulatedDeviceTest.change_state_to( SimulatedDeviceManager.device_by_filter( lambda device: device.platform_device.device_type == DeviceType .from_string('iPhone 8'), host)[0], SimulatedDevice.DeviceState.BOOTED) SimulatedDeviceTest.change_state_to( SimulatedDeviceManager.device_by_filter( lambda device: device.platform_device.device_type == DeviceType .from_string('iPhone X'), host)[0], SimulatedDevice.DeviceState.BOOTED) SimulatedDeviceManager.initialize_devices(DeviceRequest( DeviceType.from_string('iPhone 8')), host=host) self.assertEquals(1, len(SimulatedDeviceManager.INITIALIZED_DEVICES)) self.assertEquals('17104B4F-E77D-4019-98E6-621FE3CC3653', SimulatedDeviceManager.INITIALIZED_DEVICES[0].udid) self.assertEquals( SimulatedDevice.DeviceState.BOOTED, SimulatedDeviceManager. INITIALIZED_DEVICES[0].platform_device.state()) # Now swap for the X SimulatedDeviceTest.change_state_to( SimulatedDeviceManager.INITIALIZED_DEVICES[0], SimulatedDevice.DeviceState.SHUT_DOWN) SimulatedDeviceManager.swap( SimulatedDeviceManager.INITIALIZED_DEVICES[0], DeviceRequest(DeviceType.from_string('iPhone X')), host) self.assertEquals(1, len(SimulatedDeviceManager.INITIALIZED_DEVICES)) self.assertEquals('4E6E7393-C4E3-4323-AA8B-4A42A45AE7B8', SimulatedDeviceManager.INITIALIZED_DEVICES[0].udid) self.assertEquals( SimulatedDevice.DeviceState.BOOTED, SimulatedDeviceManager. INITIALIZED_DEVICES[0].platform_device.state()) SimulatedDeviceTest.change_state_to( SimulatedDeviceManager.INITIALIZED_DEVICES[0], SimulatedDevice.DeviceState.SHUT_DOWN) SimulatedDeviceManager.tear_down(host) self.assertIsNone(SimulatedDeviceManager.INITIALIZED_DEVICES)
def check_sys_deps(self, needs_http): target_device_type = DeviceType(software_variant='iOS', software_version=self.ios_version()) for device in SimulatedDeviceManager.available_devices(self.host): if device.platform_device.device_type in target_device_type: return super(IOSSimulatorPort, self).check_sys_deps(needs_http) _log.error('No Simulated device matching "{}" defined in Xcode iOS SDK'.format(str(target_device_type))) return False
def test_layout_searchpath_wih_device_type(self): search_path = self.make_port( port_name='ios-device-wk2', os_version=Version(12)).default_baseline_search_path( DeviceType.from_string('iPhone SE')) self.assertEqual(search_path, [ '/mock-checkout/LayoutTests/platform/iphone-se-device-12-wk2', '/mock-checkout/LayoutTests/platform/iphone-se-device-12', '/mock-checkout/LayoutTests/platform/iphone-se-device-wk2', '/mock-checkout/LayoutTests/platform/iphone-se-device', '/mock-checkout/LayoutTests/platform/iphone-device-12-wk2', '/mock-checkout/LayoutTests/platform/iphone-device-12', '/mock-checkout/LayoutTests/platform/iphone-device-wk2', '/mock-checkout/LayoutTests/platform/iphone-device', '/mock-checkout/LayoutTests/platform/ios-device-12-wk2', '/mock-checkout/LayoutTests/platform/ios-device-12', '/mock-checkout/LayoutTests/platform/ios-device-wk2', '/mock-checkout/LayoutTests/platform/ios-device', '/mock-checkout/LayoutTests/platform/iphone-se-12-wk2', '/mock-checkout/LayoutTests/platform/iphone-se-12', '/mock-checkout/LayoutTests/platform/iphone-se-wk2', '/mock-checkout/LayoutTests/platform/iphone-se', '/mock-checkout/LayoutTests/platform/iphone-12-wk2', '/mock-checkout/LayoutTests/platform/iphone-12', '/mock-checkout/LayoutTests/platform/iphone-wk2', '/mock-checkout/LayoutTests/platform/iphone', '/mock-checkout/LayoutTests/platform/ios-12-wk2', '/mock-checkout/LayoutTests/platform/ios-12', '/mock-checkout/LayoutTests/platform/ios-wk2', '/mock-checkout/LayoutTests/platform/ios', '/mock-checkout/LayoutTests/platform/wk2', ])
def _create_device_with_runtime(host, runtime, device_info): if device_info.get('availability') != '(available)' and device_info.get('isAvailable') != 'YES' and device_info.get('isAvailable') != True: return None # Check existing devices. for device in SimulatedDeviceManager.AVAILABLE_DEVICES: if device.udid == device_info['udid']: return device # Check that the device.plist exists device_plist = host.filesystem.expanduser(host.filesystem.join(SimulatedDeviceManager.simulator_device_path, device_info['udid'], 'device.plist')) if not host.filesystem.isfile(device_plist): return None # Find device type. If we can't parse the device type, ignore this device. try: device_type_string = SimulatedDeviceManager._device_identifier_to_name[plistlib.readPlist(host.filesystem.open_binary_file_for_reading(device_plist))['deviceType']] device_type = DeviceType.from_string(device_type_string, runtime.version) assert device_type.software_variant == runtime.os_variant except (ValueError, AssertionError): return None result = Device(SimulatedDevice( name=device_info['name'], udid=device_info['udid'], host=host, device_type=device_type, build_version=runtime.build_version, )) SimulatedDeviceManager.AVAILABLE_DEVICES.append(result) return result
def test_generic_ios_device(self): type = DeviceType(software_variant='iOS') self.assertEquals(None, type.hardware_family) self.assertEquals(None, type.hardware_type) self.assertEquals('iOS', type.software_variant) self.assertEquals(None, type.software_version) self.assertEqual('Device running iOS', str(type))
def _device_type_with_version(self, device_type=None): device_type = device_type if device_type else self.DEVICE_TYPE return DeviceType( hardware_family=device_type.hardware_family, hardware_type=device_type.hardware_type, software_version=self.device_version(), software_variant=device_type.software_variant, )
def test_matching_up_failure(self): SimulatedDeviceTest.reset_simulated_device_manager() host = SimulatedDeviceTest.mock_host_for_simctl() SimulatedDeviceManager.available_devices(host) runtime = SimulatedDeviceManager.get_runtime_for_device_type( DeviceType.from_string('iphone 5s', Version(9, 4))) self.assertEquals(runtime, None)
def test_matching_up_success(self): SimulatedDeviceTest.reset_simulated_device_manager() host = SimulatedDeviceTest.mock_host_for_simctl() SimulatedDeviceManager.available_devices(host) runtime = SimulatedDeviceManager.get_runtime_for_device_type( DeviceType.from_string('iphone 5s', Version(9, 2))) self.assertEquals(runtime.os_variant, 'iOS') self.assertEquals(runtime.version, Version(9, 3))
def _initialize_devices(self): if 'simulator' in self._port.port_name: SimulatedDeviceManager.initialize_devices(DeviceRequest( DeviceType.from_string(self._port.DEFAULT_DEVICE_CLASS), allow_incomplete_match=True), self.host, simulator_ui=False) elif 'device' in self._port.port_name: raise RuntimeError( 'Running api tests on {} is not supported'.format( self._port.port_name))
def test_contained_in(self): self.assertTrue( DeviceType.from_string('iPhone 6s') in DeviceType.from_string( 'iPhone')) self.assertFalse( DeviceType.from_string('iPhone') in DeviceType.from_string( 'iPhone 6s')) self.assertTrue( DeviceType.from_string('iPhone', Version(11, 1)) in DeviceType.from_string('iPhone', Version(11))) self.assertFalse( DeviceType.from_string('iPhone', Version(11)) in DeviceType.from_string('iPhone', Version(11, 1)))
def device_count_for_type(device_type, host=SystemHost(), use_booted_simulator=True, **kwargs): if not host.platform.is_mac(): return 0 if SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.is_booted_or_booting(), host=host) and use_booted_simulator: filter = lambda device: device.platform_device.is_booted_or_booting() and device.device_type in device_type return len(SimulatedDeviceManager.device_by_filter(filter, host=host)) for name in SimulatedDeviceManager._device_identifier_to_name.itervalues(): if DeviceType.from_string(name) in device_type: return SimulatedDeviceManager.max_supported_simulators(host) return 0
def test_existing_simulator(self): SimulatedDeviceTest.reset_simulated_device_manager() host = SimulatedDeviceTest.mock_host_for_simctl() SimulatedDeviceManager.available_devices(host) SimulatedDeviceManager.initialize_devices(DeviceRequest(DeviceType.from_string('iPhone', Version(11))), host=host) self.assertEquals(1, len(SimulatedDeviceManager.INITIALIZED_DEVICES)) self.assertEquals('34FB476C-6FA0-43C8-8945-1BD7A4EBF0DE', SimulatedDeviceManager.INITIALIZED_DEVICES[0].udid) self.assertEquals(SimulatedDevice.DeviceState.BOOTED, SimulatedDeviceManager.INITIALIZED_DEVICES[0].platform_device.state()) SimulatedDeviceManager.tear_down(host) self.assertIsNone(SimulatedDeviceManager.INITIALIZED_DEVICES)
def _create_devices(self, device_class): self._set_device_class(device_class) device_type = DeviceType.from_string(self._device_class, self.ios_version()) _log.debug('') _log.debug('creating devices for {}'.format(device_type)) request = DeviceRequest( device_type, use_booted_simulator=not self.get_option('dedicated_simulators', False), use_existing_simulator=False, allow_incomplete_match=True, ) SimulatedDeviceManager.initialize_devices([request] * self.child_processes(), self.host)
def test_from_string(self): self.assertEqual('iPhone 6s running iOS', str(DeviceType.from_string('iPhone 6s'))) self.assertEqual('iPhone 6 Plus running iOS', str(DeviceType.from_string('iPhone 6 Plus'))) self.assertEqual('iPhone running iOS 11', str(DeviceType.from_string('iPhone', Version(11)))) self.assertEqual('iPad Air 2 running iOS', str(DeviceType.from_string('iPad Air 2'))) self.assertEqual( 'Apple Watch Series 2 - 42mm running watchOS', str(DeviceType.from_string('Apple Watch Series 2 - 42mm'))) self.assertEqual('Apple TV 4K running tvOS', str(DeviceType.from_string('Apple TV 4K'))) self.assertEqual('Device running iOS', str(DeviceType.from_string(''))) self.assertEqual('Apple Watch running watchOS', str(DeviceType.from_string('Apple Watch')))
def test_uses_custom_device(self): class MockCustomDevicePort(TestPort): CUSTOM_DEVICE_TYPES = [DeviceType(hardware_family='iPad')] def __init__(self, host): super(MockCustomDevicePort, self).__init__(host) def get_manager(): host = MockHost() port = MockCustomDevicePort(host) manager = Manager(port, options=MockOptions( test_list=['fast/ipad/lasers.html'], http=True), printer=Mock()) return manager manager = get_manager() self.assertTrue( manager._custom_device_for_test('fast/ipad/lasers.html') == DeviceType(hardware_family='iPad'))
class WatchSimulatorPort(WatchPort): port_name = 'watchos-simulator' ARCHITECTURES = ['i386'] DEFAULT_ARCHITECTURE = 'i386' DEVICE_MANAGER = SimulatedDeviceManager DEFAULT_DEVICE_TYPE = DeviceType(hardware_family='Apple Watch', hardware_type='Series 3 - 42mm') SDK = apple_additions().get_sdk( 'watchsimulator') if apple_additions() else 'watchsimulator' def architecture(self): return self.DEFAULT_ARCHITECTURE # This supports the mapping of a port name such as watchos-simulator-5 to the construction of a port # using watchOS 5. @staticmethod def _version_from_name(name): if len(name.split('-')) > 2 and name.split('-')[2].isdigit(): return Version.from_string(name.split('-')[2]) return None @memoized def device_version(self): if self.get_option('version'): return Version.from_string(self.get_option('version')) return WatchSimulatorPort._version_from_name( self._name) or self.host.platform.xcode_sdk_version( 'watchsimulator') def environment_for_api_tests(self): inherited_env = super(WatchSimulatorPort, self).environment_for_api_tests() new_environment = {} SIMCTL_ENV_PREFIX = 'SIMCTL_CHILD_' for value in inherited_env: if not value.startswith(SIMCTL_ENV_PREFIX): new_environment[SIMCTL_ENV_PREFIX + value] = inherited_env[value] else: new_environment[value] = inherited_env[value] return new_environment def operating_system(self): return 'watchos-simulator' def setup_environ_for_server(self, server_name=None): _log.debug('Setting up environment for server on {}'.format( self.operating_system())) env = super(WatchSimulatorPort, self).setup_environ_for_server(server_name) if server_name == self.driver_name() and self.get_option('leaks'): env['MallocStackLogging'] = '1' env['__XPC_MallocStackLogging'] = '1' env['MallocScribble'] = '1' env['__XPC_MallocScribble'] = '1' return env def reset_preferences(self): SimulatedDeviceManager.tear_down(self.host) def nm_command(self): return self.xcrun_find('nm') @property @memoized def developer_dir(self): return self._executive.run_command(['xcode-select', '--print-path']).rstrip() def logging_patterns_to_strip(self): return [] def stderr_patterns_to_strip(self): return []
def test_max_child_processes(self): port = self.make_port() self.assertEqual( port.max_child_processes(DeviceType.from_string('Apple Watch')), 0)
def test_comparison_lower_case(self): self.assertEqual(DeviceType.from_string('iphone X'), DeviceType.from_string('iPhone')) self.assertEqual(DeviceType.from_string('iphone'), DeviceType.from_string('iPhone X')) self.assertEqual(DeviceType.from_string('iPhone X'), DeviceType.from_string('iphone')) self.assertEqual(DeviceType.from_string('iPhone'), DeviceType.from_string('iphone X')) self.assertEqual(DeviceType.from_string('iphone X'), DeviceType.from_string('iphone')) self.assertEqual(DeviceType.from_string('iphone'), DeviceType.from_string('iphone X')) self.assertTrue( DeviceType.from_string('iphone 6s') in DeviceType.from_string( 'iPhone')) self.assertTrue( DeviceType.from_string('iPhone 6s') in DeviceType.from_string( 'iphone')) self.assertTrue( DeviceType.from_string('iphone 6s') in DeviceType.from_string( 'iphone'))
def test_unmapped_version(self): self.assertEqual('iPhone running iOS', str(DeviceType.from_string('iPhone', Version(9))))
def booted_ios_devices_filter(device): if not device.platform_device.is_booted_or_booting(): return False return device.platform_device.device_type in DeviceType(software_variant='iOS', software_version=self.ios_version())
class IOSPort(DevicePort): port_name = "ios" CURRENT_VERSION = Version(12) DEVICE_TYPE = DeviceType(software_variant='iOS') def __init__(self, host, port_name, **kwargs): super(IOSPort, self).__init__(host, port_name, **kwargs) self._test_runner_process_constructor = SimulatorProcess self._printing_cmd_line = False def version_name(self): if self._os_version is None: return None return VersionNameMap.map(self.host.platform).to_name(self._os_version, platform=IOSPort.port_name) def default_baseline_search_path(self, device_type=None): wk_string = 'wk1' if self.get_option('webkit_test_runner'): wk_string = 'wk2' versions_to_fallback = [] if self.device_version().major == self.CURRENT_VERSION.major: versions_to_fallback = [self.CURRENT_VERSION] elif self.device_version(): temp_version = Version(self.device_version().major) while temp_version != self.CURRENT_VERSION: versions_to_fallback.append(Version.from_iterable(temp_version)) if temp_version < self.CURRENT_VERSION: temp_version.major += 1 else: temp_version.major -= 1 runtime_type = 'simulator' if 'simulator' in self.SDK else 'device' hardware_family = device_type.hardware_family.lower() if device_type and device_type.hardware_family else None hardware_type = device_type.hardware_type.lower() if device_type and device_type.hardware_type else None base_variants = [] if hardware_family and hardware_type: base_variants.append('{}-{}-{}'.format(hardware_family, hardware_type, runtime_type)) if hardware_family: base_variants.append('{}-{}'.format(hardware_family, runtime_type)) base_variants.append('{}-{}'.format(IOSPort.port_name, runtime_type)) if hardware_family and hardware_type: base_variants.append('{}-{}'.format(hardware_family, hardware_type)) if hardware_family: base_variants.append(hardware_family) base_variants.append(IOSPort.port_name) expectations = [] for variant in base_variants: for version in versions_to_fallback: apple_name = None if apple_additions(): apple_name = VersionNameMap.map(self.host.platform).to_name(version, platform=IOSPort.port_name, table=INTERNAL_TABLE) if apple_name: expectations.append(self._apple_baseline_path('{}-{}-{}'.format(variant, apple_name.lower().replace(' ', ''), wk_string))) expectations.append(self._webkit_baseline_path('{}-{}-{}'.format(variant, version.major, wk_string))) if apple_name: expectations.append(self._apple_baseline_path('{}-{}'.format(variant, apple_name.lower().replace(' ', '')))) expectations.append(self._webkit_baseline_path('{}-{}'.format(variant, version.major))) if apple_additions(): expectations.append(self._apple_baseline_path('{}-{}'.format(variant, wk_string))) expectations.append(self._webkit_baseline_path('{}-{}'.format(variant, wk_string))) if apple_additions(): expectations.append(self._apple_baseline_path(variant)) expectations.append(self._webkit_baseline_path(variant)) if self.get_option('webkit_test_runner'): expectations.append(self._webkit_baseline_path('wk2')) return expectations def test_expectations_file_position(self): return 5
def test_available_devices(self): SimulatedDeviceTest.reset_simulated_device_manager() host = SimulatedDeviceTest.mock_host_for_simctl() SimulatedDeviceManager.available_devices(host) # There should only be 1 iPhone X, iPhone 8 and iPhone SE self.assertEquals( 1, len( SimulatedDeviceManager.device_by_filter( lambda device: device.device_type == DeviceType. from_string('iPhone X'), host))) self.assertEquals( 1, len( SimulatedDeviceManager.device_by_filter( lambda device: device.device_type == DeviceType. from_string('iPhone 8'), host))) # There should be 2 5s and 6s self.assertEquals( 2, len( SimulatedDeviceManager.device_by_filter( lambda device: device.device_type == DeviceType. from_string('iPhone 5s'), host))) self.assertEquals( 2, len( SimulatedDeviceManager.device_by_filter( lambda device: device.device_type == DeviceType. from_string('iPhone 6s'), host))) # 19 iPhones self.assertEquals( 19, len( SimulatedDeviceManager.device_by_filter( lambda device: device.device_type == DeviceType. from_string('iPhone'), host))) # 11 iPads self.assertEquals( 11, len( SimulatedDeviceManager.device_by_filter( lambda device: device.device_type == DeviceType. from_string('iPad'), host))) # 18 Apple watches self.assertEquals( 6, len( SimulatedDeviceManager.device_by_filter( lambda device: device.device_type == DeviceType. from_string('Apple Watch'), host))) # 3 Apple TVs self.assertEquals( 3, len( SimulatedDeviceManager.device_by_filter( lambda device: device.device_type == DeviceType. from_string('Apple TV'), host))) # 18 devices running iOS 11.0 self.assertEquals( 18, len( SimulatedDeviceManager.device_by_filter( lambda device: device.device_type == DeviceType( software_variant='iOS', software_version=Version(11, 0, 1)), host))) # 11 iPhones running iOS 11.0 self.assertEquals( 11, len( SimulatedDeviceManager.device_by_filter( lambda device: device.device_type == DeviceType( hardware_family='iPhone', software_version=Version(11, 0, 1)), host))) # 1 device running iOS 12 self.assertEquals( 1, len( SimulatedDeviceManager.device_by_filter( lambda device: device.device_type == DeviceType( software_variant='iOS', software_version=Version(12, 0, 0)), host)))