class RunLoop::PhysicalDevice::IOSDeviceManager
Constants
- DEFAULTS
- NOT_INSTALLED_EXIT_CODE
Public Class Methods
executable_path()
click to toggle source
Path to tool.
# File lib/run_loop/physical_device/ios_device_manager.rb, line 25 def self.executable_path RunLoop::DeviceAgent::IOSDeviceManager.ios_device_manager end
new(device)
click to toggle source
Calls superclass method
RunLoop::PhysicalDevice::LifeCycle::new
# File lib/run_loop/physical_device/ios_device_manager.rb, line 29 def initialize(device) super(device) # Expands the Frameworks.zip if necessary. RunLoop::DeviceAgent::Frameworks.instance.install end
tool_is_installed?()
click to toggle source
Is the tool installed?
# File lib/run_loop/physical_device/ios_device_manager.rb, line 20 def self.tool_is_installed? File.exist?(IOSDeviceManager.executable_path) end
Public Instance Methods
app_installed?(app)
click to toggle source
# File lib/run_loop/physical_device/ios_device_manager.rb, line 53 def app_installed?(app) bundle_id = app if is_ipa?(app) || is_app?(app) bundle_id = app.bundle_identifier end args = [ IOSDeviceManager.executable_path, "is-installed", bundle_id, "-d", device.udid ] options = { :log_cmd => true } hash = run_shell_command(args, options) exit_status = hash[:exit_status] if exit_status != 0 && exit_status != NOT_INSTALLED_EXIT_CODE raise_error_on_failure( RuntimeError, "Encountered an error checking if app is installed on device", app, device, hash ) else RunLoop::log_debug("Took #{hash[:seconds_elapsed]} seconds to check " + "app was installed") hash[:exit_status] == 0 end end
can_reset_app_sandbox?()
click to toggle source
# File lib/run_loop/physical_device/ios_device_manager.rb, line 116 def can_reset_app_sandbox? true end
ensure_newest_installed(app_or_ipa)
click to toggle source
# File lib/run_loop/physical_device/ios_device_manager.rb, line 88 def ensure_newest_installed(app_or_ipa) install_app_internal(app_or_ipa) end
install_app(app_or_ipa)
click to toggle source
# File lib/run_loop/physical_device/ios_device_manager.rb, line 84 def install_app(app_or_ipa) install_app_internal(app_or_ipa, ["--force"]) end
raise_error_on_failure(error_klass, message, app, device, hash)
click to toggle source
# File lib/run_loop/physical_device/ios_device_manager.rb, line 36 def raise_error_on_failure(error_klass, message, app, device, hash) if hash[:exit_status] == 0 true else raise error_klass, %Q[ #{message} app: #{app} device: #{device} exit status: #{hash[:exit_status]} #{hash[:out]} ] end end
reset_app_sandbox(app_or_ipa)
click to toggle source
# File lib/run_loop/physical_device/ios_device_manager.rb, line 120 def reset_app_sandbox(app_or_ipa) args = [IOSDeviceManager.executable_path, "clear-app-data", app_or_ipa.path, device.udid] options = { :log_cmd => true } hash = run_shell_command(args, options) raise_error_on_failure( ResetAppSandboxError, "Could not clear app data", app_or_ipa, device, hash ) hash[:out] end
uninstall_app(app_or_ipa)
click to toggle source
# File lib/run_loop/physical_device/ios_device_manager.rb, line 92 def uninstall_app(app_or_ipa) bundle_identifier = app_or_ipa.bundle_identifier if !app_installed?(bundle_identifier) return :was_not_installed end args = [ IOSDeviceManager.executable_path, "uninstall", bundle_identifier, "-d", device.udid ] options = { :log_cmd => true } hash = run_shell_command(args, options) raise_error_on_failure( UninstallError, "Could not remove app from device", app_or_ipa, device, hash ) hash[:out] end
Private Instance Methods
install_app_internal(app_or_ipa, additional_args=[])
click to toggle source
Private Methods
# File lib/run_loop/physical_device/ios_device_manager.rb, line 144 def install_app_internal(app_or_ipa, additional_args=[]) args = [ IOSDeviceManager.executable_path, "install", app_or_ipa.path, "-d", device.udid ] args = args + additional_args code_sign_identity = RunLoop::Environment.code_sign_identity if code_sign_identity args = args + ["-c", code_sign_identity] end provisioning_profile = RunLoop::Environment.provisioning_profile if provisioning_profile args = args + ["-p", provisioning_profile] end options = { :log_cmd => true, timeout: DEFAULTS[:install_timeout] } hash = run_shell_command(args, options) raise_error_on_failure( InstallError, "Could not install app on device", app_or_ipa, device, hash ) RunLoop::log_debug("Took #{hash[:seconds_elapsed]} seconds to install app") hash[:out] end