Example #1
0
    def _create_devices(self, device_class):
        mac_os_version = self.host.platform.os_version

        self._set_device_class(device_class)

        _log.debug('')
        _log.debug('setup_test_run for %s', self._device_class)

        self._create_simulators()

        if not self._using_dedicated_simulators():
            return

        for i in xrange(self.child_processes()):
            device_udid = Simulator.managed_devices[i].udid
            _log.debug('testing device %s has udid %s', i, device_udid)

            # FIXME: <rdar://problem/20916140> Switch to using CoreSimulator.framework for launching and quitting iOS Simulator
            self._executive.run_command([
                'open', '-g', '-b', self.SIMULATOR_BUNDLE_ID + str(i),
                '--args', '-CurrentDeviceUDID', device_udid])

            if mac_os_version in ['elcapitan', 'yosemite', 'mavericks']:
                time.sleep(2.5)

        _log.info('Waiting for all iOS Simulators to finish booting.')
        for i in xrange(self.child_processes()):
            Simulator.wait_until_device_is_booted(Simulator.managed_devices[i].udid)

        IOSSimulatorPort._DEVICE_MAP = {}
        for i in xrange(self.child_processes()):
            IOSSimulatorPort._DEVICE_MAP[i] = Device(Simulator.managed_devices[i])
Example #2
0
    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
Example #3
0
    def __init__(self, host, port_name, **kwargs):
        super(IOSSimulatorPort, self).__init__(host, port_name, **kwargs)

        optional_device_class = self.get_option('device_class')
        self._device_class = optional_device_class if optional_device_class else self.DEFAULT_DEVICE_CLASS
        _log.debug('IOSSimulatorPort _device_class is %s', self._device_class)

        if not IOSSimulatorPort._CURRENT_DEVICE:
            try:
                IOSSimulatorPort._CURRENT_DEVICE = Device(Simulator(host).current_device())
            except ScriptError:
                # Failure to find a current device should not result in an exception being thrown
                IOSSimulatorPort._CURRENT_DEVICE = Device(None)
        self._current_device = IOSSimulatorPort._CURRENT_DEVICE
        if not self._current_device:
            self.set_option('dedicated_simulators', True)
        if not self.get_option('dedicated_simulators'):
            if self.get_option('child_processes') > 1:
                _log.warn('Cannot have more than one child process when using a running simulator.  Setting child_processes to 1.')
            self.set_option('child_processes', 1)