calabash 1.2.1 → 1.9.9.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +39 -0
- data/LICENSE +204 -21
- data/README.md +36 -6
- data/VERSIONING.md +16 -0
- data/bin/calabash +95 -0
- data/lib/calabash.rb +185 -1
- data/lib/calabash/android.rb +64 -0
- data/lib/calabash/android/adb.rb +277 -0
- data/lib/calabash/android/application.rb +110 -0
- data/lib/calabash/android/build.rb +12 -0
- data/lib/calabash/android/build/application.rb +13 -0
- data/lib/calabash/android/build/build_error.rb +11 -0
- data/lib/calabash/android/build/builder.rb +119 -0
- data/lib/calabash/android/build/java_keystore.rb +177 -0
- data/lib/calabash/android/build/resigner.rb +56 -0
- data/lib/calabash/android/build/test_server.rb +27 -0
- data/lib/calabash/android/console_helpers.rb +44 -0
- data/lib/calabash/android/cucumber.rb +3 -0
- data/lib/calabash/android/device.rb +965 -0
- data/lib/calabash/android/environment.rb +470 -0
- data/lib/calabash/android/gestures.rb +369 -0
- data/lib/calabash/android/interactions.rb +45 -0
- data/lib/calabash/android/lib/.irbrc +55 -0
- data/lib/calabash/android/lib/AndroidManifest.xml +51 -0
- data/lib/calabash/android/lib/TestServer.apk +0 -0
- data/lib/calabash/android/lib/calmd5/arm64-v8a/calmd5 +0 -0
- data/lib/calabash/android/lib/calmd5/arm64-v8a/calmd5-pie +0 -0
- data/lib/calabash/android/lib/calmd5/armeabi-v7a/calmd5 +0 -0
- data/lib/calabash/android/lib/calmd5/armeabi-v7a/calmd5-pie +0 -0
- data/lib/calabash/android/lib/calmd5/armeabi/calmd5 +0 -0
- data/lib/calabash/android/lib/calmd5/armeabi/calmd5-pie +0 -0
- data/lib/calabash/android/lib/calmd5/mips/calmd5 +0 -0
- data/lib/calabash/android/lib/calmd5/mips/calmd5-pie +0 -0
- data/lib/calabash/android/lib/calmd5/mips64/calmd5 +0 -0
- data/lib/calabash/android/lib/calmd5/mips64/calmd5-pie +0 -0
- data/lib/calabash/android/lib/calmd5/x86/calmd5 +0 -0
- data/lib/calabash/android/lib/calmd5/x86/calmd5-pie +0 -0
- data/lib/calabash/android/lib/calmd5/x86_64/calmd5 +0 -0
- data/lib/calabash/android/lib/calmd5/x86_64/calmd5-pie +0 -0
- data/lib/calabash/android/lib/screenshot_taker.jar +0 -0
- data/lib/calabash/android/life_cycle.rb +37 -0
- data/lib/calabash/android/orientation.rb +30 -0
- data/lib/calabash/android/physical_buttons.rb +39 -0
- data/lib/calabash/android/screenshot.rb +9 -0
- data/lib/calabash/android/scroll.rb +5 -0
- data/lib/calabash/android/server.rb +10 -0
- data/lib/calabash/android/text.rb +54 -0
- data/lib/calabash/application.rb +74 -0
- data/lib/calabash/cli.rb +12 -0
- data/lib/calabash/cli/build.rb +33 -0
- data/lib/calabash/cli/console.rb +90 -0
- data/lib/calabash/cli/generate.rb +110 -0
- data/lib/calabash/cli/helpers.rb +130 -0
- data/lib/calabash/cli/resign.rb +33 -0
- data/lib/calabash/cli/run.rb +99 -0
- data/lib/calabash/cli/setup_keystore.rb +39 -0
- data/lib/calabash/color.rb +32 -0
- data/lib/calabash/console_helpers.rb +90 -0
- data/lib/calabash/defaults.rb +56 -0
- data/lib/calabash/device.rb +401 -0
- data/lib/calabash/environment.rb +75 -0
- data/lib/calabash/gestures.rb +384 -0
- data/lib/calabash/http.rb +8 -0
- data/lib/calabash/http/error.rb +15 -0
- data/lib/calabash/http/request.rb +42 -0
- data/lib/calabash/http/retriable_client.rb +156 -0
- data/lib/calabash/interactions.rb +105 -0
- data/lib/calabash/ios.rb +37 -0
- data/lib/calabash/ios/application.rb +119 -0
- data/lib/calabash/ios/conditions.rb +79 -0
- data/lib/calabash/ios/console_helpers.rb +72 -0
- data/lib/calabash/ios/device.rb +24 -0
- data/lib/calabash/ios/device/device_implementation.rb +779 -0
- data/lib/calabash/ios/device/gestures_mixin.rb +167 -0
- data/lib/calabash/ios/device/keyboard_mixin.rb +133 -0
- data/lib/calabash/ios/device/physical_device_mixin.rb +266 -0
- data/lib/calabash/ios/device/rotation_mixin.rb +124 -0
- data/lib/calabash/ios/device/routes/backdoor_route_mixin.rb +86 -0
- data/lib/calabash/ios/device/routes/condition_route_mixin.rb +62 -0
- data/lib/calabash/ios/device/routes/error.rb +8 -0
- data/lib/calabash/ios/device/routes/handle_route_mixin.rb +102 -0
- data/lib/calabash/ios/device/routes/map_route_mixin.rb +38 -0
- data/lib/calabash/ios/device/routes/playback_route_mixin.rb +70 -0
- data/lib/calabash/ios/device/routes/response_parser.rb +48 -0
- data/lib/calabash/ios/device/routes/uia_route_mixin.rb +238 -0
- data/lib/calabash/ios/device/runtime_attributes.rb +184 -0
- data/lib/calabash/ios/device/status_bar_mixin.rb +17 -0
- data/lib/calabash/ios/device/text_mixin.rb +19 -0
- data/lib/calabash/ios/device/uia_keyboard_mixin.rb +188 -0
- data/lib/calabash/ios/device/uia_mixin.rb +12 -0
- data/lib/calabash/ios/environment.rb +41 -0
- data/lib/calabash/ios/interactions.rb +10 -0
- data/lib/calabash/ios/lib/.irbrc +55 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_down_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_down_iphone.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_left_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_left_iphone.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_right_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_right_iphone.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_up_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_left_home_up_iphone.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_down_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_down_iphone.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_left_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_left_iphone.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_right_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_right_iphone.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_up_ipad.base64 +2 -0
- data/lib/calabash/ios/lib/recordings/rotate_right_home_up_iphone.base64 +2 -0
- data/lib/calabash/ios/orientation.rb +117 -0
- data/lib/calabash/ios/scroll.rb +504 -0
- data/lib/calabash/ios/server.rb +73 -0
- data/lib/calabash/ios/text.rb +248 -0
- data/lib/calabash/ios/uia.rb +24 -0
- data/lib/calabash/lib/skeleton/config/cucumber.yml +6 -0
- data/lib/calabash/lib/skeleton/features/sample.feature +5 -0
- data/lib/calabash/lib/skeleton/features/step_definitions/calabash_steps.rb +29 -0
- data/lib/calabash/lib/skeleton/features/support/env.rb +54 -0
- data/lib/calabash/lib/skeleton/features/support/hooks.rb +83 -0
- data/lib/calabash/life_cycle.rb +111 -0
- data/lib/calabash/location.rb +51 -0
- data/lib/calabash/logger.rb +87 -0
- data/lib/calabash/orientation.rb +84 -0
- data/lib/calabash/page.rb +35 -0
- data/lib/calabash/patch.rb +14 -0
- data/lib/calabash/patch/array.rb +16 -0
- data/lib/calabash/patch/run_loop.rb +90 -0
- data/lib/calabash/query.rb +160 -0
- data/lib/calabash/query_result.rb +85 -0
- data/lib/calabash/screenshot.rb +89 -0
- data/lib/calabash/server.rb +16 -0
- data/lib/calabash/text.rb +76 -0
- data/lib/calabash/utility.rb +58 -0
- data/lib/calabash/version.rb +3 -1
- data/lib/calabash/wait.rb +474 -0
- metadata +462 -24
@@ -0,0 +1,369 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Calabash
|
4
|
+
module Android
|
5
|
+
module Gestures
|
6
|
+
class MultiTouchGesture
|
7
|
+
attr_reader :gestures
|
8
|
+
attr_accessor :timeout
|
9
|
+
|
10
|
+
def initialize(gestures = [])
|
11
|
+
unless gestures.is_a?(Array)
|
12
|
+
gestures = [gestures]
|
13
|
+
end
|
14
|
+
|
15
|
+
@gestures = gestures
|
16
|
+
@timeout = Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT
|
17
|
+
end
|
18
|
+
|
19
|
+
def +(gesture_collection)
|
20
|
+
MultiTouchGesture.new(@gestures + gesture_collection.gestures)
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_gesture
|
24
|
+
gestures = @gestures
|
25
|
+
MultiTouchGesture.new(gestures + gesture_collection.gestures)
|
26
|
+
end
|
27
|
+
|
28
|
+
def <<(gesture)
|
29
|
+
@gestures << gesture
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_touch(touch, index=0)
|
33
|
+
gestures = @gestures
|
34
|
+
gestures[index] << touch
|
35
|
+
MultiTouchGesture.new(gestures)
|
36
|
+
end
|
37
|
+
|
38
|
+
def add_touch!(touch, index=0)
|
39
|
+
@gestures = add_touch(touch, index).gestures
|
40
|
+
end
|
41
|
+
|
42
|
+
def merge(multi_touch_gesture)
|
43
|
+
MultiTouchGesture.new(gestures.map.with_index {|gesture, index| gesture + multi_touch_gesture.gestures[index]})
|
44
|
+
end
|
45
|
+
|
46
|
+
def merge!(multi_touch_gesture)
|
47
|
+
@gestures = merge(multi_touch_gesture).gestures
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_json(*object)
|
51
|
+
{
|
52
|
+
query_timeout: @timeout.to_f,
|
53
|
+
gestures: @gestures
|
54
|
+
}.to_json(*object)
|
55
|
+
end
|
56
|
+
|
57
|
+
def query=(query)
|
58
|
+
@gestures.each {|gesture| gesture.query=query}
|
59
|
+
end
|
60
|
+
|
61
|
+
def reset_query
|
62
|
+
@gestures.each {|gesture| gesture.reset_query}
|
63
|
+
end
|
64
|
+
|
65
|
+
def offset=(offset)
|
66
|
+
@gestures.each {|gesture| gesture.offset=offset}
|
67
|
+
end
|
68
|
+
|
69
|
+
def max_execution_time
|
70
|
+
(@gestures.map {|gesture| gesture.max_execution_time}).max
|
71
|
+
end
|
72
|
+
|
73
|
+
def queries
|
74
|
+
gestures.map(&:queries).flatten.uniq.reject(&:nil?)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class Gesture
|
79
|
+
attr_reader :touches
|
80
|
+
|
81
|
+
def initialize(touches = [], query = nil)
|
82
|
+
unless touches.is_a?(Array)
|
83
|
+
touches = [touches]
|
84
|
+
end
|
85
|
+
|
86
|
+
@touches = []
|
87
|
+
|
88
|
+
touches.each do |touch|
|
89
|
+
@touches << Touch.new(touch)
|
90
|
+
end
|
91
|
+
|
92
|
+
@query = query
|
93
|
+
end
|
94
|
+
|
95
|
+
def from(touch)
|
96
|
+
to(touch)
|
97
|
+
end
|
98
|
+
|
99
|
+
def to(touch)
|
100
|
+
if touch.is_a?(Hash)
|
101
|
+
touch = Touch.new(touch)
|
102
|
+
end
|
103
|
+
|
104
|
+
unless (last_touch = @touches.last).nil?
|
105
|
+
touch.x ||= last_touch.x
|
106
|
+
touch.y ||= last_touch.y
|
107
|
+
end
|
108
|
+
|
109
|
+
Gesture.new(@touches << touch, @query)
|
110
|
+
end
|
111
|
+
|
112
|
+
def +(gesture)
|
113
|
+
Gesture.new(@touches + gesture.touches, @query)
|
114
|
+
end
|
115
|
+
|
116
|
+
def add_touch(touch)
|
117
|
+
touches = @touches
|
118
|
+
Gesture.new(touches << touch, @query)
|
119
|
+
end
|
120
|
+
|
121
|
+
def <<(touch)
|
122
|
+
@touches << touch
|
123
|
+
end
|
124
|
+
|
125
|
+
def to_json(*object)
|
126
|
+
{
|
127
|
+
query_string: @query && @query.to_s,
|
128
|
+
touches: @touches
|
129
|
+
}.to_json(*object)
|
130
|
+
end
|
131
|
+
|
132
|
+
def query=(query)
|
133
|
+
@query = query
|
134
|
+
end
|
135
|
+
|
136
|
+
def reset_query
|
137
|
+
touches.each {|touch| touch.query=nil}
|
138
|
+
end
|
139
|
+
|
140
|
+
def offset=(offset)
|
141
|
+
@touches.each {|touch| touch.offset=offset}
|
142
|
+
end
|
143
|
+
|
144
|
+
def max_execution_time
|
145
|
+
(@touches.map {|touch| touch.wait + touch.time}).reduce(:+)
|
146
|
+
end
|
147
|
+
|
148
|
+
def queries
|
149
|
+
(@touches.map(&:query).uniq + [@query]).reject(&:nil?)
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.with_parameters(multi_touch_gesture, params={})
|
153
|
+
multi_touch_gesture.query = params[:query] if params[:query]
|
154
|
+
multi_touch_gesture.timeout = params[:timeout] if params[:timeout]
|
155
|
+
|
156
|
+
multi_touch_gesture
|
157
|
+
end
|
158
|
+
|
159
|
+
def self.generate_tap(touch_hash)
|
160
|
+
MultiTouchGesture.new(Gesture.new(Touch.new(touch_hash)))
|
161
|
+
end
|
162
|
+
|
163
|
+
def self.tap(opt={})
|
164
|
+
touch = opt[:touch] || {}
|
165
|
+
touch[:x] ||= (opt[:x] || 50)
|
166
|
+
touch[:y] ||= (opt[:y] || 50)
|
167
|
+
touch[:time] ||= (opt[:time] || 0.1)
|
168
|
+
touch[:release] = touch[:release].nil? ? (opt[:release].nil? ? true : opt[:release]) : touch[:release]
|
169
|
+
touch[:wait] ||= (opt[:wait] || 0)
|
170
|
+
touch[:offset] ||= opt[:offset]
|
171
|
+
|
172
|
+
generate_tap(touch)
|
173
|
+
end
|
174
|
+
|
175
|
+
def self.double_tap(opt={})
|
176
|
+
self.tap(opt).merge(self.tap({wait: 0.1}.merge(opt)))
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.generate_swipe(from_hash, to_hash, opt={})
|
180
|
+
from_params = from_hash.merge(opt).merge(opt[:from] || {})
|
181
|
+
to_params = {time: 0}.merge(to_hash).merge(opt[:to] || {})
|
182
|
+
|
183
|
+
if opt[:flick]
|
184
|
+
to_params.merge!(wait: 0)
|
185
|
+
else
|
186
|
+
to_params = {wait: 0.2}.merge(to_params)
|
187
|
+
end
|
188
|
+
|
189
|
+
self.tap({release: false}.merge(from_params)).merge(self.tap(to_params))
|
190
|
+
end
|
191
|
+
|
192
|
+
def self.swipe(direction, opt={})
|
193
|
+
from = {x: 50, y: 50}
|
194
|
+
to = {x: 50, y: 50}
|
195
|
+
|
196
|
+
case direction
|
197
|
+
when :left
|
198
|
+
from[:x] = 90
|
199
|
+
to[:x] = 10
|
200
|
+
when :right
|
201
|
+
from[:x] = 10
|
202
|
+
to[:x] = 90
|
203
|
+
when :up
|
204
|
+
from[:y] = 90
|
205
|
+
to[:y] = 10
|
206
|
+
when :down
|
207
|
+
from[:y] = 10
|
208
|
+
to[:y] = 90
|
209
|
+
else
|
210
|
+
raise "Cannot swipe in #{direction}"
|
211
|
+
end
|
212
|
+
|
213
|
+
opt[:time] ||= 0.3
|
214
|
+
|
215
|
+
generate_swipe(from, to, opt)
|
216
|
+
end
|
217
|
+
|
218
|
+
def self.generate_pinch_out(from_arr, to_arr, opt={})
|
219
|
+
self.generate_swipe(from_arr[0], to_arr[0], opt) + self.generate_swipe(from_arr[1], to_arr[1], opt)
|
220
|
+
end
|
221
|
+
|
222
|
+
def self.pinch(direction, opt={})
|
223
|
+
opt[:from] ||= []
|
224
|
+
opt[:from][0] = (opt[:from][0] || {}).merge(opt)
|
225
|
+
opt[:from][1] = (opt[:from][1] || {}).merge(opt)
|
226
|
+
opt[:to] ||= []
|
227
|
+
opt[:to][0] ||= {}
|
228
|
+
opt[:to][1] ||= {}
|
229
|
+
|
230
|
+
from = [{x: 40, y: 40}.merge(opt[:from][0]), {x: 60, y: 60}.merge(opt[:from][1])]
|
231
|
+
to = [{x: 10, y: 10}.merge(opt[:to][0]), {x: 90, y: 90}.merge(opt[:to][1])]
|
232
|
+
|
233
|
+
case direction
|
234
|
+
when :out
|
235
|
+
|
236
|
+
when :in
|
237
|
+
from,to = to,from
|
238
|
+
else
|
239
|
+
raise "Cannot pinch #{direction}"
|
240
|
+
end
|
241
|
+
|
242
|
+
generate_pinch_out(from, to)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
class Touch
|
247
|
+
attr_accessor :x, :y, :offset_x, :offset_y, :wait, :time, :release, :query
|
248
|
+
|
249
|
+
def initialize(touch)
|
250
|
+
if touch.is_a?(Touch)
|
251
|
+
touch = touch.to_hash
|
252
|
+
end
|
253
|
+
|
254
|
+
touch[:offset] ||= {}
|
255
|
+
touch[:offset_x] ||= touch[:offset][:x]
|
256
|
+
touch[:offset_y] ||= touch[:offset][:y]
|
257
|
+
|
258
|
+
@x = touch[:x]
|
259
|
+
@y = touch[:y]
|
260
|
+
@offset_x = touch[:offset_x] || 0
|
261
|
+
@offset_y = touch[:offset_y] || 0
|
262
|
+
@wait = touch[:wait] || 0
|
263
|
+
@time = touch[:time] || 0
|
264
|
+
@release = touch[:release].nil? ? false : touch[:release]
|
265
|
+
@query = touch[:query]
|
266
|
+
end
|
267
|
+
|
268
|
+
def merge(touch)
|
269
|
+
Touch.new(to_hash.merge(touch.to_hash))
|
270
|
+
end
|
271
|
+
|
272
|
+
def to_hash
|
273
|
+
{
|
274
|
+
x: @x,
|
275
|
+
y: @y,
|
276
|
+
offset_x: @offset_x || 0,
|
277
|
+
offset_y: @offset_y || 0,
|
278
|
+
wait: @wait.to_f,
|
279
|
+
time: @time.to_f,
|
280
|
+
release: @release,
|
281
|
+
query: @query && @query
|
282
|
+
}
|
283
|
+
end
|
284
|
+
|
285
|
+
def to_json(object = Hash)
|
286
|
+
hash = to_hash
|
287
|
+
hash[:query_string] = hash[:query] && hash[:query].to_s
|
288
|
+
hash.to_json(object)
|
289
|
+
end
|
290
|
+
|
291
|
+
def +(touch)
|
292
|
+
hash = to_hash
|
293
|
+
hash[:x] += touch.x
|
294
|
+
hash[:y] += touch.y
|
295
|
+
hash[:offset_x] += touch.offset_x
|
296
|
+
hash[:offset_y] += touch.offset_y
|
297
|
+
Touch.new(hash)
|
298
|
+
end
|
299
|
+
|
300
|
+
def -(touch)
|
301
|
+
hash = to_hash
|
302
|
+
hash[:x] -= touch.x
|
303
|
+
hash[:y] -= touch.y
|
304
|
+
hash[:offset_x] -= touch.offset_x
|
305
|
+
hash[:offset_y] -= touch.offset_y
|
306
|
+
Touch.new(hash)
|
307
|
+
end
|
308
|
+
|
309
|
+
def offset=(offset)
|
310
|
+
@offset_x = offset[:x]
|
311
|
+
@offset_y = offset[:y]
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
# @!visibility private
|
316
|
+
def _pan_screen_up(options={})
|
317
|
+
from = {x: 50, y: 90}
|
318
|
+
to = {x: 50, y: 10}
|
319
|
+
|
320
|
+
pan("* id:'content'", from, to, options)
|
321
|
+
end
|
322
|
+
|
323
|
+
# @!visibility private
|
324
|
+
def _pan_screen_down(options={})
|
325
|
+
from = {x: 50, y: 10}
|
326
|
+
to = {x: 50, y: 90}
|
327
|
+
|
328
|
+
pan("* id:'content'", from, to, options)
|
329
|
+
end
|
330
|
+
|
331
|
+
# @!visibility private
|
332
|
+
def _flick_screen_up(options={})
|
333
|
+
from = {x: 50, y: 90}
|
334
|
+
to = {x: 50, y: 10}
|
335
|
+
|
336
|
+
flick("* id:'content'", from, to, options)
|
337
|
+
end
|
338
|
+
|
339
|
+
# @!visibility private
|
340
|
+
def _flick_screen_down(options={})
|
341
|
+
from = {x: 50, y: 10}
|
342
|
+
to = {x: 50, y: 90}
|
343
|
+
|
344
|
+
flick("* id:'content'", from, to, options)
|
345
|
+
end
|
346
|
+
|
347
|
+
# !@visibility private
|
348
|
+
def _pinch_screen(direction, options={})
|
349
|
+
Device.default.pinch(direction, "* id:'content'", options)
|
350
|
+
end
|
351
|
+
|
352
|
+
# !@visibility private
|
353
|
+
def _pinch_to_zoom(direction, query, options={})
|
354
|
+
if direction == :out
|
355
|
+
Device.default.pinch(:in, query, options)
|
356
|
+
elsif direction == :in
|
357
|
+
Device.default.pinch(:out, query, options)
|
358
|
+
else
|
359
|
+
raise "Invalid direction '#{direction}'"
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
# !@visibility private
|
364
|
+
def _pinch_screen_to_zoom(direction, options={})
|
365
|
+
_pinch_to_zoom(direction, "* id:'content'", options)
|
366
|
+
end
|
367
|
+
end
|
368
|
+
end
|
369
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Calabash
|
2
|
+
module Android
|
3
|
+
module Interactions
|
4
|
+
# Go back.
|
5
|
+
def go_back
|
6
|
+
dismiss_keyboard
|
7
|
+
press_back_button
|
8
|
+
end
|
9
|
+
|
10
|
+
# Go to the home screen.
|
11
|
+
def go_home
|
12
|
+
Device.default.go_home
|
13
|
+
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get the name of the currently focused activity
|
18
|
+
#
|
19
|
+
# @example
|
20
|
+
# puts focused_activity
|
21
|
+
# # => com.example.MainActivity
|
22
|
+
#
|
23
|
+
# @return [String] The name of the currently focused activity.
|
24
|
+
def focused_activity
|
25
|
+
Device.default.current_focus[:activity]
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get the name of the currently focused package
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# puts focused_package
|
32
|
+
# # => com.example
|
33
|
+
#
|
34
|
+
# @return [String] The name of the currently focused package
|
35
|
+
def focused_package
|
36
|
+
Device.default.current_focus[:package]
|
37
|
+
end
|
38
|
+
|
39
|
+
# @!visibility private
|
40
|
+
def _evaluate_javascript_in(query, javascript)
|
41
|
+
Device.default.evaluate_javascript_in(query, javascript)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
begin
|
2
|
+
require 'irb/completion'
|
3
|
+
require 'irb/ext/save-history'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'awesome_print'
|
7
|
+
rescue LoadError => e
|
8
|
+
msg = ["Caught a LoadError: could not load 'awesome_print'",
|
9
|
+
"#{e}",
|
10
|
+
'',
|
11
|
+
'Use bundler (recommended) or uninstall awesome_print.',
|
12
|
+
'',
|
13
|
+
'# Use bundler (recommended)',
|
14
|
+
'$ bundle update',
|
15
|
+
'$ bundle exec calabash console [path to apk]',
|
16
|
+
'',
|
17
|
+
'# Uninstall',
|
18
|
+
'$ gem update --system',
|
19
|
+
'$ gem uninstall -Vax --force --no-abort-on-dependent awesome_print']
|
20
|
+
puts msg
|
21
|
+
exit(1)
|
22
|
+
end
|
23
|
+
|
24
|
+
AwesomePrint.irb!
|
25
|
+
|
26
|
+
ARGV.concat [ '--readline',
|
27
|
+
'--prompt-mode',
|
28
|
+
'simple']
|
29
|
+
|
30
|
+
# 50 entries in the list
|
31
|
+
IRB.conf[:SAVE_HISTORY] = 50
|
32
|
+
|
33
|
+
# Store results in home directory with specified file name
|
34
|
+
IRB.conf[:HISTORY_FILE] = '.irb-history'
|
35
|
+
|
36
|
+
require 'calabash/android'
|
37
|
+
|
38
|
+
extend Calabash::Android
|
39
|
+
extend Calabash::ConsoleHelpers
|
40
|
+
|
41
|
+
identifier = Calabash::Android::Device.default_serial
|
42
|
+
server = Calabash::Android::Server.default
|
43
|
+
|
44
|
+
Calabash::Android::Device.default = Calabash::Android::Device.new(identifier, server)
|
45
|
+
|
46
|
+
Calabash::Application.default = Calabash::Android::Application.default_from_environment
|
47
|
+
|
48
|
+
Calabash.new_embed_method!(lambda {|*_| Calabash::Logger.info 'Embed is not available in the console.'})
|
49
|
+
Calabash::Screenshot.screenshot_directory_prefix = 'console_'
|
50
|
+
rescue Exception => e
|
51
|
+
puts 'Unable to start console:'
|
52
|
+
puts "#{e.class}: #{e.message}"
|
53
|
+
puts "#{e.backtrace.join("\n")}"
|
54
|
+
exit(1)
|
55
|
+
end
|