Skip to content

Commit

Permalink
Merge pull request #795 from mykola-mokhnach/less_strict_verification
Browse files Browse the repository at this point in the history
Less strict verification
  • Loading branch information
TikhomirovSergey committed Dec 22, 2017
2 parents b238538 + a2d8410 commit e76d217
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/main/java/io/appium/java_client/TouchAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public T release() {
* Moves current touch to a new position.
*
* @param moveToOptions see {@link PointOption} and {@link ElementOption}
* Important: some older Appium drivers releases have a bug when moveTo
* coordinates are calculated as relative to the recent pointer position
* in the chain instead of being absolute.
* @see <a href="https://github.com/appium/appium/issues/7486">Appium Issue #7486</a>
* for more details.
* @return this TouchAction, for chaining.
*/
public T moveTo(PointOption moveToOptions) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.appium.java_client.touch.offset;

import static com.google.common.base.Preconditions.checkArgument;
import static java.lang.String.format;
import static java.util.Optional.ofNullable;

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

protected Point coordinates;

private static final String ERROR_MESSAGE_TEMPLATE = "%s coordinate value should be equal or greater than zero";

/**
* It creates a built instance of {@link PointOption} which takes x and y coordinates.
* This is offset from the upper left corner of the screen.
Expand All @@ -36,14 +32,14 @@ public static PointOption point(int xOffset, int yOffset) {
* @return self-reference
*/
public T withCoordinates(int xOffset, int yOffset) {
checkArgument(xOffset >= 0, format(ERROR_MESSAGE_TEMPLATE, "X"));
checkArgument(yOffset >= 0, format(ERROR_MESSAGE_TEMPLATE, "Y"));
coordinates = new Point(xOffset, yOffset);
//noinspection unchecked
return (T) this;
}

@Override
protected void verify() {
//noinspection ResultOfMethodCallIgnored
ofNullable(coordinates).orElseThrow(() -> new IllegalArgumentException(
"Coordinate values must be defined"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ public void invalidOptionsArgumentsShouldFailOnAltering() throws Exception {
final List<Runnable> invalidOptions = new ArrayList<>();
invalidOptions.add(() -> waitOptions(ofMillis(-1)));
invalidOptions.add(() -> new ElementOption().withCoordinates(0, 0).withElement(null));
invalidOptions.add(() -> new PointOption().withCoordinates(0, -1));
invalidOptions.add(() -> new PointOption().withCoordinates(-1, 0));
invalidOptions.add(() -> new WaitOptions().withDuration(null));
invalidOptions.add(() -> tapOptions().withTapsCount(-1));
invalidOptions.add(() -> longPressOptions().withDuration(null));
Expand Down

0 comments on commit e76d217

Please sign in to comment.