calabash 2.0.0.pre11 → 2.0.0.prelegacy
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -5
- data/bin/calabash +4 -3
- data/lib/calabash/android/adb.rb +37 -34
- data/lib/calabash/android/application.rb +1 -1
- data/lib/calabash/android/build/builder.rb +1 -1
- data/lib/calabash/android/build/java_keystore.rb +1 -1
- data/lib/calabash/android/build/resigner.rb +1 -1
- data/lib/calabash/android/device.rb +46 -204
- data/lib/calabash/android/environment.rb +1 -14
- data/lib/calabash/android/gestures.rb +22 -6
- data/lib/calabash/android/interactions.rb +17 -14
- data/lib/calabash/android/legacy.rb +141 -4
- data/lib/calabash/android/lib/.irbrc +1 -9
- data/lib/calabash/android/lib/AndroidManifest.xml +2 -23
- data/lib/calabash/android/lib/TestServer.apk +0 -0
- data/lib/calabash/android/life_cycle.rb +3 -3
- data/lib/calabash/android/orientation.rb +8 -8
- data/lib/calabash/android/physical_buttons.rb +16 -19
- data/lib/calabash/android/server.rb +1 -6
- data/lib/calabash/android/text.rb +12 -12
- data/lib/calabash/android.rb +26 -92
- data/lib/calabash/application.rb +0 -3
- data/lib/calabash/cli/generate.rb +18 -8
- data/lib/calabash/cli/helpers.rb +9 -4
- data/lib/calabash/cli/run.rb +1 -1
- data/lib/calabash/console_helpers.rb +11 -179
- data/lib/calabash/device.rb +19 -4
- data/lib/calabash/gestures.rb +198 -292
- data/lib/calabash/http/retriable_client.rb +3 -18
- data/lib/calabash/http.rb +0 -1
- data/lib/calabash/interactions.rb +40 -3
- data/lib/calabash/ios/conditions.rb +1 -1
- data/lib/calabash/ios/console_helpers.rb +2 -2
- data/lib/calabash/ios/date_picker.rb +8 -10
- data/lib/calabash/ios/device/device_implementation.rb +21 -9
- data/lib/calabash/ios/device/gestures_mixin.rb +55 -53
- data/lib/calabash/ios/device/keyboard_mixin.rb +0 -21
- data/lib/calabash/ios/device/rotation_mixin.rb +65 -3
- data/lib/calabash/ios/device/text_mixin.rb +21 -0
- data/lib/calabash/ios/device.rb +1 -0
- data/lib/calabash/ios/gestures.rb +90 -24
- data/lib/calabash/ios/interactions.rb +6 -1
- data/lib/calabash/ios/lib/.irbrc +2 -9
- data/lib/calabash/ios/orientation.rb +8 -8
- data/lib/calabash/ios/runtime.rb +14 -14
- data/lib/calabash/ios/scroll.rb +17 -25
- data/lib/calabash/ios/slider.rb +18 -11
- data/lib/calabash/ios/text.rb +74 -20
- data/lib/calabash/ios/uia.rb +1 -1
- data/lib/calabash/ios.rb +16 -77
- data/lib/calabash/legacy.rb +6 -9
- data/lib/calabash/lib/skeleton/{Gemfile.skeleton → Gemfile} +0 -0
- data/lib/calabash/lib/skeleton/config/{cucumber.yml.skeleton → cucumber.yml} +0 -0
- data/lib/calabash/lib/skeleton/features/{sample.feature.skeleton → sample.feature} +0 -0
- data/lib/calabash/lib/skeleton/features/step_definitions/{sample_steps.rb.skeleton → calabash_steps.rb} +8 -8
- data/lib/calabash/lib/skeleton/features/support/{dry_run.rb.skeleton → dry_run.rb} +5 -2
- data/lib/calabash/lib/skeleton/features/support/{env.rb.skeleton → env.rb} +8 -2
- data/lib/calabash/lib/skeleton/features/support/hooks.rb +83 -0
- data/lib/calabash/life_cycle.rb +8 -16
- data/lib/calabash/location.rb +15 -14
- data/lib/calabash/orientation.rb +8 -8
- data/lib/calabash/page.rb +4 -1
- data/lib/calabash/screenshot.rb +3 -3
- data/lib/calabash/text.rb +19 -31
- data/lib/calabash/utility.rb +8 -41
- data/lib/calabash/version.rb +1 -1
- data/lib/calabash/wait.rb +192 -177
- data/lib/calabash.rb +10 -53
- metadata +32 -43
- data/lib/calabash/android/device/helper_application.rb +0 -95
- data/lib/calabash/android/lib/HelperApplication.apk +0 -0
- data/lib/calabash/android/lib/HelperApplicationTestServer.apk +0 -0
- data/lib/calabash/android/web.rb +0 -12
- data/lib/calabash/http/forwarding_client.rb +0 -23
- data/lib/calabash/internal.rb +0 -48
- data/lib/calabash/ios/automator/automator.rb +0 -217
- data/lib/calabash/ios/automator/coordinates.rb +0 -37
- data/lib/calabash/ios/automator/device_agent.rb +0 -379
- data/lib/calabash/ios/automator.rb +0 -9
- data/lib/calabash/ios/legacy.rb +0 -6
- data/lib/calabash/ios/web.rb +0 -10
- data/lib/calabash/lib/skeleton/features/support/hooks.rb.skeleton +0 -34
- data/lib/calabash/retry.rb +0 -33
- data/lib/calabash/stubs.rb +0 -21
- data/lib/calabash/web.rb +0 -44
data/lib/calabash/gestures.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Calabash
|
2
2
|
# Methods for performing gestures. Gestures are taps, flicks, and pans.
|
3
|
-
#
|
3
|
+
#
|
4
|
+
# Many gestures take an optional :duration. On iOS, the duration must be
|
5
|
+
# between 0.5 and 60 (seconds). This is a limitation of the UIAutomation API.
|
4
6
|
#
|
5
7
|
# @note All gestures have _undefined return values._ This is intentional.
|
6
8
|
# Please do not rely on return values of gestures in your tests. For
|
@@ -29,24 +31,23 @@ module Calabash
|
|
29
31
|
# | │ 4 │
|
30
32
|
# ┴ └─────────────────────────────────────┘
|
31
33
|
#
|
32
|
-
# 1.
|
33
|
-
# 2.
|
34
|
-
# 3.
|
35
|
-
# 4.
|
34
|
+
# 1. tap("* marked:'email'")
|
35
|
+
# 2. tap("* marked:'email'", at: {x: 0, y: 0})
|
36
|
+
# 3. tap("* marked:'email'", at: {x: 100, y: 0})
|
37
|
+
# 4. tap("* marked:'email'", at: {x: 50, y: 100})
|
36
38
|
#
|
37
39
|
# @param [String, Hash, Calabash::Query] query A query describing the view
|
38
40
|
# to tap.
|
39
|
-
# @param [Hash]
|
41
|
+
# @param [Hash] options Options for modifying the details of the touch.
|
42
|
+
# @option options [Hash] :at ({x: 50, y: 50}) The point at which the
|
40
43
|
# gesture originates from. It is a percentage-based translation using
|
41
|
-
# top-left `
|
44
|
+
# top-left `(0,0)` as the reference point.
|
42
45
|
# @raise [ViewNotFoundError] If the `query` returns no results.
|
43
46
|
# @raise [ArgumentError] If `query` is invalid.
|
44
|
-
def tap(query,
|
47
|
+
def tap(query, options={})
|
45
48
|
Query.ensure_valid_query(query)
|
46
49
|
|
47
|
-
|
48
|
-
|
49
|
-
Calabash::Internal.with_default_device {|device| device.tap(Query.new(query), options)}
|
50
|
+
Device.default.tap(Query.new(query), options)
|
50
51
|
end
|
51
52
|
|
52
53
|
# Performs a **double_tap** on the first view that matches `query`.
|
@@ -55,18 +56,17 @@ module Calabash
|
|
55
56
|
#
|
56
57
|
# @param [String, Hash, Calabash::Query] query A query describing the view
|
57
58
|
# to tap.
|
58
|
-
# @param [Hash]
|
59
|
+
# @param [Hash] options Options for modifying the details of the touch.
|
60
|
+
# @option options [Hash] :at ({x: 50, y: 50}) The point at which the
|
59
61
|
# gesture originates from. It is a percentage-based translation using
|
60
|
-
# top-left `
|
62
|
+
# top-left `(0,0)` as the reference point.
|
61
63
|
#
|
62
64
|
# @raise [ViewNotFoundError] If the `query` returns no results.
|
63
65
|
# @raise [ArgumentError] If `query` is invalid.
|
64
|
-
def double_tap(query,
|
66
|
+
def double_tap(query, options={})
|
65
67
|
Query.ensure_valid_query(query)
|
66
68
|
|
67
|
-
|
68
|
-
|
69
|
-
Calabash::Internal.with_default_device {|device| device.double_tap(Query.new(query), options)}
|
69
|
+
Device.default.double_tap(Query.new(query), options)
|
70
70
|
end
|
71
71
|
|
72
72
|
# Performs a **long_press** on the first view that matches `query`.
|
@@ -77,39 +77,33 @@ module Calabash
|
|
77
77
|
# @see #tap
|
78
78
|
#
|
79
79
|
# @param [String] query A query describing the view to tap.
|
80
|
-
# @param [
|
80
|
+
# @param [Hash] options Options for modifying the details of the touch.
|
81
|
+
# @option options [Number] :duration (1.0) The amount of time in seconds to
|
81
82
|
# press. On iOS, the duration must be between 0.5 and 60.
|
82
|
-
# @param [Hash] at (default: `{x: 50, y: 50}`) The point at which the
|
83
|
-
# gesture originates from. It is a percentage-based translation using
|
84
|
-
# top-left `{x: 0, y: 0}` as the reference point.
|
85
83
|
# @raise [ViewNotFoundError] If the `query` returns no results.
|
86
84
|
# @raise [ArgumentError] If `query` is invalid.
|
87
|
-
|
85
|
+
# @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
|
86
|
+
def long_press(query, options={})
|
88
87
|
Query.ensure_valid_query(query)
|
89
88
|
|
90
|
-
options
|
91
|
-
at: at || {x: 50, y: 50},
|
92
|
-
duration: duration || 1.0
|
93
|
-
}
|
94
|
-
|
95
|
-
Calabash::Internal.with_default_device {|device| device.long_press(Query.new(query), options)}
|
89
|
+
Device.default.long_press(Query.new(query), options)
|
96
90
|
end
|
97
91
|
|
98
|
-
# Performs a **pan**
|
92
|
+
# Performs a **pan** on the first view that matches `query`.
|
99
93
|
#
|
100
94
|
# A pan is a straight line swipe that pauses at the final point
|
101
95
|
# before releasing the gesture. This is the general purpose pan method. For
|
102
|
-
# standardized pans see
|
96
|
+
# standardized pans see `pan_left`, `pan_right`, `pan_up`, and `pan_down`.
|
103
97
|
#
|
104
|
-
#
|
105
|
-
# # Consider a pan on a scrollable view. When the finger is is released,
|
106
|
-
# # the velocity of the view is zero.
|
98
|
+
# Also known as **scroll** and **swipe**.
|
107
99
|
#
|
108
100
|
# @example
|
109
|
-
#
|
110
|
-
#
|
101
|
+
# Consider a pan on a scrollable view. When the finger is is released,
|
102
|
+
# the velocity of the view is zero.
|
111
103
|
#
|
112
|
-
#
|
104
|
+
# @example
|
105
|
+
# A scrollable view displays the alphabet. Panning left will cause the
|
106
|
+
# view to scroll right.
|
113
107
|
#
|
114
108
|
# Before After
|
115
109
|
# ┌───────────┐ | ┌───────────┐
|
@@ -118,6 +112,15 @@ module Calabash
|
|
118
112
|
# │ <───────┤ │ | │ │
|
119
113
|
# └───────────┘ | └───────────┘
|
120
114
|
#
|
115
|
+
# Apple's UIAutomation 'dragInsideWithOptions' is broken on iOS Simulators.
|
116
|
+
# Call `pan` on iOS Simulators >= iOS 7.0 will raise an error. See the
|
117
|
+
# iOS Scroll API for alternatives.
|
118
|
+
#
|
119
|
+
# @see Calabash::IOS::Scroll#scroll
|
120
|
+
# @see Calabash::IOS::Scroll#scroll_to_row
|
121
|
+
# @see Calabash::IOS::Scroll#scroll_to_row_with_mark
|
122
|
+
# @see Calabash::IOS::Scroll#scroll_to_item
|
123
|
+
# @see Calabash::IOS::Scroll#scroll_to_item_with_mark
|
121
124
|
#
|
122
125
|
# @param [String, Hash, Calabash::Query] query A query describing the view
|
123
126
|
# to pan inside.
|
@@ -125,18 +128,19 @@ module Calabash
|
|
125
128
|
# originates from.
|
126
129
|
# @param [Hash] to `({:x, :y})` The point at which the gesture
|
127
130
|
# ends.
|
128
|
-
#
|
129
|
-
#
|
131
|
+
#
|
132
|
+
# @param [Hash] options Options for modifying the details of the pan.
|
133
|
+
# @option options [Number] :duration (0.5) How many seconds the pan takes
|
134
|
+
# to complete. On iOS, the duration must be between 0.5 and 60.
|
135
|
+
#
|
130
136
|
# @raise [ViewNotFoundError] If the `query` returns no results.
|
131
137
|
# @raise [ArgumentError] If `query` is invalid.
|
132
|
-
|
138
|
+
# @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
|
139
|
+
# @raise [RuntimeError] If called on an iOS Simulator > iOS 7.
|
140
|
+
def pan(query, from, to, options={})
|
133
141
|
Query.ensure_valid_query(query)
|
134
142
|
|
135
|
-
|
136
|
-
duration: duration || DEFAULT_PAN_OPTIONS[:duration]
|
137
|
-
}
|
138
|
-
|
139
|
-
Calabash::Internal.with_default_device {|device| device.pan(Query.new(query), from, to, options)}
|
143
|
+
Device.default.pan(Query.new(query), from, to, options)
|
140
144
|
end
|
141
145
|
|
142
146
|
# Performs a **pan** from the center of the first view that matches
|
@@ -145,8 +149,8 @@ module Calabash
|
|
145
149
|
# Also known as **drag and drop**.
|
146
150
|
#
|
147
151
|
# @example
|
148
|
-
#
|
149
|
-
#
|
152
|
+
# Panning between two elements.
|
153
|
+
# `pan_between("* id:'first'", "* id:'second'")`
|
150
154
|
#
|
151
155
|
#
|
152
156
|
# ┌───────────┐
|
@@ -166,137 +170,86 @@ module Calabash
|
|
166
170
|
# │ │
|
167
171
|
# └───────────┘
|
168
172
|
#
|
169
|
-
# @
|
170
|
-
#
|
171
|
-
# @param [String, Hash, Calabash::Query] query_to A query describing the
|
172
|
-
# view to pan *to*
|
173
|
-
# @param [Number] duration (default: 1.0) The amount of time in seconds the
|
174
|
-
# gesture lasts.
|
173
|
+
# @option options [Number] :duration (1.0) How many seconds the swipe takes
|
174
|
+
# to complete.
|
175
175
|
# @raise [ViewNotFoundError] If the `query_from` returns no results.
|
176
176
|
# @raise [ViewNotFoundError] If the `query_to` returns no results.
|
177
177
|
# @raise [ArgumentError] If `query_from` is invalid.
|
178
178
|
# @raise [ArgumentError] If `query_to` is invalid.
|
179
|
-
|
179
|
+
# @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
|
180
|
+
def pan_between(query_from, query_to, options={})
|
180
181
|
Query.ensure_valid_query(query_from)
|
181
182
|
Query.ensure_valid_query(query_to)
|
182
183
|
|
183
|
-
|
184
|
-
duration: duration || DEFAULT_PAN_OPTIONS[:duration]
|
185
|
-
}
|
186
|
-
|
187
|
-
Calabash::Internal.with_default_device do |device|
|
188
|
-
device.pan_between(Query.new(query_from), Query.new(query_to), options)
|
189
|
-
end
|
184
|
+
Device.default.pan_between(Query.new(query_from), Query.new(query_to), options)
|
190
185
|
end
|
191
186
|
|
192
|
-
# Performs a **pan** heading _left_
|
193
|
-
# `query`.
|
187
|
+
# Performs a **pan** heading _left_ on the first view that matches `query`.
|
194
188
|
#
|
195
189
|
# @see #pan
|
196
|
-
|
197
|
-
|
198
|
-
def pan_left(query, duration: nil)
|
199
|
-
pan(query, {x: 90, y: 50}, {x: 10, y: 50}, duration: duration)
|
190
|
+
def pan_left(query, options={})
|
191
|
+
pan(query, {x: 90, y: 50}, {x: 10, y: 50}, options)
|
200
192
|
end
|
201
193
|
|
202
|
-
# Performs a **pan** heading _right_
|
203
|
-
# `query`.
|
194
|
+
# Performs a **pan** heading _right_ on the first view that matches `query`.
|
204
195
|
#
|
205
196
|
# @see #pan
|
206
|
-
|
207
|
-
|
208
|
-
def pan_right(query, duration: nil)
|
209
|
-
pan(query, {x: 10, y: 50}, {x: 90, y: 50}, duration: duration)
|
197
|
+
def pan_right(query, options={})
|
198
|
+
pan(query, {x: 10, y: 50}, {x: 90, y: 50}, options)
|
210
199
|
end
|
211
200
|
|
212
|
-
# Performs a **pan** heading _up_
|
213
|
-
# `query`.
|
201
|
+
# Performs a **pan** heading _up_ on the first view that matches `query`.
|
214
202
|
#
|
215
203
|
# @see #pan
|
216
|
-
|
217
|
-
|
218
|
-
def pan_up(query, duration: nil)
|
219
|
-
pan(query, {x: 50, y: 90}, {x: 50, y: 10}, duration: duration)
|
204
|
+
def pan_up(query, options={})
|
205
|
+
pan(query, {x: 50, y: 90}, {x: 50, y: 10}, options)
|
220
206
|
end
|
221
207
|
|
222
|
-
# Performs a **pan** heading _down_
|
223
|
-
# `query`.
|
208
|
+
# Performs a **pan** heading _down_ on the first view that matches `query`.
|
224
209
|
#
|
225
210
|
# @see #pan
|
226
|
-
|
227
|
-
|
228
|
-
def pan_down(query, duration: nil)
|
229
|
-
pan(query, {x: 50, y: 10}, {x: 50, y: 90}, duration: duration)
|
211
|
+
def pan_down(query, options={})
|
212
|
+
pan(query, {x: 50, y: 10}, {x: 50, y: 90}, options)
|
230
213
|
end
|
231
214
|
|
232
215
|
# Performs a **pan** heading _left_ on the screen.
|
233
216
|
#
|
234
217
|
# @see #pan
|
235
|
-
|
236
|
-
# gesture lasts.
|
237
|
-
def pan_screen_left(duration: nil)
|
238
|
-
options = {
|
239
|
-
duration: duration || DEFAULT_PAN_OPTIONS[:duration]
|
240
|
-
}
|
241
|
-
|
218
|
+
def pan_screen_left(options={})
|
242
219
|
pan_left('*', options)
|
243
220
|
end
|
244
221
|
|
245
222
|
# Performs a **pan** heading _right_ on the screen.
|
246
223
|
#
|
247
224
|
# @see #pan
|
248
|
-
|
249
|
-
# gesture lasts.
|
250
|
-
def pan_screen_right(duration: nil)
|
251
|
-
options = {
|
252
|
-
duration: duration || DEFAULT_PAN_OPTIONS[:duration]
|
253
|
-
}
|
254
|
-
|
225
|
+
def pan_screen_right(options={})
|
255
226
|
pan_right('*', options)
|
256
227
|
end
|
257
228
|
|
258
229
|
# Performs a **pan** heading _up_ on the screen.
|
259
230
|
#
|
260
231
|
# @see #pan
|
261
|
-
|
262
|
-
# gesture lasts.
|
263
|
-
def pan_screen_up(duration: nil)
|
264
|
-
options = {
|
265
|
-
duration: duration || DEFAULT_PAN_OPTIONS[:duration]
|
266
|
-
}
|
267
|
-
|
232
|
+
def pan_screen_up(options={})
|
268
233
|
_pan_screen_up(options)
|
269
234
|
end
|
270
235
|
|
271
236
|
# Performs a **pan** heading _down_ on the screen.
|
272
237
|
#
|
273
238
|
# @see #pan
|
274
|
-
|
275
|
-
# gesture lasts.
|
276
|
-
def pan_screen_down(duration: nil)
|
277
|
-
options = {
|
278
|
-
duration: duration || DEFAULT_PAN_OPTIONS[:duration]
|
279
|
-
}
|
280
|
-
|
239
|
+
def pan_screen_down(options={})
|
281
240
|
_pan_screen_down(options)
|
282
241
|
end
|
283
242
|
|
284
|
-
# Performs a **flick**
|
243
|
+
# Performs a **flick** on the first view that matches `query`.
|
285
244
|
#
|
286
245
|
# A flick is a straight line swipe that **lifts the finger while
|
287
246
|
# the gesture is still in motion**. This will often cause scrollable
|
288
247
|
# views to continue moving for some time after the gesture is released.
|
289
|
-
#
|
290
|
-
# It is likely that the gesture you want to automate is a {pan}, not a
|
291
|
-
# flick.
|
292
|
-
#
|
293
248
|
# @see pan
|
294
249
|
#
|
295
250
|
# @example
|
296
|
-
#
|
297
|
-
#
|
298
|
-
#
|
299
|
-
# cal.flick("* id:'alphabetView'", cal.pct(80, 80), cal.pct(20, 80))
|
251
|
+
# A scrollable view displays the alphabet. Flicking left will cause the
|
252
|
+
# view to scroll right.
|
300
253
|
#
|
301
254
|
# Before After
|
302
255
|
# ┌───────────┐ | ┌───────────┐
|
@@ -306,266 +259,219 @@ module Calabash
|
|
306
259
|
# └───────────┘ | └───────────┘
|
307
260
|
#
|
308
261
|
# @param [String,Hash,Query] query A query describing the view to flick
|
309
|
-
# inside.
|
262
|
+
# inside of.
|
310
263
|
# @param [Hash] from `({:x, :y})` The point at which the gesture
|
311
264
|
# originates from.
|
312
265
|
# @param [Hash] to `({:x, :y})` The point at which the gesture
|
313
266
|
# ends.
|
314
|
-
#
|
315
|
-
#
|
267
|
+
#
|
268
|
+
# @param [Hash] options Options for controlling the flick.
|
269
|
+
# @option options [Numeric] :duration The duration of the flick. On iOS,
|
270
|
+
# the duration must be between 0.5 and 60.
|
271
|
+
#
|
316
272
|
# @raise [ViewNotFoundError] If the `query` returns no results.
|
317
273
|
# @raise [ArgumentError] If `query` is invalid.
|
318
|
-
|
274
|
+
# @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
|
275
|
+
def flick(query, from, to, options={})
|
319
276
|
Query.ensure_valid_query(query)
|
320
277
|
|
321
|
-
|
322
|
-
duration: duration || DEFAULT_PAN_OPTIONS[:duration]
|
323
|
-
}
|
324
|
-
|
325
|
-
Calabash::Internal.with_default_device do |device|
|
326
|
-
device.flick(Query.new(query), from, to, options)
|
327
|
-
end
|
278
|
+
Device.default.flick(Query.new(query), from, to, options)
|
328
279
|
end
|
329
280
|
|
330
|
-
# Performs a **flick** heading _left_
|
331
|
-
# `query`.
|
281
|
+
# Performs a **flick** heading _left_ on the first view that matches `query`.
|
332
282
|
# @see #flick
|
333
|
-
|
334
|
-
|
335
|
-
def flick_left(query, duration: nil)
|
336
|
-
flick(query, {x: 90, y: 50}, {x: 10, y: 50}, duration: duration)
|
283
|
+
def flick_left(query, options={})
|
284
|
+
flick(query, {x: 90, y: 50}, {x: 10, y: 50}, options)
|
337
285
|
end
|
338
286
|
|
339
|
-
# Performs a **flick** heading _right_
|
287
|
+
# Performs a **flick** heading _right_ on the first view that matches
|
340
288
|
# `query`.
|
341
289
|
# @see #flick
|
342
|
-
|
343
|
-
|
344
|
-
def flick_right(query, duration: nil)
|
345
|
-
flick(query, {x: 10, y: 50}, {x: 90, y: 50}, duration: duration)
|
290
|
+
def flick_right(query, options={})
|
291
|
+
flick(query, {x: 10, y: 50}, {x: 90, y: 50}, options)
|
346
292
|
end
|
347
293
|
|
348
|
-
# Performs a **flick** heading _up_
|
349
|
-
# `query`.
|
294
|
+
# Performs a **flick** heading _up_ on the first view that matches `query`.
|
350
295
|
# @see #flick
|
351
|
-
|
352
|
-
|
353
|
-
def flick_up(query, duration: nil)
|
354
|
-
flick(query, {x: 50, y: 90}, {x: 50, y: 10}, duration: duration)
|
296
|
+
def flick_up(query, options={})
|
297
|
+
flick(query, {x: 50, y: 90}, {x: 50, y: 10}, options)
|
355
298
|
end
|
356
299
|
|
357
|
-
# Performs a **flick** heading _down_
|
358
|
-
# `query`.
|
300
|
+
# Performs a **flick** heading _down_ on the first view that matches `query`.
|
359
301
|
# @see #flick
|
360
|
-
|
361
|
-
|
362
|
-
def flick_down(query, duration: nil)
|
363
|
-
flick(query, {x: 50, y: 10}, {x: 50, y: 90}, duration: duration)
|
302
|
+
def flick_down(query, options={})
|
303
|
+
flick(query, {x: 50, y: 10}, {x: 50, y: 90}, options)
|
364
304
|
end
|
365
305
|
|
366
306
|
# Performs a **flick** heading _left_ on the screen.
|
367
307
|
# @see #flick
|
368
|
-
|
369
|
-
# gesture lasts.
|
370
|
-
def flick_screen_left(duration: nil)
|
371
|
-
options = {
|
372
|
-
duration: duration || DEFAULT_PAN_OPTIONS[:duration]
|
373
|
-
}
|
374
|
-
|
308
|
+
def flick_screen_left(options={})
|
375
309
|
flick_left('*', options)
|
376
310
|
end
|
377
311
|
|
378
312
|
# Performs a **flick** heading _right_ on the screen.
|
379
313
|
# @see #flick
|
380
|
-
|
381
|
-
# gesture lasts.
|
382
|
-
def flick_screen_right(duration: nil)
|
383
|
-
options = {
|
384
|
-
duration: duration || DEFAULT_PAN_OPTIONS[:duration]
|
385
|
-
}
|
386
|
-
|
314
|
+
def flick_screen_right(options={})
|
387
315
|
flick_right('*', options)
|
388
316
|
end
|
389
317
|
|
390
318
|
# Performs a **flick** heading _up_ on the screen.
|
391
319
|
# @see #flick
|
392
|
-
|
393
|
-
# gesture lasts.
|
394
|
-
def flick_screen_up(duration: nil)
|
395
|
-
options = {
|
396
|
-
duration: duration || DEFAULT_PAN_OPTIONS[:duration]
|
397
|
-
}
|
398
|
-
|
320
|
+
def flick_screen_up(options={})
|
399
321
|
_flick_screen_up(options)
|
400
322
|
end
|
401
323
|
|
402
324
|
# Performs a **flick** heading _down_ on the screen.
|
403
325
|
# @see #flick
|
404
|
-
|
405
|
-
# gesture lasts.
|
406
|
-
def flick_screen_down(duration: nil)
|
407
|
-
options = {
|
408
|
-
duration: duration || DEFAULT_PAN_OPTIONS[:duration]
|
409
|
-
}
|
410
|
-
|
326
|
+
def flick_screen_down(options={})
|
411
327
|
_flick_screen_down(options)
|
412
328
|
end
|
413
329
|
|
414
|
-
# Performs a **pinch** outwards
|
330
|
+
# Performs a **pinch** outwards on the first view match by `query`.
|
415
331
|
#
|
416
|
-
#
|
417
|
-
#
|
418
|
-
#
|
419
|
-
#
|
420
|
-
#
|
421
|
-
# # We have a webview that we want to pinch out on
|
422
|
-
#
|
423
|
-
# cal.pinch_out("* id:'webView'")
|
424
|
-
#
|
425
|
-
# Application
|
426
|
-
# ┌───────────────────────┐
|
427
|
-
# │───────────────────────│
|
428
|
-
# │ id: webview │
|
429
|
-
# │ ┌─────────────────┐ │
|
430
|
-
# │ │ ^ │ │
|
431
|
-
# │ │ \ │ │
|
432
|
-
# │ │ \ │ │
|
433
|
-
# │ │ * * │ │
|
434
|
-
# │ │ \ │ │
|
435
|
-
# │ │ \ │ │
|
436
|
-
# │ │ v │ │
|
437
|
-
# │ └─────────────────┘ │
|
438
|
-
# └───────────────────────┘
|
439
|
-
#
|
440
|
-
# @example
|
441
|
-
# # We have a MapView rendering a map. We want to zoom it in.
|
442
|
-
# # On iOS, we should pinch out to zoom in
|
443
|
-
# # On Android, we should pinch in to zoom in.
|
332
|
+
# @param [String, Hash, Calabash::Query] query A query describing the view
|
333
|
+
# to pinch.
|
334
|
+
# @param [Hash] options Options for controlling the pinch.
|
335
|
+
# @option options [Numeric] :duration The duration of the pinch. On iOS,
|
336
|
+
# the duration must be between 0.5 and 60.
|
444
337
|
#
|
445
|
-
#
|
446
|
-
#
|
447
|
-
#
|
448
|
-
|
449
|
-
|
338
|
+
# @raise [ViewNotFoundError] If the `query` returns no results.
|
339
|
+
# @raise [ArgumentError] If `query` is invalid.
|
340
|
+
# @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
|
341
|
+
def pinch_out(query, options={})
|
342
|
+
Device.default.pinch(:out, query, options)
|
343
|
+
end
|
344
|
+
|
345
|
+
# Performs a **pinch** inwards on the first view match by `query`.
|
450
346
|
#
|
451
347
|
# @param [String, Hash, Calabash::Query] query A query describing the view
|
452
348
|
# to pinch.
|
453
|
-
# @param [
|
454
|
-
#
|
349
|
+
# @param [Hash] options Options for controlling the pinch.
|
350
|
+
# @option options [Numeric] :duration The duration of the pinch. On iOS,
|
351
|
+
# the duration must be between 0.5 and 60.
|
352
|
+
#
|
455
353
|
# @raise [ViewNotFoundError] If the `query` returns no results.
|
456
354
|
# @raise [ArgumentError] If `query` is invalid.
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
}
|
461
|
-
|
462
|
-
Calabash::Internal.with_default_device {|device| device.pinch(:out, query, options)}
|
355
|
+
# @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
|
356
|
+
def pinch_in(query, options={})
|
357
|
+
Device.default.pinch(:in, query, options)
|
463
358
|
end
|
464
359
|
|
465
|
-
# Performs a **pinch**
|
360
|
+
# Performs a **pinch** outwards on the screen.
|
466
361
|
#
|
467
|
-
#
|
468
|
-
#
|
469
|
-
#
|
362
|
+
# @param [Hash] options Options for controlling the pinch.
|
363
|
+
# @option options [Numeric] :duration The duration of the pinch. On iOS,
|
364
|
+
# the duration must be between 0.5 and 60.
|
470
365
|
#
|
471
|
-
# @
|
472
|
-
#
|
473
|
-
#
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
#
|
479
|
-
# │ id: webview │
|
480
|
-
# │ ┌─────────────────┐ │
|
481
|
-
# │ │ * │ │
|
482
|
-
# │ │ \ │ │
|
483
|
-
# │ │ \ │ │
|
484
|
-
# │ │ v ^ │ │
|
485
|
-
# │ │ \ │ │
|
486
|
-
# │ │ \ │ │
|
487
|
-
# │ │ * │ │
|
488
|
-
# │ └─────────────────┘ │
|
489
|
-
# └───────────────────────┘
|
366
|
+
# @raise [ViewNotFoundError] If the `query` returns no results.
|
367
|
+
# @raise [ArgumentError] If `query` is invalid.
|
368
|
+
# @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
|
369
|
+
def pinch_screen_out(options={})
|
370
|
+
_pinch_screen(:out, options)
|
371
|
+
end
|
372
|
+
|
373
|
+
# Performs a **pinch** inwards on the screen.
|
490
374
|
#
|
491
|
-
# @
|
492
|
-
#
|
493
|
-
#
|
494
|
-
# # On Android, we should pinch in to zoom in.
|
375
|
+
# @param [Hash] options Options for controlling the pinch.
|
376
|
+
# @option options [Numeric] :duration The duration of the pinch. On iOS,
|
377
|
+
# the duration must be between 0.5 and 60.
|
495
378
|
#
|
496
|
-
#
|
497
|
-
#
|
498
|
-
#
|
499
|
-
|
500
|
-
|
379
|
+
# @raise [ViewNotFoundError] If the `query` returns no results.
|
380
|
+
# @raise [ArgumentError] If `query` is invalid.
|
381
|
+
# @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
|
382
|
+
def pinch_screen_in(options={})
|
383
|
+
_pinch_screen(:in, options)
|
384
|
+
end
|
385
|
+
|
386
|
+
# Performs a **pinch** to zoom out.
|
501
387
|
#
|
502
388
|
# @param [String, Hash, Calabash::Query] query A query describing the view
|
503
389
|
# to pinch.
|
504
|
-
# @param [
|
505
|
-
#
|
390
|
+
# @param [Hash] options Options for controlling the pinch.
|
391
|
+
# @option options [Numeric] :duration The duration of the pinch. On iOS,
|
392
|
+
# the duration must be between 0.5 and 60.
|
393
|
+
#
|
506
394
|
# @raise [ViewNotFoundError] If the `query` returns no results.
|
507
395
|
# @raise [ArgumentError] If `query` is invalid.
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
}
|
512
|
-
|
513
|
-
Calabash::Internal.with_default_device {|device| device.pinch(:in, query, options)}
|
396
|
+
# @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
|
397
|
+
def pinch_to_zoom_out(query, options={})
|
398
|
+
_pinch_to_zoom(:out, query, options)
|
514
399
|
end
|
515
400
|
|
516
|
-
# Performs a **pinch**
|
401
|
+
# Performs a **pinch** to zoom in.
|
517
402
|
#
|
518
|
-
# @
|
403
|
+
# @param [String, Hash, Calabash::Query] query A query describing the view
|
404
|
+
# to pinch.
|
405
|
+
# @param [Hash] options Options for controlling the pinch.
|
406
|
+
# @option options [Numeric] :duration The duration of the pinch. On iOS,
|
407
|
+
# the duration must be between 0.5 and 60.
|
519
408
|
#
|
520
|
-
# @param [Number] duration (default: 1.0) The amount of time in seconds the
|
521
|
-
# gesture lasts.
|
522
409
|
# @raise [ViewNotFoundError] If the `query` returns no results.
|
523
410
|
# @raise [ArgumentError] If `query` is invalid.
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
411
|
+
# @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
|
412
|
+
def pinch_to_zoom_in(query, options={})
|
413
|
+
_pinch_to_zoom(:in, query, options)
|
414
|
+
end
|
528
415
|
|
529
|
-
|
416
|
+
# Performs a **pinch** on the screen to zoom in.
|
417
|
+
#
|
418
|
+
# @param [Hash] options Options for controlling the pinch.
|
419
|
+
# @option options [Numeric] :duration The duration of the pinch. On iOS,
|
420
|
+
# the duration must be between 0.5 and 60.
|
421
|
+
#
|
422
|
+
# @raise [ViewNotFoundError] If the `query` returns no results.
|
423
|
+
# @raise [ArgumentError] If `query` is invalid.
|
424
|
+
# @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
|
425
|
+
def pinch_screen_to_zoom_in(options={})
|
426
|
+
_pinch_screen_to_zoom(:in, options)
|
530
427
|
end
|
531
428
|
|
532
|
-
# Performs a **pinch**
|
429
|
+
# Performs a **pinch** on the screen to zoom out.
|
533
430
|
#
|
534
|
-
# @
|
431
|
+
# @param [Hash] options Options for controlling the pinch.
|
432
|
+
# @option options [Numeric] :duration The duration of the pinch. On iOS,
|
433
|
+
# the duration must be between 0.5 and 60.
|
535
434
|
#
|
536
|
-
# @param [Number] duration (default: 1.0) The amount of time in seconds the
|
537
|
-
# gesture lasts.
|
538
435
|
# @raise [ViewNotFoundError] If the `query` returns no results.
|
539
436
|
# @raise [ArgumentError] If `query` is invalid.
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
437
|
+
# @raise [ArgumentError] iOS: if the `:duration` is not between 0.5 and 60.
|
438
|
+
def pinch_screen_to_zoom_out(options={})
|
439
|
+
_pinch_screen_to_zoom(:out, options)
|
440
|
+
end
|
544
441
|
|
545
|
-
|
442
|
+
# @!visibility private
|
443
|
+
def _pan_screen_up(options={})
|
444
|
+
abstract_method!
|
546
445
|
end
|
547
446
|
|
548
447
|
# @!visibility private
|
549
|
-
|
550
|
-
abstract_method!
|
448
|
+
def _pan_screen_down(options={})
|
449
|
+
abstract_method!
|
551
450
|
end
|
552
451
|
|
553
452
|
# @!visibility private
|
554
|
-
|
555
|
-
abstract_method!
|
453
|
+
def _flick_screen_up(options={})
|
454
|
+
abstract_method!
|
556
455
|
end
|
557
456
|
|
558
457
|
# @!visibility private
|
559
|
-
|
560
|
-
abstract_method!
|
458
|
+
def _flick_screen_down(options={})
|
459
|
+
abstract_method!
|
561
460
|
end
|
562
461
|
|
563
462
|
# @!visibility private
|
564
|
-
|
565
|
-
abstract_method!
|
463
|
+
def _pinch_screen(direction, options={})
|
464
|
+
abstract_method!
|
566
465
|
end
|
567
466
|
|
568
467
|
# @!visibility private
|
569
|
-
|
468
|
+
def _pinch_to_zoom(direction, query, options={})
|
469
|
+
abstract_method!
|
470
|
+
end
|
471
|
+
|
472
|
+
# @!visibility private
|
473
|
+
def _pinch_screen_to_zoom(direction, options={})
|
474
|
+
abstract_method!
|
475
|
+
end
|
570
476
|
end
|
571
477
|
end
|