Sha256: a011966cbfb60b80edbb371253f450c6785bd8cdbc256f07268039fd9789dafa

Contents?: true

Size: 1.49 KB

Versions: 28

Compression:

Stored size: 1.49 KB

Contents

module Appium
  module Core
    class Base
      module Device
        module KeyEvent
          # Only for Selendroid
          def keyevent(key, metastate = nil)
            args             = { keycode: key }
            args[:metastate] = metastate if metastate
            execute :keyevent, {}, args
          end

          def press_keycode(key, metastate: [], flags: [])
            raise ArgumentError, 'flags should be Array' unless flags.is_a? Array
            raise ArgumentError, 'metastates should be Array' unless metastate.is_a? Array

            args             = { keycode: key }
            args[:metastate] = metastate.reduce(0) { |acc, meta| acc | meta } unless metastate.empty?
            args[:flags]     = flags.reduce(0) { |acc, flag| acc | flag } unless flags.empty?

            execute :press_keycode, {}, args
          end

          def long_press_keycode(key, metastate: [], flags: [])
            raise ArgumentError, 'flags should be Array' unless flags.is_a? Array
            raise ArgumentError, 'metastates should be Array' unless metastate.is_a? Array

            args             = { keycode: key }
            args[:metastate] = metastate.reduce(0) { |acc, meta| acc | meta } unless metastate.empty?
            args[:flags]     = flags.reduce(0) { |acc, flag| acc | flag } unless flags.empty?

            execute :long_press_keycode, {}, args
          end
        end # module KeyEvent
      end # module Device
    end # class Base
  end # module Core
end # module Appium

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
appium_lib_core-3.0.2 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-3.0.1 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-3.0.0 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.3.4 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.3.3 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.3.2 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.3.1 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.3.0 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.2.2 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.2.1 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.2.0 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.1.1 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.1.0 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.0.6 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.0.5 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.0.4 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.0.3 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.0.2 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.0.1 lib/appium_lib_core/common/device/keyevent.rb
appium_lib_core-2.0.0 lib/appium_lib_core/common/device/keyevent.rb