Skip to content

Commit

Permalink
Rotation support.
Browse files Browse the repository at this point in the history
  • Loading branch information
rafe-g committed Jul 21, 2016
1 parent 0e9746b commit 4757a3c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion google-style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,4 @@
</module>
<module name="CommentsIndentation"/>
</module>
</module>
</module>
20 changes: 20 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
<artifactId>gson</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
Expand All @@ -38,6 +48,16 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
22 changes: 19 additions & 3 deletions src/main/java/io/appium/java_client/AppiumDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.ScreenOrientation;
import org.openqa.selenium.DeviceRotation;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
Expand Down Expand Up @@ -225,11 +226,11 @@ private static CommandInfo deleteC(String url) {
@Override public List<T> findElements(By by) {
return super.findElements(by);
}

@Override public List<T> findElements(String by, String using) {
return super.findElements(by, using);
}

@Override public List<T> findElementsById(String id) {
return super.findElementsById(id);
}
Expand Down Expand Up @@ -630,7 +631,22 @@ protected void setSetting(AppiumSetting setting, Object value) {
throw new WebDriverException("Unexpected orientation returned: " + orientation);
}
}


@Override
public void rotate(DeviceRotation rotation) {
execute(DriverCommand.SET_SCREEN_ROTATION, rotation.parameters());
}

@Override
public DeviceRotation rotation() {
Response response = execute(DriverCommand.GET_SCREEN_ROTATION);
DeviceRotation deviceRotation = new DeviceRotation((Map<String, Number>)response.getValue());
if (deviceRotation.getX() < 0 || deviceRotation.getY() < 0 || deviceRotation.getZ() < 0) {
throw new WebDriverException("Unexpected orientation returned: " + deviceRotation);
}
return deviceRotation;
}

@Override public Location location() {
return locationContext.location();
}
Expand Down

0 comments on commit 4757a3c

Please sign in to comment.