forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
java: Setting background for executing action chains "all at once" (i…
…nstead of the current "one by one" implementation).
- Loading branch information
Showing
4 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
java/client/src/org/openqa/selenium/interactions/ActionChainExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. 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 org.openqa.selenium.interactions; | ||
|
||
/** | ||
* Interface representing an operation that allows to execute an action chain. | ||
*/ | ||
public interface ActionChainExecutor { | ||
|
||
/** | ||
* @param action action to execute, can be a single action or a CompositeAction | ||
*/ | ||
void execute(Action action); | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
java/client/src/org/openqa/selenium/interactions/CanPerformActionChain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. 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 org.openqa.selenium.interactions; | ||
|
||
|
||
/** | ||
* Interface implemented by each driver that implements performing action chains. | ||
*/ | ||
public interface CanPerformActionChain { | ||
ActionChainExecutor getActionChainExecutor(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
java/client/src/org/openqa/selenium/remote/RemoteActionChainExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. 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 org.openqa.selenium.remote; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import com.google.common.collect.Maps; | ||
|
||
import org.openqa.selenium.interactions.Action; | ||
import org.openqa.selenium.interactions.ActionChainExecutor; | ||
import org.openqa.selenium.interactions.CompositeAction; | ||
import org.openqa.selenium.interactions.Mouse; | ||
import org.openqa.selenium.interactions.internal.Coordinates; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Executes advanced interactions API commands over wire | ||
*/ | ||
public class RemoteActionChainExecutor implements ActionChainExecutor { | ||
protected final ExecuteMethod executor; | ||
|
||
public RemoteActionChainExecutor(ExecuteMethod executor) { | ||
this.executor = executor; | ||
} | ||
|
||
public void execute(Action action) { | ||
List<Action> actions = new ArrayList<Action>(); | ||
if (action instanceof CompositeAction) { | ||
actions = ((CompositeAction) action).asList(); | ||
} else { | ||
actions.add(action); | ||
} | ||
Map<String, Object> params = Maps.newHashMap(); | ||
params.put("chain", actions); | ||
executor.execute(DriverCommand.ACTION_CHAIN, params); | ||
} | ||
} |