From 79541b4e99e0010b47806c825db04a97c0f2a021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E5=95=B8?= Date: Wed, 8 Jun 2016 14:38:39 +0800 Subject: [PATCH] add support to set UiAutomator Congfigurator values --- .../io/appium/java_client/AppiumSetting.java | 3 +- .../java_client/android/AndroidDriver.java | 60 ++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/appium/java_client/AppiumSetting.java b/src/main/java/io/appium/java_client/AppiumSetting.java index 697e1457f..cd70b4997 100644 --- a/src/main/java/io/appium/java_client/AppiumSetting.java +++ b/src/main/java/io/appium/java_client/AppiumSetting.java @@ -21,7 +21,8 @@ */ public enum AppiumSetting { - IGNORE_UNIMPORTANT_VIEWS("ignoreUnimportantViews"); + IGNORE_UNIMPORTANT_VIEWS("ignoreUnimportantViews"), + CONFIGURATOR("configurator"); private String name; private AppiumSetting(String name) { diff --git a/src/main/java/io/appium/java_client/android/AndroidDriver.java b/src/main/java/io/appium/java_client/android/AndroidDriver.java index eec6ea5f1..9c7ae834e 100644 --- a/src/main/java/io/appium/java_client/android/AndroidDriver.java +++ b/src/main/java/io/appium/java_client/android/AndroidDriver.java @@ -37,7 +37,6 @@ import io.appium.java_client.AppiumDriver; import io.appium.java_client.AppiumSetting; import io.appium.java_client.FindsByAndroidUIAutomator; -import io.appium.java_client.SwipeElementDirection; import io.appium.java_client.android.internal.JsonToAndroidElementConverter; import io.appium.java_client.remote.MobilePlatform; import io.appium.java_client.service.local.AppiumDriverLocalService; @@ -395,6 +394,65 @@ public void ignoreUnimportantViews(Boolean compress) { setSetting(AppiumSetting.IGNORE_UNIMPORTANT_VIEWS, compress); } + /** + * Set the `configurator` setting. *Android-only method*. + * Sets the timeouts and delays in {@code com.android.uiautomator.core.Configurator} + * + * @param method set method names in {@code com.android.uiautomator.core.Configurator} + * @param value set method argument, in milliseconds, 0 would reset to their default values + */ + private void configuratorSet(String method, int value) { + setSetting(AppiumSetting.CONFIGURATOR, + String.format("{\"method\":\"%s\",\"value\":%d}", method, value)); + } + + /** + * invoke {@code setWaitForIdleTimeout} in {@code com.android.uiautomator.core.Configurator} + * + * @param timeout in milliseconds, 0 would reset to its default value + */ + public void configuratorSetWaitForIdleTimeout(int timeout) { + configuratorSet("setWaitForIdleTimeout", timeout); + } + + /** + * invoke {@code setWaitForSelectorTimeout} in {@code com.android.uiautomator.core.Configurator} + * + * @param timeout in milliseconds, 0 would reset to its default value + */ + public void configuratorSetWaitForSelectorTimeout(int timeout) { + configuratorSet("setWaitForSelectorTimeout", timeout); + } + + /** + * invoke {@code setScrollAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator} + * + * @param timeout in milliseconds, 0 would reset to its default value + */ + public void configuratorSetScrollAcknowledgmentTimeout(int timeout) { + configuratorSet("setScrollAcknowledgmentTimeout", timeout); + } + + /** + * invoke {@code configuratorSetKeyInjectionDelay} in {@code com.android.uiautomator.core.Configurator} + * + * @param delay in milliseconds, 0 would reset to its default value + */ + public void configuratorSetKeyInjectionDelay(int delay) { + configuratorSet("setKeyInjectionDelay", delay); + } + + /** + * invoke {@code setActionAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator} + * + * @param timeout in milliseconds, 0 would reset to its default value + */ + public void configuratorSetActionAcknowledgmentTimeout(int timeout) { + configuratorSet("setActionAcknowledgmentTimeout", timeout); + } + + + /** * @throws org.openqa.selenium.WebDriverException This method is not * applicable with browser/webview UI.