def _create_simulators(self): if (self.default_child_processes() < self.child_processes()): _log.warn( "You have specified very high value({0}) for --child-processes" .format(self.child_processes())) _log.warn( "maximum child-processes which can be supported on this system are: {0}" .format(self.default_child_processes())) _log.warn("This is very likely to fail.") if self._using_dedicated_simulators(): self._createSimulatorApps() for i in xrange(self.child_processes()): self._create_device(i) for i in xrange(self.child_processes()): device_udid = self._testing_device(i).udid Simulator.wait_until_device_is_in_state( device_udid, Simulator.DeviceState.SHUTDOWN) Simulator.reset_device(device_udid) else: assert (self._current_device) if self._current_device.name != self.simulator_device_type().name: _log.warn("Expected simulator of type '" + self.simulator_device_type().name + "' but found simulator of type '" + self._current_device.name + "'") _log.warn( 'The next block of tests may fail due to device mis-match')
def reset_preferences(self): # We assume that if testing_device is booted that it was booted by the iOS Simulator app # (as opposed to simctl). So, quit the iOS Simulator app to shutdown testing_device. self._quit_ios_simulator() Simulator.wait_until_device_is_in_state(self.testing_device.udid, Simulator.DeviceState.SHUTDOWN) data_path = os.path.join(self.testing_device.path, 'data') if os.path.isdir(data_path): shutil.rmtree(data_path)
def reset_preferences(self): # We assume that if testing_device is booted that it was booted by the iOS Simulator app # (as opposed to simctl). So, quit the iOS Simulator app to shutdown testing_device. self._quit_ios_simulator() Simulator.wait_until_device_is_in_state(self.testing_device.udid, Simulator.DeviceState.SHUTDOWN) data_path = os.path.join(self.testing_device.path, 'data') if os.path.isdir(data_path): shutil.rmtree(data_path)
def setup_test_run(self): device_udid = self.testing_device.udid self._executive.run_command([ 'open', '-a', os.path.join(self.developer_dir, 'Applications', 'iOS Simulator.app'), '--args', '-CurrentDeviceUDID', device_udid]) Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.BOOTED) # FIXME: Pause here until SpringBoard finishes launching to workaround <rdar://problem/20000383>. boot_delay = 30 _log.debug('Waiting {seconds} seconds for iOS Simulator to finish booting ...'.format(seconds=boot_delay)) time.sleep(boot_delay)
def setup_test_run(self): device_udid = self.testing_device.udid # FIXME: <rdar://problem/20916140> Switch to using CoreSimulator.framework for launching and quitting iOS Simulator self._executive.run_command([ 'open', '-b', 'com.apple.iphonesimulator', '--args', '-CurrentDeviceUDID', device_udid]) Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.BOOTED) # FIXME: Pause here until SpringBoard finishes launching to workaround <rdar://problem/20000383>. boot_delay = 30 _log.debug('Waiting {seconds} seconds for iOS Simulator to finish booting ...'.format(seconds=boot_delay)) time.sleep(boot_delay)
def setup_test_run(self): device_udid = self.testing_device.udid # FIXME: <rdar://problem/20916140> Switch to using CoreSimulator.framework for launching and quitting iOS Simulator self._executive.run_command([ 'open', '-b', self.SIMULATOR_BUNDLE_ID, '--args', '-CurrentDeviceUDID', device_udid]) Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.BOOTED) # FIXME: Pause here until SpringBoard finishes launching to workaround <rdar://problem/20000383>. boot_delay = 30 _log.debug('Waiting {seconds} seconds for iOS Simulator to finish booting ...'.format(seconds=boot_delay)) time.sleep(boot_delay)
def shutdown(cls, udid): """ Shut down the given CoreSimulator device. :param udid: The udid of the device. :type udid: str """ device_state = Simulator.device_state(udid) if device_state == Simulator.DeviceState.BOOTING or device_state == Simulator.DeviceState.BOOTED: _log.debug('xcrun simctl shutdown %s', udid) # Don't throw on error. Device shutdown seems to be racy with Simulator app killing. subprocess.call(['xcrun', 'simctl', 'shutdown', udid]) Simulator.wait_until_device_is_in_state(udid, Simulator.DeviceState.SHUTDOWN)
def reset_preferences(self): if (self.default_child_processes() < self.child_processes()): _log.warn("You have specified very high value({0}) for --child-processes".format(self.child_processes())) _log.warn("maximum child-processes which can be supported on this system are: {0}".format(self.default_child_processes())) _log.warn("This is very likely to fail.") self._quit_ios_simulator() self._createSimulatorApps() for i in xrange(self.child_processes()): Simulator.wait_until_device_is_in_state(self.testing_device(i).udid, Simulator.DeviceState.SHUTDOWN) data_path = os.path.join(self.testing_device(i).path, 'data') if os.path.isdir(data_path): shutil.rmtree(data_path)
def _create_simulators(self): if (self.default_child_processes() < self.child_processes()): _log.warn("You have specified very high value({0}) for --child-processes".format(self.child_processes())) _log.warn("maximum child-processes which can be supported on this system are: {0}".format(self.default_child_processes())) _log.warn("This is very likely to fail.") self._createSimulatorApps() for i in xrange(self.child_processes()): self._create_device(i) for i in xrange(self.child_processes()): device_udid = self._testing_device(i).udid Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.SHUTDOWN) Simulator.reset_device(device_udid)
def _create_simulators(self): if (self.default_child_processes() < self.child_processes()): _log.warn("You have specified very high value({0}) for --child-processes".format(self.child_processes())) _log.warn("maximum child-processes which can be supported on this system are: {0}".format(self.default_child_processes())) _log.warn("This is very likely to fail.") self._createSimulatorApps() for i in xrange(self.child_processes()): self._create_device(i) for i in xrange(self.child_processes()): device_udid = self._testing_device(i).udid Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.SHUTDOWN) Simulator.reset_device(device_udid)
def check_sys_deps(self, needs_http): if not self.simulator_runtime.available: _log.error('The iOS Simulator runtime with identifier "{0}" cannot be used because it is unavailable.'.format(self.simulator_runtime.identifier)) return False testing_device = self.testing_device # May create a new simulator device # testing_device will fail to boot if it is already booted. We assume that if testing_device # is booted that it was booted by the iOS Simulator app (as opposed to simctl). So, quit the # iOS Simulator app to shutdown testing_device. self._executive.run_command(['osascript', '-e', 'tell application id "com.apple.iphonesimulator" to quit']) Simulator.wait_until_device_is_in_state(testing_device.udid, Simulator.DeviceState.SHUTDOWN) if not Simulator.check_simulator_device_and_erase_if_needed(self.host, testing_device.udid): _log.error('Unable to boot the simulator device with UDID {0}.'.format(testing_device.udid)) return False return super(IOSSimulatorPort, self).check_sys_deps(needs_http)
def setup_test_run(self): device_udid = self.testing_device.udid self._executive.run_command([ 'open', '-a', os.path.join(self.developer_dir, 'Applications', 'iOS Simulator.app'), '--args', '-CurrentDeviceUDID', device_udid ]) Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.BOOTED) # FIXME: Pause here until SpringBoard finishes launching to workaround <rdar://problem/20000383>. boot_delay = 30 _log.debug( 'Waiting {seconds} seconds for iOS Simulator to finish booting ...' .format(seconds=boot_delay)) time.sleep(boot_delay)
def create(cls, name, device_type, runtime): """ Create a new CoreSimulator device. :param name: The name of the device. :type name: str :param device_type: The CoreSimulatort device type. :type device_type: DeviceType :param runtime: The CoreSimualtor runtime. :type runtime: Runtime :return: The new device or raises a CalledProcessError if ``simctl create`` failed. :rtype: Device """ device_udid = subprocess.check_output([ 'xcrun', 'simctl', 'create', name, device_type.identifier, runtime.identifier ]).rstrip() _log.debug('"xcrun simctl create %s %s %s" returned %s', name, device_type.identifier, runtime.identifier, device_udid) Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.SHUTDOWN) return Simulator().find_device_by_udid(device_udid)
def _create_simulators(self): if (self.default_child_processes() < self.child_processes()): _log.warn("You have specified very high value({0}) for --child-processes".format(self.child_processes())) _log.warn("maximum child-processes which can be supported on this system are: {0}".format(self.default_child_processes())) _log.warn("This is very likely to fail.") if self._using_dedicated_simulators(): self._createSimulatorApps() for i in xrange(self.child_processes()): self._create_device(i) for i in xrange(self.child_processes()): device_udid = self._testing_device(i).udid Simulator.wait_until_device_is_in_state(device_udid, Simulator.DeviceState.SHUTDOWN) Simulator.reset_device(device_udid) else: assert(self._current_device) if self._current_device.name != self.simulator_device_type().name: _log.warn("Expected simulator of type '" + self.simulator_device_type().name + "' but found simulator of type '" + self._current_device.name + "'") _log.warn('The next block of tests may fail due to device mis-match')