Class: Acouchi::Solo

Inherits:
Object
  • Object
show all
Defined in:
lib/acouchi/solo.rb

Constant Summary collapse

82
LEFT =
21
RIGHT =
22

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Solo

Returns a new instance of Solo.



10
11
12
# File 'lib/acouchi/solo.rb', line 10

def initialize(configuration)
  @configuration = configuration
end

Instance Method Details

#all_contentObject



56
57
58
59
60
61
62
63
64
# File 'lib/acouchi/solo.rb', line 56

def all_content
  all_content = []
  until scroll_up == false; end
  begin
    all_content << text_views.map {|t| t["text"]}
  end while scroll_down
  all_content << text_views.map {|t| t["text"]}
  all_content.flatten.uniq
end

#buttonsObject



40
41
42
# File 'lib/acouchi/solo.rb', line 40

def buttons
  call_method("getCurrentButtons")
end

#clear_text(index = 0) ⇒ Object



22
23
24
# File 'lib/acouchi/solo.rb', line 22

def clear_text index=0
  call_method("clearEditText", [index])
end

#click_image(index) ⇒ Object



96
97
98
# File 'lib/acouchi/solo.rb', line 96

def click_image index
  call_method("clickOnImage", [index])
end

#click_menu_item(text, options = {}) ⇒ Object



78
79
80
81
82
83
84
85
86
# File 'lib/acouchi/solo.rb', line 78

def click_menu_item text, options={}
  options = {
    :sub_menu => true
  }.merge(options)
  call_method("clickOnMenuItem", [
    text,
    options[:sub_menu]
  ])
end

#click_text(text, options = {}) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/acouchi/solo.rb', line 66

def click_text text, options={}
  options = {
    :match => 1,
    :auto_scroll => true
  }.merge(options)
  call_method("clickOnText", [
    text,
    options[:match],
    options[:auto_scroll]
  ])
end

#click_view(id) ⇒ Object



92
93
94
# File 'lib/acouchi/solo.rb', line 92

def click_view id
  call_method("clickOnViewById", [id])
end

#contentObject



52
53
54
# File 'lib/acouchi/solo.rb', line 52

def content
  call_method("getCurrentContent")
end

#enter_text(text, index = 0) ⇒ Object



18
19
20
# File 'lib/acouchi/solo.rb', line 18

def enter_text text, index=0
  call_method("enterText", [index, text])
end

#go_backObject



124
125
126
# File 'lib/acouchi/solo.rb', line 124

def go_back
  call_method("goBack")
end

#has_button?(text) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/acouchi/solo.rb', line 44

def has_button? text
  buttons.any? { |b| b["text"] == text }
end

#has_text?(text, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/acouchi/solo.rb', line 26

def has_text? text, options={}
  options = {
    :scroll          => true,
    :minimum_matches => 0,
    :must_be_visible => true
  }.merge(options)
  call_method("searchText", [
    text,
    options[:minimum_matches],
    options[:scroll],
    options[:must_be_visible]
  ])
end

#scroll_downObject



104
105
106
# File 'lib/acouchi/solo.rb', line 104

def scroll_down
  call_method("scrollDown")
end

#scroll_down_list(index = 0) ⇒ Object



112
113
114
# File 'lib/acouchi/solo.rb', line 112

def scroll_down_list index=0
  call_method("scrollDownList", [index])
end

#scroll_to_leftObject



116
117
118
# File 'lib/acouchi/solo.rb', line 116

def scroll_to_left
  call_method("scrollToSide", [LEFT])
end

#scroll_to_rightObject



120
121
122
# File 'lib/acouchi/solo.rb', line 120

def scroll_to_right
  call_method("scrollToSide", [RIGHT])
end

#scroll_upObject



100
101
102
# File 'lib/acouchi/solo.rb', line 100

def scroll_up
  call_method("scrollUp")
end

#scroll_up_list(index = 0) ⇒ Object



108
109
110
# File 'lib/acouchi/solo.rb', line 108

def scroll_up_list index=0
  call_method("scrollUpList", [index])
end

#send_key(key) ⇒ Object



14
15
16
# File 'lib/acouchi/solo.rb', line 14

def send_key key
  call_method("sendKey", [key])
end

#text_viewsObject



48
49
50
# File 'lib/acouchi/solo.rb', line 48

def text_views
  call_method("getTextViews")
end

#viewsObject



88
89
90
# File 'lib/acouchi/solo.rb', line 88

def views
  call_method("getViews")
end

#wait_for_text(text, options = {}) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/acouchi/solo.rb', line 128

def wait_for_text text, options = {}
  options = {
    :minimum_number_of_matches => 0,
    :timeout                   => 20,
    :scroll                    => true,
    :must_be_visible           => true
  }.merge(options)
  call_method("waitForText", [
    text,
    options[:minimum_number_of_matches],
    options[:timeout],
    options[:scroll],
    options[:must_be_visible]
  ])
end