calabash 2.0.0.pre1 → 2.0.0.prelegacy2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -38
- data/lib/calabash.rb +18 -5
- data/lib/calabash/android.rb +3 -0
- data/lib/calabash/android/adb.rb +25 -1
- data/lib/calabash/android/application.rb +14 -3
- data/lib/calabash/android/build/builder.rb +15 -2
- data/lib/calabash/android/build/java_keystore.rb +10 -0
- data/lib/calabash/android/build/resigner.rb +4 -0
- data/lib/calabash/android/build/test_server.rb +2 -0
- data/lib/calabash/android/defaults.rb +1 -0
- data/lib/calabash/android/device.rb +42 -1
- data/lib/calabash/android/environment.rb +10 -0
- data/lib/calabash/android/interactions.rb +2 -0
- data/lib/calabash/android/legacy.rb +149 -0
- data/lib/calabash/android/lib/TestServer.apk +0 -0
- data/lib/calabash/android/life_cycle.rb +1 -0
- data/lib/calabash/android/physical_buttons.rb +8 -0
- data/lib/calabash/android/screenshot.rb +1 -0
- data/lib/calabash/android/scroll.rb +110 -0
- data/lib/calabash/android/server.rb +3 -1
- data/lib/calabash/android/text.rb +6 -0
- data/lib/calabash/application.rb +29 -0
- data/lib/calabash/cli/build.rb +15 -1
- data/lib/calabash/cli/console.rb +9 -5
- data/lib/calabash/cli/generate.rb +3 -0
- data/lib/calabash/cli/helpers.rb +7 -1
- data/lib/calabash/cli/resign.rb +1 -0
- data/lib/calabash/cli/run.rb +10 -6
- data/lib/calabash/cli/setup_keystore.rb +2 -0
- data/lib/calabash/color.rb +7 -0
- data/lib/calabash/defaults.rb +1 -0
- data/lib/calabash/device.rb +7 -0
- data/lib/calabash/environment.rb +1 -0
- data/lib/calabash/http/retriable_client.rb +2 -0
- data/lib/calabash/interactions.rb +1 -0
- data/lib/calabash/ios.rb +2 -0
- data/lib/calabash/ios/application.rb +8 -1
- data/lib/calabash/ios/conditions.rb +3 -0
- data/lib/calabash/ios/date_picker.rb +412 -0
- data/lib/calabash/ios/defaults.rb +1 -0
- data/lib/calabash/ios/device.rb +1 -0
- data/lib/calabash/ios/device/device_implementation.rb +16 -11
- data/lib/calabash/ios/device/ipad_1x_2x_mixin.rb +253 -0
- data/lib/calabash/ios/device/keyboard_mixin.rb +2 -0
- data/lib/calabash/ios/device/rotation_mixin.rb +1 -0
- data/lib/calabash/ios/device/routes/condition_route_mixin.rb +1 -0
- data/lib/calabash/ios/device/routes/map_route_mixin.rb +1 -0
- data/lib/calabash/ios/device/routes/response_parser.rb +1 -0
- data/lib/calabash/ios/device/routes/uia_route_mixin.rb +44 -6
- data/lib/calabash/ios/device/text_mixin.rb +2 -0
- data/lib/calabash/ios/device/uia_keyboard_mixin.rb +9 -0
- data/lib/calabash/ios/device/uia_mixin.rb +1 -0
- data/lib/calabash/ios/interactions.rb +30 -1
- data/lib/calabash/ios/runtime.rb +8 -0
- data/lib/calabash/ios/text.rb +5 -45
- data/lib/calabash/legacy.rb +7 -0
- data/lib/calabash/lib/skeleton/config/cucumber.yml +1 -3
- data/lib/calabash/lib/skeleton/features/support/env.rb +15 -1
- data/lib/calabash/life_cycle.rb +19 -2
- data/lib/calabash/location.rb +2 -0
- data/lib/calabash/page.rb +13 -0
- data/lib/calabash/patch.rb +1 -0
- data/lib/calabash/query_result.rb +4 -0
- data/lib/calabash/text.rb +53 -0
- data/lib/calabash/utility.rb +4 -4
- data/lib/calabash/version.rb +1 -1
- data/lib/calabash/wait.rb +4 -0
- metadata +119 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7eec9905c00a2b1822fe2023e350f2f62c419c0a
|
4
|
+
data.tar.gz: 6e04cfd68a0a182b63344fdf5656afc35613bf59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fb4d1de04c47649ceade147f1977eef6ce298c2f4216f0d0861bef340ed57bbc49dfac5626d0932bb4827629aa81989db7d5d51f640a1bc5cf4856ec391e2e8
|
7
|
+
data.tar.gz: 67fd7bdd4c7f84483ed9424ec9540e8acbff3add8dfc5ce4f5d3813c3507c38a4b49cc1ee50cbb41cd4cd72d90ebf72df97a14d6dd189ec1abaae652f039b1ef
|
data/README.md
CHANGED
@@ -6,18 +6,6 @@
|
|
6
6
|
|
7
7
|
Automated Acceptance Testing for Mobile Apps
|
8
8
|
|
9
|
-
## Initial workflow
|
10
|
-
|
11
|
-
**TL;DR**
|
12
|
-
|
13
|
-
```
|
14
|
-
$ cd calabash
|
15
|
-
$ ./copy_repos.sh
|
16
|
-
$ ./changing_old_files.sh
|
17
|
-
```
|
18
|
-
|
19
|
-
Before Calabash is ready to be released, the old gems will exist outside version control. To make a change run the script `copy_repos.sh`. This will copy the Android and iOS repositories and extract them as files in the directory `old`. Then execute `changing_old_files.sh`. This script will move old files into their new directories. To make changes to "old files" e.g. move them, add your steps to `changing_old_files.sh` and execute it. To make code changes to old files, change them locally first to ensure they work. Then copy the change to the branch `united` on either iOS or Android. Commit the changes and push them upstream. `copy_repos.sh` will always download the newest files.
|
20
|
-
|
21
9
|
## Rake
|
22
10
|
|
23
11
|
**TODO** Release instructions for Android and iOS.
|
@@ -27,8 +15,6 @@ $ rake -T
|
|
27
15
|
rake android:build # Build the Android test server
|
28
16
|
rake build # Build calabash-1.9.9.pre2.gem into the pkg directory
|
29
17
|
rake ctags # Generate ctags in ./git/tags
|
30
|
-
rake cucumber:android # Run Android cucumber tests
|
31
|
-
rake cucumber:ios # Run iOS cucumber tests
|
32
18
|
rake install # Build and install calabash-1.9.9.pre2.gem into system gems
|
33
19
|
rake release # Create tag v1.9.9.pre2 and build and push calabash-1.9.9.pre2.gem to Rubygems
|
34
20
|
rake spec # Run RSpec code examples
|
@@ -63,28 +49,5 @@ $ be cucumber
|
|
63
49
|
|
64
50
|
### Cucumber iOS
|
65
51
|
|
66
|
-
|
67
|
-
$ cd cucumber/ios
|
68
|
-
$ bundle update
|
69
|
-
$ rake ensure_app # Optional. See note below.
|
70
|
-
$ be cucumber
|
71
|
-
```
|
72
|
-
|
73
|
-
The rake task `ensure_app` checks the `cucumber/ios` directory for
|
74
|
-
CalSmoke-cal.app. If it exists, it will do nothing. If it does not exist,
|
75
|
-
it will pull the latest sources from the CalSmoke repo, build the
|
76
|
-
CalSmoke-cal.app from the master branch, and install it in the
|
77
|
-
`cucumber/ios` directory.
|
78
|
-
|
79
|
-
If you want to use a different CalSmoke-cal.app, drop it into `cucumber/ios`
|
80
|
-
or call cucumber with `CAL\_APP` set.
|
81
|
-
|
82
|
-
```
|
83
|
-
$ CAL_APP=/path/to/your/CalSmoke-cal.app be cucumber
|
84
|
-
```
|
85
|
-
|
86
|
-
The rake task `ensure_ipa` does the same thing, but for the CalSmoke-cal.ipa.
|
87
|
-
|
88
|
-
Testing against physical devices requires that you have ideviceinstaller
|
89
|
-
installed in /usr/local/bin/ideviceinstaller.
|
52
|
+
See `cucumber/ios/README.md`.
|
90
53
|
|
data/lib/calabash.rb
CHANGED
@@ -25,6 +25,7 @@ module Calabash
|
|
25
25
|
require 'calabash/text'
|
26
26
|
require 'calabash/interactions'
|
27
27
|
require 'calabash/defaults'
|
28
|
+
require 'calabash/legacy'
|
28
29
|
require 'calabash/console_helpers'
|
29
30
|
|
30
31
|
|
@@ -112,7 +113,6 @@ module Calabash
|
|
112
113
|
raise ArgumentError, "Expected a 'Class', got '#{page_class.class}'"
|
113
114
|
end
|
114
115
|
|
115
|
-
|
116
116
|
page_name = page_class.name
|
117
117
|
full_page_name = "#{platform_module}::#{page_name}"
|
118
118
|
|
@@ -120,6 +120,17 @@ module Calabash
|
|
120
120
|
page_class = platform_module.const_get(page_name, false)
|
121
121
|
|
122
122
|
if page_class.is_a?(Class)
|
123
|
+
modules = page_class.included_modules.map(&:to_s)
|
124
|
+
|
125
|
+
unless modules.include?("Calabash::#{platform_module}")
|
126
|
+
raise "Page '#{page_class}' does not include Calabash::#{platform_module}"
|
127
|
+
end
|
128
|
+
|
129
|
+
if modules.include?('Calabash::Android') &&
|
130
|
+
modules.include?('Calabash::IOS')
|
131
|
+
raise "Page '#{page_class}' includes both Calabash::Android and Calabash::IOS"
|
132
|
+
end
|
133
|
+
|
123
134
|
page = page_class.send(:new, self)
|
124
135
|
|
125
136
|
if page.is_a?(Calabash::Page)
|
@@ -241,6 +252,7 @@ module Calabash
|
|
241
252
|
@@has_set_embedding_context
|
242
253
|
end
|
243
254
|
|
255
|
+
# @!visibility private
|
244
256
|
def self.new_embed_method(method)
|
245
257
|
define_method(:embed) do |*args|
|
246
258
|
method.call(*args)
|
@@ -249,6 +261,7 @@ module Calabash
|
|
249
261
|
@@has_set_embedding_context = true
|
250
262
|
end
|
251
263
|
|
264
|
+
# @!visibility private
|
252
265
|
def embed(*_)
|
253
266
|
Logger.warn 'Embed is not available in this context. Will not embed.'
|
254
267
|
end
|
@@ -264,9 +277,9 @@ unless Object.const_defined?(:IOS)
|
|
264
277
|
end
|
265
278
|
|
266
279
|
if Calabash::Environment::DEBUG_CALLED_METHODS
|
267
|
-
$stdout.puts "#{Calabash::Color.red(
|
268
|
-
$stdout.puts "#{Calabash::Color.red(
|
269
|
-
$stdout.puts "#{Calabash::Color.red(
|
280
|
+
$stdout.puts "#{Calabash::Color.red('Will print every Calabash method called!')}"
|
281
|
+
$stdout.puts "#{Calabash::Color.red('Warning: This might slow down your test drastically')}"
|
282
|
+
$stdout.puts "#{Calabash::Color.red('and is an experimental feature.')}"
|
270
283
|
|
271
284
|
calabash_file = Calabash.method(:extended).source_location.first
|
272
285
|
$__calabash_dir_name = File.dirname(calabash_file)
|
@@ -274,7 +287,7 @@ if Calabash::Environment::DEBUG_CALLED_METHODS
|
|
274
287
|
trace_func = lambda do |event, file, line, id, binding, classname|
|
275
288
|
if event == 'call'
|
276
289
|
if classname.to_s.split('::').first == 'Calabash'
|
277
|
-
binding_caller_locations = binding.eval(
|
290
|
+
binding_caller_locations = binding.eval('caller_locations')
|
278
291
|
files = binding_caller_locations[3..-1].map(&:path)
|
279
292
|
|
280
293
|
calabash_not_in_stacktrace = files.none? do |file|
|
data/lib/calabash/android.rb
CHANGED
@@ -38,6 +38,8 @@ module Calabash
|
|
38
38
|
require 'calabash/android/text'
|
39
39
|
require 'calabash/android/console_helpers'
|
40
40
|
require 'calabash/android/life_cycle'
|
41
|
+
require 'calabash/android/scroll'
|
42
|
+
require 'calabash/android/legacy'
|
41
43
|
|
42
44
|
include Calabash::Android::Gestures
|
43
45
|
include Calabash::Android::Interactions
|
@@ -45,6 +47,7 @@ module Calabash
|
|
45
47
|
include Calabash::Android::Orientation
|
46
48
|
include Calabash::Android::PhysicalButtons
|
47
49
|
include Calabash::Android::Text
|
50
|
+
include Calabash::Android::Scroll
|
48
51
|
|
49
52
|
# @!visibility private
|
50
53
|
def self.binary_location(name, abi, using_pie)
|
data/lib/calabash/android/adb.rb
CHANGED
@@ -17,8 +17,10 @@ module Calabash
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
# @!visibility private
|
20
21
|
PROCESS_WAIT_TIME = 10
|
21
22
|
|
23
|
+
# @!visibility private
|
22
24
|
def self.open_pipe_with_timeout(timeout, *cmd, &block)
|
23
25
|
begin
|
24
26
|
i, o, e, t, pid = nil
|
@@ -52,6 +54,7 @@ module Calabash
|
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
57
|
+
# @!visibility private
|
55
58
|
def self.open_adb_pipe(*cmd, **options, &block)
|
56
59
|
timeout = options.fetch(:timeout, PROCESS_WAIT_TIME)
|
57
60
|
|
@@ -60,11 +63,23 @@ module Calabash
|
|
60
63
|
end
|
61
64
|
end
|
62
65
|
|
66
|
+
# @!visibility private
|
63
67
|
DAEMON_STARTED_MESSAGE = "* daemon not running. starting it now on port 5037 *\n* daemon started successfully *\n"
|
64
68
|
|
65
69
|
def self.command(*cmd, **args)
|
66
70
|
Logger.debug("ADB Command: #{cmd.join(', ')}")
|
67
71
|
Logger.debug("ADB input: #{args[:input]}")
|
72
|
+
|
73
|
+
cmd_s = "#{Environment.adb_path} #{cmd.join(' ')}"
|
74
|
+
|
75
|
+
Logger.debug("Going to execute: #{cmd_s}")
|
76
|
+
`#{cmd_s}`
|
77
|
+
end
|
78
|
+
|
79
|
+
# @!visibility private
|
80
|
+
def self.old_command(*cmd, **args)
|
81
|
+
Logger.debug("ADB Command: #{cmd.join(', ')}")
|
82
|
+
Logger.debug("ADB input: #{args[:input]}")
|
68
83
|
stderr = nil
|
69
84
|
stdout = nil
|
70
85
|
exit_code = nil
|
@@ -121,10 +136,12 @@ module Calabash
|
|
121
136
|
|
122
137
|
attr_reader :serial
|
123
138
|
|
139
|
+
# @!visibility private
|
124
140
|
def initialize(serial)
|
125
141
|
@serial = serial
|
126
142
|
end
|
127
143
|
|
144
|
+
# @!visibility private
|
128
145
|
def command(*argv, **args)
|
129
146
|
cmd = argv.dup
|
130
147
|
|
@@ -135,9 +152,16 @@ module Calabash
|
|
135
152
|
ADB.command(*cmd, args)
|
136
153
|
end
|
137
154
|
|
155
|
+
# @!visibility private
|
156
|
+
def shell(shell_cmd, options={})
|
157
|
+
command('shell', shell_cmd)
|
158
|
+
end
|
159
|
+
|
160
|
+
# @!visibility private
|
138
161
|
END_STRING = '__CAL_END__'
|
139
162
|
|
140
|
-
|
163
|
+
# @!visibility private
|
164
|
+
def old_shell(shell_cmd, options={})
|
141
165
|
if shell_cmd.nil? || shell_cmd.empty?
|
142
166
|
raise ArgumentError, "Invalid shell command '#{shell_cmd}'"
|
143
167
|
end
|
@@ -8,7 +8,7 @@ module Calabash
|
|
8
8
|
application_path = Environment::APP_PATH
|
9
9
|
|
10
10
|
if application_path.nil?
|
11
|
-
raise 'No application path is set'
|
11
|
+
raise 'No application path is set. Specify application with environment variable CAL_APP'
|
12
12
|
end
|
13
13
|
|
14
14
|
unless File.exist?(application_path)
|
@@ -20,8 +20,12 @@ module Calabash
|
|
20
20
|
end
|
21
21
|
|
22
22
|
build_test_server = Build::TestServer.new(application_path)
|
23
|
-
test_server_path = Environment::TEST_SERVER_PATH
|
24
|
-
|
23
|
+
test_server_path = Environment::TEST_SERVER_PATH
|
24
|
+
|
25
|
+
unless test_server_path
|
26
|
+
test_server_path = build_test_server.path
|
27
|
+
Logger.info "No test-server specified. Defaulting to path '#{test_server_path}'"
|
28
|
+
end
|
25
29
|
|
26
30
|
unless File.exist?(test_server_path)
|
27
31
|
Logger.error "Test-server '#{test_server_path}' does not exist."
|
@@ -38,6 +42,13 @@ module Calabash
|
|
38
42
|
@test_server = Application.new(test_server_path, nil, options) if test_server_path
|
39
43
|
end
|
40
44
|
|
45
|
+
# Is this application an android application
|
46
|
+
#
|
47
|
+
# @return [Boolean] Always returns true
|
48
|
+
def android_application?
|
49
|
+
true
|
50
|
+
end
|
51
|
+
|
41
52
|
def extract_identifier
|
42
53
|
package_line = aapt_dump('package').first
|
43
54
|
raise "'package' not found in aapt output" unless package_line
|
@@ -16,7 +16,8 @@ module Calabash
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
# @!visibility private
|
20
|
+
def build(out_file = nil)
|
20
21
|
apk_fingerprint = fingerprint_from_apk
|
21
22
|
@logger.log "#{@application_path} was signed with a certificate with fingerprint #{apk_fingerprint}", :debug
|
22
23
|
|
@@ -48,7 +49,7 @@ module Calabash
|
|
48
49
|
|
49
50
|
application = Calabash::Application.from_path(@application_path)
|
50
51
|
|
51
|
-
test_server_file_name = TestServer.new(@application_path).path
|
52
|
+
test_server_file_name = out_file || TestServer.new(@application_path).path
|
52
53
|
FileUtils.mkdir_p File.dirname(test_server_file_name) unless File.exist? File.dirname(test_server_file_name)
|
53
54
|
|
54
55
|
Dir.mktmpdir do |workspace_dir|
|
@@ -69,6 +70,17 @@ module Calabash
|
|
69
70
|
|
70
71
|
Zip::File.new("dummy.apk").extract("AndroidManifest.xml","customAndroidManifest.xml")
|
71
72
|
Zip::File.open("TestServer.apk") do |zip_file|
|
73
|
+
begin
|
74
|
+
check_file("AndroidManifest.xml")
|
75
|
+
manifest_exists = true
|
76
|
+
rescue
|
77
|
+
manifest_exists = false
|
78
|
+
end
|
79
|
+
|
80
|
+
if manifest_exists
|
81
|
+
zip_file.remove("AndroidManifest.xml")
|
82
|
+
end
|
83
|
+
|
72
84
|
zip_file.add("AndroidManifest.xml", "customAndroidManifest.xml")
|
73
85
|
end
|
74
86
|
end
|
@@ -83,6 +95,7 @@ module Calabash
|
|
83
95
|
@logger.log "Done signing the test server. Moved it to #{test_server_file_name}"
|
84
96
|
end
|
85
97
|
|
98
|
+
# @!visibility private
|
86
99
|
def fingerprint_from_apk
|
87
100
|
application_path = File.expand_path(@application_path)
|
88
101
|
|
@@ -5,6 +5,7 @@ module Calabash
|
|
5
5
|
module Build
|
6
6
|
# @!visibility private
|
7
7
|
class JavaKeystore
|
8
|
+
# @!visibility private
|
8
9
|
CALABASH_KEYSTORE_SETTINGS_FILENAME = 'calabash_keystore_settings.json'
|
9
10
|
|
10
11
|
attr_reader :errors, :location, :keystore_alias, :store_password
|
@@ -68,6 +69,7 @@ module Calabash
|
|
68
69
|
@logger.log "Signature algorithm name: #{signature_algorithm_name}", :debug
|
69
70
|
end
|
70
71
|
|
72
|
+
# @!visibility private
|
71
73
|
def sign_apk(apk_path, dest_path)
|
72
74
|
raise "Cannot sign with a miss configured keystore" if errors
|
73
75
|
raise "No such file: #{apk_path}" unless File.exists?(apk_path)
|
@@ -86,6 +88,7 @@ module Calabash
|
|
86
88
|
end
|
87
89
|
end
|
88
90
|
|
91
|
+
# @!visibility private
|
89
92
|
def system_with_stdout_on_success(cmd, *args)
|
90
93
|
a = Escape.shell_command(args)
|
91
94
|
cmd = "#{cmd} #{a.gsub("'", '"')}"
|
@@ -98,10 +101,12 @@ module Calabash
|
|
98
101
|
end
|
99
102
|
end
|
100
103
|
|
104
|
+
# @!visibility private
|
101
105
|
def fail_wrong_info
|
102
106
|
raise "Could not read keystore with the given credentials. Please ensure "
|
103
107
|
end
|
104
108
|
|
109
|
+
# @!visibility private
|
105
110
|
def self.read_keystore_with_default_password_and_alias(path)
|
106
111
|
path = File.expand_path path
|
107
112
|
|
@@ -128,6 +133,7 @@ module Calabash
|
|
128
133
|
end
|
129
134
|
end
|
130
135
|
|
136
|
+
# @!visibility private
|
131
137
|
def self.get_keystores
|
132
138
|
if keystore = keystore_from_settings
|
133
139
|
[ keystore ]
|
@@ -141,6 +147,7 @@ module Calabash
|
|
141
147
|
end
|
142
148
|
end
|
143
149
|
|
150
|
+
# @!visibility private
|
144
151
|
def self.keystore_from_settings
|
145
152
|
if File.exist?(CALABASH_KEYSTORE_SETTINGS_FILENAME)
|
146
153
|
Logger.info "Reading keystore information specified in #{CALABASH_KEYSTORE_SETTINGS_FILENAME}"
|
@@ -157,16 +164,19 @@ module Calabash
|
|
157
164
|
end
|
158
165
|
end
|
159
166
|
|
167
|
+
# @!visibility private
|
160
168
|
def self.fail_if_key_missing(map, key)
|
161
169
|
raise "Found #{CALABASH_KEYSTORE_SETTINGS_FILENAME} but no #{key} defined." unless map[key]
|
162
170
|
end
|
163
171
|
|
172
|
+
# @!visibility private
|
164
173
|
def self.extract_md5_fingerprint(fingerprints)
|
165
174
|
m = fingerprints.scan(/MD5.*((?:[a-fA-F\d]{2}:){15}[a-fA-F\d]{2})/).flatten
|
166
175
|
raise "No MD5 fingerprint found:\n #{fingerprints}" if m.empty?
|
167
176
|
m.first
|
168
177
|
end
|
169
178
|
|
179
|
+
# @!visibility private
|
170
180
|
def self.extract_signature_algorithm_name(fingerprints)
|
171
181
|
m = fingerprints.scan(/Signature algorithm name: (.*)/).flatten
|
172
182
|
raise "No signature algorithm names found:\n #{fingerprints}" if m.empty?
|
@@ -14,6 +14,7 @@ module Calabash
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
# @!visibility private
|
17
18
|
def resign!
|
18
19
|
Dir.mktmpdir do |tmp_dir|
|
19
20
|
@logger.log 'Resigning apk', :debug
|
@@ -26,6 +27,7 @@ module Calabash
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
30
|
+
# @!visibility private
|
29
31
|
def unsign(unsigned_path)
|
30
32
|
meta_files = `"#{Environment.aapt_path}" list "#{unsigned_path}"`.lines.collect(&:strip).grep(/^META-INF\//)
|
31
33
|
|
@@ -53,12 +55,14 @@ module Calabash
|
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
58
|
+
# @!visibility private
|
56
59
|
def zipalign(unaligned_path, app_path)
|
57
60
|
cmd = %Q("#{Environment.zipalign_path}" -f 4 "#{unaligned_path}" "#{app_path}")
|
58
61
|
@logger.log "Zipaligning using: #{cmd}", :debug
|
59
62
|
system(cmd)
|
60
63
|
end
|
61
64
|
|
65
|
+
# @!visibility private
|
62
66
|
def sign(app_path, dest_path)
|
63
67
|
java_keystore = JavaKeystore.get_keystores.first
|
64
68
|
|
@@ -7,10 +7,12 @@ module Calabash
|
|
7
7
|
@application_path = application_path
|
8
8
|
end
|
9
9
|
|
10
|
+
# @!visibility private
|
10
11
|
def path
|
11
12
|
File.expand_path("test_servers/#{checksum(@application_path)}_#{VERSION}.apk")
|
12
13
|
end
|
13
14
|
|
15
|
+
# @!visibility private
|
14
16
|
def exists?
|
15
17
|
File.exists?(path)
|
16
18
|
end
|
@@ -22,6 +22,7 @@ module Calabash
|
|
22
22
|
port_forward(new_server.endpoint.port, new_server.test_server_port)
|
23
23
|
end
|
24
24
|
|
25
|
+
# @!visibility private
|
25
26
|
def self.default_serial
|
26
27
|
serials = list_serials
|
27
28
|
|
@@ -46,6 +47,7 @@ module Calabash
|
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
50
|
+
# @!visibility private
|
49
51
|
def self.list_serials
|
50
52
|
output = ADB.command('devices')
|
51
53
|
lines = output.lines
|
@@ -62,12 +64,14 @@ module Calabash
|
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
67
|
+
# @!visibility private
|
65
68
|
def installed_packages
|
66
69
|
adb.shell('pm list packages').lines.map do |line|
|
67
70
|
line.sub('package:', '').chomp
|
68
71
|
end
|
69
72
|
end
|
70
73
|
|
74
|
+
# @!visibility private
|
71
75
|
def installed_apps
|
72
76
|
adb.shell('pm list packages -f').lines.map do |line|
|
73
77
|
# line will be package:<path>=<package>
|
@@ -80,6 +84,7 @@ module Calabash
|
|
80
84
|
end
|
81
85
|
end
|
82
86
|
|
87
|
+
# @!visibility private
|
83
88
|
def test_server_responding?
|
84
89
|
begin
|
85
90
|
http_client.get(HTTP::Request.new('ping'), retries: 1).body == 'pong'
|
@@ -88,6 +93,7 @@ module Calabash
|
|
88
93
|
end
|
89
94
|
end
|
90
95
|
|
96
|
+
# @!visibility private
|
91
97
|
def test_server_ready?
|
92
98
|
begin
|
93
99
|
http_client.get(HTTP::Request.new('ready')).body == 'true'
|
@@ -96,6 +102,7 @@ module Calabash
|
|
96
102
|
end
|
97
103
|
end
|
98
104
|
|
105
|
+
# @!visibility private
|
99
106
|
def port_forward(host_port, test_server_port = nil)
|
100
107
|
if test_server_port.nil?
|
101
108
|
test_server_port = server.test_server_port
|
@@ -105,6 +112,7 @@ module Calabash
|
|
105
112
|
adb.command(*adb_forward_cmd)
|
106
113
|
end
|
107
114
|
|
115
|
+
# @!visibility private
|
108
116
|
def make_map_parameters(query, map_method_name, *method_args)
|
109
117
|
converted_args = []
|
110
118
|
|
@@ -172,6 +180,7 @@ module Calabash
|
|
172
180
|
Calabash::QueryResult.create(result['results'], query)
|
173
181
|
end
|
174
182
|
|
183
|
+
# @!visibility private
|
175
184
|
def perform_action(action, *arguments)
|
176
185
|
@logger.log "Action: #{action} - Arguments: #{arguments.join(', ')}"
|
177
186
|
|
@@ -197,10 +206,12 @@ module Calabash
|
|
197
206
|
result
|
198
207
|
end
|
199
208
|
|
209
|
+
# @!visibility private
|
200
210
|
def enter_text(text)
|
201
211
|
perform_action('keyboard_enter_text', text)
|
202
212
|
end
|
203
213
|
|
214
|
+
# @!visibility private
|
204
215
|
def md5_checksum(file_path)
|
205
216
|
result = adb.shell("#{md5_binary} '#{file_path}'")
|
206
217
|
captures = result.match(/(\w+)/).captures
|
@@ -234,15 +245,41 @@ module Calabash
|
|
234
245
|
result['result']
|
235
246
|
end
|
236
247
|
|
248
|
+
|
249
|
+
# @!visibility private
|
250
|
+
def keyboard_visible?
|
251
|
+
input_method = adb.shell("dumpsys input_method")
|
252
|
+
input_method.lines.each do |line|
|
253
|
+
match = line.match(/mInputShown\s*=\s*(.*)/)
|
254
|
+
|
255
|
+
if match && match.captures.length != 0
|
256
|
+
shown = match.captures.first.chomp
|
257
|
+
|
258
|
+
if shown == "true"
|
259
|
+
return true
|
260
|
+
elsif shown == "false"
|
261
|
+
return false
|
262
|
+
else
|
263
|
+
raise "Could not detect keyboard visibility. '#{shown}'"
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
raise "Could not detect keyboard visibility. Could not find 'mInputShown'"
|
269
|
+
end
|
270
|
+
|
271
|
+
# @!visibility private
|
237
272
|
def go_home
|
238
273
|
adb.shell("input keyevent 3")
|
239
274
|
end
|
240
275
|
|
276
|
+
# @!visibility private
|
241
277
|
def set_location(location)
|
242
278
|
perform_action('set_gps_coordinates',
|
243
279
|
location[:latitude], location[:longitude])
|
244
280
|
end
|
245
281
|
|
282
|
+
# @!visibility private
|
246
283
|
def resume_app(path_or_application)
|
247
284
|
application = parse_path_or_app_parameters(path_or_application)
|
248
285
|
|
@@ -263,6 +300,7 @@ module Calabash
|
|
263
300
|
true
|
264
301
|
end
|
265
302
|
|
303
|
+
# @!visibility private
|
266
304
|
def resume_activity(package, activity)
|
267
305
|
if package_running?(package)
|
268
306
|
if info[:sdk_version] >= 11
|
@@ -279,12 +317,14 @@ module Calabash
|
|
279
317
|
end
|
280
318
|
end
|
281
319
|
|
320
|
+
# @!visibility private
|
282
321
|
def app_running?(path_or_application)
|
283
322
|
application = parse_path_or_app_parameters(path_or_application)
|
284
323
|
|
285
324
|
package_running?(application.identifier)
|
286
325
|
end
|
287
326
|
|
327
|
+
# @!visibility private
|
288
328
|
def current_focus
|
289
329
|
# Example: mFocusedApp=AppWindowToken{42c52610 token=Token{42b5d048 ActivityRecord{42a7bcc8 u0 com.example/.MainActivity t3}}}
|
290
330
|
result = adb.shell('dumpsys window windows')
|
@@ -314,6 +354,7 @@ module Calabash
|
|
314
354
|
raise "Unexpected output from `dumpsys window windows`"
|
315
355
|
end
|
316
356
|
|
357
|
+
# @!visibility private
|
317
358
|
def evaluate_javascript_in(query, javascript)
|
318
359
|
parameters =
|
319
360
|
{
|
@@ -705,7 +746,7 @@ module Calabash
|
|
705
746
|
installed_app_md5_checksum = md5_checksum(installed_app[:path])
|
706
747
|
|
707
748
|
if application.md5_checksum != installed_app_md5_checksum
|
708
|
-
@logger.log("The md5 checksum has changed (#{application.md5_checksum} != #{installed_app_md5_checksum}.", :info)
|
749
|
+
@logger.log("The md5 checksum has changed (#{application.md5_checksum} != #{installed_app_md5_checksum}).", :info)
|
709
750
|
_install_app(application)
|
710
751
|
end
|
711
752
|
else
|