Module: Cukunity::Android::KeyboardInput
- Extended by:
- Utils, KeyboardInputMethods
- Defined in:
- lib/cukunity/drivers/android/keycodes.rb,
lib/cukunity/drivers/android/keyboard_input.rb
Defined Under Namespace
Modules: KeyCodes
Class Method Summary
collapse
Methods included from Utils
adb, launchable_activity_name, monkey, package_name, shell
Methods included from Utils
#check_timeout, #merge_options, #restrict_options, #to_options, #wait_connectivity
open
Class Method Details
.choose_method(method2, options = {}) ⇒ Object
100
101
102
103
104
105
106
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 100
def self.choose_method(method2, options = {})
while not method?(method2)
press_key('Sym', options)
dpad_down(options)
dpad_center(options)
end
end
|
.dpad_center(options = {}) ⇒ Object
73
74
75
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 73
def self.dpad_center(options = {})
press_key('DPad Center', options)
end
|
.dpad_down(options = {}) ⇒ Object
61
62
63
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 61
def self.dpad_down(options = {})
press_key('DPad Down', options)
end
|
.dpad_left(options = {}) ⇒ Object
65
66
67
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 65
def self.dpad_left(options = {})
press_key('DPad Left', options)
end
|
.dpad_right(options = {}) ⇒ Object
69
70
71
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 69
def self.dpad_right(options = {})
press_key('DPad Right', options)
end
|
.dpad_up(options = {}) ⇒ Object
57
58
59
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 57
def self.dpad_up(options = {})
press_key('DPad Up', options)
end
|
.key_down(code, options = {}) ⇒ Object
25
26
27
28
29
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 25
def self.key_down(code, options = {})
keyboard_command(options) do
"key down #{keycode(code)}"
end
end
|
.key_up(code, options = {}) ⇒ Object
31
32
33
34
35
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 31
def self.key_up(code, options = {})
keyboard_command(options) do
"key up #{keycode(code)}"
end
end
|
.method ⇒ Object
85
86
87
88
89
90
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 85
def self.method
shell('dumpsys input_method').match(/\smCurId=(\S+)\s/) do |m|
return m[1]
end
nil
end
|
.method?(method2) ⇒ Boolean
92
93
94
95
96
97
98
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 92
def self.method?(method2)
if method2.kind_of? Regexp
method.match(method2)
else
method.downcase == method2.downcase
end
end
|
.methods ⇒ Object
81
82
83
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 81
def self.methods
shell('dumpsys input_method').scan(/\smId=(\S+)\s/).flatten
end
|
.press_back(options = {}) ⇒ Object
41
42
43
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 41
def self.press_back(options = {})
press_key('Back', options)
end
|
.press_delete(options = {}) ⇒ Object
53
54
55
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 53
def self.press_delete(options = {})
press_key('Del', options)
end
|
.press_done(options = {}) ⇒ Object
37
38
39
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 37
def self.press_done(options = {})
press_back(options)
end
|
.press_enter(options = {}) ⇒ Object
45
46
47
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 45
def self.press_enter(options = {})
press_key('Enter', options)
end
|
.press_key(code, options = {}) ⇒ Object
19
20
21
22
23
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 19
def self.press_key(code, options = {})
keyboard_command(options) do
"press #{keycode(code)}"
end
end
|
.press_space(options = {}) ⇒ Object
49
50
51
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 49
def self.press_space(options = {})
press_key('Space', options)
end
|
.show_symbols ⇒ Object
77
78
79
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 77
def self.show_symbols
press_key('PictSymbols', options)
end
|
.type_text(text, options = {}) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/cukunity/drivers/android/keyboard_input.rb', line 7
def self.type_text(text, options = {})
text.to_s.scan(/[^ ]+| /) do |tokens|
if tokens == ' '
press_space
else
keyboard_command(options) do
%Q[type #{tokens}]
end
end
end
end
|