calabash-android 0.5.1 → 0.5.2.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/calabash-android-console.rb +24 -9
- data/bin/calabash-android-run.rb +4 -1
- data/bin/calabash-android-setup.rb +1 -1
- data/lib/calabash-android/deprecated_actions.map +8 -0
- data/lib/calabash-android/env.rb +30 -2
- data/lib/calabash-android/environment_helpers.rb +12 -0
- data/lib/calabash-android/gestures.rb +308 -0
- data/lib/calabash-android/helpers.rb +55 -6
- data/lib/calabash-android/java_keystore.rb +2 -1
- data/lib/calabash-android/lib/TestServer.apk +0 -0
- data/lib/calabash-android/operations.rb +901 -707
- data/lib/calabash-android/removed_actions.txt +4 -0
- data/lib/calabash-android/steps/date_picker_steps.rb +4 -4
- data/lib/calabash-android/steps/time_picker_steps.rb +3 -3
- data/lib/calabash-android/touch_helpers.rb +114 -18
- data/lib/calabash-android/version.rb +1 -1
- data/test-server/calabash-js/src/calabash.js +42 -1
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/HttpServer.java +67 -2
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/MultiTouchGesture.java +749 -0
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/softkey/PressKey.java +85 -0
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/text/HideSoftKeyboard.java +24 -2
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/text/PressUserActionButton.java +128 -0
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/QueryHelper.java +8 -1
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/InvocationOperation.java +56 -9
- metadata +10 -8
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/time/SetDateByContentDescription.java +0 -33
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/time/SetDateByIndex.java +0 -24
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/time/SetTimeByContentDescription.java +0 -34
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/time/SetTimeByIndex.java +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea9071972253360f02e1b1ed07308aca2b219e0e
|
4
|
+
data.tar.gz: 4b7f3b9df746943d83ebacf832da0a992b9a4ed2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4067273b985fec4f1c3cf4dfb0f2ac0ddc365f65bf406d82fb8cd03c1138229e8845791a84ea8b01a20449de0e025f441b9f5d06f44a6bd3a4a6fdcf73829a30
|
7
|
+
data.tar.gz: 760f7891db8314ad420179f5cb5e4219db7ac3738ea165032e14c534bb6472a9906ddde18e28a24d7abfdbf4d0f516d35b4e99f374b907abf7daf453d0af5034
|
data/Gemfile.lock
CHANGED
@@ -1,23 +1,38 @@
|
|
1
1
|
def calabash_console(app_path = nil)
|
2
2
|
test_server_path = test_server_path(app_path)
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
path = ENV['CALABASH_IRBRC']
|
6
|
+
unless path
|
7
|
+
if File.exist?('.irbrc')
|
8
|
+
path = File.expand_path('.irbrc')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
unless path
|
13
|
+
path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'irbrc'))
|
6
14
|
end
|
7
15
|
|
8
|
-
|
9
|
-
|
16
|
+
ENV['IRBRC'] = path
|
17
|
+
|
18
|
+
|
19
|
+
unless ENV['MAIN_ACTIVITY']
|
20
|
+
ENV['MAIN_ACTIVITY'] = main_activity(app_path)
|
10
21
|
end
|
11
22
|
|
12
|
-
unless ENV[
|
13
|
-
ENV[
|
23
|
+
unless ENV['APP_PATH']
|
24
|
+
ENV['APP_PATH'] = app_path
|
14
25
|
end
|
15
26
|
|
16
|
-
unless ENV[
|
17
|
-
ENV[
|
27
|
+
unless ENV['TEST_APP_PATH']
|
28
|
+
ENV['TEST_APP_PATH'] = test_server_path
|
18
29
|
end
|
19
30
|
|
20
31
|
build_test_server_if_needed(app_path)
|
21
32
|
|
22
|
-
|
33
|
+
puts 'Starting calabash-android console...'
|
34
|
+
puts "Loading #{ENV['IRBRC']}"
|
35
|
+
puts 'Running irb...'
|
36
|
+
exec('irb')
|
37
|
+
|
23
38
|
end
|
data/bin/calabash-android-run.rb
CHANGED
@@ -16,7 +16,10 @@ def calabash_run(app_path = nil)
|
|
16
16
|
build_test_server_if_needed(app_path)
|
17
17
|
|
18
18
|
test_server_path = test_server_path(app_path)
|
19
|
-
|
19
|
+
|
20
|
+
main_activity = ENV['MAIN_ACTIVITY'] || main_activity(app_path)
|
21
|
+
|
22
|
+
env = "MAIN_ACTIVITY=#{main_activity} "\
|
20
23
|
"APP_PATH=\"#{app_path}\" "\
|
21
24
|
"TEST_APP_PATH=\"#{test_server_path}\""
|
22
25
|
else
|
@@ -9,7 +9,7 @@ def calabash_setup
|
|
9
9
|
ask_for_setting(:keystore_password, "Please enter the password for the keystore")
|
10
10
|
ask_for_setting(:keystore_alias, "Please enter the alias")
|
11
11
|
|
12
|
-
open('calabash_settings', 'w') do |f|
|
12
|
+
open('.calabash_settings', 'w') do |f|
|
13
13
|
f.puts @settings.to_json
|
14
14
|
end
|
15
15
|
puts "Saved your settings to .calabash_settings. You can edit the settings manually or run this setup script again"
|
@@ -0,0 +1,8 @@
|
|
1
|
+
send_key_enter,press_enter_button
|
2
|
+
send_key_left,press_left_button
|
3
|
+
send_key_right,press_right_button
|
4
|
+
send_key_up,press_up_button
|
5
|
+
send_key_down,press_down_button
|
6
|
+
press_menu,press_menu_button
|
7
|
+
go_back,press_back_button
|
8
|
+
backdoor,backdoor(method_name, arguments)
|
data/lib/calabash-android/env.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require_relative 'helpers'
|
1
2
|
|
2
3
|
class Env
|
3
4
|
require 'win32/registry' if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
@@ -79,7 +80,28 @@ class Env
|
|
79
80
|
end
|
80
81
|
|
81
82
|
def self.zipalign_path
|
82
|
-
|
83
|
+
zipalign_path = File.join(android_home_path, 'tools', zipalign_executable)
|
84
|
+
|
85
|
+
unless File.exists?(zipalign_path)
|
86
|
+
log "Did not find zipalign at '#{zipalign_path}'. Trying to find zipalign in tools directories."
|
87
|
+
|
88
|
+
tools_directories.each do |dir|
|
89
|
+
zipalign_path = File.join(dir, zipalign_executable)
|
90
|
+
break if File.exists?(zipalign_path)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
if File.exists?(zipalign_path)
|
95
|
+
log "Found zipalign at '#{zipalign_path}'"
|
96
|
+
zipalign_path
|
97
|
+
else
|
98
|
+
log("Did not find zipalign in any of '#{tools_directories.join("','")}'.", true)
|
99
|
+
raise 'Could not find zipalign'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.zipalign_executable
|
104
|
+
is_windows? ? 'zipalign.exe' : 'zipalign'
|
83
105
|
end
|
84
106
|
|
85
107
|
def self.jarsigner_executable
|
@@ -107,10 +129,16 @@ class Env
|
|
107
129
|
end
|
108
130
|
|
109
131
|
def self.tools_dir
|
132
|
+
tools_dir = tools_directories.first
|
133
|
+
log "Found tools directory at '#{tools_dir}'"
|
134
|
+
tools_dir
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.tools_directories
|
110
138
|
Dir.chdir(android_home_path) do
|
111
139
|
dirs = Dir["build-tools/*"] + Dir["platform-tools"]
|
112
140
|
raise "Could not find tools directory in #{android_home_path}" if dirs.empty?
|
113
|
-
File.expand_path(
|
141
|
+
dirs.map {|dir| File.expand_path(dir)}
|
114
142
|
end
|
115
143
|
end
|
116
144
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Calabash
|
2
|
+
module Android
|
3
|
+
module EnvironmentHelpers
|
4
|
+
# Are we running in the Xamarin Test Cloud?
|
5
|
+
#
|
6
|
+
# @return [Boolean] Returns true if cucumber is running in the test cloud.
|
7
|
+
def xamarin_test_cloud?
|
8
|
+
ENV['XAMARIN_TEST_CLOUD'] == '1'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,308 @@
|
|
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
|
+
DEFAULT_TIMEOUT = 5
|
11
|
+
|
12
|
+
def initialize(gestures = [])
|
13
|
+
unless gestures.is_a?(Array)
|
14
|
+
gestures = [gestures]
|
15
|
+
end
|
16
|
+
|
17
|
+
@gestures = gestures
|
18
|
+
@timeout = (ENV['CALABASH_DEFAULT_TIMEOUT'] && ENV['CALABASH_DEFAULT_TIMEOUT'].to_i) || DEFAULT_TIMEOUT
|
19
|
+
end
|
20
|
+
|
21
|
+
def +(gesture_collection)
|
22
|
+
MultiTouchGesture.new(@gestures + gesture_collection.gestures)
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_gesture
|
26
|
+
gestures = @gestures
|
27
|
+
MultiTouchGesture.new(gestures + gesture_collection.gestures)
|
28
|
+
end
|
29
|
+
|
30
|
+
def <<(gesture)
|
31
|
+
@gestures << gesture
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_touch(touch, index=0)
|
35
|
+
gestures = @gestures
|
36
|
+
gestures[index] << touch
|
37
|
+
MultiTouchGesture.new(gestures)
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_touch!(touch, index=0)
|
41
|
+
@gestures = add_touch(touch, index).gestures
|
42
|
+
end
|
43
|
+
|
44
|
+
def merge(multi_touch_gesture)
|
45
|
+
MultiTouchGesture.new(gestures.map.with_index {|gesture, index| gesture + multi_touch_gesture.gestures[index]})
|
46
|
+
end
|
47
|
+
|
48
|
+
def merge!(multi_touch_gesture)
|
49
|
+
@gestures = merge(multi_touch_gesture).gestures
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_json(*object)
|
53
|
+
{
|
54
|
+
query_timeout: @timeout.to_f,
|
55
|
+
gestures: @gestures
|
56
|
+
}.to_json(*object)
|
57
|
+
end
|
58
|
+
|
59
|
+
def query_string=(query_string)
|
60
|
+
@gestures.each {|gesture| gesture.query_string=query_string}
|
61
|
+
end
|
62
|
+
|
63
|
+
def reset_query_string
|
64
|
+
@gestures.each {|gesture| gesture.reset_query_string}
|
65
|
+
end
|
66
|
+
|
67
|
+
def offset=(offset)
|
68
|
+
@gestures.each {|gesture| gesture.offset=offset}
|
69
|
+
end
|
70
|
+
|
71
|
+
def max_execution_time
|
72
|
+
(@gestures.map {|gesture| gesture.max_execution_time}).max
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
class Gesture
|
77
|
+
attr_reader :touches
|
78
|
+
|
79
|
+
def initialize(touches = [], query_string = nil)
|
80
|
+
unless touches.is_a?(Array)
|
81
|
+
touches = [touches]
|
82
|
+
end
|
83
|
+
|
84
|
+
@touches = []
|
85
|
+
|
86
|
+
touches.each do |touch|
|
87
|
+
@touches << Touch.new(touch)
|
88
|
+
end
|
89
|
+
|
90
|
+
@query_string = query_string
|
91
|
+
end
|
92
|
+
|
93
|
+
def from(touch)
|
94
|
+
to(touch)
|
95
|
+
end
|
96
|
+
|
97
|
+
def to(touch)
|
98
|
+
if touch.is_a?(Hash)
|
99
|
+
touch = Touch.new(touch)
|
100
|
+
end
|
101
|
+
|
102
|
+
unless (last_touch = @touches.last).nil?
|
103
|
+
touch.x ||= last_touch.x
|
104
|
+
touch.y ||= last_touch.y
|
105
|
+
end
|
106
|
+
|
107
|
+
Gesture.new(@touches << touch, @query_string)
|
108
|
+
end
|
109
|
+
|
110
|
+
def +(gesture)
|
111
|
+
Gesture.new(@touches + gesture.touches, @query_string)
|
112
|
+
end
|
113
|
+
|
114
|
+
def add_touch(touch)
|
115
|
+
touches = @touches
|
116
|
+
Gesture.new(touches << touch, @query_string)
|
117
|
+
end
|
118
|
+
|
119
|
+
def <<(touch)
|
120
|
+
@touches << touch
|
121
|
+
end
|
122
|
+
|
123
|
+
def to_json(*object)
|
124
|
+
{
|
125
|
+
query_string: @query_string,
|
126
|
+
touches: @touches
|
127
|
+
}.to_json(*object)
|
128
|
+
end
|
129
|
+
|
130
|
+
def query_string=(query_string)
|
131
|
+
@query_string = query_string
|
132
|
+
end
|
133
|
+
|
134
|
+
def reset_query_string
|
135
|
+
touches.each {|touch| touch.query_string=nil}
|
136
|
+
end
|
137
|
+
|
138
|
+
def offset=(offset)
|
139
|
+
@touches.each {|touch| touch.offset=offset}
|
140
|
+
end
|
141
|
+
|
142
|
+
def max_execution_time
|
143
|
+
(@touches.map {|touch| touch.wait + touch.time}).reduce(:+)
|
144
|
+
end
|
145
|
+
|
146
|
+
def self.with_parameters(multi_touch_gesture, params={})
|
147
|
+
multi_touch_gesture.query_string = params[:query_string] if params[:query_string]
|
148
|
+
multi_touch_gesture.timeout = params[:timeout] if params[:timeout]
|
149
|
+
|
150
|
+
multi_touch_gesture
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.generate_tap(touch_hash)
|
154
|
+
MultiTouchGesture.new(Gesture.new(Touch.new(touch_hash)))
|
155
|
+
end
|
156
|
+
|
157
|
+
def self.tap(opt={})
|
158
|
+
touch = opt[:touch] || {}
|
159
|
+
touch[:x] ||= (opt[:x] || 50)
|
160
|
+
touch[:y] ||= (opt[:y] || 50)
|
161
|
+
touch[:time] ||= (opt[:time] || 0.2)
|
162
|
+
touch[:release] = touch[:release].nil? ? (opt[:release].nil? ? true : opt[:release]) : touch[:release]
|
163
|
+
touch[:wait] ||= (opt[:wait] || 0)
|
164
|
+
touch[:offset] ||= opt[:offset]
|
165
|
+
|
166
|
+
generate_tap(touch)
|
167
|
+
end
|
168
|
+
|
169
|
+
def self.double_tap(opt={})
|
170
|
+
self.tap(opt).merge(self.tap({wait: 0.1}.merge(opt)))
|
171
|
+
end
|
172
|
+
|
173
|
+
def self.generate_swipe(from_hash, to_hash, opt={})
|
174
|
+
from_params = from_hash.merge(opt).merge(opt[:from] || {})
|
175
|
+
to_params = {time: 0}.merge(to_hash).merge(opt[:to] || {})
|
176
|
+
|
177
|
+
if opt[:flick]
|
178
|
+
to_params.merge!(wait: 0)
|
179
|
+
else
|
180
|
+
to_params = {wait: 0.2}.merge(to_params)
|
181
|
+
end
|
182
|
+
|
183
|
+
self.tap({release: false}.merge(from_params)).merge(self.tap(to_params))
|
184
|
+
end
|
185
|
+
|
186
|
+
def self.swipe(direction, opt={})
|
187
|
+
from = {x: 50, y: 50}
|
188
|
+
to = {x: 50, y: 50}
|
189
|
+
|
190
|
+
case direction
|
191
|
+
when :left
|
192
|
+
from[:x] = 90
|
193
|
+
to[:x] = 10
|
194
|
+
when :right
|
195
|
+
from[:x] = 10
|
196
|
+
to[:x] = 90
|
197
|
+
when :up
|
198
|
+
from[:y] = 90
|
199
|
+
to[:y] = 10
|
200
|
+
when :down
|
201
|
+
from[:y] = 10
|
202
|
+
to[:y] = 90
|
203
|
+
else
|
204
|
+
raise "Cannot swipe in #{direction}"
|
205
|
+
end
|
206
|
+
|
207
|
+
opt[:time] ||= 0.3
|
208
|
+
|
209
|
+
generate_swipe(from, to, opt)
|
210
|
+
end
|
211
|
+
|
212
|
+
def self.generate_pinch_out(from_arr, to_arr, opt={})
|
213
|
+
self.generate_swipe(from_arr[0], to_arr[0], opt) + self.generate_swipe(from_arr[1], to_arr[1], opt)
|
214
|
+
end
|
215
|
+
|
216
|
+
def self.pinch(direction, opt={})
|
217
|
+
opt[:from] ||= []
|
218
|
+
opt[:from][0] = (opt[:from][0] || {}).merge(opt)
|
219
|
+
opt[:from][1] = (opt[:from][1] || {}).merge(opt)
|
220
|
+
opt[:to] ||= []
|
221
|
+
opt[:to][0] ||= {}
|
222
|
+
opt[:to][1] ||= {}
|
223
|
+
|
224
|
+
from = [{x: 40, y: 40}.merge(opt[:from][0]), {x: 60, y: 60}.merge(opt[:from][1])]
|
225
|
+
to = [{x: 10, y: 10}.merge(opt[:to][0]), {x: 90, y: 90}.merge(opt[:to][1])]
|
226
|
+
|
227
|
+
case direction
|
228
|
+
when :out
|
229
|
+
|
230
|
+
when :in
|
231
|
+
from,to = to,from
|
232
|
+
else
|
233
|
+
raise "Cannot pinch #{direction}"
|
234
|
+
end
|
235
|
+
|
236
|
+
generate_pinch_out(from, to)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
class Touch
|
241
|
+
attr_accessor :x, :y, :offset_x, :offset_y, :wait, :time, :release, :query_string
|
242
|
+
|
243
|
+
def initialize(touch)
|
244
|
+
if touch.is_a?(Touch)
|
245
|
+
touch = touch.to_hash
|
246
|
+
end
|
247
|
+
|
248
|
+
touch[:offset] ||= {}
|
249
|
+
touch[:offset_x] ||= touch[:offset][:x]
|
250
|
+
touch[:offset_y] ||= touch[:offset][:y]
|
251
|
+
|
252
|
+
@x = touch[:x]
|
253
|
+
@y = touch[:y]
|
254
|
+
@offset_x = touch[:offset_x] || 0
|
255
|
+
@offset_y = touch[:offset_y] || 0
|
256
|
+
@wait = touch[:wait] || 0
|
257
|
+
@time = touch[:time] || 0
|
258
|
+
@release = touch[:release].nil? ? false : touch[:release]
|
259
|
+
@query_string = touch[:query_string]
|
260
|
+
end
|
261
|
+
|
262
|
+
def merge(touch)
|
263
|
+
Touch.new(to_hash.merge(touch.to_hash))
|
264
|
+
end
|
265
|
+
|
266
|
+
def to_hash
|
267
|
+
{
|
268
|
+
x: @x,
|
269
|
+
y: @y,
|
270
|
+
offset_x: @offset_x || 0,
|
271
|
+
offset_y: @offset_y || 0,
|
272
|
+
wait: @wait.to_f,
|
273
|
+
time: @time.to_f,
|
274
|
+
release: @release,
|
275
|
+
query_string: @query_string
|
276
|
+
}
|
277
|
+
end
|
278
|
+
|
279
|
+
def to_json(object = Hash)
|
280
|
+
to_hash.to_json(object)
|
281
|
+
end
|
282
|
+
|
283
|
+
def +(touch)
|
284
|
+
hash = to_hash
|
285
|
+
hash[:x] += touch.x
|
286
|
+
hash[:y] += touch.y
|
287
|
+
hash[:offset_x] += touch.offset_x
|
288
|
+
hash[:offset_y] += touch.offset_y
|
289
|
+
Touch.new(hash)
|
290
|
+
end
|
291
|
+
|
292
|
+
def -(touch)
|
293
|
+
hash = to_hash
|
294
|
+
hash[:x] -= touch.x
|
295
|
+
hash[:y] -= touch.y
|
296
|
+
hash[:offset_x] -= touch.offset_x
|
297
|
+
hash[:offset_y] -= touch.offset_y
|
298
|
+
Touch.new(hash)
|
299
|
+
end
|
300
|
+
|
301
|
+
def offset=(offset)
|
302
|
+
@offset_x = offset[:x]
|
303
|
+
@offset_y = offset[:y]
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|