calabash 2.0.0.pre10 → 2.0.0.pre11
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 +5 -17
- data/bin/calabash +3 -4
- data/lib/calabash.rb +53 -10
- data/lib/calabash/android.rb +89 -28
- data/lib/calabash/android/adb.rb +32 -20
- 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 +22 -66
- data/lib/calabash/android/device/helper_application.rb +95 -0
- data/lib/calabash/android/environment.rb +14 -1
- data/lib/calabash/android/gestures.rb +6 -22
- data/lib/calabash/android/interactions.rb +14 -17
- data/lib/calabash/android/lib/.irbrc +9 -1
- data/lib/calabash/android/lib/AndroidManifest.xml +23 -2
- data/lib/calabash/android/lib/HelperApplication.apk +0 -0
- data/lib/calabash/android/lib/HelperApplicationTestServer.apk +0 -0
- 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 +19 -16
- data/lib/calabash/android/server.rb +1 -1
- data/lib/calabash/android/text.rb +12 -12
- data/lib/calabash/android/web.rb +12 -0
- data/lib/calabash/application.rb +3 -0
- data/lib/calabash/cli/generate.rb +8 -18
- data/lib/calabash/cli/helpers.rb +4 -9
- data/lib/calabash/cli/run.rb +1 -1
- data/lib/calabash/console_helpers.rb +179 -11
- data/lib/calabash/device.rb +4 -19
- data/lib/calabash/gestures.rb +292 -198
- data/lib/calabash/interactions.rb +3 -40
- data/lib/calabash/internal.rb +48 -0
- data/lib/calabash/ios.rb +76 -16
- data/lib/calabash/ios/automator.rb +9 -0
- data/lib/calabash/ios/automator/automator.rb +217 -0
- data/lib/calabash/ios/automator/coordinates.rb +37 -0
- data/lib/calabash/ios/automator/device_agent.rb +379 -0
- data/lib/calabash/ios/conditions.rb +1 -1
- data/lib/calabash/ios/console_helpers.rb +2 -2
- data/lib/calabash/ios/date_picker.rb +10 -8
- data/lib/calabash/ios/device.rb +0 -1
- data/lib/calabash/ios/device/device_implementation.rb +9 -21
- data/lib/calabash/ios/device/gestures_mixin.rb +53 -55
- data/lib/calabash/ios/device/keyboard_mixin.rb +21 -0
- data/lib/calabash/ios/device/rotation_mixin.rb +3 -65
- data/lib/calabash/ios/gestures.rb +24 -90
- data/lib/calabash/ios/interactions.rb +1 -6
- data/lib/calabash/ios/lib/.irbrc +9 -2
- data/lib/calabash/ios/orientation.rb +8 -8
- data/lib/calabash/ios/runtime.rb +14 -14
- data/lib/calabash/ios/scroll.rb +25 -17
- data/lib/calabash/ios/slider.rb +11 -18
- data/lib/calabash/ios/text.rb +20 -74
- data/lib/calabash/ios/uia.rb +1 -1
- data/lib/calabash/ios/web.rb +10 -0
- data/lib/calabash/lib/skeleton/{Gemfile → Gemfile.skeleton} +0 -0
- data/lib/calabash/lib/skeleton/config/{cucumber.yml → cucumber.yml.skeleton} +0 -0
- data/lib/calabash/lib/skeleton/features/{sample.feature → sample.feature.skeleton} +0 -0
- data/lib/calabash/lib/skeleton/features/step_definitions/{calabash_steps.rb → sample_steps.rb.skeleton} +8 -8
- data/lib/calabash/lib/skeleton/features/support/{dry_run.rb → dry_run.rb.skeleton} +2 -5
- data/lib/calabash/lib/skeleton/features/support/{env.rb → env.rb.skeleton} +2 -8
- data/lib/calabash/lib/skeleton/features/support/hooks.rb.skeleton +34 -0
- data/lib/calabash/life_cycle.rb +16 -8
- data/lib/calabash/location.rb +14 -15
- data/lib/calabash/orientation.rb +8 -8
- data/lib/calabash/page.rb +1 -4
- data/lib/calabash/retry.rb +33 -0
- data/lib/calabash/screenshot.rb +3 -3
- data/lib/calabash/stubs.rb +21 -0
- data/lib/calabash/text.rb +31 -19
- data/lib/calabash/utility.rb +41 -8
- data/lib/calabash/version.rb +1 -1
- data/lib/calabash/wait.rb +177 -192
- data/lib/calabash/web.rb +44 -0
- metadata +39 -32
- data/lib/calabash/ios/device/text_mixin.rb +0 -21
- data/lib/calabash/lib/skeleton/features/support/hooks.rb +0 -83
data/lib/calabash/ios/device.rb
CHANGED
@@ -16,7 +16,6 @@ module Calabash
|
|
16
16
|
require 'calabash/ios/device/rotation_mixin'
|
17
17
|
require 'calabash/ios/device/keyboard_mixin'
|
18
18
|
require 'calabash/ios/device/uia_keyboard_mixin'
|
19
|
-
require 'calabash/ios/device/text_mixin'
|
20
19
|
require 'calabash/ios/device/uia_mixin'
|
21
20
|
require 'calabash/ios/device/ipad_1x_2x_mixin'
|
22
21
|
require 'calabash/ios/device/device_implementation'
|
@@ -17,13 +17,11 @@ module Calabash
|
|
17
17
|
include Calabash::IOS::RotationMixin
|
18
18
|
include Calabash::IOS::KeyboardMixin
|
19
19
|
include Calabash::IOS::UIAKeyboardMixin
|
20
|
-
include Calabash::IOS::TextMixin
|
21
20
|
include Calabash::IOS::UIAMixin
|
22
21
|
include Calabash::IOS::IPadMixin
|
23
22
|
include Calabash::IOS::GesturesMixin
|
24
23
|
|
25
24
|
attr_reader :run_loop
|
26
|
-
attr_reader :uia_strategy
|
27
25
|
attr_reader :start_options
|
28
26
|
|
29
27
|
# Returns the default simulator identifier. The string that is return
|
@@ -50,7 +48,7 @@ module Calabash
|
|
50
48
|
if run_loop_device.nil?
|
51
49
|
raise "Could not find a simulator with a UDID or name matching '#{identifier}'"
|
52
50
|
end
|
53
|
-
run_loop_device.instruments_identifier
|
51
|
+
run_loop_device.instruments_identifier(RunLoop::SimControl.new.xcode)
|
54
52
|
end
|
55
53
|
end
|
56
54
|
|
@@ -84,14 +82,14 @@ module Calabash
|
|
84
82
|
elsif connected_devices.count > 1
|
85
83
|
raise 'There is more than one physical devices connected. Use CAL_DEVICE_ID to indicate which you want to connect to.'
|
86
84
|
else
|
87
|
-
connected_devices.first.instruments_identifier
|
85
|
+
connected_devices.first.instruments_identifier(RunLoop::SimControl.new.xcode)
|
88
86
|
end
|
89
87
|
else
|
90
88
|
run_loop_device = Device.fetch_matching_physical_device(identifier)
|
91
89
|
if run_loop_device.nil?
|
92
90
|
raise "Could not find a physical device with a UDID or name matching '#{identifier}'"
|
93
91
|
end
|
94
|
-
run_loop_device.instruments_identifier
|
92
|
+
run_loop_device.instruments_identifier(RunLoop::SimControl.new.xcode)
|
95
93
|
end
|
96
94
|
end
|
97
95
|
|
@@ -345,8 +343,7 @@ module Calabash
|
|
345
343
|
|
346
344
|
{
|
347
345
|
:device => self,
|
348
|
-
:application => application
|
349
|
-
:uia_strategy => uia_strategy
|
346
|
+
:application => application
|
350
347
|
}
|
351
348
|
end
|
352
349
|
|
@@ -394,7 +391,7 @@ module Calabash
|
|
394
391
|
def start_app_with_device_and_options(application, run_loop_device, user_defined_options)
|
395
392
|
start_options = merge_start_options!(application, run_loop_device, user_defined_options)
|
396
393
|
@run_loop = RunLoop.run(start_options)
|
397
|
-
@
|
394
|
+
@automator = Calabash::IOS::Automator::DeviceAgent.new(@run_loop)
|
398
395
|
end
|
399
396
|
|
400
397
|
# @!visibility private
|
@@ -528,12 +525,6 @@ module Calabash
|
|
528
525
|
end
|
529
526
|
end
|
530
527
|
|
531
|
-
# @!visibility private
|
532
|
-
def enter_text(text)
|
533
|
-
# @todo implement this
|
534
|
-
raise 'ni'
|
535
|
-
end
|
536
|
-
|
537
528
|
# @!visibility private
|
538
529
|
def clear_app_data_on_simulator(application, run_loop_device, bridge)
|
539
530
|
begin
|
@@ -630,9 +621,8 @@ module Calabash
|
|
630
621
|
# @!visibility private
|
631
622
|
# Expensive!
|
632
623
|
def Device.fetch_matching_simulator(udid_or_name)
|
633
|
-
|
634
|
-
|
635
|
-
sim.instruments_identifier == udid_or_name ||
|
624
|
+
RunLoop::SimControl.new.simulators.detect do |sim|
|
625
|
+
sim.instruments_identifier(RunLoop::SimControl.new.xcode) == udid_or_name ||
|
636
626
|
sim.udid == udid_or_name
|
637
627
|
end
|
638
628
|
end
|
@@ -662,7 +652,7 @@ module Calabash
|
|
662
652
|
Logger.error('which resolves to a physical device.')
|
663
653
|
Logger.error("The server endpoint '#{server.endpoint}' is for an iOS Simulator.")
|
664
654
|
Logger.error('Use CAL_ENDPOINT to specify the IP address of your device')
|
665
|
-
Logger.error("Ex. $ CAL_ENDPOINT=http://10.0.1.2:37265 CAL_DEVICE_ID=#{identifier}
|
655
|
+
Logger.error("Ex. $ CAL_ENDPOINT=http://10.0.1.2:37265 CAL_DEVICE_ID=#{identifier} #{Calabash::Utility.bundle_exec_prepend}calabash ...")
|
666
656
|
raise "Invalid device endpoint '#{server.endpoint}'"
|
667
657
|
end
|
668
658
|
end
|
@@ -703,7 +693,7 @@ module Calabash
|
|
703
693
|
{
|
704
694
|
:app => application.path,
|
705
695
|
:bundle_id => application.identifier,
|
706
|
-
:device_target => run_loop_device.instruments_identifier,
|
696
|
+
:device_target => run_loop_device.instruments_identifier(RunLoop::SimControl.new.xcode),
|
707
697
|
:uia_strategy => strategy
|
708
698
|
}
|
709
699
|
@start_options = default_options.merge(options_from_user)
|
@@ -775,13 +765,11 @@ module Calabash
|
|
775
765
|
|
776
766
|
if strategy == :host
|
777
767
|
@run_loop = RunLoop::HostCache.default.read
|
778
|
-
@uia_strategy = :host
|
779
768
|
else
|
780
769
|
pid = instruments_pid
|
781
770
|
@run_loop = {}
|
782
771
|
@run_loop[:uia_strategy] = strategy
|
783
772
|
@run_loop[:pid] = pid
|
784
|
-
@uia_strategy = strategy
|
785
773
|
end
|
786
774
|
|
787
775
|
# populate the @runtime_attributes
|
@@ -96,36 +96,33 @@ module Calabash
|
|
96
96
|
|
97
97
|
# @!visibility private
|
98
98
|
def _tap(query, options={})
|
99
|
-
view_to_touch = _gesture_waiter.wait_for_view(query, options)
|
99
|
+
view_to_touch = _gesture_waiter.wait_for_view(query, timeout: options[:timeout])
|
100
100
|
|
101
101
|
rect = view_to_touch['rect']
|
102
102
|
x = rect['x'] + (rect['width'] * (options[:at][:x] / 100.0)).to_i
|
103
103
|
y = rect['y'] + (rect['height'] * (options[:at][:y] / 100.0)).to_i
|
104
104
|
|
105
|
-
|
106
|
-
|
107
|
-
uia_serialize_and_call(:tapOffset, offset, options)
|
105
|
+
@automator.touch({coordinates: coordinate(x, y)})
|
108
106
|
|
109
107
|
Calabash::QueryResult.create([view_to_touch], query)
|
110
108
|
end
|
111
109
|
|
112
110
|
# @!visibility private
|
113
111
|
def _double_tap(query, options={})
|
114
|
-
view_to_touch = _gesture_waiter.wait_for_view(query, options)
|
112
|
+
view_to_touch = _gesture_waiter.wait_for_view(query, timeout: options[:timeout])
|
115
113
|
|
116
114
|
rect = view_to_touch['rect']
|
117
115
|
x = rect['x'] + (rect['width'] * (options[:at][:x] / 100.0)).to_i
|
118
116
|
y = rect['y'] + (rect['height'] * (options[:at][:y] / 100.0)).to_i
|
119
117
|
|
120
|
-
|
121
|
-
|
122
|
-
uia_serialize_and_call(:doubleTapOffset, offset, options)
|
118
|
+
@automator.double_tap({coordinates: coordinate(x, y)})
|
123
119
|
|
124
120
|
Calabash::QueryResult.create([view_to_touch], query)
|
125
121
|
end
|
126
122
|
|
127
123
|
# @!visibility private
|
128
124
|
def _long_press(query, options={})
|
125
|
+
options[:duration] += 0.2
|
129
126
|
|
130
127
|
begin
|
131
128
|
_expect_valid_duration(options)
|
@@ -133,39 +130,66 @@ module Calabash
|
|
133
130
|
raise ArgumentError e
|
134
131
|
end
|
135
132
|
|
136
|
-
view_to_touch = _gesture_waiter.wait_for_view(query, options)
|
133
|
+
view_to_touch = _gesture_waiter.wait_for_view(query, timeout: options[:timeout])
|
137
134
|
|
138
135
|
rect = view_to_touch['rect']
|
139
136
|
x = rect['x'] + (rect['width'] * (options[:at][:x] / 100.0)).to_i
|
140
137
|
y = rect['y'] + (rect['height'] * (options[:at][:y] / 100.0)).to_i
|
141
138
|
|
142
|
-
|
143
|
-
|
144
|
-
uia_serialize_and_call(:touchHoldOffset, options[:duration], offset)
|
139
|
+
@automator.touch_hold({coordinates: coordinate(x, y), duration: options[:duration]})
|
145
140
|
|
146
141
|
Calabash::QueryResult.create([view_to_touch], query)
|
147
142
|
end
|
148
143
|
|
149
144
|
# @!visibility private
|
150
145
|
def _pan_between(query_from, query_to, options={})
|
146
|
+
from_query_result = nil
|
147
|
+
to_query_result = nil
|
148
|
+
from = coordinate(0, 0)
|
149
|
+
to = coordinate(0, 0)
|
150
|
+
|
151
|
+
unless query_from.nil?
|
152
|
+
from_view = _gesture_waiter.wait_for_view(query_from, timeout: options[:timeout])
|
153
|
+
from = coordinate(from_view['rect']['center_x'], from_view['rect']['center_y'])
|
154
|
+
from_query_result = Calabash::QueryResult.create([from_view], query_from)
|
155
|
+
end
|
151
156
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
157
|
+
unless query_to.nil?
|
158
|
+
to_view = _gesture_waiter.wait_for_view(query_to, timeout: options[:timeout])
|
159
|
+
to = coordinate(to_view['rect']['center_x'], to_view['rect']['center_y'])
|
160
|
+
Calabash::QueryResult.create([to_view], query_to)
|
156
161
|
end
|
157
162
|
|
158
|
-
|
159
|
-
|
163
|
+
offset = options[:offset]
|
164
|
+
|
165
|
+
if offset
|
166
|
+
from_offset = offset[:from]
|
167
|
+
|
168
|
+
if from_offset
|
169
|
+
x, y = from_offset[:x], from_offset[:y]
|
160
170
|
|
161
|
-
|
162
|
-
|
171
|
+
from[:x] += x || 0
|
172
|
+
from[:y] += y || 0
|
173
|
+
end
|
174
|
+
|
175
|
+
to_offset = offset[:to]
|
176
|
+
|
177
|
+
if from_offset
|
178
|
+
x, y = to_offset[:x], to_offset[:y]
|
179
|
+
|
180
|
+
to[:x] += x || 0
|
181
|
+
to[:y] += y || 0
|
182
|
+
end
|
183
|
+
end
|
163
184
|
|
164
|
-
|
185
|
+
@automator.pan({coordinates:
|
186
|
+
{from: from,
|
187
|
+
to: to},
|
188
|
+
duration: options[:duration]})
|
165
189
|
|
166
190
|
{
|
167
|
-
:from =>
|
168
|
-
:to =>
|
191
|
+
:from => from_query_result,
|
192
|
+
:to => to_query_result
|
169
193
|
}
|
170
194
|
end
|
171
195
|
|
@@ -178,48 +202,22 @@ module Calabash
|
|
178
202
|
# If the view has a UINavigationBar or UITabBar, the defaults *might*
|
179
203
|
# cause vertical gestures to start and/or end on one of these bars.
|
180
204
|
def _pan(query, from, to, options={})
|
181
|
-
|
182
|
-
begin
|
183
|
-
_expect_valid_duration(options)
|
184
|
-
rescue ArgumentError => e
|
185
|
-
raise ArgumentError, e
|
186
|
-
end
|
187
|
-
|
188
205
|
gesture_waiter = _gesture_waiter
|
189
|
-
view_to_pan = gesture_waiter.wait_for_view(query, options)
|
190
|
-
|
191
|
-
begin
|
192
|
-
check_for_broken_uia_automation(query, view_to_pan, gesture_waiter)
|
193
|
-
rescue => e
|
194
|
-
raise "Could not pan with query: #{query}\n#{e.message}"
|
195
|
-
end
|
206
|
+
view_to_pan = gesture_waiter.wait_for_view(query, timeout: options[:timeout])
|
196
207
|
|
197
208
|
rect = view_to_pan['rect']
|
198
209
|
|
199
210
|
from_x = rect['width'] * (from[:x]/100.0)
|
200
211
|
from_y = rect['height'] * (from[:y]/100.0)
|
201
|
-
from_offset = coordinate(from_x, from_y)
|
202
212
|
|
203
213
|
to_x = rect['width'] * (to[:x]/100.0)
|
204
214
|
to_y = rect['height'] * (to[:y]/100.0)
|
205
|
-
to_offset = coordinate(to_x, to_y)
|
206
215
|
|
207
|
-
|
216
|
+
@automator.pan({coordinates: {from: coordinate(from_x, from_y), to: coordinate(to_x, to_y)},
|
217
|
+
duration: options[:duration]})
|
208
218
|
|
209
|
-
Calabash::QueryResult.create([view_to_pan], query)
|
210
|
-
end
|
211
219
|
|
212
|
-
|
213
|
-
def pan_screen(view_to_pan, from_offset, to_offset, options)
|
214
|
-
begin
|
215
|
-
_expect_valid_duration(options)
|
216
|
-
rescue ArgumentError => e
|
217
|
-
raise ArgumentError, e
|
218
|
-
end
|
219
|
-
|
220
|
-
uia_serialize_and_call(:panOffset, from_offset, to_offset, options)
|
221
|
-
|
222
|
-
Calabash::QueryResult.create([view_to_pan], '*')
|
220
|
+
Calabash::QueryResult.create([view_to_pan], query)
|
223
221
|
end
|
224
222
|
|
225
223
|
# @!visibility private
|
@@ -238,7 +236,7 @@ module Calabash
|
|
238
236
|
end
|
239
237
|
|
240
238
|
gesture_waiter = _gesture_waiter
|
241
|
-
view_to_flick = gesture_waiter.wait_for_view(query, options)
|
239
|
+
view_to_flick = gesture_waiter.wait_for_view(query, timeout: options[:timeout])
|
242
240
|
|
243
241
|
begin
|
244
242
|
check_for_broken_uia_automation(query, view_to_flick, gesture_waiter)
|
@@ -287,7 +285,7 @@ module Calabash
|
|
287
285
|
|
288
286
|
gesture_waiter = _gesture_waiter
|
289
287
|
|
290
|
-
view_to_pinch = gesture_waiter.wait_for_view(query, options)
|
288
|
+
view_to_pinch = gesture_waiter.wait_for_view(query, timeout: options[:timeout])
|
291
289
|
offset = uia_center_of_view(view_to_pinch)
|
292
290
|
|
293
291
|
gesture_direction = direction == :in ? :out : :in
|
@@ -3,6 +3,12 @@ module Calabash
|
|
3
3
|
|
4
4
|
# @!visibility private
|
5
5
|
module KeyboardMixin
|
6
|
+
# Enter `text` into the currently focused view.
|
7
|
+
# @see Calabash::Text#enter_text
|
8
|
+
# @!visibility private
|
9
|
+
def enter_text(text, options={})
|
10
|
+
@automator.enter_text_with_keyboard(text, options)
|
11
|
+
end
|
6
12
|
|
7
13
|
# Returns true if a docked keyboard is visible.
|
8
14
|
#
|
@@ -61,6 +67,21 @@ module Calabash
|
|
61
67
|
docked_keyboard_visible? || undocked_keyboard_visible? || split_keyboard_visible?
|
62
68
|
end
|
63
69
|
|
70
|
+
def tap_keyboard_delete_key(options={})
|
71
|
+
@automator.tap_keyboard_delete_key
|
72
|
+
end
|
73
|
+
|
74
|
+
def tap_keyboard_action_key
|
75
|
+
results = keyboard_waiter.query("* isFirstResponder:1", :returnKeyType)
|
76
|
+
|
77
|
+
if results.empty?
|
78
|
+
RunLoop.log_debug("Cannot find keyboard first responder to ask for its returnKeyType")
|
79
|
+
raise 'Cannot tap_keyboard_action_key. No view has focus'
|
80
|
+
end
|
81
|
+
|
82
|
+
@automator.tap_keyboard_action_key(results.first)
|
83
|
+
end
|
84
|
+
|
64
85
|
# Returns the the text in the first responder.
|
65
86
|
#
|
66
87
|
# The first responder will be the UITextField or UITextView instance
|
@@ -14,55 +14,14 @@ module Calabash
|
|
14
14
|
wait_for_server_to_start({:timeout => 1})
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
current_orientation = status_bar_orientation.to_sym
|
20
|
-
recording_name = nil
|
21
|
-
case direction
|
22
|
-
when :left
|
23
|
-
if current_orientation == :down
|
24
|
-
recording_name = 'left_home_down'
|
25
|
-
elsif current_orientation == :right
|
26
|
-
recording_name = 'left_home_right'
|
27
|
-
elsif current_orientation == :left
|
28
|
-
recording_name = 'left_home_left'
|
29
|
-
elsif current_orientation == :up
|
30
|
-
recording_name = 'left_home_up'
|
31
|
-
end
|
32
|
-
when :right
|
33
|
-
if current_orientation == :down
|
34
|
-
recording_name = 'right_home_down'
|
35
|
-
elsif current_orientation == :left
|
36
|
-
recording_name = 'right_home_left'
|
37
|
-
elsif current_orientation == :right
|
38
|
-
recording_name = 'right_home_right'
|
39
|
-
elsif current_orientation == :up
|
40
|
-
recording_name = 'right_home_up'
|
41
|
-
end
|
42
|
-
else
|
43
|
-
# Caller should have guarded us against this case.
|
44
|
-
raise ArgumentError, "Expected '#{direction}' to be :left or :right"
|
45
|
-
end
|
46
|
-
|
47
|
-
if family == 'iPad'
|
48
|
-
form_factor = 'ipad'
|
49
|
-
else
|
50
|
-
form_factor = 'iphone'
|
51
|
-
end
|
52
|
-
|
53
|
-
if recording_name.nil?
|
54
|
-
raise "Could not rotate device in direction '#{direction}' " \
|
55
|
-
"with orientation '#{current_orientation}'"
|
56
|
-
end
|
17
|
+
orientation = status_bar_orientation.to_sym
|
57
18
|
|
58
|
-
|
59
|
-
playback_route(recording_name, form_factor)
|
19
|
+
@automator.rotate(direction, orientation)
|
60
20
|
end
|
61
21
|
|
62
22
|
# @!visibility private
|
63
23
|
# Caller must pass position one of these positions :down, :left, :right, :up
|
64
24
|
def rotate_home_button_to(position)
|
65
|
-
|
66
25
|
valid_positions = [:down, :left, :right, :up]
|
67
26
|
unless valid_positions.include?(position)
|
68
27
|
raise ArgumentError,
|
@@ -83,28 +42,7 @@ module Calabash
|
|
83
42
|
return orientation
|
84
43
|
end
|
85
44
|
|
86
|
-
|
87
|
-
|
88
|
-
if family == 'iPad'
|
89
|
-
form_factor = 'ipad'
|
90
|
-
else
|
91
|
-
form_factor = 'iphone'
|
92
|
-
end
|
93
|
-
|
94
|
-
ROTATION_CANDIDATES.each do |recording_name|
|
95
|
-
playback_route(recording_name, form_factor)
|
96
|
-
|
97
|
-
# Wait for rotation animation.
|
98
|
-
#
|
99
|
-
# Can't wait for animations because there might be animations other
|
100
|
-
# than rotation on the screen.
|
101
|
-
sleep(0.4)
|
102
|
-
|
103
|
-
orientation = status_bar_orientation.to_sym
|
104
|
-
if orientation == position
|
105
|
-
return orientation.to_s
|
106
|
-
end
|
107
|
-
end
|
45
|
+
@automator.rotate_home_button_to(position, status_bar_orientation)
|
108
46
|
|
109
47
|
orientation.to_s
|
110
48
|
end
|
@@ -3,15 +3,8 @@ module Calabash
|
|
3
3
|
|
4
4
|
# @!visibility private
|
5
5
|
module Gestures
|
6
|
-
|
7
6
|
# @!visibility private
|
8
|
-
|
9
|
-
def _pan_screen_up(options={})
|
10
|
-
|
11
|
-
gesture_options = options.dup
|
12
|
-
gesture_options[:duration] ||= 0.5
|
13
|
-
gesture_options[:timeout] ||= Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT
|
14
|
-
|
7
|
+
define_method (:_swipe_coordinates_for_screen) do
|
15
8
|
points_from_top = gesture_points_from_top
|
16
9
|
points_from_bottom = gesture_points_from_bottom
|
17
10
|
|
@@ -24,108 +17,49 @@ module Calabash
|
|
24
17
|
end_y = points_from_top
|
25
18
|
x = width/2.0
|
26
19
|
|
27
|
-
|
28
|
-
to_offset = coordinate(x, end_y)
|
29
|
-
|
30
|
-
Device.default.pan_screen(top_view, from_offset, to_offset, gesture_options)
|
20
|
+
{bottom: coordinate(x, start_y), top: coordinate(x, end_y)}
|
31
21
|
end
|
32
22
|
|
33
23
|
# @!visibility private
|
34
|
-
# Concrete implementation of
|
35
|
-
|
36
|
-
|
37
|
-
gesture_options = options.
|
38
|
-
gesture_options[:duration] ||= 0.5
|
39
|
-
gesture_options[:timeout] ||= Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT
|
40
|
-
|
41
|
-
points_from_top = gesture_points_from_top
|
42
|
-
points_from_bottom = gesture_points_from_bottom
|
43
|
-
|
44
|
-
top_view = query('*').first
|
45
|
-
|
46
|
-
height = top_view['frame']['height'].to_f
|
47
|
-
width = top_view['frame']['width'].to_f
|
24
|
+
# Concrete implementation of pan_screen_up gesture.
|
25
|
+
define_method (:_pan_screen_up) do |options={}|
|
26
|
+
swipe = _swipe_coordinates_for_screen
|
27
|
+
gesture_options = options.merge({offset: {from: swipe[:bottom], to: swipe[:top]}})
|
48
28
|
|
49
|
-
|
50
|
-
|
51
|
-
x = width/2.0
|
29
|
+
Calabash::Internal.with_default_device(required_os: :ios) {|device| device.pan_between(nil, nil, gesture_options)}
|
30
|
+
end
|
52
31
|
|
53
|
-
|
54
|
-
|
32
|
+
# @!visibility private
|
33
|
+
# Concrete implementation of pan_screen_down gesture.
|
34
|
+
define_method (:_pan_screen_down) do |options={}|
|
35
|
+
swipe = _swipe_coordinates_for_screen
|
36
|
+
gesture_options = options.merge({offset: {from: swipe[:top], to: swipe[:bottom]}})
|
55
37
|
|
56
|
-
|
38
|
+
Calabash::Internal.with_default_device(required_os: :ios) {|device| device.pan_between(nil, nil, gesture_options)}
|
57
39
|
end
|
58
40
|
|
59
41
|
# @!visibility private
|
60
42
|
# Concrete implementation of flick_screen_up gesture.
|
61
|
-
|
62
|
-
|
63
|
-
gesture_options = options.
|
64
|
-
gesture_options[:duration] ||= 0.5
|
65
|
-
gesture_options[:timeout] ||= Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT
|
66
|
-
|
67
|
-
points_from_top = gesture_points_from_top
|
68
|
-
points_from_bottom = gesture_points_from_bottom
|
69
|
-
|
70
|
-
top_view = query('*').first
|
43
|
+
define_method (:_flick_screen_up) do |options={}|
|
44
|
+
swipe = _swipe_coordinates_for_screen
|
45
|
+
gesture_options = options.merge({offset: {from: swipe[:bottom], to: swipe[:top]}})
|
71
46
|
|
72
|
-
|
73
|
-
width = top_view['frame']['width'].to_f
|
74
|
-
|
75
|
-
start_y = height - points_from_bottom
|
76
|
-
end_y = points_from_top
|
77
|
-
x = width/2.0
|
78
|
-
|
79
|
-
from_offset = coordinate(x, start_y)
|
80
|
-
to_offset = coordinate(x, end_y)
|
81
|
-
|
82
|
-
Device.default.flick_screen(top_view, from_offset, to_offset, gesture_options)
|
47
|
+
Calabash::Internal.with_default_device(required_os: :ios) {|device| device.flick_between(nil, nil, gesture_options)}
|
83
48
|
end
|
84
49
|
|
85
50
|
# @!visibility private
|
86
51
|
# Concrete implementation of flick_screen_down gesture.
|
87
|
-
|
88
|
-
|
89
|
-
gesture_options = options.
|
90
|
-
gesture_options[:duration] ||= 0.5
|
91
|
-
gesture_options[:timeout] ||= Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT
|
92
|
-
|
93
|
-
points_from_top = gesture_points_from_top
|
94
|
-
points_from_bottom = gesture_points_from_bottom
|
95
|
-
|
96
|
-
top_view = query('*').first
|
97
|
-
|
98
|
-
height = top_view['frame']['height'].to_f
|
99
|
-
width = top_view['frame']['width'].to_f
|
100
|
-
|
101
|
-
start_y = points_from_top
|
102
|
-
end_y = height - points_from_bottom
|
103
|
-
x = width/2.0
|
104
|
-
|
105
|
-
from_offset = coordinate(x, start_y)
|
106
|
-
to_offset = coordinate(x, end_y)
|
52
|
+
define_method (:_flick_screen_down) do |options={}|
|
53
|
+
swipe = _swipe_coordinates_for_screen
|
54
|
+
gesture_options = options.merge({offset: {from: swipe[:top], to: swipe[:bottom]}})
|
107
55
|
|
108
|
-
|
56
|
+
Calabash::Internal.with_default_device(required_os: :ios) {|device| device.flick_between(nil, nil, gesture_options)}
|
109
57
|
end
|
110
58
|
|
111
59
|
# @!visibility private
|
112
60
|
# Concrete implementation of pinch_screen
|
113
|
-
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
# @!visibility private
|
118
|
-
# Concrete implementation of pinch_to_zoom
|
119
|
-
def _pinch_to_zoom(direction, query, options={})
|
120
|
-
gesture_direction = direction == :in ? :out : :in
|
121
|
-
Device.default.pinch(gesture_direction, query, options)
|
122
|
-
end
|
123
|
-
|
124
|
-
# @!visibility private
|
125
|
-
# Concrete implementation of pinch_screen_to_zoom
|
126
|
-
def _pinch_screen_to_zoom(direction, options={})
|
127
|
-
gesture_direction = direction == :in ? :out : :in
|
128
|
-
Device.default.pinch(gesture_direction, '*', options)
|
61
|
+
define_method (:_pinch_screen) do |direction, options={}|
|
62
|
+
Calabash::Internal.with_default_device(required_os: :ios) {|device| device.pinch(direction, '*', options)}
|
129
63
|
end
|
130
64
|
|
131
65
|
private
|