calabash 2.0.0.pre1 → 2.0.0.prelegacy2
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 +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
@@ -3,6 +3,7 @@ module Calabash
|
|
3
3
|
# @!visibility private
|
4
4
|
module TextMixin
|
5
5
|
|
6
|
+
# @!visibility private
|
6
7
|
def enter_text(text)
|
7
8
|
wait_for_keyboard(Calabash::Wait.default_options[:timeout])
|
8
9
|
existing_text = text_from_keyboard_first_responder
|
@@ -10,6 +11,7 @@ module Calabash
|
|
10
11
|
uia_type_string(text, options)
|
11
12
|
end
|
12
13
|
|
14
|
+
# @!visibility private
|
13
15
|
def _enter_text_in(query, text)
|
14
16
|
_tap(query)
|
15
17
|
enter_text(text)
|
@@ -43,6 +43,7 @@ module Calabash
|
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
+
# @!visibility private
|
46
47
|
def uia_type_string_handler(string, escaped_string, existing_text, result, logger)
|
47
48
|
UIATypeStringHandler.new(string,
|
48
49
|
escaped_string,
|
@@ -73,6 +74,7 @@ module Calabash
|
|
73
74
|
@logger = logger
|
74
75
|
end
|
75
76
|
|
77
|
+
# @!visibility private
|
76
78
|
def self.escape_backslashes_in_string(string)
|
77
79
|
return string if string.index(/\\/)
|
78
80
|
|
@@ -95,10 +97,12 @@ module Calabash
|
|
95
97
|
result['value']
|
96
98
|
end
|
97
99
|
|
100
|
+
# @!visibility private
|
98
101
|
def log(message)
|
99
102
|
logger.log(Color.blue(message), :info)
|
100
103
|
end
|
101
104
|
|
105
|
+
# @!visibility private
|
102
106
|
def log_preamble
|
103
107
|
log('When typing:')
|
104
108
|
log(" raw string: #{string}")
|
@@ -106,6 +110,7 @@ module Calabash
|
|
106
110
|
log("existing text: #{existing_text}")
|
107
111
|
end
|
108
112
|
|
113
|
+
# @!visibility private
|
109
114
|
def log_epilogue
|
110
115
|
log(" result: #{result}")
|
111
116
|
log('')
|
@@ -113,6 +118,7 @@ module Calabash
|
|
113
118
|
log('https://github.com/calabash/calabash-ios/issues/374')
|
114
119
|
end
|
115
120
|
|
121
|
+
# @!visibility private
|
116
122
|
def handle_result
|
117
123
|
the_status = status
|
118
124
|
if the_status == 'error'
|
@@ -130,6 +136,7 @@ module Calabash
|
|
130
136
|
end
|
131
137
|
end
|
132
138
|
|
139
|
+
# @!visibility private
|
133
140
|
def handle_error
|
134
141
|
log_preamble
|
135
142
|
if result.has_key? 'value'
|
@@ -161,6 +168,7 @@ module Calabash
|
|
161
168
|
end
|
162
169
|
end
|
163
170
|
|
171
|
+
# @!visibility private
|
164
172
|
def handle_success_with_incident
|
165
173
|
log_preamble
|
166
174
|
if value.nil?
|
@@ -176,6 +184,7 @@ module Calabash
|
|
176
184
|
false
|
177
185
|
end
|
178
186
|
|
187
|
+
# @!visibility private
|
179
188
|
def handle_unknown_status
|
180
189
|
log_preamble
|
181
190
|
log("receive response with an unknown value for 'status' key: '#{status}'")
|
@@ -1,7 +1,36 @@
|
|
1
1
|
module Calabash
|
2
2
|
module IOS
|
3
|
-
|
3
|
+
|
4
|
+
# Interactions with your app that are specific to iOS
|
4
5
|
module Interactions
|
6
|
+
|
7
|
+
# @!visibility private
|
8
|
+
# Sends app to background. Simulates pressing the home button.
|
9
|
+
#
|
10
|
+
# @note Cannot be more than 60 seconds.
|
11
|
+
#
|
12
|
+
# @param [Numeric] seconds The number of seconds to keep the app
|
13
|
+
# in the background
|
14
|
+
# @raise [ArgumentError] If number of seconds is less than 1 and more
|
15
|
+
# than 60 seconds.
|
16
|
+
def _send_current_app_to_background(seconds)
|
17
|
+
unless (1..60).member?(seconds)
|
18
|
+
raise ArgumentError,
|
19
|
+
"Number of seconds: '#{seconds}' must be between 1 and 60"
|
20
|
+
end
|
21
|
+
|
22
|
+
javascript = %Q(
|
23
|
+
var x = target.deactivateAppForDuration(#{seconds});
|
24
|
+
var MAX_RETRY=5, retry_count = 0;
|
25
|
+
while (!x && retry_count < MAX_RETRY) {
|
26
|
+
x = target.deactivateAppForDuration(#{seconds});
|
27
|
+
retry_count += 1
|
28
|
+
};
|
29
|
+
x
|
30
|
+
)
|
31
|
+
uia(javascript)
|
32
|
+
end
|
33
|
+
|
5
34
|
# @!visibility private
|
6
35
|
def _evaluate_javascript_in(query, javascript)
|
7
36
|
query(query, calabashStringByEvaluatingJavaScript: javascript)
|
data/lib/calabash/ios/runtime.rb
CHANGED
@@ -63,6 +63,14 @@ module Calabash
|
|
63
63
|
end
|
64
64
|
|
65
65
|
# Is the device under test an iPhone 3.5in?
|
66
|
+
#
|
67
|
+
# @note If the app under test is an iPhone app emulated on an iPad then
|
68
|
+
# the form factor will _always_ be 'iphone 3.5.in'. If you need to
|
69
|
+
# branch on the actual device the app is running on, use the #ipad?
|
70
|
+
# method.
|
71
|
+
#
|
72
|
+
# @see #iphone_app_emulated_on_ipad?
|
73
|
+
# @see #ipad?
|
66
74
|
def iphone_35in?
|
67
75
|
Calabash::IOS::Device.default.form_factor == 'iphone 3.5in'
|
68
76
|
end
|
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
|
@@ -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/life_cycle.rb
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
module Calabash
|
2
|
+
|
3
|
+
# Methods for managing an app's life cycle.
|
4
|
+
#
|
5
|
+
# The life cycle of an app includes:
|
6
|
+
# * installing / uninstalling
|
7
|
+
# * stopping / starting
|
8
|
+
# * clearing the application data
|
9
|
+
# * sending the application to background and resuming it
|
2
10
|
module LifeCycle
|
3
11
|
# Start the given application (and its test-server) on the port of
|
4
12
|
# {Calabash::Defaults#default_server Calabash.default_server}.
|
@@ -122,11 +130,20 @@ module Calabash
|
|
122
130
|
end
|
123
131
|
|
124
132
|
# Sends the current app to the background and resumes it after
|
125
|
-
# `for_seconds`.
|
133
|
+
# `for_seconds`.
|
134
|
+
#
|
135
|
+
# On iOS, `for_seconds` must be between 1 and 60 seconds.
|
136
|
+
#
|
137
|
+
# On iOS the _current app_ is the app under test (your app).
|
126
138
|
#
|
127
|
-
# On Android you can control the app lifecycle more
|
139
|
+
# On Android you can control the app lifecycle more granularity using
|
128
140
|
# {Calabash::Android::Interactions#go_home \#go_home} and
|
129
141
|
# {Calabash::Android::LifeCycle#resume_app \#resume_app}.
|
142
|
+
#
|
143
|
+
# @param [Numeric] for_seconds How long to keep the app to the background.
|
144
|
+
#
|
145
|
+
# @raise [ArgumentError] On iOS, if number of seconds is less than 1 and
|
146
|
+
# more than 60 seconds.
|
130
147
|
def send_current_app_to_background(for_seconds = 10)
|
131
148
|
_send_current_app_to_background(for_seconds)
|
132
149
|
|
data/lib/calabash/location.rb
CHANGED
data/lib/calabash/page.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
module Calabash
|
2
|
+
|
3
|
+
# A base class for the Page Object Model (POM) or Page Object Pattern.
|
4
|
+
#
|
5
|
+
# We recommend the POM for testing cross-platform apps.
|
6
|
+
#
|
7
|
+
# We have a great examples of using the POM in the Calabash 2.0 repository.
|
8
|
+
# * https://github.com/calabash/calabash/tree/develop/samples/wordpress
|
9
|
+
# * https://github.com/calabash/calabash/tree/develop/samples/shared-page-logic
|
2
10
|
class Page
|
3
11
|
# For auto-completion
|
4
12
|
include Calabash
|
5
13
|
|
14
|
+
# @!visibility private
|
6
15
|
def self.inherited(subclass)
|
7
16
|
# Define the page into global scope
|
8
17
|
full_name = subclass.name
|
@@ -49,14 +58,18 @@ module Calabash
|
|
49
58
|
|
50
59
|
private_class_method :new
|
51
60
|
|
61
|
+
# @!visibility private
|
52
62
|
def initialize(world)
|
53
63
|
@world = world
|
54
64
|
end
|
55
65
|
|
66
|
+
# A query that distinguishes your page.
|
67
|
+
# @return [String, Hash, Calabash::Query] A query.
|
56
68
|
def trait
|
57
69
|
raise 'Implement your own trait'
|
58
70
|
end
|
59
71
|
|
72
|
+
# Waits for the page trait to appear.
|
60
73
|
def await(options={})
|
61
74
|
wait_for_view(trait, options)
|
62
75
|
end
|
data/lib/calabash/patch.rb
CHANGED
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/utility.rb
CHANGED
@@ -5,6 +5,7 @@ module Calabash
|
|
5
5
|
|
6
6
|
end
|
7
7
|
|
8
|
+
# Utility methods for testing.
|
8
9
|
module Utility
|
9
10
|
|
10
11
|
# @!visibility private
|
@@ -39,17 +40,16 @@ module Calabash
|
|
39
40
|
alias_method :pct, :percent
|
40
41
|
|
41
42
|
# A convenience method for creating a coordinate hash that that can be
|
42
|
-
# passed to
|
43
|
+
# passed to the tap_coordinate gesture.
|
43
44
|
#
|
44
45
|
# @example
|
45
46
|
# # These are equivalent.
|
46
|
-
#
|
47
|
-
#
|
47
|
+
# tap_coordinate(coordinate(20, 50)
|
48
|
+
# tap_coordinate({x: 20, y: 50})
|
48
49
|
#
|
49
50
|
# @param [Number] x The value of the x.
|
50
51
|
# @param [Number] y The value of the y.
|
51
52
|
# @return [Hash] Representing the given values.
|
52
|
-
# @!visibility private
|
53
53
|
def coordinate(x, y)
|
54
54
|
{x: x, y: y}
|
55
55
|
end
|