Skip to content

Commit 2a9f79c

Browse files
montdidierbootstraponline
authored andcommitted
swipe proffers use of delta_x, delta_y instead of end_x, end_y which … (#380)
* swipe proffers use of delta_x, delta_y instead of end_x, end_y which are marked as deprecated * stylistic compliance
1 parent 6705226 commit 2a9f79c

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

lib/appium_lib/common/version.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Appium
22
# Version and Date are defined on the 'Appium' module, not 'Appium::Common'
3-
VERSION = '8.0.2' unless defined? ::Appium::VERSION
4-
DATE = '2016-01-29' unless defined? ::Appium::DATE
3+
VERSION = '8.0.3' unless defined? ::Appium::VERSION
4+
DATE = '2016-10-12' unless defined? ::Appium::DATE
55
end

lib/appium_lib/device/touch_actions.rb

+19-5
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,33 @@ def wait(milliseconds)
120120
#
121121
# @option opts [int] :start_x Where to start swiping, on the x axis. Default 0.
122122
# @option opts [int] :start_y Where to start swiping, on the y axis. Default 0.
123-
# @option opts [int] :end_x Where to end swiping, on the x axis. Default 0.
124-
# @option opts [int] :end_y Where to end swiping, on the y axis. Default 0.
123+
# @option opts [int] :delta_x The distance from start to move, on the x axis. Default 0.
124+
# @option opts [int] :delta_y The distance from start to move, on the y axis. Default 0.
125125
# @option opts [int] :duration How long the actual swipe takes to complete in milliseconds. Default 200.
126+
# @deprecated Please do not use end_x, end_y anymore
126127
def swipe(opts)
127128
start_x = opts.fetch :start_x, 0
128129
start_y = opts.fetch :start_y, 0
129-
end_x = opts.fetch :end_x, 0
130-
end_y = opts.fetch :end_y, 0
130+
delta_x = opts.fetch :delta_x, nil
131+
delta_y = opts.fetch :delta_y, nil
132+
end_x = opts.fetch :end_x, nil
133+
end_y = opts.fetch :end_y, nil
134+
135+
if end_x || end_y
136+
warn '[DEPRECATION] `end_x` and `end_y` are deprecated. Please use `delta_x` and `delta_y` instead.'
137+
end
138+
139+
delta_x ||= end_x
140+
delta_y ||= end_y
141+
142+
delta_x ||= 0
143+
delta_y ||= 0
144+
131145
duration = opts.fetch :duration, 200
132146

133147
press x: start_x, y: start_y
134148
wait(duration) if duration
135-
move_to x: end_x, y: end_y
149+
move_to x: delta_x, y: delta_y
136150
release
137151
self
138152
end

0 commit comments

Comments
 (0)