module Appium::Core::Android::Device::Emulator
def self.add_methods
def self.add_methods ::Appium::Core::Device.add_endpoint_method(:send_sms) do def send_sms(phone_number:, message:) execute_script 'mobile:sendSms', { phoneNumber: phone_number, message: message } end end ::Appium::Core::Device.add_endpoint_method(:gsm_call) do def gsm_call(phone_number:, action:) unless GSM_CALL_ACTIONS.member? action.to_sym raise ::Appium::Core::Error::ArgumentError, "action: should be member of #{GSM_CALL_ACTIONS}. Not #{action}." end execute_script 'mobile:gsmCall', { phoneNumber: phone_number, action: action } end end ::Appium::Core::Device.add_endpoint_method(:gsm_signal) do def gsm_signal(signal_strength) if GSM_SIGNALS[signal_strength.to_sym].nil? raise ::Appium::Core::Error::ArgumentError, "#{signal_strength} should be member of #{GSM_SIGNALS.keys} " end execute_script 'mobile:gsmSignal', { strength: GSM_SIGNALS[signal_strength] } end end ::Appium::Core::Device.add_endpoint_method(:gsm_voice) do def gsm_voice(state) unless GSM_VOICE_STATES.member? state.to_sym raise ::Appium::Core::Error::ArgumentError, "The state should be member of #{GSM_VOICE_STATES}. Not #{state}." end execute_script 'mobile:gsmVoice', { state: state } end end ::Appium::Core::Device.add_endpoint_method(:set_network_speed) do def set_network_speed(netspeed) unless NET_SPEED.member? netspeed.to_sym raise ::Appium::Core::Error::ArgumentError, "The netspeed should be member of #{NET_SPEED}. Not #{netspeed}." end execute_script 'mobile:networkSpeed', { speed: netspeed } end end ::Appium::Core::Device.add_endpoint_method(:set_power_capacity) do def set_power_capacity(percent) unless (0..100).member? percent ::Appium::Logger.warn "The percent should be between 0 and 100. Not #{percent}." end execute_script 'mobile:powerCapacity', { percent: percent } end end ::Appium::Core::Device.add_endpoint_method(:set_power_ac) do def set_power_ac(state) unless POWER_AC_STATE.member? state.to_sym raise ::Appium::Core::Error::ArgumentError, "The state should be member of #{POWER_AC_STATE}. Not #{state}." end execute_script 'mobile:powerAc', { state: state } end end end # def self.emulator_commands
def gsm_call(phone_number:, action:)
def gsm_call(phone_number:, action:) unless GSM_CALL_ACTIONS.member? action.to_sym raise ::Appium::Core::Error::ArgumentError, "action: should be member of #{GSM_CALL_ACTIONS}. Not #{action}." end execute_script 'mobile:gsmCall', { phoneNumber: phone_number, action: action } end
def gsm_signal(signal_strength)
def gsm_signal(signal_strength) if GSM_SIGNALS[signal_strength.to_sym].nil? raise ::Appium::Core::Error::ArgumentError, "#{signal_strength} should be member of #{GSM_SIGNALS.keys} " end execute_script 'mobile:gsmSignal', { strength: GSM_SIGNALS[signal_strength] } end
def gsm_voice(state)
def gsm_voice(state) unless GSM_VOICE_STATES.member? state.to_sym raise ::Appium::Core::Error::ArgumentError, "The state should be member of #{GSM_VOICE_STATES}. Not #{state}." end execute_script 'mobile:gsmVoice', { state: state } end
def send_sms(phone_number:, message:)
def send_sms(phone_number:, message:) execute_script 'mobile:sendSms', { phoneNumber: phone_number, message: message } end
def set_network_speed(netspeed)
def set_network_speed(netspeed) unless NET_SPEED.member? netspeed.to_sym raise ::Appium::Core::Error::ArgumentError, "The netspeed should be member of #{NET_SPEED}. Not #{netspeed}." end execute_script 'mobile:networkSpeed', { speed: netspeed } end
def set_power_ac(state)
def set_power_ac(state) unless POWER_AC_STATE.member? state.to_sym raise ::Appium::Core::Error::ArgumentError, "The state should be member of #{POWER_AC_STATE}. Not #{state}." end execute_script 'mobile:powerAc', { state: state } end
def set_power_capacity(percent)
def set_power_capacity(percent) unless (0..100).member? percent ::Appium::Logger.warn "The percent should be between 0 and 100. Not #{percent}." end execute_script 'mobile:powerCapacity', { percent: percent } end