calabash-android 0.9.19 → 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/lib/AndroidManifest.xml +2 -2
- data/lib/calabash-android/lib/TestServer.apk +0 -0
- data/lib/calabash-android/operations.rb +46 -42
- data/lib/calabash-android/version.rb +1 -1
- metadata +4 -4
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
|
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
4
4
|
package="#testPackage#"
|
5
|
-
android:versionCode="
|
6
|
-
android:versionName="0.9.
|
5
|
+
android:versionCode="21"
|
6
|
+
android:versionName="0.9.21">
|
7
7
|
|
8
8
|
<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="28" />
|
9
9
|
|
Binary file
|
@@ -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
|
|
@@ -158,7 +158,11 @@ module Calabash module Android
|
|
158
158
|
|
159
159
|
def screenshot_embed(options={:prefix => nil, :name => nil, :label => nil})
|
160
160
|
path = default_device.screenshot(options)
|
161
|
-
|
161
|
+
begin
|
162
|
+
embed(path, "image/png", options[:label] || File.basename(path))
|
163
|
+
rescue NoMethodError
|
164
|
+
attach(path, "image/png")
|
165
|
+
end
|
162
166
|
end
|
163
167
|
|
164
168
|
def screenshot(options={:prefix => nil, :name => nil})
|
@@ -322,8 +326,8 @@ module Calabash module Android
|
|
322
326
|
@test_server_port = test_server_port
|
323
327
|
|
324
328
|
forward_cmd = "#{adb_command} forward tcp:#{@server_port} tcp:#{@test_server_port}"
|
325
|
-
|
326
|
-
|
329
|
+
calabash_log forward_cmd
|
330
|
+
calabash_log `#{forward_cmd}`
|
327
331
|
end
|
328
332
|
|
329
333
|
def _sdk_version
|
@@ -352,7 +356,7 @@ module Calabash module Android
|
|
352
356
|
md5 = Digest::MD5.file(File.expand_path(app))
|
353
357
|
|
354
358
|
if !application_installed?(package) || (!@@installed_apps.keys.include?(package) || @@installed_apps[package] != md5)
|
355
|
-
|
359
|
+
calabash_log "MD5 checksum for app '#{app}' (#{package}): #{md5}"
|
356
360
|
uninstall_app(package)
|
357
361
|
install_app(app)
|
358
362
|
@@installed_apps[package] = md5
|
@@ -367,9 +371,9 @@ module Calabash module Android
|
|
367
371
|
cmd = "#{adb_command} install -t \"#{app_path}\""
|
368
372
|
end
|
369
373
|
|
370
|
-
|
374
|
+
calabash_log "Installing: #{app_path}"
|
371
375
|
result = `#{cmd}`
|
372
|
-
|
376
|
+
calabash_log result
|
373
377
|
pn = package_name(app_path)
|
374
378
|
succeeded = `#{adb_command} shell pm list packages`.lines.map{|line| line.chomp.sub("package:", "")}.include?(pn)
|
375
379
|
|
@@ -381,7 +385,7 @@ module Calabash module Android
|
|
381
385
|
# Enable GPS location mocking on Android Marshmallow+
|
382
386
|
if _sdk_version >= 23
|
383
387
|
cmd = "#{adb_command} shell appops set #{package_name(app_path)} 58 allow"
|
384
|
-
|
388
|
+
calabash_log("Enabling GPS mocking using '#{cmd}'")
|
385
389
|
`#{cmd}`
|
386
390
|
end
|
387
391
|
|
@@ -395,9 +399,9 @@ module Calabash module Android
|
|
395
399
|
cmd = "#{adb_command} install -r \"#{app_path}\""
|
396
400
|
end
|
397
401
|
|
398
|
-
|
402
|
+
calabash_log "Updating: #{app_path}"
|
399
403
|
result = `#{cmd}`
|
400
|
-
|
404
|
+
calabash_log "result: #{result}"
|
401
405
|
succeeded = result.include?("Success")
|
402
406
|
|
403
407
|
unless succeeded
|
@@ -411,8 +415,8 @@ module Calabash module Android
|
|
411
415
|
exists = application_installed?(package_name)
|
412
416
|
|
413
417
|
if exists
|
414
|
-
|
415
|
-
|
418
|
+
calabash_log "Uninstalling: #{package_name}"
|
419
|
+
calabash_log `#{adb_command} uninstall #{package_name}`
|
416
420
|
|
417
421
|
succeeded = !application_installed?(package_name)
|
418
422
|
|
@@ -421,7 +425,7 @@ module Calabash module Android
|
|
421
425
|
raise "#{package_name} was not uninstalled. Aborting!"
|
422
426
|
end
|
423
427
|
else
|
424
|
-
|
428
|
+
calabash_log "Package not installed: #{package_name}. Skipping uninstall."
|
425
429
|
end
|
426
430
|
end
|
427
431
|
|
@@ -444,7 +448,7 @@ module Calabash module Android
|
|
444
448
|
end
|
445
449
|
|
446
450
|
def perform_action(action, *arguments)
|
447
|
-
|
451
|
+
calabash_log "Action: #{action} - Params: #{arguments.join(', ')}"
|
448
452
|
|
449
453
|
params = {"command" => action, "arguments" => arguments}
|
450
454
|
|
@@ -452,10 +456,10 @@ module Calabash module Android
|
|
452
456
|
begin
|
453
457
|
result = http("/", params, {:read_timeout => 350})
|
454
458
|
rescue => e
|
455
|
-
|
459
|
+
calabash_log "Error communicating with test server: #{e}"
|
456
460
|
raise e
|
457
461
|
end
|
458
|
-
|
462
|
+
calabash_log "Result:'" + result.strip + "'"
|
459
463
|
raise "Empty result from TestServer" if result.chomp.empty?
|
460
464
|
result = JSON.parse(result)
|
461
465
|
if not result["success"] then
|
@@ -481,7 +485,7 @@ module Calabash module Android
|
|
481
485
|
HTTPClient::KeepAliveDisconnected,
|
482
486
|
Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED,
|
483
487
|
Errno::ETIMEDOUT => e
|
484
|
-
|
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."
|
485
489
|
raise e
|
486
490
|
end
|
487
491
|
end
|
@@ -500,7 +504,7 @@ module Calabash module Android
|
|
500
504
|
HTTPClient::KeepAliveDisconnected,
|
501
505
|
Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED,
|
502
506
|
Errno::ETIMEDOUT => e
|
503
|
-
|
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."
|
504
508
|
raise e
|
505
509
|
end
|
506
510
|
end
|
@@ -599,7 +603,7 @@ module Calabash module Android
|
|
599
603
|
end
|
600
604
|
else
|
601
605
|
screenshot_cmd = "java -jar \"#{File.join(File.dirname(__FILE__), 'lib', 'screenshotTaker.jar')}\" #{serial} \"#{path}\""
|
602
|
-
|
606
|
+
calabash_log screenshot_cmd
|
603
607
|
raise "Could not take screenshot" unless system(screenshot_cmd)
|
604
608
|
end
|
605
609
|
|
@@ -616,8 +620,8 @@ module Calabash module Android
|
|
616
620
|
response = perform_action('version')
|
617
621
|
raise 'Invalid response' unless response['success']
|
618
622
|
rescue => e
|
619
|
-
|
620
|
-
|
623
|
+
calabash_log("Could not contact server")
|
624
|
+
calabash_log(e && e.backtrace && e.backtrace.join("\n"))
|
621
625
|
raise "The server did not respond. Make sure the server is running."
|
622
626
|
end
|
623
627
|
|
@@ -630,7 +634,7 @@ module Calabash module Android
|
|
630
634
|
|
631
635
|
def default_serial
|
632
636
|
devices = connected_devices
|
633
|
-
|
637
|
+
calabash_log "connected_devices: #{devices}"
|
634
638
|
raise "No connected devices" if devices.empty?
|
635
639
|
raise "More than one device connected. Specify device serial using ADB_DEVICE_ARG" if devices.length > 1
|
636
640
|
devices.first
|
@@ -652,7 +656,7 @@ module Calabash module Android
|
|
652
656
|
f.write(YAML::dump(state))
|
653
657
|
f.truncate(f.pos)
|
654
658
|
|
655
|
-
|
659
|
+
calabash_log "Persistently allocated port #{port} to #{serial}"
|
656
660
|
return port
|
657
661
|
end
|
658
662
|
end
|
@@ -672,8 +676,8 @@ module Calabash module Android
|
|
672
676
|
|
673
677
|
def wake_up
|
674
678
|
wake_up_cmd = "#{adb_command} shell am start -a android.intent.action.MAIN -n #{package_name(@test_server_path)}/sh.calaba.instrumentationbackend.WakeUp"
|
675
|
-
|
676
|
-
|
679
|
+
calabash_log "Waking up device using:"
|
680
|
+
calabash_log wake_up_cmd
|
677
681
|
raise "Could not wake up the device" unless system(wake_up_cmd)
|
678
682
|
|
679
683
|
Calabash::Android::Retry.retry :tries => 10, :interval => 1 do
|
@@ -740,8 +744,8 @@ module Calabash module Android
|
|
740
744
|
else
|
741
745
|
cmd = cmd_arr.join(" ")
|
742
746
|
|
743
|
-
|
744
|
-
|
747
|
+
calabash_log "Starting test server using:"
|
748
|
+
calabash_log cmd
|
745
749
|
raise "Could not execute command to start test server" unless system("#{cmd} 2>&1")
|
746
750
|
end
|
747
751
|
|
@@ -751,15 +755,15 @@ module Calabash module Android
|
|
751
755
|
|
752
756
|
begin
|
753
757
|
Calabash::Android::Retry.retry :tries => 300, :interval => 0.1 do
|
754
|
-
|
758
|
+
calabash_log "Checking if instrumentation backend is ready"
|
755
759
|
|
756
|
-
|
760
|
+
calabash_log "Is app running? #{app_running?}"
|
757
761
|
ready = http("/ready", {}, {:read_timeout => 1})
|
758
762
|
if ready != "true"
|
759
|
-
|
763
|
+
calabash_log "Instrumentation backend not yet ready"
|
760
764
|
raise "Not ready"
|
761
765
|
else
|
762
|
-
|
766
|
+
calabash_log "Instrumentation backend is ready!"
|
763
767
|
end
|
764
768
|
end
|
765
769
|
rescue => e
|
@@ -775,24 +779,24 @@ module Calabash module Android
|
|
775
779
|
msg = ["Unable to obtain Test Server version. "]
|
776
780
|
msg << "Please run 'reinstall_test_server' to make sure you have the correct version"
|
777
781
|
msg_s = msg.join("\n")
|
778
|
-
|
782
|
+
calabash_log(msg_s)
|
779
783
|
raise msg_s
|
780
784
|
end
|
781
785
|
|
782
786
|
client_version = client_version()
|
783
787
|
|
784
788
|
if Calabash::Android::Environment.skip_version_check?
|
785
|
-
|
789
|
+
calabash_log(%Q[
|
786
790
|
Client version #{client_version}
|
787
791
|
Test-server version #{server_version}
|
788
792
|
|
789
793
|
])
|
790
794
|
$stdout.flush
|
791
795
|
else
|
792
|
-
|
796
|
+
calabash_log "Checking client-server version match..."
|
793
797
|
|
794
798
|
if server_version != client_version
|
795
|
-
|
799
|
+
calabash_log(%Q[
|
796
800
|
Calabash Client and Test-server version mismatch.
|
797
801
|
|
798
802
|
Client version #{client_version}
|
@@ -805,7 +809,7 @@ Run 'reinstall_test_server' to make sure you have the correct version
|
|
805
809
|
|
806
810
|
])
|
807
811
|
else
|
808
|
-
|
812
|
+
calabash_log("Client and server versions match (client: #{client_version}, server: #{server_version}). Proceeding...")
|
809
813
|
end
|
810
814
|
end
|
811
815
|
|
@@ -847,11 +851,11 @@ Run 'reinstall_test_server' to make sure you have the correct version
|
|
847
851
|
sleep 0.3 while app_running?
|
848
852
|
end
|
849
853
|
rescue HTTPClient::KeepAliveDisconnected
|
850
|
-
|
854
|
+
calabash_log ("Server not responding. Moving on.")
|
851
855
|
rescue Timeout::Error
|
852
|
-
|
856
|
+
calabash_log ("Could not kill app. Waited to 3 seconds.")
|
853
857
|
rescue EOFError
|
854
|
-
|
858
|
+
calabash_log ("Could not kill app. App is most likely not running anymore.")
|
855
859
|
end
|
856
860
|
end
|
857
861
|
|
@@ -871,7 +875,7 @@ Run 'reinstall_test_server' to make sure you have the correct version
|
|
871
875
|
|
872
876
|
def get_preferences(name)
|
873
877
|
|
874
|
-
|
878
|
+
calabash_log "Get preferences: #{name}, app running? #{app_running?}"
|
875
879
|
preferences = {}
|
876
880
|
|
877
881
|
if app_running?
|
@@ -905,7 +909,7 @@ Run 'reinstall_test_server' to make sure you have the correct version
|
|
905
909
|
|
906
910
|
def set_preferences(name, hash)
|
907
911
|
|
908
|
-
|
912
|
+
calabash_log "Set preferences: #{name}, #{hash}, app running? #{app_running?}"
|
909
913
|
|
910
914
|
if app_running?
|
911
915
|
perform_action('set_preferences', name, hash);
|
@@ -930,7 +934,7 @@ Run 'reinstall_test_server' to make sure you have the correct version
|
|
930
934
|
|
931
935
|
def clear_preferences(name)
|
932
936
|
|
933
|
-
|
937
|
+
calabash_log "Clear preferences: #{name}, app running? #{app_running?}"
|
934
938
|
|
935
939
|
if app_running?
|
936
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
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.2.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.2.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: awesome_print
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|