Module: Appium::Android::Device::Emulator
- Defined in:
- lib/appium_lib_core/android/device/emulator.rb
Constant Summary collapse
- GSM_CALL_ACTIONS =
[:call, :accept, :cancel, :hold].freeze
- GSM_VOICE_STATES =
[:on, :off, :denied, :searching, :roaming, :home, :unregistered].freeze
- GSM_SIGNALS =
{ none_or_unknown: 0, poor: 1, moderate: 2, good: 3, great: 4 }.freeze
- NET_SPEED =
:gsm // GSM/CSD (up: 14.4, down: 14.4). :scsd // HSCSD (up: 14.4, down: 57.6). :gprs // GPRS (up: 28.8, down: 57.6). :edge // EDGE/EGPRS (up: 473.6, down: 473.6). :umts // UMTS/3G (up: 384.0, down: 384.0). :hsdpa // HSDPA (up: 5760.0, down: 13,980.0). :lte // LTE (up: 58,000, down: 173,000). :evdo // EVDO (up: 75,000, down: 280,000). :full // No limit, the default (up: 0.0, down: 0.0).
[:gsm, :scsd, :gprs, :edge, :umts, :hsdpa, :lte, :evdo, :full].freeze
- POWER_AC_STATE =
[:on, :off].freeze
Class Method Summary collapse
-
.emulator_commands ⇒ Object
self.emulator_commands.
Instance Method Summary collapse
-
#gsm_call(phone_number: , action: ) ⇒ Object
Emulate GSM call event on the connected emulator.
-
#gsm_signal(signal_strength) ⇒ Object
Emulate GSM signal strength change event on the connected emulator.
-
#gsm_voice(state) ⇒ Object
Emulate GSM voice event on the connected emulator.
-
#send_sms(phone_number: , message: ) ⇒ Object
Emulate send SMS event on the connected emulator.
-
#set_network_speed(netspeed) ⇒ Object
Emulate network speed change event on the connected emulator.
-
#set_power_ac(state) ⇒ Object
Emulate power state change on the connected emulator.
-
#set_power_capacity(percent) ⇒ Object
Emulate power capacity change on the connected emulator.
Class Method Details
.emulator_commands ⇒ Object
self.emulator_commands
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/appium_lib_core/android/device/emulator.rb', line 100 def self.emulator_commands Appium::Core::Device.add_endpoint_method(:send_sms) do def send_sms(phone_number:, message:) execute(:send_sms, {}, { phoneNumber: phone_number, 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 "action: should be member of #{GSM_CALL_ACTIONS}. Not #{action}." end execute(:gsm_call, {}, { phoneNumber: phone_number, action: action }) end end Appium::Core::Device.add_endpoint_method(:gsm_signal) do def gsm_signal(signal_strength) raise "#{signal_strength} should be member of #{GSM_SIGNALS} " if GSM_SIGNALS[signal_strength.to_sym].nil? execute(:gsm_signal, {}, { signalStrengh: 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 "The state should be member of #{GSM_VOICE_STATES}. Not #{state}." end execute(:gsm_voice, {}, { 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 "The netspeed should be member of #{NET_SPEED}. Not #{netspeed}." end execute(:set_network_speed, {}, { netspeed: netspeed }) end end Appium::Core::Device.add_endpoint_method(:set_power_capacity) do def set_power_capacity(percent) unless (0..100).member? percent raise "The percent should be between 0 and 100. Not #{percent}." end execute(:set_power_capacity, {}, { 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 "The state should be member of #{POWER_AC_STATE}. Not #{state}." end execute(:set_power_ac, {}, { state: state }) end end end |
Instance Method Details
#gsm_call(phone_number: , action: ) ⇒ Object
Emulate GSM call event on the connected emulator.
|
|
# File 'lib/appium_lib_core/android/device/emulator.rb', line 35
|
#gsm_signal(signal_strength) ⇒ Object
Emulate GSM signal strength change event on the connected emulator.
|
|
# File 'lib/appium_lib_core/android/device/emulator.rb', line 46
|
#gsm_voice(state) ⇒ Object
Emulate GSM voice event on the connected emulator.
|
|
# File 'lib/appium_lib_core/android/device/emulator.rb', line 56
|
#send_sms(phone_number: , message: ) ⇒ Object
Emulate send SMS event on the connected emulator.
|
|
# File 'lib/appium_lib_core/android/device/emulator.rb', line 24
|
#set_network_speed(netspeed) ⇒ Object
Emulate network speed change event on the connected emulator.
|
|
# File 'lib/appium_lib_core/android/device/emulator.rb', line 66
|
#set_power_ac(state) ⇒ Object
Emulate power state change on the connected emulator.
|
|
# File 'lib/appium_lib_core/android/device/emulator.rb', line 86
|
#set_power_capacity(percent) ⇒ Object
Emulate power capacity change on the connected emulator.
|
|
# File 'lib/appium_lib_core/android/device/emulator.rb', line 76
|