Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear existing actions/parameters after perform is invoked #663

Merged
merged 1 commit into from
Jun 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/java/io/appium/java_client/MultiTouchAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,14 @@ protected ImmutableMap<String, ImmutableList<Object>> getParameters() {
});
return ImmutableMap.of("actions", listOfActionChains.build());
}

/**
* Clears all the existing touch actions and resets the instance to the initial state.
*
* @return this MultiTouchAction, for possible segmented-touches.
*/
protected MultiTouchAction clearActions() {
actions = ImmutableList.builder();
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public interface PerformsTouchActions extends ExecutesMethod {
* https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html
* It's more convenient to call the perform() method of the TouchAction
* object itself.
* All the existing touch action parameters will be wiped out after this method
* is called.
*
* @param touchAction A TouchAction object, which contains a list of individual
* touch actions to perform
Expand All @@ -37,7 +39,7 @@ public interface PerformsTouchActions extends ExecutesMethod {
default TouchAction performTouchAction(TouchAction touchAction) {
ImmutableMap<String, ImmutableList<Object>> parameters = touchAction.getParameters();
execute(PERFORM_TOUCH_ACTION, parameters);
return touchAction;
return touchAction.clearParameters();
}

/**
Expand All @@ -46,11 +48,14 @@ default TouchAction performTouchAction(TouchAction touchAction) {
* https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html
* It's more convenient to call the perform() method of the MultiTouchAction
* object.
* All the existing multi touch actions will be wiped out after this method
* is called.
*
* @param multiAction the MultiTouchAction object to perform.
*/
default void performMultiTouchAction(MultiTouchAction multiAction) {
ImmutableMap<String, ImmutableList<Object>> parameters = multiAction.getParameters();
execute(PERFORM_MULTI_TOUCH, parameters);
multiAction.clearActions();
}
}
8 changes: 7 additions & 1 deletion src/main/java/io/appium/java_client/TouchAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,14 @@ protected ImmutableMap<String, ImmutableList<Object>> getParameters() {
return ImmutableMap.of("actions", parameters.build());
}

protected void clearParameters() {
/**
* Clears all the existing action parameters and resets the instance to the initial state.
*
* @return this TouchAction, for possible segmented-touches.
*/
protected TouchAction clearParameters() {
parameterBuilder = ImmutableList.builder();
return this;
}

/**
Expand Down