Skip to content

Commit 847a222

Browse files
The addition to #477 (#480)
* The addition to #477 - the enum `io.appium.java_client.android.ConfiguratorParameters` was removed - new elements were added to the `io.appium.java_client.android.Settings` - refactoring of the `io.appium.java_client.HasSettings`. * Work on remarks. Addition to #477
1 parent 57092e5 commit 847a222

File tree

4 files changed

+28
-67
lines changed

4 files changed

+28
-67
lines changed

src/main/java/io/appium/java_client/android/ConfiguratorParameters.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/main/java/io/appium/java_client/android/HasSettings.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,50 +73,45 @@ default void ignoreUnimportantViews(Boolean compress) {
7373
/**
7474
* invoke {@code setWaitForIdleTimeout} in {@code com.android.uiautomator.core.Configurator}
7575
*
76-
* @param timeout in milliseconds, 0 would reset to its default value
76+
* @param timeout in milliseconds. A negative value would reset to its default value
7777
*/
7878
default void configuratorSetWaitForIdleTimeout(int timeout) {
79-
setSetting(Setting.CONFIGURATOR,
80-
ConfiguratorParameters.WAIT_FOR_IDLE_TIMEOUT.format(timeout));
79+
setSetting(Setting.WAIT_FOR_IDLE_TIMEOUT, timeout);
8180
}
8281

8382
/**
8483
* invoke {@code setWaitForSelectorTimeout} in {@code com.android.uiautomator.core.Configurator}
8584
*
86-
* @param timeout in milliseconds, 0 would reset to its default value
85+
* @param timeout in milliseconds. A negative value would reset to its default value
8786
*/
8887
default void configuratorSetWaitForSelectorTimeout(int timeout) {
89-
setSetting(Setting.CONFIGURATOR,
90-
ConfiguratorParameters.WAIT_FOR_SELECTOR_TIMEOUT.format(timeout));
88+
setSetting(Setting.WAIT_FOR_SELECTOR_TIMEOUT, timeout);
9189
}
9290

9391
/**
9492
* invoke {@code setScrollAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator}
9593
*
96-
* @param timeout in milliseconds, 0 would reset to its default value
94+
* @param timeout in milliseconds. A negative value would reset to its default value
9795
*/
9896
default void configuratorSetScrollAcknowledgmentTimeout(int timeout) {
99-
setSetting(Setting.CONFIGURATOR,
100-
ConfiguratorParameters.WAIT_SCROLL_ACKNOWLEDGMENT_TIMEOUT.format(timeout));
97+
setSetting(Setting.WAIT_SCROLL_ACKNOWLEDGMENT_TIMEOUT, timeout);
10198
}
10299

103100
/**
104101
* invoke {@code configuratorSetKeyInjectionDelay} in {@code com.android.uiautomator.core.Configurator}
105102
*
106-
* @param delay in milliseconds, 0 would reset to its default value
103+
* @param delay in milliseconds. A negative value would reset to its default value
107104
*/
108105
default void configuratorSetKeyInjectionDelay(int delay) {
109-
setSetting(Setting.CONFIGURATOR,
110-
ConfiguratorParameters.KEY_INJECTION_DELAY.format(delay));
106+
setSetting(Setting.KEY_INJECTION_DELAY, delay);
111107
}
112108

113109
/**
114110
* invoke {@code setActionAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator}
115111
*
116-
* @param timeout in milliseconds, 0 would reset to its default value
112+
* @param timeout in milliseconds. A negative value would reset to its default value
117113
*/
118114
default void configuratorSetActionAcknowledgmentTimeout(int timeout) {
119-
setSetting(Setting.CONFIGURATOR,
120-
ConfiguratorParameters.WAIT_ACTION_ACKNOWLEDGMENT_TIMEOUT.format(timeout));
115+
setSetting(Setting.WAIT_ACTION_ACKNOWLEDGMENT_TIMEOUT, timeout);
121116
}
122117
}

src/main/java/io/appium/java_client/android/Setting.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
public enum Setting {
2323

2424
IGNORE_UNIMPORTANT_VIEWS("ignoreUnimportantViews"),
25-
CONFIGURATOR("configurator");
25+
WAIT_FOR_IDLE_TIMEOUT("setWaitForIdleTimeout"),
26+
WAIT_FOR_SELECTOR_TIMEOUT("setWaitForSelectorTimeout"),
27+
WAIT_SCROLL_ACKNOWLEDGMENT_TIMEOUT("setScrollAcknowledgmentTimeout"),
28+
WAIT_ACTION_ACKNOWLEDGMENT_TIMEOUT("setActionAcknowledgmentTimeout"),
29+
KEY_INJECTION_DELAY("setKeyInjectionDelay");
2630

2731
private String name;
2832

src/test/java/io/appium/java_client/android/SettingTest.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,24 @@ public class SettingTest extends BaseAndroidTest {
2121
}
2222

2323
@Test public void configuratorTest() {
24-
driver.configuratorSetActionAcknowledgmentTimeout(5);
25-
assertJSONElementContains("setActionAcknowledgmentTimeout", 5);
24+
driver.configuratorSetActionAcknowledgmentTimeout(500);
25+
assertJSONElementContains(Setting.WAIT_ACTION_ACKNOWLEDGMENT_TIMEOUT, 500);
2626

27-
driver.configuratorSetKeyInjectionDelay(4);
28-
assertJSONElementContains("setKeyInjectionDelay", 4);
27+
driver.configuratorSetKeyInjectionDelay(400);
28+
assertJSONElementContains(Setting.KEY_INJECTION_DELAY, 400);
2929

30-
driver.configuratorSetScrollAcknowledgmentTimeout(3);
31-
assertJSONElementContains("setScrollAcknowledgmentTimeout", 3);
30+
driver.configuratorSetScrollAcknowledgmentTimeout(300);
31+
assertJSONElementContains(Setting.WAIT_SCROLL_ACKNOWLEDGMENT_TIMEOUT, 300);
3232

33-
driver.configuratorSetWaitForIdleTimeout(6);
34-
assertJSONElementContains("setWaitForIdleTimeout", 6);
33+
driver.configuratorSetWaitForIdleTimeout(600);
34+
assertJSONElementContains(Setting.WAIT_FOR_IDLE_TIMEOUT, 600);
3535

36-
driver.configuratorSetWaitForSelectorTimeout(1);
37-
assertJSONElementContains("setWaitForSelectorTimeout", 1);
36+
driver.configuratorSetWaitForSelectorTimeout(1000);
37+
assertJSONElementContains(Setting.WAIT_FOR_SELECTOR_TIMEOUT, 1000);
3838
}
3939

40-
private void assertJSONElementContains(String method, int value) {
41-
driver.getSettings().get(Setting.CONFIGURATOR.toString());
42-
assertEquals(driver.getSettings().get(Setting.CONFIGURATOR.toString())
43-
.getAsJsonObject().get("method").getAsString(), method);
44-
assertEquals(driver.getSettings().get(Setting.CONFIGURATOR.toString())
45-
.getAsJsonObject().get("value").getAsInt(), value);
40+
private void assertJSONElementContains(Setting setting, int value) {
41+
assertEquals(driver.getSettings().get(setting.toString())
42+
.getAsInt(), value);
4643
}
4744
}

0 commit comments

Comments
 (0)