diff --git a/wa/framework/uiauto/app/src/main/java/com/arm/wa/uiauto/BaseUiAutomation.java b/wa/framework/uiauto/app/src/main/java/com/arm/wa/uiauto/BaseUiAutomation.java index 0a29df26..2c657e91 100644 --- a/wa/framework/uiauto/app/src/main/java/com/arm/wa/uiauto/BaseUiAutomation.java +++ b/wa/framework/uiauto/app/src/main/java/com/arm/wa/uiauto/BaseUiAutomation.java @@ -45,7 +45,7 @@ public class BaseUiAutomation { public enum FindByCriteria { BY_ID, BY_TEXT, BY_DESC }; public enum Direction { UP, DOWN, LEFT, RIGHT, NULL }; - public enum ScreenOrientation { RIGHT, NATURAL, LEFT }; + public enum ScreenOrientation { RIGHT, NATURAL, LEFT, PORTRAIT, LANDSCAPE }; public enum PinchType { IN, OUT, NULL }; // Time in milliseconds @@ -176,6 +176,8 @@ public class BaseUiAutomation { } public void setScreenOrientation(ScreenOrientation orientation) throws Exception { + int width = mDevice.getDisplayWidth(); + int height = mDevice.getDisplayHeight(); switch (orientation) { case RIGHT: mDevice.setOrientationRight(); @@ -186,6 +188,30 @@ public class BaseUiAutomation { case LEFT: mDevice.setOrientationLeft(); break; + case LANDSCAPE: + if (mDevice.isNaturalOrientation()){ + if (height > width){ + mDevice.setOrientationRight(); + } + } + else { + if (height > width){ + mDevice.setOrientationNatural(); + } + } + break; + case PORTRAIT: + if (mDevice.isNaturalOrientation()){ + if (height < width){ + mDevice.setOrientationRight(); + } + } + else { + if (height < width){ + mDevice.setOrientationNatural(); + } + } + break; default: throw new Exception("No orientation specified"); } diff --git a/wa/framework/uiauto/uiauto.aar b/wa/framework/uiauto/uiauto.aar index a39b662b..b58f040a 100644 Binary files a/wa/framework/uiauto/uiauto.aar and b/wa/framework/uiauto/uiauto.aar differ