From 1415f61e3687dfd550fd3268cb07947627097d48 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Fri, 8 Feb 2019 14:28:25 +0000 Subject: workloads/chrome: Fix for tablet devices Some tablet devices use an alternate tab switching method due to the larger screen space. Add support for adding new tabs via the menu instead of via the tab switcher. --- wa/workloads/chrome/com.arm.wa.uiauto.chrome.apk | Bin 265222 -> 264518 bytes .../main/java/com/arm/wa/uiauto/UiAutomation.java | 22 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/wa/workloads/chrome/com.arm.wa.uiauto.chrome.apk b/wa/workloads/chrome/com.arm.wa.uiauto.chrome.apk index cb391833..692e2a93 100644 Binary files a/wa/workloads/chrome/com.arm.wa.uiauto.chrome.apk and b/wa/workloads/chrome/com.arm.wa.uiauto.chrome.apk differ diff --git a/wa/workloads/chrome/uiauto/app/src/main/java/com/arm/wa/uiauto/UiAutomation.java b/wa/workloads/chrome/uiauto/app/src/main/java/com/arm/wa/uiauto/UiAutomation.java index 3d7c5e2a..c643ff26 100644 --- a/wa/workloads/chrome/uiauto/app/src/main/java/com/arm/wa/uiauto/UiAutomation.java +++ b/wa/workloads/chrome/uiauto/app/src/main/java/com/arm/wa/uiauto/UiAutomation.java @@ -81,12 +81,22 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface // Activate the tab switcher tabSwitcher = mDevice.findObject(new UiSelector().resourceId(packageID + "tab_switcher_button") .className("android.widget.ImageButton")); - tabSwitcher.clickAndWaitForNewWindow(uiAutoTimeout); - - // Click the New Tab button - newTab = mDevice.findObject(new UiSelector().resourceId(packageID + "new_tab_button") - .className("android.widget.Button")); - newTab.clickAndWaitForNewWindow(uiAutoTimeout); + if (tabSwitcher.exists()){ + tabSwitcher.clickAndWaitForNewWindow(uiAutoTimeout); + // Click the New Tab button + newTab = mDevice.findObject(new UiSelector().resourceId(packageID + "new_tab_button") + .className("android.widget.Button")); + newTab.clickAndWaitForNewWindow(uiAutoTimeout); + } + // Support Tablet devices which do not have tab switcher + else { + UiObject menu_button = mDevice.findObject(new UiSelector().resourceId(packageID + "menu_button") + .className("android.widget.ImageButton")); + menu_button.click(); + newTab = mDevice.findObject(new UiSelector().resourceId(packageID + "menu_item_text") + .textContains("New tab")); + newTab.click(); + } } public void followTextLink(String text) throws Exception { -- cgit v1.2.3