calabash 2.0.0.pre6 → 2.0.0.pre9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +0 -12
- data/lib/calabash.rb +1 -0
- data/lib/calabash/android.rb +2 -0
- data/lib/calabash/android/application.rb +14 -3
- data/lib/calabash/android/build/builder.rb +13 -2
- data/lib/calabash/android/device.rb +52 -19
- data/lib/calabash/android/environment.rb +10 -0
- data/lib/calabash/android/legacy.rb +6 -0
- data/lib/calabash/android/lib/TestServer.apk +0 -0
- data/lib/calabash/android/server.rb +2 -1
- data/lib/calabash/android/text.rb +5 -0
- data/lib/calabash/application.rb +29 -0
- data/lib/calabash/cli/build.rb +14 -1
- data/lib/calabash/cli/console.rb +8 -6
- data/lib/calabash/cli/helpers.rb +1 -1
- data/lib/calabash/cli/run.rb +9 -7
- data/lib/calabash/device.rb +5 -0
- data/lib/calabash/http/retriable_client.rb +14 -2
- data/lib/calabash/ios.rb +1 -0
- data/lib/calabash/ios/application.rb +8 -1
- data/lib/calabash/ios/legacy.rb +6 -0
- data/lib/calabash/ios/text.rb +5 -45
- data/lib/calabash/legacy.rb +10 -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/text.rb +53 -0
- data/lib/calabash/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d018a4059fbc167401a00153fe9d5dd8a7660684
|
4
|
+
data.tar.gz: c7d01f02885927df13058ec9417dbdad8f254fc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b776516069ecd91364f819286532ea841d4eb1b25ab4ed364033a7faf50f406546fd986ffbd2e64484efb9df4045911232b95c9f670a7be883c3e2cdc5633d5f
|
7
|
+
data.tar.gz: a973bee5a42a306303f4ac7c8304b961488e14a11f0348358fb006c6d0fb3c385c62fdbadd290a154157f202a59ae63f2e9352a6471958e8bb41708605d1648a
|
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.
|
data/lib/calabash.rb
CHANGED
data/lib/calabash/android.rb
CHANGED
@@ -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
|
@@ -17,7 +17,7 @@ module Calabash
|
|
17
17
|
end
|
18
18
|
|
19
19
|
# @!visibility private
|
20
|
-
def build
|
20
|
+
def build(out_file = nil)
|
21
21
|
apk_fingerprint = fingerprint_from_apk
|
22
22
|
@logger.log "#{@application_path} was signed with a certificate with fingerprint #{apk_fingerprint}", :debug
|
23
23
|
|
@@ -49,7 +49,7 @@ module Calabash
|
|
49
49
|
|
50
50
|
application = Calabash::Application.from_path(@application_path)
|
51
51
|
|
52
|
-
test_server_file_name = TestServer.new(@application_path).path
|
52
|
+
test_server_file_name = out_file || TestServer.new(@application_path).path
|
53
53
|
FileUtils.mkdir_p File.dirname(test_server_file_name) unless File.exist? File.dirname(test_server_file_name)
|
54
54
|
|
55
55
|
Dir.mktmpdir do |workspace_dir|
|
@@ -70,6 +70,17 @@ module Calabash
|
|
70
70
|
|
71
71
|
Zip::File.new("dummy.apk").extract("AndroidManifest.xml","customAndroidManifest.xml")
|
72
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
|
+
|
73
84
|
zip_file.add("AndroidManifest.xml", "customAndroidManifest.xml")
|
74
85
|
end
|
75
86
|
end
|
@@ -87,7 +87,7 @@ module Calabash
|
|
87
87
|
# @!visibility private
|
88
88
|
def test_server_responding?
|
89
89
|
begin
|
90
|
-
http_client.
|
90
|
+
http_client.post(HTTP::Request.new('ping'), retries: 1).body == 'pong'
|
91
91
|
rescue HTTP::Error => _
|
92
92
|
false
|
93
93
|
end
|
@@ -96,7 +96,7 @@ module Calabash
|
|
96
96
|
# @!visibility private
|
97
97
|
def test_server_ready?
|
98
98
|
begin
|
99
|
-
http_client.
|
99
|
+
http_client.post(HTTP::Request.new('ready')).body == 'true'
|
100
100
|
rescue HTTP::Error => _
|
101
101
|
false
|
102
102
|
end
|
@@ -166,9 +166,9 @@ module Calabash
|
|
166
166
|
request = HTTP::Request.new('map', params_for_request(parameters))
|
167
167
|
|
168
168
|
http_result = if method_name == :flash
|
169
|
-
http_client.
|
169
|
+
http_client.post(request, timeout: 30)
|
170
170
|
else
|
171
|
-
http_client.
|
171
|
+
http_client.post(request)
|
172
172
|
end
|
173
173
|
|
174
174
|
result = JSON.parse(http_result.body)
|
@@ -185,9 +185,9 @@ module Calabash
|
|
185
185
|
@logger.log "Action: #{action} - Arguments: #{arguments.join(', ')}"
|
186
186
|
|
187
187
|
parameters = {command: action, arguments: arguments}
|
188
|
-
request = HTTP::Request.new('
|
188
|
+
request = HTTP::Request.new('', params_for_request(parameters))
|
189
189
|
|
190
|
-
result = JSON.parse(http_client.
|
190
|
+
result = JSON.parse(http_client.post(request).body)
|
191
191
|
|
192
192
|
unless result['success']
|
193
193
|
message = result['message'] || result['bonusInformation']
|
@@ -211,6 +211,17 @@ module Calabash
|
|
211
211
|
perform_action('keyboard_enter_text', text)
|
212
212
|
end
|
213
213
|
|
214
|
+
# @!visibility private
|
215
|
+
def md5_checksum_for_app_package(package)
|
216
|
+
app = installed_apps.find{|app| app[:package] == package}
|
217
|
+
|
218
|
+
unless app
|
219
|
+
raise "Application with package '#{app}' not installed"
|
220
|
+
end
|
221
|
+
|
222
|
+
md5_checksum(app[:path])
|
223
|
+
end
|
224
|
+
|
214
225
|
# @!visibility private
|
215
226
|
def md5_checksum(file_path)
|
216
227
|
result = adb.shell("#{md5_binary} '#{file_path}'")
|
@@ -229,7 +240,7 @@ module Calabash
|
|
229
240
|
json = parameters.to_json
|
230
241
|
request = HTTP::Request.new('/backdoor', json: json)
|
231
242
|
|
232
|
-
body = http_client.
|
243
|
+
body = http_client.post(request).body
|
233
244
|
result = JSON.parse(body)
|
234
245
|
|
235
246
|
if result['outcome'] != 'SUCCESS'
|
@@ -245,6 +256,29 @@ module Calabash
|
|
245
256
|
result['result']
|
246
257
|
end
|
247
258
|
|
259
|
+
|
260
|
+
# @!visibility private
|
261
|
+
def keyboard_visible?
|
262
|
+
input_method = adb.shell("dumpsys input_method")
|
263
|
+
input_method.lines.each do |line|
|
264
|
+
match = line.match(/mInputShown\s*=\s*(.*)/)
|
265
|
+
|
266
|
+
if match && match.captures.length != 0
|
267
|
+
shown = match.captures.first.chomp
|
268
|
+
|
269
|
+
if shown == "true"
|
270
|
+
return true
|
271
|
+
elsif shown == "false"
|
272
|
+
return false
|
273
|
+
else
|
274
|
+
raise "Could not detect keyboard visibility. '#{shown}'"
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
raise "Could not detect keyboard visibility. Could not find 'mInputShown'"
|
280
|
+
end
|
281
|
+
|
248
282
|
# @!visibility private
|
249
283
|
def go_home
|
250
284
|
adb.shell("input keyevent 3")
|
@@ -343,7 +377,7 @@ module Calabash
|
|
343
377
|
json = parameters.to_json
|
344
378
|
request = HTTP::Request.new('/map', json: json)
|
345
379
|
|
346
|
-
body = http_client.
|
380
|
+
body = http_client.post(request).body
|
347
381
|
result = JSON.parse(body)
|
348
382
|
|
349
383
|
if result['outcome'] != 'SUCCESS'
|
@@ -422,6 +456,8 @@ module Calabash
|
|
422
456
|
|
423
457
|
if options[:activity]
|
424
458
|
env_options[:main_activity] = options[:activity]
|
459
|
+
else
|
460
|
+
env_options[:main_activity] = 'null'
|
425
461
|
end
|
426
462
|
|
427
463
|
if application.test_server.nil?
|
@@ -436,15 +472,13 @@ module Calabash
|
|
436
472
|
raise "The test-server '#{application.test_server.identifier}' is not installed"
|
437
473
|
end
|
438
474
|
|
439
|
-
|
440
|
-
installed_app_md5_checksum = md5_checksum(installed_app[:path])
|
475
|
+
installed_app_md5_checksum = md5_checksum_for_app_package(application.identifier)
|
441
476
|
|
442
477
|
if application.md5_checksum != installed_app_md5_checksum
|
443
478
|
raise "The specified app is not the same as the installed app (#{application.md5_checksum} != #{installed_app_md5_checksum})."
|
444
479
|
end
|
445
480
|
|
446
|
-
|
447
|
-
installed_test_server_md5_checksum = md5_checksum(installed_test_server[:path])
|
481
|
+
installed_test_server_md5_checksum = md5_checksum_for_app_package(application.test_server.identifier)
|
448
482
|
|
449
483
|
if application.test_server.md5_checksum != installed_test_server_md5_checksum
|
450
484
|
raise "The specified test-server is not the same as the installed test-server (#{application.test_server.md5_checksum} != #{installed_test_server_md5_checksum})."
|
@@ -477,7 +511,7 @@ module Calabash
|
|
477
511
|
extras = ''
|
478
512
|
|
479
513
|
env_options.each_pair do |key, val|
|
480
|
-
extras = "#{extras} -e
|
514
|
+
extras = "#{extras} -e #{key.to_s} #{val.to_s}"
|
481
515
|
end
|
482
516
|
|
483
517
|
begin
|
@@ -527,7 +561,7 @@ module Calabash
|
|
527
561
|
def _stop_app
|
528
562
|
Retriable.retriable(tries: 5, interval: 1) do
|
529
563
|
begin
|
530
|
-
http_client.
|
564
|
+
http_client.post(HTTP::Request.new('kill'), retries: 1, interval: 0)
|
531
565
|
rescue HTTP::Error => _
|
532
566
|
# It's fine that we can't contact the test-server, as it might already have been shut down
|
533
567
|
if test_server_responding?
|
@@ -719,11 +753,10 @@ module Calabash
|
|
719
753
|
if installed_packages.include?(application.identifier)
|
720
754
|
@logger.log 'Application is already installed. Ensuring right checksum'
|
721
755
|
|
722
|
-
|
723
|
-
installed_app_md5_checksum = md5_checksum(installed_app[:path])
|
756
|
+
installed_app_md5_checksum = md5_checksum_for_app_package(application.identifier)
|
724
757
|
|
725
758
|
if application.md5_checksum != installed_app_md5_checksum
|
726
|
-
@logger.log("The md5 checksum has changed (#{application.md5_checksum} != #{installed_app_md5_checksum}.", :info)
|
759
|
+
@logger.log("The md5 checksum has changed (#{application.md5_checksum} != #{installed_app_md5_checksum}).", :info)
|
727
760
|
_install_app(application)
|
728
761
|
end
|
729
762
|
else
|
@@ -965,9 +998,9 @@ module Calabash
|
|
965
998
|
|
966
999
|
# @!visibility private
|
967
1000
|
def execute_gesture(multi_touch_gesture)
|
968
|
-
request = HTTP::Request.new('gesture',
|
1001
|
+
request = HTTP::Request.new('gesture', params_for_request(multi_touch_gesture))
|
969
1002
|
|
970
|
-
body = http_client.
|
1003
|
+
body = http_client.post(request, timeout: multi_touch_gesture.timeout + 10).body
|
971
1004
|
result = JSON.parse(body)
|
972
1005
|
|
973
1006
|
if result['outcome'] != 'SUCCESS'
|
@@ -15,6 +15,16 @@ module Calabash
|
|
15
15
|
# @!visibility private
|
16
16
|
class InvalidJavaSDKHome < RuntimeError; end
|
17
17
|
|
18
|
+
# A URI that points to the embedded Calabash server in the app under test.
|
19
|
+
#
|
20
|
+
# The default value is 'http://localhost:34777'.
|
21
|
+
#
|
22
|
+
# You can control the value of this variable by setting the `CAL_ENDPOINT`
|
23
|
+
# variable.
|
24
|
+
#
|
25
|
+
# @todo Maybe rename this to CAL_SERVER_URL or CAL_SERVER?
|
26
|
+
DEVICE_ENDPOINT = URI.parse((variable('CAL_ENDPOINT') || 'http://127.0.0.1:34777'))
|
27
|
+
|
18
28
|
private
|
19
29
|
|
20
30
|
def self.set_android_dependencies(android_dependencies)
|
Binary file
|
data/lib/calabash/application.rb
CHANGED
@@ -21,6 +21,21 @@ module Calabash
|
|
21
21
|
|
22
22
|
attr_reader :path
|
23
23
|
|
24
|
+
# Get the application from the default environment.
|
25
|
+
def self.default_from_environment
|
26
|
+
application_path = Environment::APP_PATH
|
27
|
+
|
28
|
+
if application_path.nil?
|
29
|
+
raise 'No application path is set. Specify application with environment variable CAL_APP'
|
30
|
+
end
|
31
|
+
|
32
|
+
unless File.exist?(application_path)
|
33
|
+
raise "Application '#{application_path}' does not exist"
|
34
|
+
end
|
35
|
+
|
36
|
+
Application.from_path(application_path)
|
37
|
+
end
|
38
|
+
|
24
39
|
# Create an application from a path
|
25
40
|
#
|
26
41
|
# @return [Calabash::Android::Application, Calabash::IOS::Application] An
|
@@ -51,6 +66,20 @@ module Calabash
|
|
51
66
|
ensure_application_path
|
52
67
|
end
|
53
68
|
|
69
|
+
# Is this application an android application
|
70
|
+
#
|
71
|
+
# @return [Boolean] true if this application is an android application
|
72
|
+
def android_application?
|
73
|
+
false
|
74
|
+
end
|
75
|
+
|
76
|
+
# Is this application an iOS application
|
77
|
+
#
|
78
|
+
# @return [Boolean] true if this application is an iOS application
|
79
|
+
def ios_application?
|
80
|
+
false
|
81
|
+
end
|
82
|
+
|
54
83
|
# @!visibility private
|
55
84
|
def to_s
|
56
85
|
"#<Application #{path}>"
|
data/lib/calabash/cli/build.rb
CHANGED
@@ -7,6 +7,19 @@ module Calabash
|
|
7
7
|
fail('Should only build test-server for Android') unless @platform.nil? || @platform == :android
|
8
8
|
|
9
9
|
application = @arguments.shift
|
10
|
+
test_server_path = nil
|
11
|
+
|
12
|
+
arg = @arguments.shift
|
13
|
+
|
14
|
+
if arg != nil
|
15
|
+
if arg == '-o'
|
16
|
+
test_server_path = @arguments.shift
|
17
|
+
|
18
|
+
if test_server_path == nil
|
19
|
+
raise 'Expected an output path for the test-server'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
10
23
|
|
11
24
|
if application.nil?
|
12
25
|
fail('Must supply application as first parameter to build', :build)
|
@@ -19,7 +32,7 @@ module Calabash
|
|
19
32
|
case extension
|
20
33
|
when '.apk'
|
21
34
|
set_platform!(:android)
|
22
|
-
Calabash::Android::Build::Builder.new(application_path).build
|
35
|
+
Calabash::Android::Build::Builder.new(application_path).build(test_server_path)
|
23
36
|
when '.ipa', '.app'
|
24
37
|
set_platform!(:ios)
|
25
38
|
fail('Should only build test-server for Android')
|
data/lib/calabash/cli/console.rb
CHANGED
@@ -23,12 +23,14 @@ module Calabash
|
|
23
23
|
when '.apk'
|
24
24
|
set_platform!(:android)
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
unless Environment::TEST_SERVER_PATH
|
27
|
+
# Create the test server if it does not exist
|
28
|
+
test_server = Android::Build::TestServer.new(application_path)
|
29
|
+
|
30
|
+
unless test_server.exists?
|
31
|
+
Logger.info('Test server does not exist. Creating test server.')
|
32
|
+
Calabash::Android::Build::Builder.new(application_path).build
|
33
|
+
end
|
32
34
|
end
|
33
35
|
|
34
36
|
enter_console(application_path)
|
data/lib/calabash/cli/helpers.rb
CHANGED
data/lib/calabash/cli/run.rb
CHANGED
@@ -31,12 +31,14 @@ module Calabash
|
|
31
31
|
when '.apk'
|
32
32
|
set_platform!(:android)
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
unless Environment::TEST_SERVER_PATH
|
35
|
+
# Create the test server if it does not exist
|
36
|
+
test_server = Android::Build::TestServer.new(application_path)
|
37
|
+
|
38
|
+
unless test_server.exists?
|
39
|
+
Logger.info('Test server does not exist. Creating test server.')
|
40
|
+
Calabash::Android::Build::Builder.new(application_path).build
|
41
|
+
end
|
40
42
|
end
|
41
43
|
|
42
44
|
run(application_path, @arguments)
|
@@ -90,7 +92,7 @@ module Calabash
|
|
90
92
|
end
|
91
93
|
end
|
92
94
|
|
93
|
-
arguments = ['-S', 'cucumber',
|
95
|
+
arguments = ['-S', 'cucumber', *cucumber_arguments]
|
94
96
|
|
95
97
|
Logger.debug("Starting Ruby with arguments: #{arguments.join(', ')} and environment #{cucumber_environment.to_s}")
|
96
98
|
|
data/lib/calabash/device.rb
CHANGED
@@ -131,8 +131,20 @@ module Calabash
|
|
131
131
|
client.receive_timeout = [time_diff, client.receive_timeout].min
|
132
132
|
|
133
133
|
begin
|
134
|
-
|
135
|
-
|
134
|
+
if request_method == :get
|
135
|
+
return client.send(request_method, @server.endpoint + request.route,
|
136
|
+
request.params, header)
|
137
|
+
else
|
138
|
+
if request.params.is_a?(Hash)
|
139
|
+
if request.params.key?(:json)
|
140
|
+
return client.send(request_method, @server.endpoint + request.route,
|
141
|
+
{body: request.params[:json]}.merge(header: header))
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
return client.send(request_method, @server.endpoint + request.route,
|
146
|
+
{body: request.params}.merge(header: header))
|
147
|
+
end
|
136
148
|
rescue *RETRY_ON => e
|
137
149
|
@logger.log "Http error: #{e}"
|
138
150
|
|
data/lib/calabash/ios.rb
CHANGED
@@ -27,7 +27,7 @@ module Calabash
|
|
27
27
|
application_path = Environment::APP_PATH
|
28
28
|
|
29
29
|
if application_path.nil?
|
30
|
-
raise 'No application path is set'
|
30
|
+
raise 'No application path is set. Specify application with environment variable CAL_APP'
|
31
31
|
end
|
32
32
|
|
33
33
|
Application.new(application_path)
|
@@ -67,6 +67,13 @@ module Calabash
|
|
67
67
|
@device_binary
|
68
68
|
end
|
69
69
|
|
70
|
+
# Is this application an iOS application
|
71
|
+
#
|
72
|
+
# @return [Boolean] Always returns true
|
73
|
+
def ios_application?
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
70
77
|
# Returns the sha1 of the directory or binary of this app's path.
|
71
78
|
# @return [String] A checksum.
|
72
79
|
def sha1
|
data/lib/calabash/ios/text.rb
CHANGED
@@ -73,43 +73,6 @@ module Calabash
|
|
73
73
|
Device.default.split_keyboard_visible?
|
74
74
|
end
|
75
75
|
|
76
|
-
# Returns true if there is a visible keyboard.
|
77
|
-
#
|
78
|
-
# @return [Boolean] Returns true if there is a visible keyboard.
|
79
|
-
def keyboard_visible?
|
80
|
-
docked_keyboard_visible? || undocked_keyboard_visible? || split_keyboard_visible?
|
81
|
-
end
|
82
|
-
|
83
|
-
# Waits for a keyboard to appear.
|
84
|
-
#
|
85
|
-
# @see Calabash::Wait.default_options
|
86
|
-
#
|
87
|
-
# @param [Number] timeout How long to wait for the keyboard.
|
88
|
-
# @raise [Calabash::Wait::TimeoutError] Raises error if no keyboard
|
89
|
-
# appears.
|
90
|
-
def wait_for_keyboard(timeout=nil)
|
91
|
-
keyboard_timeout = keyboard_wait_timeout(timeout)
|
92
|
-
message = "Timed out after #{keyboard_timeout} seconds waiting for the keyboard to appear"
|
93
|
-
wait_for(message, timeout: keyboard_timeout) do
|
94
|
-
keyboard_visible?
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# Waits for the keyboard to disappear.
|
99
|
-
#
|
100
|
-
# @see Calabash::Wait.default_options
|
101
|
-
#
|
102
|
-
# @param [Number] timeout How log to wait for the keyboard to disappear.
|
103
|
-
# @raise [Calabash::Wait::TimeoutError] Raises error if any keyboard is
|
104
|
-
# visible after the `timeout`.
|
105
|
-
def wait_for_no_keyboard(timeout=nil)
|
106
|
-
keyboard_timeout = keyboard_wait_timeout(timeout)
|
107
|
-
message = "Timed out after #{keyboard_timeout} seconds waiting for the keyboard to disappear"
|
108
|
-
wait_for(message, timeout: keyboard_timeout) do
|
109
|
-
!keyboard_visible?
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
76
|
# Touches the keyboard action key.
|
114
77
|
#
|
115
78
|
# The action key depends on the keyboard. Some examples include:
|
@@ -137,6 +100,11 @@ module Calabash
|
|
137
100
|
Device.default.uia_route("uia.keyboard().typeString('#{char_sequence}')")
|
138
101
|
end
|
139
102
|
|
103
|
+
# @!visibility private
|
104
|
+
def _keyboard_visible?
|
105
|
+
docked_keyboard_visible? || undocked_keyboard_visible? || split_keyboard_visible?
|
106
|
+
end
|
107
|
+
|
140
108
|
# Touches the keyboard delete key.
|
141
109
|
#
|
142
110
|
# The 'delete' key difficult to find and touch because its behavior
|
@@ -242,14 +210,6 @@ module Calabash
|
|
242
210
|
#'International' => nil,
|
243
211
|
#'More' => nil,
|
244
212
|
}
|
245
|
-
|
246
|
-
def keyboard_wait_timeout(timeout)
|
247
|
-
if timeout.nil?
|
248
|
-
Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT
|
249
|
-
else
|
250
|
-
timeout
|
251
|
-
end
|
252
|
-
end
|
253
213
|
end
|
254
214
|
end
|
255
215
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
if Calabash::Environment.variable('TEST_APP_PATH')
|
2
|
+
Calabash::Logger.warn("Deprecated use of old ENV variable 'TEST_APP_PATH'")
|
3
|
+
Calabash::Environment::TEST_SERVER_PATH =
|
4
|
+
Calabash::Environment.variable('TEST_APP_PATH')
|
5
|
+
end
|
6
|
+
|
7
|
+
if Calabash::Environment.variable('APP_PATH')
|
8
|
+
Calabash::Logger.warn("Deprecated use of old ENV variable 'APP_PATH'")
|
9
|
+
Calabash::Environment::APP_PATH = Calabash::Environment.variable('APP_PATH')
|
10
|
+
end
|
@@ -1,7 +1,21 @@
|
|
1
1
|
require 'calabash'
|
2
|
+
require 'calabash/android/application'
|
3
|
+
require 'calabash/ios/application'
|
2
4
|
|
3
5
|
platform = ENV['PLATFORM']
|
4
6
|
|
7
|
+
unless platform
|
8
|
+
application = Calabash::Application.default_from_environment
|
9
|
+
|
10
|
+
if application.android_application?
|
11
|
+
platform = 'android'
|
12
|
+
elsif application.ios_application?
|
13
|
+
platform = 'ios'
|
14
|
+
else
|
15
|
+
raise "Application '#{application}' is neither an Android app or an iOS app"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
5
19
|
case platform
|
6
20
|
when 'android'
|
7
21
|
require 'calabash/android'
|
@@ -26,7 +40,7 @@ case platform
|
|
26
40
|
[
|
27
41
|
'ERROR! Unable to start the cucumber test:',
|
28
42
|
message,
|
29
|
-
"
|
43
|
+
"Run cucumber with the ENV variable 'CAL_APP', or run cucumber using $ calabash run"
|
30
44
|
]
|
31
45
|
|
32
46
|
Calabash::Logger.error(failure_messages.join("\n"))
|
data/lib/calabash/text.rb
CHANGED
@@ -93,6 +93,45 @@ module Calabash
|
|
93
93
|
Text.escape_single_quotes(string)
|
94
94
|
end
|
95
95
|
|
96
|
+
# Returns true if there is a visible keyboard.
|
97
|
+
# On Android, if a physical keyboard is connected, this method will always
|
98
|
+
# return true.
|
99
|
+
#
|
100
|
+
# @return [Boolean] Returns true if there is a visible keyboard.
|
101
|
+
def keyboard_visible?
|
102
|
+
_keyboard_visible?
|
103
|
+
end
|
104
|
+
|
105
|
+
# Waits for a keyboard to appear.
|
106
|
+
#
|
107
|
+
# @see Calabash::Wait.default_options
|
108
|
+
#
|
109
|
+
# @param [Number] timeout How long to wait for the keyboard.
|
110
|
+
# @raise [Calabash::Wait::TimeoutError] Raises error if no keyboard
|
111
|
+
# appears.
|
112
|
+
def wait_for_keyboard(timeout=nil)
|
113
|
+
keyboard_timeout = keyboard_wait_timeout(timeout)
|
114
|
+
message = "Timed out after #{keyboard_timeout} seconds waiting for the keyboard to appear"
|
115
|
+
wait_for(message, timeout: keyboard_timeout) do
|
116
|
+
keyboard_visible?
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# Waits for the keyboard to disappear.
|
121
|
+
#
|
122
|
+
# @see Calabash::Wait.default_options
|
123
|
+
#
|
124
|
+
# @param [Number] timeout How log to wait for the keyboard to disappear.
|
125
|
+
# @raise [Calabash::Wait::TimeoutError] Raises error if any keyboard is
|
126
|
+
# visible after the `timeout`.
|
127
|
+
def wait_for_no_keyboard(timeout=nil)
|
128
|
+
keyboard_timeout = keyboard_wait_timeout(timeout)
|
129
|
+
message = "Timed out after #{keyboard_timeout} seconds waiting for the keyboard to disappear"
|
130
|
+
wait_for(message, timeout: keyboard_timeout) do
|
131
|
+
!keyboard_visible?
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
96
135
|
# @!visibility private
|
97
136
|
def _enter_text(text)
|
98
137
|
abstract_method!
|
@@ -118,9 +157,23 @@ module Calabash
|
|
118
157
|
abstract_method!
|
119
158
|
end
|
120
159
|
|
160
|
+
# @!visibility private
|
161
|
+
def _keyboard_visible?
|
162
|
+
abstract_method!
|
163
|
+
end
|
164
|
+
|
121
165
|
# @!visibility private
|
122
166
|
def self.escape_single_quotes(string)
|
123
167
|
string.gsub("'", "\\\\'")
|
124
168
|
end
|
169
|
+
|
170
|
+
# @!visibility private
|
171
|
+
def keyboard_wait_timeout(timeout)
|
172
|
+
if timeout.nil?
|
173
|
+
Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT
|
174
|
+
else
|
175
|
+
timeout
|
176
|
+
end
|
177
|
+
end
|
125
178
|
end
|
126
179
|
end
|
data/lib/calabash/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calabash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.pre9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Maturana Larsen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: edn
|
@@ -389,6 +389,7 @@ files:
|
|
389
389
|
- lib/calabash/android/environment.rb
|
390
390
|
- lib/calabash/android/gestures.rb
|
391
391
|
- lib/calabash/android/interactions.rb
|
392
|
+
- lib/calabash/android/legacy.rb
|
392
393
|
- lib/calabash/android/lib/.irbrc
|
393
394
|
- lib/calabash/android/lib/AndroidManifest.xml
|
394
395
|
- lib/calabash/android/lib/TestServer.apk
|
@@ -463,6 +464,7 @@ files:
|
|
463
464
|
- lib/calabash/ios/environment.rb
|
464
465
|
- lib/calabash/ios/gestures.rb
|
465
466
|
- lib/calabash/ios/interactions.rb
|
467
|
+
- lib/calabash/ios/legacy.rb
|
466
468
|
- lib/calabash/ios/lib/.irbrc
|
467
469
|
- lib/calabash/ios/lib/recordings/rotate_left_home_down_ipad.base64
|
468
470
|
- lib/calabash/ios/lib/recordings/rotate_left_home_down_iphone.base64
|
@@ -487,6 +489,7 @@ files:
|
|
487
489
|
- lib/calabash/ios/slider.rb
|
488
490
|
- lib/calabash/ios/text.rb
|
489
491
|
- lib/calabash/ios/uia.rb
|
492
|
+
- lib/calabash/legacy.rb
|
490
493
|
- lib/calabash/lib/skeleton/.gitignore
|
491
494
|
- lib/calabash/lib/skeleton/Gemfile
|
492
495
|
- lib/calabash/lib/skeleton/config/cucumber.yml
|
@@ -530,7 +533,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
530
533
|
version: 1.3.1
|
531
534
|
requirements: []
|
532
535
|
rubyforge_project:
|
533
|
-
rubygems_version: 2.4.
|
536
|
+
rubygems_version: 2.4.5.1
|
534
537
|
signing_key:
|
535
538
|
specification_version: 4
|
536
539
|
summary: Automated Acceptance Testing for Mobile Apps
|