calabash 2.0.0.pre11 → 2.0.0.prelegacy
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 +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
@@ -3,8 +3,15 @@ module Calabash
|
|
3
3
|
|
4
4
|
# @!visibility private
|
5
5
|
module Gestures
|
6
|
+
|
6
7
|
# @!visibility private
|
7
|
-
|
8
|
+
# Concrete implementation of pan_screen_up gesture.
|
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
|
+
|
8
15
|
points_from_top = gesture_points_from_top
|
9
16
|
points_from_bottom = gesture_points_from_bottom
|
10
17
|
|
@@ -17,49 +24,108 @@ module Calabash
|
|
17
24
|
end_y = points_from_top
|
18
25
|
x = width/2.0
|
19
26
|
|
20
|
-
|
21
|
-
|
27
|
+
from_offset = coordinate(x, start_y)
|
28
|
+
to_offset = coordinate(x, end_y)
|
22
29
|
|
23
|
-
|
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]}})
|
28
|
-
|
29
|
-
Calabash::Internal.with_default_device(required_os: :ios) {|device| device.pan_between(nil, nil, gesture_options)}
|
30
|
+
Device.default.pan_screen(top_view, from_offset, to_offset, gesture_options)
|
30
31
|
end
|
31
32
|
|
32
33
|
# @!visibility private
|
33
34
|
# Concrete implementation of pan_screen_down gesture.
|
34
|
-
|
35
|
-
|
36
|
-
gesture_options = options.
|
35
|
+
def _pan_screen_down(options={})
|
36
|
+
|
37
|
+
gesture_options = options.dup
|
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
|
48
|
+
|
49
|
+
start_y = points_from_top
|
50
|
+
end_y = height - points_from_bottom
|
51
|
+
x = width/2.0
|
52
|
+
|
53
|
+
from_offset = coordinate(x, start_y)
|
54
|
+
to_offset = coordinate(x, end_y)
|
37
55
|
|
38
|
-
|
56
|
+
Device.default.pan_screen(top_view, from_offset, to_offset, gesture_options)
|
39
57
|
end
|
40
58
|
|
41
59
|
# @!visibility private
|
42
60
|
# Concrete implementation of flick_screen_up gesture.
|
43
|
-
|
44
|
-
|
45
|
-
gesture_options = options.
|
61
|
+
def _flick_screen_up(options={})
|
62
|
+
|
63
|
+
gesture_options = options.dup
|
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
|
46
71
|
|
47
|
-
|
72
|
+
height = top_view['frame']['height'].to_f
|
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)
|
48
83
|
end
|
49
84
|
|
50
85
|
# @!visibility private
|
51
86
|
# Concrete implementation of flick_screen_down gesture.
|
52
|
-
|
53
|
-
|
54
|
-
gesture_options = options.
|
87
|
+
def _flick_screen_down(options={})
|
88
|
+
|
89
|
+
gesture_options = options.dup
|
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)
|
55
107
|
|
56
|
-
|
108
|
+
Device.default.flick_screen(top_view, from_offset, to_offset, gesture_options)
|
57
109
|
end
|
58
110
|
|
59
111
|
# @!visibility private
|
60
112
|
# Concrete implementation of pinch_screen
|
61
|
-
|
62
|
-
|
113
|
+
def _pinch_screen(direction, options={})
|
114
|
+
Device.default.pinch(direction, '*', options)
|
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)
|
63
129
|
end
|
64
130
|
|
65
131
|
private
|
@@ -13,7 +13,7 @@ module Calabash
|
|
13
13
|
# in the background
|
14
14
|
# @raise [ArgumentError] If number of seconds is less than 1 and more
|
15
15
|
# than 60 seconds.
|
16
|
-
|
16
|
+
def _send_current_app_to_background(seconds)
|
17
17
|
unless (1..60).member?(seconds)
|
18
18
|
raise ArgumentError,
|
19
19
|
"Number of seconds: '#{seconds}' must be between 1 and 60"
|
@@ -30,6 +30,11 @@ module Calabash
|
|
30
30
|
)
|
31
31
|
uia(javascript)
|
32
32
|
end
|
33
|
+
|
34
|
+
# @!visibility private
|
35
|
+
def _evaluate_javascript_in(query, javascript)
|
36
|
+
query(query, calabashStringByEvaluatingJavaScript: javascript)
|
37
|
+
end
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
data/lib/calabash/ios/lib/.irbrc
CHANGED
@@ -37,17 +37,10 @@ rescue LoadError => e
|
|
37
37
|
end
|
38
38
|
|
39
39
|
begin
|
40
|
-
require 'calabash/ios'
|
41
|
-
|
42
|
-
IRB.conf[:PROMPT][:CALABASH] = {
|
43
|
-
:PROMPT_I => "calabash #{Calabash::VERSION}> ",
|
44
|
-
:PROMPT_S => "%03n> ",
|
45
|
-
:PROMPT_C => "%03n> ",
|
46
|
-
:RETURN => "%s\n"
|
47
|
-
}
|
48
40
|
|
49
|
-
|
41
|
+
require 'calabash/ios'
|
50
42
|
|
43
|
+
extend Calabash::IOS
|
51
44
|
extend Calabash::ConsoleHelpers
|
52
45
|
|
53
46
|
Calabash::IOS.setup_defaults!
|
@@ -13,7 +13,7 @@ module Calabash
|
|
13
13
|
# @return [String] Returns the device orientation as one of
|
14
14
|
# `{'down' | 'up' | 'left' | 'right'}`.
|
15
15
|
def status_bar_orientation
|
16
|
-
|
16
|
+
Device.default.status_bar_orientation
|
17
17
|
end
|
18
18
|
|
19
19
|
# Rotate the device left - clockwise relative to the home button.
|
@@ -26,7 +26,7 @@ module Calabash
|
|
26
26
|
# @return [String] The position of the home button relative to the status
|
27
27
|
# bar after the rotation. Can be one of 'down', 'left', 'right', 'up'.
|
28
28
|
def rotate_device_left
|
29
|
-
|
29
|
+
Device.default.rotate(:left)
|
30
30
|
status_bar_orientation
|
31
31
|
end
|
32
32
|
|
@@ -40,7 +40,7 @@ module Calabash
|
|
40
40
|
# @return [String] The position of the home button relative to the status
|
41
41
|
# bar after the rotation. Can be one of 'down', 'left', 'right', 'up'.
|
42
42
|
def rotate_device_right
|
43
|
-
|
43
|
+
Device.default.rotate(:right)
|
44
44
|
status_bar_orientation
|
45
45
|
end
|
46
46
|
|
@@ -83,11 +83,11 @@ module Calabash
|
|
83
83
|
canonical_position = :down if position.to_sym == :bottom
|
84
84
|
canonical_position = :up if position.to_sym == :top
|
85
85
|
|
86
|
-
Calabash::
|
86
|
+
Calabash::Device.default.rotate_home_button_to(canonical_position)
|
87
87
|
end
|
88
88
|
|
89
89
|
# @!visibility private
|
90
|
-
|
90
|
+
def _set_orientation_landscape
|
91
91
|
orientation = status_bar_orientation
|
92
92
|
return orientation if landscape?
|
93
93
|
|
@@ -95,7 +95,7 @@ module Calabash
|
|
95
95
|
end
|
96
96
|
|
97
97
|
# @!visibility private
|
98
|
-
|
98
|
+
def _set_orientation_portrait
|
99
99
|
orientation = status_bar_orientation
|
100
100
|
return orientation if portrait?
|
101
101
|
|
@@ -103,13 +103,13 @@ module Calabash
|
|
103
103
|
end
|
104
104
|
|
105
105
|
# @!visibility private
|
106
|
-
|
106
|
+
def _portrait?
|
107
107
|
orientation = status_bar_orientation
|
108
108
|
orientation.eql?('up') || orientation.eql?('down')
|
109
109
|
end
|
110
110
|
|
111
111
|
# @!visibility private
|
112
|
-
|
112
|
+
def _landscape?
|
113
113
|
orientation = status_bar_orientation
|
114
114
|
orientation.eql?('right') || orientation.eql?('left')
|
115
115
|
end
|
data/lib/calabash/ios/runtime.rb
CHANGED
@@ -11,27 +11,27 @@ module Calabash
|
|
11
11
|
|
12
12
|
# Is the device under test a simulator?
|
13
13
|
def simulator?
|
14
|
-
Calabash::
|
14
|
+
Calabash::IOS::Device.default.simulator?
|
15
15
|
end
|
16
16
|
|
17
17
|
# Is the device under test a physical device?
|
18
18
|
def physical_device?
|
19
|
-
Calabash::
|
19
|
+
Calabash::IOS::Device.default.physical_device?
|
20
20
|
end
|
21
21
|
|
22
22
|
# Is the device under test an iPad?
|
23
23
|
def ipad?
|
24
|
-
Calabash::
|
24
|
+
Calabash::IOS::Device.default.device_family == 'iPad'
|
25
25
|
end
|
26
26
|
|
27
27
|
# Is the device under test an iPhone?
|
28
28
|
def iphone?
|
29
|
-
Calabash::
|
29
|
+
Calabash::IOS::Device.default.device_family == 'iPhone'
|
30
30
|
end
|
31
31
|
|
32
32
|
# Is the device under test an iPod?
|
33
33
|
def ipod?
|
34
|
-
Calabash::
|
34
|
+
Calabash::IOS::Device.default.device_family == 'iPod'
|
35
35
|
end
|
36
36
|
|
37
37
|
# Is the device under test an iPhone or iPod?
|
@@ -44,22 +44,22 @@ module Calabash
|
|
44
44
|
# An iPhone only app running on an iPad will be displayed in an emulated
|
45
45
|
# mode. Starting in iOS 7, such apps will always be launched in 2x mode.
|
46
46
|
def iphone_app_emulated_on_ipad?
|
47
|
-
Calabash::
|
47
|
+
Calabash::IOS::Device.default.iphone_app_emulated_on_ipad?
|
48
48
|
end
|
49
49
|
|
50
50
|
# Is the device under test have a 4 inch screen?
|
51
51
|
def iphone_4in?
|
52
|
-
Calabash::
|
52
|
+
Calabash::IOS::Device.default.form_factor == 'iphone 4in'
|
53
53
|
end
|
54
54
|
|
55
55
|
# Is the device under test an iPhone 6.
|
56
56
|
def iphone_6?
|
57
|
-
Calabash::
|
57
|
+
Calabash::IOS::Device.default.form_factor == 'iphone 6'
|
58
58
|
end
|
59
59
|
|
60
60
|
# Is the device under test an iPhone 6+?
|
61
61
|
def iphone_6_plus?
|
62
|
-
Calabash::
|
62
|
+
Calabash::IOS::Device.default.form_factor == 'iphone 6 +'
|
63
63
|
end
|
64
64
|
|
65
65
|
# Is the device under test an iPhone 3.5in?
|
@@ -72,7 +72,7 @@ module Calabash
|
|
72
72
|
# @see #iphone_app_emulated_on_ipad?
|
73
73
|
# @see #ipad?
|
74
74
|
def iphone_35in?
|
75
|
-
Calabash::
|
75
|
+
Calabash::IOS::Device.default.form_factor == 'iphone 3.5in'
|
76
76
|
end
|
77
77
|
|
78
78
|
# The screen dimensions and details about scale and sample rates.
|
@@ -88,7 +88,7 @@ module Calabash
|
|
88
88
|
#
|
89
89
|
# @return [Hash] See the example.
|
90
90
|
def app_screen_details
|
91
|
-
Calabash::
|
91
|
+
Calabash::IOS::Device.default.screen_dimensions
|
92
92
|
end
|
93
93
|
|
94
94
|
# The version of iOS running on the test device.
|
@@ -100,7 +100,7 @@ module Calabash
|
|
100
100
|
#
|
101
101
|
# @return [RunLoop::Version] A version object.
|
102
102
|
def ios_version
|
103
|
-
Calabash::
|
103
|
+
Calabash::IOS::Device.default.ios_version
|
104
104
|
end
|
105
105
|
|
106
106
|
# Is the device under test running iOS 6?
|
@@ -132,7 +132,7 @@ module Calabash
|
|
132
132
|
#
|
133
133
|
# @return [RunLoop::Version] A version object.
|
134
134
|
def server_version
|
135
|
-
Calabash::
|
135
|
+
Calabash::IOS::Device.default.server_version
|
136
136
|
end
|
137
137
|
|
138
138
|
# Details about the version of the app under test.
|
@@ -161,7 +161,7 @@ module Calabash
|
|
161
161
|
# the methods in the {Calabash::IOS::Runtime} module instead.
|
162
162
|
# @return[Hash] Key/value pairs that describe the runtime environment.
|
163
163
|
def runtime_details
|
164
|
-
Calabash::
|
164
|
+
Calabash::IOS::Device.default.runtime_details
|
165
165
|
end
|
166
166
|
end
|
167
167
|
end
|
data/lib/calabash/ios/scroll.rb
CHANGED
@@ -71,7 +71,7 @@ module Calabash
|
|
71
71
|
raise RuntimeError, e
|
72
72
|
end
|
73
73
|
|
74
|
-
results =
|
74
|
+
results = Device.default.map_route(query, :scroll, direction)
|
75
75
|
|
76
76
|
if results.first.nil?
|
77
77
|
fail("Expected '#{query}' to match a UIScrollView or a subclass")
|
@@ -153,10 +153,8 @@ module Calabash
|
|
153
153
|
position = merged_options[:scroll_position].to_sym
|
154
154
|
animate = merged_options[:animate]
|
155
155
|
|
156
|
-
results =
|
157
|
-
|
158
|
-
section.to_i, position, animate)
|
159
|
-
end
|
156
|
+
results = Device.default.map_route(query, :scrollToRow, row.to_i,
|
157
|
+
section.to_i, position, animate)
|
160
158
|
|
161
159
|
if results.first.nil?
|
162
160
|
message = [
|
@@ -242,10 +240,8 @@ module Calabash
|
|
242
240
|
position = merged_options[:scroll_position].to_sym
|
243
241
|
animate = merged_options[:animate]
|
244
242
|
|
245
|
-
results =
|
246
|
-
|
247
|
-
position, animate)
|
248
|
-
end
|
243
|
+
results = Device.default.map_route(query, :scrollToRowWithMark, mark,
|
244
|
+
position, animate)
|
249
245
|
|
250
246
|
if results.first.nil?
|
251
247
|
message = [
|
@@ -338,12 +334,9 @@ module Calabash
|
|
338
334
|
position = merged_options[:scroll_position].to_sym
|
339
335
|
animate = merged_options[:animate]
|
340
336
|
|
341
|
-
results =
|
342
|
-
|
343
|
-
|
344
|
-
position, animate)
|
345
|
-
end
|
346
|
-
|
337
|
+
results = Device.default.map_route(query, :collectionViewScroll,
|
338
|
+
item.to_i, section.to_i,
|
339
|
+
position, animate)
|
347
340
|
if results.first.nil?
|
348
341
|
message = [
|
349
342
|
"Could not scroll collection to item '#{item}' and section '#{section}'.",
|
@@ -434,11 +427,9 @@ module Calabash
|
|
434
427
|
position = merged_options[:scroll_position].to_sym
|
435
428
|
animate = merged_options[:animate]
|
436
429
|
|
437
|
-
results =
|
438
|
-
|
439
|
-
|
440
|
-
mark, position, animate)
|
441
|
-
end
|
430
|
+
results = Device.default.map_route(query,
|
431
|
+
:collectionViewScrollToItemWithMark,
|
432
|
+
mark, position, animate)
|
442
433
|
|
443
434
|
if results.first.nil?
|
444
435
|
message = [
|
@@ -464,7 +455,8 @@ module Calabash
|
|
464
455
|
:left, :center_horizontal, :right]
|
465
456
|
|
466
457
|
# @!visibility private
|
467
|
-
|
458
|
+
def _wait_for_exactly_one_scroll_view(query)
|
459
|
+
|
468
460
|
results = []
|
469
461
|
|
470
462
|
found_none = "Expected '#{query}' to match exactly one view, but found no matches."
|
@@ -485,7 +477,7 @@ module Calabash
|
|
485
477
|
end
|
486
478
|
|
487
479
|
# @!visibility private
|
488
|
-
|
480
|
+
def _expect_valid_scroll_positions(valid_positions, position)
|
489
481
|
unless valid_positions.include?(position.to_sym)
|
490
482
|
raise ArgumentError,
|
491
483
|
"Expected '#{position}' to be one of #{valid_positions.join(', ')}"
|
@@ -493,7 +485,7 @@ module Calabash
|
|
493
485
|
end
|
494
486
|
|
495
487
|
# @!visibility private
|
496
|
-
|
488
|
+
def _expect_valid_scroll_animate(animate)
|
497
489
|
unless [true, false].include?(animate)
|
498
490
|
raise ArgumentError,
|
499
491
|
"Expected '#{animate}' to be a Boolean true or false"
|
@@ -501,13 +493,13 @@ module Calabash
|
|
501
493
|
end
|
502
494
|
|
503
495
|
# @!visibility private
|
504
|
-
|
496
|
+
def _expect_valid_scroll_options(valid_positions, options)
|
505
497
|
_expect_valid_scroll_positions(valid_positions, options[:scroll_position])
|
506
498
|
_expect_valid_scroll_animate(options[:animate])
|
507
499
|
end
|
508
500
|
|
509
501
|
# @!visibility private
|
510
|
-
|
502
|
+
def _expect_valid_scroll_mark(mark)
|
511
503
|
if mark.nil? || mark == ''
|
512
504
|
raise ArgumentError,
|
513
505
|
if mark.nil?
|
data/lib/calabash/ios/slider.rb
CHANGED
@@ -16,25 +16,34 @@ module Calabash
|
|
16
16
|
# * Use the index language feature: "UISlider index:0"
|
17
17
|
#
|
18
18
|
# @example
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
19
|
+
# slider_set_value("UISlider marked:'office slider'", 2)
|
20
|
+
# slider_set_value("slider marked:'weather slider'", -1)
|
21
|
+
# slider_set_value("UISlider", 11)
|
22
22
|
#
|
23
23
|
# @param [String, Hash, Calabash::Query] query A query to that indicates
|
24
24
|
# in which slider to set the value.
|
25
25
|
# @param [Numeric] value The value to set the slider to. value.to_s should
|
26
26
|
# produce a String representation of a Number.
|
27
|
-
#
|
28
|
-
# @param [
|
27
|
+
#
|
28
|
+
# @param [options] options Options to control the behavior of the gesture.
|
29
|
+
# @option options [Boolean] :animate (true) Animate the change.
|
30
|
+
# @option options [Boolean] :notify_targets (true) Simulate a UIEvent by
|
29
31
|
# calling every target/action pair defined on the UISlider matching
|
30
32
|
# `query`.
|
31
33
|
#
|
32
34
|
# @raise [RuntimeError] When `query` does not match exactly one slider.
|
33
35
|
# @raise [RuntimeError] When setting the value of the slider matched by
|
34
36
|
# `query` is not successful.
|
35
|
-
def slider_set_value(query, value,
|
37
|
+
def slider_set_value(query, value, options={})
|
36
38
|
Query.ensure_valid_query(query)
|
37
39
|
|
40
|
+
default_options = {
|
41
|
+
:animate => true,
|
42
|
+
:notify_targets => true
|
43
|
+
}
|
44
|
+
|
45
|
+
merged_options = default_options.merge(options)
|
46
|
+
|
38
47
|
found_none = "Expected '#{query}' to match exactly one view, but found no matches."
|
39
48
|
query_object = Query.new(query)
|
40
49
|
wait_for(found_none) do
|
@@ -44,7 +53,7 @@ module Calabash
|
|
44
53
|
"Expected '#{query}' to match exactly one view, but found '#{results.length}'",
|
45
54
|
results.join("\n")
|
46
55
|
].join("\n")
|
47
|
-
|
56
|
+
fail(message)
|
48
57
|
else
|
49
58
|
results.length == 1
|
50
59
|
end
|
@@ -52,11 +61,9 @@ module Calabash
|
|
52
61
|
|
53
62
|
value_str = value.to_s
|
54
63
|
|
55
|
-
args = [animate, notify_targets]
|
64
|
+
args = [merged_options[:animate], merged_options[:notify_targets]]
|
56
65
|
|
57
|
-
|
58
|
-
device.map_route(query, :changeSlider, value_str, *args)
|
59
|
-
end
|
66
|
+
Device.default.map_route(query, :changeSlider, value_str, *args)
|
60
67
|
end
|
61
68
|
end
|
62
69
|
end
|