提交 50557a4d 编写于 作者: S Sergey Tikhomirov

#102 FIX

上级 c60cadcb
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.appium.java_client;
public class MissingParameterException
extends IllegalArgumentException {
private static final long serialVersionUID = 1L;
public MissingParameterException(String reason) {
super(reason);
}
public MissingParameterException(String reason, Throwable cause) {
super(reason, cause);
}
}
......@@ -16,10 +16,13 @@
package io.appium.java_client;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.List;
/**
* Used for Webdriver 3 multi-touch gestures
* See the Webriver 3 spec https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html
......@@ -62,16 +65,14 @@ public class MultiTouchAction implements PerformsActions<MultiTouchAction> {
* Perform the multi-touch action on the mobile performsTouchActions.
*/
public MultiTouchAction perform() {
int size = actions.build().size();
if (size > 1) {
List<TouchAction> touchActions = actions.build();
checkArgument(touchActions.size() > 0,
"MultiTouch action must have at least one TouchAction added before it can be performed");
if (touchActions.size() > 1) {
performsTouchActions.performMultiTouchAction(this);
} else if (size == 1) {
} else {
//android doesn't like having multi-touch actions with only a single TouchAction...
performsTouchActions.performTouchAction(actions.build().get(0));
} else {
throw new MissingParameterException(
"MultiTouch action must have at least one TouchAction "
+ "added before it can be performed");
}
return this;
}
......@@ -80,9 +81,8 @@ public class MultiTouchAction implements PerformsActions<MultiTouchAction> {
ImmutableList.Builder<Object> listOfActionChains = ImmutableList.builder();
ImmutableList<TouchAction> touchActions = actions.build();
touchActions.forEach(action -> {
listOfActionChains.add(action.getParameters().get("actions"));
});
touchActions.forEach(action ->
listOfActionChains.add(action.getParameters().get("actions")));
return ImmutableMap.of("actions", listOfActionChains.build());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册