Skip to content

Commit e76d217

Browse files
Merge pull request #795 from mykola-mokhnach/less_strict_verification
Less strict verification
2 parents b238538 + a2d8410 commit e76d217

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/main/java/io/appium/java_client/TouchAction.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ public T release() {
125125
* Moves current touch to a new position.
126126
*
127127
* @param moveToOptions see {@link PointOption} and {@link ElementOption}
128+
* Important: some older Appium drivers releases have a bug when moveTo
129+
* coordinates are calculated as relative to the recent pointer position
130+
* in the chain instead of being absolute.
131+
* @see <a href="https://github.com/appium/appium/issues/7486">Appium Issue #7486</a>
132+
* for more details.
128133
* @return this TouchAction, for chaining.
129134
*/
130135
public T moveTo(PointOption moveToOptions) {

src/main/java/io/appium/java_client/touch/offset/PointOption.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package io.appium.java_client.touch.offset;
22

3-
import static com.google.common.base.Preconditions.checkArgument;
4-
import static java.lang.String.format;
53
import static java.util.Optional.ofNullable;
64

75
import io.appium.java_client.touch.ActionOptions;
@@ -13,8 +11,6 @@ public class PointOption<T extends PointOption<T>> extends ActionOptions<T> {
1311

1412
protected Point coordinates;
1513

16-
private static final String ERROR_MESSAGE_TEMPLATE = "%s coordinate value should be equal or greater than zero";
17-
1814
/**
1915
* It creates a built instance of {@link PointOption} which takes x and y coordinates.
2016
* This is offset from the upper left corner of the screen.
@@ -36,14 +32,14 @@ public static PointOption point(int xOffset, int yOffset) {
3632
* @return self-reference
3733
*/
3834
public T withCoordinates(int xOffset, int yOffset) {
39-
checkArgument(xOffset >= 0, format(ERROR_MESSAGE_TEMPLATE, "X"));
40-
checkArgument(yOffset >= 0, format(ERROR_MESSAGE_TEMPLATE, "Y"));
4135
coordinates = new Point(xOffset, yOffset);
36+
//noinspection unchecked
4237
return (T) this;
4338
}
4439

4540
@Override
4641
protected void verify() {
42+
//noinspection ResultOfMethodCallIgnored
4743
ofNullable(coordinates).orElseThrow(() -> new IllegalArgumentException(
4844
"Coordinate values must be defined"));
4945
}

src/test/java/io/appium/java_client/touch/TouchOptionsTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ public void invalidOptionsArgumentsShouldFailOnAltering() throws Exception {
4444
final List<Runnable> invalidOptions = new ArrayList<>();
4545
invalidOptions.add(() -> waitOptions(ofMillis(-1)));
4646
invalidOptions.add(() -> new ElementOption().withCoordinates(0, 0).withElement(null));
47-
invalidOptions.add(() -> new PointOption().withCoordinates(0, -1));
48-
invalidOptions.add(() -> new PointOption().withCoordinates(-1, 0));
4947
invalidOptions.add(() -> new WaitOptions().withDuration(null));
5048
invalidOptions.add(() -> tapOptions().withTapsCount(-1));
5149
invalidOptions.add(() -> longPressOptions().withDuration(null));

0 commit comments

Comments
 (0)