calabash-android 0.9.22 → 0.9.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/calabash-android-build.rb +2 -2
- data/bin/calabash-android-run.rb +1 -1
- data/features-skeleton/support/app_installation_hooks.rb +2 -2
- data/lib/calabash-android/drag_helpers.rb +1 -1
- data/lib/calabash-android/env.rb +7 -7
- data/lib/calabash-android/helpers.rb +13 -13
- data/lib/calabash-android/java_keystore.rb +15 -15
- data/lib/calabash-android/operations.rb +41 -41
- data/lib/calabash-android/version.rb +1 -1
- metadata +6 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3d0ebc52f3b6f52dc1204c8d7932cbf7363df28e69772bc301bdef6b10674d9
|
4
|
+
data.tar.gz: 0db12e629560e593b3217b7b329ea0fb128eb4354d9ecbc4b2047aa94b909ef0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20a43f3ba87da88e5adf452695d8f5f295ff4db07a87b107dcedd8d57f11411cf030e2c24de0a83ec7f7053c6b2571edfa307093849096f7cdbfdab1e04ba38b
|
7
|
+
data.tar.gz: c4b476e6b10f4b15286c7b43738b28ac929736a4ef8b4df87c3e2ba075dd773edf6271541b7b30b0aeedb73b72657ddd127cb3cb1f676f701e51bcd358413b06
|
@@ -1,6 +1,6 @@
|
|
1
1
|
def calabash_build(app)
|
2
2
|
apk_fingerprint = fingerprint_from_apk(app)
|
3
|
-
|
3
|
+
calabash_log "#{app} was signed with a certificate with fingerprint #{apk_fingerprint}"
|
4
4
|
|
5
5
|
keystores = JavaKeystore.get_keystores
|
6
6
|
if keystores.empty?
|
@@ -72,7 +72,7 @@ def calabash_build(app)
|
|
72
72
|
begin
|
73
73
|
|
74
74
|
rescue => e
|
75
|
-
|
75
|
+
calabash_log e
|
76
76
|
raise "Could not sign test server"
|
77
77
|
end
|
78
78
|
end
|
data/bin/calabash-android-run.rb
CHANGED
@@ -10,9 +10,9 @@ Before do |scenario|
|
|
10
10
|
feature = scenario.feature
|
11
11
|
if FeatureMemory.feature != feature || ENV['RESET_BETWEEN_SCENARIOS'] == '1'
|
12
12
|
if ENV['RESET_BETWEEN_SCENARIOS'] == '1'
|
13
|
-
|
13
|
+
calabash_log 'New scenario - reinstalling apps'
|
14
14
|
else
|
15
|
-
|
15
|
+
calabash_log 'First scenario in feature - reinstalling apps'
|
16
16
|
end
|
17
17
|
|
18
18
|
ensure_app_installed
|
@@ -8,7 +8,7 @@ module Calabash
|
|
8
8
|
include Calabash::Android::MonkeyHelpers
|
9
9
|
|
10
10
|
def drag_coordinates(from_x, from_y, to_x, to_y, steps=10, hold_time=0.5, hang_time=0.5)
|
11
|
-
|
11
|
+
calabash_log "Dragging from #{from_x},#{from_y} to #{to_x},#{to_y}"
|
12
12
|
monkey_move_from(from_x, from_y,
|
13
13
|
to_x, to_y,
|
14
14
|
hold_time: hold_time,
|
data/lib/calabash-android/env.rb
CHANGED
@@ -10,7 +10,7 @@ class Env
|
|
10
10
|
|
11
11
|
def self.exit_unless_android_sdk_is_available
|
12
12
|
if android_home_path
|
13
|
-
|
13
|
+
calabash_log "Android SDK found at: #{android_home_path}"
|
14
14
|
return
|
15
15
|
end
|
16
16
|
puts "Could not find an Android SDK please make sure it is installed."
|
@@ -27,8 +27,8 @@ class Env
|
|
27
27
|
def self.exit_unless_jdk_is_available
|
28
28
|
jdk = jdk_path
|
29
29
|
if find_executable_on_path(keytool_executable) || jdk
|
30
|
-
|
31
|
-
|
30
|
+
calabash_log "JDK found on PATH." if find_executable_on_path(keytool_executable)
|
31
|
+
calabash_log "JDK found at: #{jdk}" if jdk
|
32
32
|
return
|
33
33
|
end
|
34
34
|
puts "Could not find Java Development Kit please make sure it is installed."
|
@@ -84,7 +84,7 @@ class Env
|
|
84
84
|
zipalign_path = File.join(android_home_path, 'tools', zipalign_executable)
|
85
85
|
|
86
86
|
unless File.exists?(zipalign_path)
|
87
|
-
|
87
|
+
calabash_log "Did not find zipalign at '#{zipalign_path}'. Trying to find zipalign in tools directories."
|
88
88
|
|
89
89
|
tools_directories.each do |dir|
|
90
90
|
zipalign_path = File.join(dir, zipalign_executable)
|
@@ -93,10 +93,10 @@ class Env
|
|
93
93
|
end
|
94
94
|
|
95
95
|
if File.exists?(zipalign_path)
|
96
|
-
|
96
|
+
calabash_log "Found zipalign at '#{zipalign_path}'"
|
97
97
|
zipalign_path
|
98
98
|
else
|
99
|
-
|
99
|
+
calabash_log("Did not find zipalign in any of '#{tools_directories.join("','")}'.", true)
|
100
100
|
raise 'Could not find zipalign'
|
101
101
|
end
|
102
102
|
end
|
@@ -131,7 +131,7 @@ class Env
|
|
131
131
|
|
132
132
|
def self.tools_dir
|
133
133
|
tools_dir = tools_directories.first
|
134
|
-
|
134
|
+
calabash_log "Found tools directory at '#{tools_dir}'"
|
135
135
|
tools_dir
|
136
136
|
end
|
137
137
|
|
@@ -28,15 +28,15 @@ def main_activity(app)
|
|
28
28
|
end
|
29
29
|
|
30
30
|
begin
|
31
|
-
|
31
|
+
calabash_log("Trying to find launchable activity")
|
32
32
|
launchable_activity_line = aapt_dump(app, "launchable-activity").first
|
33
33
|
raise "'launchable-activity' not found in aapt output" unless launchable_activity_line
|
34
34
|
m = launchable_activity_line.match(/name='([^']+)'/)
|
35
35
|
raise "Unexpected output from aapt: #{launchable_activity_line}" unless m
|
36
|
-
|
36
|
+
calabash_log("Found launchable activity '#{m[1]}'")
|
37
37
|
m[1]
|
38
38
|
rescue => e
|
39
|
-
|
39
|
+
calabash_log("Could not find launchable activity, trying to parse raw AndroidManifest. #{e.message}")
|
40
40
|
|
41
41
|
manifest_data = `"#{Calabash::Android::Dependencies.aapt_path}" dump xmltree "#{app}" AndroidManifest.xml`
|
42
42
|
regex = /^\s*A:[\s*]android:name\(\w+\)\=\"android.intent.category.LAUNCHER\"/
|
@@ -65,13 +65,13 @@ def main_activity(app)
|
|
65
65
|
match = lines[index].match(/^\s*A:\s*android:targetActivity\(\w*\)\=\"([^\"]+)/){$1}
|
66
66
|
|
67
67
|
if match
|
68
|
-
|
68
|
+
calabash_log("Found launchable activity '#{match}'")
|
69
69
|
|
70
70
|
return match
|
71
71
|
end
|
72
72
|
else
|
73
73
|
unless lines[index].match(/\s*E: intent-filter/).nil?
|
74
|
-
|
74
|
+
calabash_log("Read intent filter")
|
75
75
|
intent_filter_found = true
|
76
76
|
end
|
77
77
|
end
|
@@ -111,7 +111,7 @@ end
|
|
111
111
|
|
112
112
|
def resign_apk(app_path)
|
113
113
|
Dir.mktmpdir do |tmp_dir|
|
114
|
-
|
114
|
+
calabash_log "Resign apk"
|
115
115
|
unsigned_path = File.join(tmp_dir, 'unsigned.apk')
|
116
116
|
unaligned_path = File.join(tmp_dir, 'unaligned.apk')
|
117
117
|
FileUtils.cp(app_path, unsigned_path)
|
@@ -142,7 +142,7 @@ def unsign_apk(path)
|
|
142
142
|
end
|
143
143
|
|
144
144
|
if files_to_remove.empty?
|
145
|
-
|
145
|
+
calabash_log "App wasn't signed. Will not try to unsign it."
|
146
146
|
else
|
147
147
|
system("\"#{Calabash::Android::Dependencies.aapt_path}\" remove \"#{path}\" #{files_to_remove.join(" ")}")
|
148
148
|
end
|
@@ -150,7 +150,7 @@ end
|
|
150
150
|
|
151
151
|
def zipalign_apk(inpath, outpath)
|
152
152
|
cmd = %Q("#{Calabash::Android::Dependencies.zipalign_path}" -f 4 "#{inpath}" "#{outpath}")
|
153
|
-
|
153
|
+
calabash_log "Zipaligning using: #{cmd}"
|
154
154
|
system(cmd)
|
155
155
|
end
|
156
156
|
|
@@ -179,20 +179,20 @@ def fingerprint_from_apk(app_path)
|
|
179
179
|
|
180
180
|
signature_files = Dir["#{tmp_dir}/META-INF/*"]
|
181
181
|
|
182
|
-
|
182
|
+
calabash_log 'Signature files:'
|
183
183
|
|
184
184
|
signature_files.each do |signature_file|
|
185
|
-
|
185
|
+
calabash_log signature_file
|
186
186
|
end
|
187
187
|
|
188
188
|
raise "No signature files found in META-INF. Cannot proceed." if signature_files.empty?
|
189
189
|
raise "More than one signature file (DSA or RSA) found in META-INF. Cannot proceed." if signature_files.length > 1
|
190
190
|
|
191
191
|
cmd = "\"#{Calabash::Android::Dependencies.keytool_path}\" -v -printcert -J\"-Dfile.encoding=utf-8\" -file \"#{signature_files.first}\""
|
192
|
-
|
192
|
+
calabash_log cmd
|
193
193
|
fingerprints = `#{cmd}`
|
194
194
|
md5_fingerprint = extract_sha1_fingerprint(fingerprints)
|
195
|
-
|
195
|
+
calabash_log "SHA1 fingerprint for signing cert (#{app_path}): #{md5_fingerprint}"
|
196
196
|
md5_fingerprint
|
197
197
|
end
|
198
198
|
end
|
@@ -216,7 +216,7 @@ def extract_signature_algorithm_name(fingerprints)
|
|
216
216
|
m.first
|
217
217
|
end
|
218
218
|
|
219
|
-
def
|
219
|
+
def calabash_log(message, error = false)
|
220
220
|
if error or ARGV.include? "-v" or ARGV.include? "--verbose" or ENV["DEBUG"] == "1"
|
221
221
|
$stdout.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")} - #{message}"
|
222
222
|
end
|
@@ -4,13 +4,13 @@ class JavaKeystore
|
|
4
4
|
|
5
5
|
def initialize(location, keystore_alias, password, key_password = nil)
|
6
6
|
raise "No such keystore file '#{location}'" unless File.exists?(File.expand_path(location))
|
7
|
-
|
7
|
+
calabash_log "Reading keystore data from keystore file '#{File.expand_path(location)}'"
|
8
8
|
|
9
9
|
keystore_data = system_with_stdout_on_success(Calabash::Android::Dependencies.keytool_path, '-list', '-v', '-alias', keystore_alias, '-keystore', location, '-storepass', password, '-J"-Dfile.encoding=utf-8"', '-J"-Duser.language=en-US"')
|
10
10
|
|
11
11
|
if keystore_data.nil?
|
12
12
|
if keystore_alias.empty?
|
13
|
-
|
13
|
+
calabash_log "Could not obtain keystore data. Will try to extract alias automatically"
|
14
14
|
|
15
15
|
keystore_data = system_with_stdout_on_success(Calabash::Android::Dependencies.keytool_path, '-list', '-v', '-keystore', location, '-storepass', password, '-J"-Dfile.encoding=utf-8"', '-J"-Duser.language=en-US"')
|
16
16
|
aliases = keystore_data.scan(/Alias name\:\s*(.*)/).flatten
|
@@ -21,14 +21,14 @@ class JavaKeystore
|
|
21
21
|
raise 'Multiple aliases found in keystore. Please specify alias using calabash-android setup'
|
22
22
|
else
|
23
23
|
keystore_alias = aliases.first
|
24
|
-
|
24
|
+
calabash_log "Extracted keystore alias '#{keystore_alias}'. Continuing"
|
25
25
|
|
26
26
|
return initialize(location, keystore_alias, password)
|
27
27
|
end
|
28
28
|
else
|
29
29
|
error = "Could not list certificates in keystore. Probably because the password was incorrect."
|
30
30
|
@errors = [{:message => error}]
|
31
|
-
|
31
|
+
calabash_log error
|
32
32
|
raise error
|
33
33
|
end
|
34
34
|
end
|
@@ -37,12 +37,12 @@ class JavaKeystore
|
|
37
37
|
@keystore_alias = keystore_alias
|
38
38
|
@password = password
|
39
39
|
@key_password = key_password
|
40
|
-
|
41
|
-
|
40
|
+
calabash_log "Key store data:"
|
41
|
+
calabash_log keystore_data
|
42
42
|
@fingerprint = extract_sha1_fingerprint(keystore_data)
|
43
43
|
@signature_algorithm_name = extract_signature_algorithm_name(keystore_data)
|
44
|
-
|
45
|
-
|
44
|
+
calabash_log "Fingerprint: #{fingerprint}"
|
45
|
+
calabash_log "Signature algorithm name: #{signature_algorithm_name}"
|
46
46
|
end
|
47
47
|
|
48
48
|
def sign_apk(apk_path, dest_path)
|
@@ -58,8 +58,8 @@ class JavaKeystore
|
|
58
58
|
signing_algorithm = "SHA1with#{encryption}"
|
59
59
|
digest_algorithm = 'SHA1'
|
60
60
|
|
61
|
-
|
62
|
-
|
61
|
+
calabash_log "Signing using the signature algorithm: '#{signing_algorithm}'"
|
62
|
+
calabash_log "Signing using the digest algorithm: '#{digest_algorithm}'"
|
63
63
|
|
64
64
|
cmd_args = {
|
65
65
|
'-sigfile' => 'CERT',
|
@@ -88,7 +88,7 @@ class JavaKeystore
|
|
88
88
|
def system_with_stdout_on_success(cmd, *args)
|
89
89
|
a = Escape.shell_command(args)
|
90
90
|
cmd = "\"#{cmd}\" #{a.gsub("'", '"')}"
|
91
|
-
|
91
|
+
calabash_log cmd
|
92
92
|
out = `#{cmd}`
|
93
93
|
if $?.exitstatus == 0
|
94
94
|
out
|
@@ -103,14 +103,14 @@ class JavaKeystore
|
|
103
103
|
if File.exists? path
|
104
104
|
keystore = JavaKeystore.new(path, 'androiddebugkey', 'android')
|
105
105
|
if keystore.errors
|
106
|
-
|
106
|
+
calabash_log "Trying to "
|
107
107
|
nil
|
108
108
|
else
|
109
|
-
|
109
|
+
calabash_log "Unlocked keystore at #{path} - fingerprint: #{keystore.fingerprint}"
|
110
110
|
keystore
|
111
111
|
end
|
112
112
|
else
|
113
|
-
|
113
|
+
calabash_log "Trying to read keystore from: #{path} - no such file"
|
114
114
|
nil
|
115
115
|
end
|
116
116
|
end
|
@@ -136,7 +136,7 @@ class JavaKeystore
|
|
136
136
|
fail_if_key_missing(keystore, "keystore_password")
|
137
137
|
fail_if_key_missing(keystore, "keystore_alias")
|
138
138
|
keystore["keystore_location"] = File.expand_path(keystore["keystore_location"])
|
139
|
-
|
139
|
+
calabash_log("Keystore location specified in #{File.exist?(".calabash_settings") ? ".calabash_settings" : "calabash_settings"}.")
|
140
140
|
JavaKeystore.new(keystore["keystore_location"], keystore["keystore_alias"], keystore["keystore_password"], keystore['key_password'])
|
141
141
|
end
|
142
142
|
|
@@ -54,7 +54,7 @@ module Calabash module Android
|
|
54
54
|
`#{default_device.adb_command} shell dumpsys window windows`.force_encoding('UTF-8').each_line.grep(/mFocusedApp.+[\.\/]([^.\s\/\}]+)/){$1}.first
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
57
|
+
def calabash_log(message)
|
58
58
|
$stdout.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")} - #{message}" if (ARGV.include? "-v" or ARGV.include? "--verbose" or ENV["DEBUG"] == "1")
|
59
59
|
end
|
60
60
|
|
@@ -326,8 +326,8 @@ module Calabash module Android
|
|
326
326
|
@test_server_port = test_server_port
|
327
327
|
|
328
328
|
forward_cmd = "#{adb_command} forward tcp:#{@server_port} tcp:#{@test_server_port}"
|
329
|
-
|
330
|
-
|
329
|
+
calabash_log forward_cmd
|
330
|
+
calabash_log `#{forward_cmd}`
|
331
331
|
end
|
332
332
|
|
333
333
|
def _sdk_version
|
@@ -356,7 +356,7 @@ module Calabash module Android
|
|
356
356
|
md5 = Digest::MD5.file(File.expand_path(app))
|
357
357
|
|
358
358
|
if !application_installed?(package) || (!@@installed_apps.keys.include?(package) || @@installed_apps[package] != md5)
|
359
|
-
|
359
|
+
calabash_log "MD5 checksum for app '#{app}' (#{package}): #{md5}"
|
360
360
|
uninstall_app(package)
|
361
361
|
install_app(app)
|
362
362
|
@@installed_apps[package] = md5
|
@@ -371,9 +371,9 @@ module Calabash module Android
|
|
371
371
|
cmd = "#{adb_command} install -t \"#{app_path}\""
|
372
372
|
end
|
373
373
|
|
374
|
-
|
374
|
+
calabash_log "Installing: #{app_path}"
|
375
375
|
result = `#{cmd}`
|
376
|
-
|
376
|
+
calabash_log result
|
377
377
|
pn = package_name(app_path)
|
378
378
|
succeeded = `#{adb_command} shell pm list packages`.lines.map{|line| line.chomp.sub("package:", "")}.include?(pn)
|
379
379
|
|
@@ -385,7 +385,7 @@ module Calabash module Android
|
|
385
385
|
# Enable GPS location mocking on Android Marshmallow+
|
386
386
|
if _sdk_version >= 23
|
387
387
|
cmd = "#{adb_command} shell appops set #{package_name(app_path)} 58 allow"
|
388
|
-
|
388
|
+
calabash_log("Enabling GPS mocking using '#{cmd}'")
|
389
389
|
`#{cmd}`
|
390
390
|
end
|
391
391
|
|
@@ -399,9 +399,9 @@ module Calabash module Android
|
|
399
399
|
cmd = "#{adb_command} install -r \"#{app_path}\""
|
400
400
|
end
|
401
401
|
|
402
|
-
|
402
|
+
calabash_log "Updating: #{app_path}"
|
403
403
|
result = `#{cmd}`
|
404
|
-
|
404
|
+
calabash_log "result: #{result}"
|
405
405
|
succeeded = result.include?("Success")
|
406
406
|
|
407
407
|
unless succeeded
|
@@ -415,8 +415,8 @@ module Calabash module Android
|
|
415
415
|
exists = application_installed?(package_name)
|
416
416
|
|
417
417
|
if exists
|
418
|
-
|
419
|
-
|
418
|
+
calabash_log "Uninstalling: #{package_name}"
|
419
|
+
calabash_log `#{adb_command} uninstall #{package_name}`
|
420
420
|
|
421
421
|
succeeded = !application_installed?(package_name)
|
422
422
|
|
@@ -425,7 +425,7 @@ module Calabash module Android
|
|
425
425
|
raise "#{package_name} was not uninstalled. Aborting!"
|
426
426
|
end
|
427
427
|
else
|
428
|
-
|
428
|
+
calabash_log "Package not installed: #{package_name}. Skipping uninstall."
|
429
429
|
end
|
430
430
|
end
|
431
431
|
|
@@ -448,7 +448,7 @@ module Calabash module Android
|
|
448
448
|
end
|
449
449
|
|
450
450
|
def perform_action(action, *arguments)
|
451
|
-
|
451
|
+
calabash_log "Action: #{action} - Params: #{arguments.join(', ')}"
|
452
452
|
|
453
453
|
params = {"command" => action, "arguments" => arguments}
|
454
454
|
|
@@ -456,10 +456,10 @@ module Calabash module Android
|
|
456
456
|
begin
|
457
457
|
result = http("/", params, {:read_timeout => 350})
|
458
458
|
rescue => e
|
459
|
-
|
459
|
+
calabash_log "Error communicating with test server: #{e}"
|
460
460
|
raise e
|
461
461
|
end
|
462
|
-
|
462
|
+
calabash_log "Result:'" + result.strip + "'"
|
463
463
|
raise "Empty result from TestServer" if result.chomp.empty?
|
464
464
|
result = JSON.parse(result)
|
465
465
|
if not result["success"] then
|
@@ -485,7 +485,7 @@ module Calabash module Android
|
|
485
485
|
HTTPClient::KeepAliveDisconnected,
|
486
486
|
Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED,
|
487
487
|
Errno::ETIMEDOUT => e
|
488
|
-
|
488
|
+
calabash_log "It looks like your app is no longer running. \nIt could be because of a crash or because your test script shut it down."
|
489
489
|
raise e
|
490
490
|
end
|
491
491
|
end
|
@@ -504,7 +504,7 @@ module Calabash module Android
|
|
504
504
|
HTTPClient::KeepAliveDisconnected,
|
505
505
|
Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED,
|
506
506
|
Errno::ETIMEDOUT => e
|
507
|
-
|
507
|
+
calabash_log "It looks like your app is no longer running. \nIt could be because of a crash or because your test script shut it down."
|
508
508
|
raise e
|
509
509
|
end
|
510
510
|
end
|
@@ -603,7 +603,7 @@ module Calabash module Android
|
|
603
603
|
end
|
604
604
|
else
|
605
605
|
screenshot_cmd = "java -jar \"#{File.join(File.dirname(__FILE__), 'lib', 'screenshotTaker.jar')}\" #{serial} \"#{path}\""
|
606
|
-
|
606
|
+
calabash_log screenshot_cmd
|
607
607
|
raise "Could not take screenshot" unless system(screenshot_cmd)
|
608
608
|
end
|
609
609
|
|
@@ -620,8 +620,8 @@ module Calabash module Android
|
|
620
620
|
response = perform_action('version')
|
621
621
|
raise 'Invalid response' unless response['success']
|
622
622
|
rescue => e
|
623
|
-
|
624
|
-
|
623
|
+
calabash_log("Could not contact server")
|
624
|
+
calabash_log(e && e.backtrace && e.backtrace.join("\n"))
|
625
625
|
raise "The server did not respond. Make sure the server is running."
|
626
626
|
end
|
627
627
|
|
@@ -634,7 +634,7 @@ module Calabash module Android
|
|
634
634
|
|
635
635
|
def default_serial
|
636
636
|
devices = connected_devices
|
637
|
-
|
637
|
+
calabash_log "connected_devices: #{devices}"
|
638
638
|
raise "No connected devices" if devices.empty?
|
639
639
|
raise "More than one device connected. Specify device serial using ADB_DEVICE_ARG" if devices.length > 1
|
640
640
|
devices.first
|
@@ -656,7 +656,7 @@ module Calabash module Android
|
|
656
656
|
f.write(YAML::dump(state))
|
657
657
|
f.truncate(f.pos)
|
658
658
|
|
659
|
-
|
659
|
+
calabash_log "Persistently allocated port #{port} to #{serial}"
|
660
660
|
return port
|
661
661
|
end
|
662
662
|
end
|
@@ -676,8 +676,8 @@ module Calabash module Android
|
|
676
676
|
|
677
677
|
def wake_up
|
678
678
|
wake_up_cmd = "#{adb_command} shell am start -a android.intent.action.MAIN -n #{package_name(@test_server_path)}/sh.calaba.instrumentationbackend.WakeUp"
|
679
|
-
|
680
|
-
|
679
|
+
calabash_log "Waking up device using:"
|
680
|
+
calabash_log wake_up_cmd
|
681
681
|
raise "Could not wake up the device" unless system(wake_up_cmd)
|
682
682
|
|
683
683
|
Calabash::Android::Retry.retry :tries => 10, :interval => 1 do
|
@@ -744,8 +744,8 @@ module Calabash module Android
|
|
744
744
|
else
|
745
745
|
cmd = cmd_arr.join(" ")
|
746
746
|
|
747
|
-
|
748
|
-
|
747
|
+
calabash_log "Starting test server using:"
|
748
|
+
calabash_log cmd
|
749
749
|
raise "Could not execute command to start test server" unless system("#{cmd} 2>&1")
|
750
750
|
end
|
751
751
|
|
@@ -755,15 +755,15 @@ module Calabash module Android
|
|
755
755
|
|
756
756
|
begin
|
757
757
|
Calabash::Android::Retry.retry :tries => 300, :interval => 0.1 do
|
758
|
-
|
758
|
+
calabash_log "Checking if instrumentation backend is ready"
|
759
759
|
|
760
|
-
|
760
|
+
calabash_log "Is app running? #{app_running?}"
|
761
761
|
ready = http("/ready", {}, {:read_timeout => 1})
|
762
762
|
if ready != "true"
|
763
|
-
|
763
|
+
calabash_log "Instrumentation backend not yet ready"
|
764
764
|
raise "Not ready"
|
765
765
|
else
|
766
|
-
|
766
|
+
calabash_log "Instrumentation backend is ready!"
|
767
767
|
end
|
768
768
|
end
|
769
769
|
rescue => e
|
@@ -779,24 +779,24 @@ module Calabash module Android
|
|
779
779
|
msg = ["Unable to obtain Test Server version. "]
|
780
780
|
msg << "Please run 'reinstall_test_server' to make sure you have the correct version"
|
781
781
|
msg_s = msg.join("\n")
|
782
|
-
|
782
|
+
calabash_log(msg_s)
|
783
783
|
raise msg_s
|
784
784
|
end
|
785
785
|
|
786
786
|
client_version = client_version()
|
787
787
|
|
788
788
|
if Calabash::Android::Environment.skip_version_check?
|
789
|
-
|
789
|
+
calabash_log(%Q[
|
790
790
|
Client version #{client_version}
|
791
791
|
Test-server version #{server_version}
|
792
792
|
|
793
793
|
])
|
794
794
|
$stdout.flush
|
795
795
|
else
|
796
|
-
|
796
|
+
calabash_log "Checking client-server version match..."
|
797
797
|
|
798
798
|
if server_version != client_version
|
799
|
-
|
799
|
+
calabash_log(%Q[
|
800
800
|
Calabash Client and Test-server version mismatch.
|
801
801
|
|
802
802
|
Client version #{client_version}
|
@@ -809,7 +809,7 @@ Run 'reinstall_test_server' to make sure you have the correct version
|
|
809
809
|
|
810
810
|
])
|
811
811
|
else
|
812
|
-
|
812
|
+
calabash_log("Client and server versions match (client: #{client_version}, server: #{server_version}). Proceeding...")
|
813
813
|
end
|
814
814
|
end
|
815
815
|
|
@@ -851,11 +851,11 @@ Run 'reinstall_test_server' to make sure you have the correct version
|
|
851
851
|
sleep 0.3 while app_running?
|
852
852
|
end
|
853
853
|
rescue HTTPClient::KeepAliveDisconnected
|
854
|
-
|
854
|
+
calabash_log ("Server not responding. Moving on.")
|
855
855
|
rescue Timeout::Error
|
856
|
-
|
856
|
+
calabash_log ("Could not kill app. Waited to 3 seconds.")
|
857
857
|
rescue EOFError
|
858
|
-
|
858
|
+
calabash_log ("Could not kill app. App is most likely not running anymore.")
|
859
859
|
end
|
860
860
|
end
|
861
861
|
|
@@ -875,7 +875,7 @@ Run 'reinstall_test_server' to make sure you have the correct version
|
|
875
875
|
|
876
876
|
def get_preferences(name)
|
877
877
|
|
878
|
-
|
878
|
+
calabash_log "Get preferences: #{name}, app running? #{app_running?}"
|
879
879
|
preferences = {}
|
880
880
|
|
881
881
|
if app_running?
|
@@ -909,7 +909,7 @@ Run 'reinstall_test_server' to make sure you have the correct version
|
|
909
909
|
|
910
910
|
def set_preferences(name, hash)
|
911
911
|
|
912
|
-
|
912
|
+
calabash_log "Set preferences: #{name}, #{hash}, app running? #{app_running?}"
|
913
913
|
|
914
914
|
if app_running?
|
915
915
|
perform_action('set_preferences', name, hash);
|
@@ -934,7 +934,7 @@ Run 'reinstall_test_server' to make sure you have the correct version
|
|
934
934
|
|
935
935
|
def clear_preferences(name)
|
936
936
|
|
937
|
-
|
937
|
+
calabash_log "Clear preferences: #{name}, app running? #{app_running?}"
|
938
938
|
|
939
939
|
if app_running?
|
940
940
|
perform_action('clear_preferences', name);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calabash-android
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Maturana Larsen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -56,22 +56,16 @@ dependencies:
|
|
56
56
|
name: rubyzip
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.2.2
|
62
|
-
- - "<"
|
59
|
+
- - '='
|
63
60
|
- !ruby/object:Gem::Version
|
64
|
-
version:
|
61
|
+
version: 1.2.1
|
65
62
|
type: :runtime
|
66
63
|
prerelease: false
|
67
64
|
version_requirements: !ruby/object:Gem::Requirement
|
68
65
|
requirements:
|
69
|
-
- -
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: 1.2.2
|
72
|
-
- - "<"
|
66
|
+
- - '='
|
73
67
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
68
|
+
version: 1.2.1
|
75
69
|
- !ruby/object:Gem::Dependency
|
76
70
|
name: awesome_print
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|