Skip to content

add the settings which introduced in appium 1.14 #1166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/main/java/io/appium/java_client/Setting.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

/**
* Enums defining constants for Appium Settings which can be set and toggled during a test session.
* https://appium.io/docs/en/advanced-concepts/settings/
* <br>
* <a href="https://appium.io/docs/en/advanced-concepts/settings/">
* https://appium.io/docs/en/advanced-concepts/settings/</a>
*/
public enum Setting {

Expand All @@ -33,12 +35,15 @@ public enum Setting {
NORMALIZE_TAG_NAMES("normalizeTagNames"),
KEY_INJECTION_DELAY("keyInjectionDelay"),
SHUTDOWN_ON_POWER_DISCONNECT("shutdownOnPowerDisconnect"),
TRACK_SCROLL_EVENTS("trackScrollEvents"),
// iOS
MJPEG_SERVER_SCREENSHOT_QUALITY("mjpegServerScreenshotQuality"),
MJPEG_SERVER_FRAMERATE("mjpegServerFramerate"),
SCREENSHOT_QUALITY("screenshotQuality"),
NATIVE_WEB_TAP("nativeWebTap"),
MJPEG_SCALING_FACTOR("mjpegScalingFactor"),
KEYBOARD_AUTOCORRECTION("keyboardAutocorrection"),
KEYBOARD_PREDICTION("keyboardPrediction"),
// Android and iOS
SHOULD_USE_COMPACT_RESPONSES("shouldUseCompactResponses"),
ELEMENT_RESPONSE_ATTRIBUTES("elementResponseAttributes"),
Expand All @@ -50,7 +55,8 @@ public enum Setting {
CHECK_IMAGE_ELEMENT_STALENESS("checkForImageElementStaleness"),
UPDATE_IMAGE_ELEMENT_POSITION("autoUpdateImageElementPosition"),
FIX_IMAGE_TEMPLATE_SCALE("fixImageTemplateScale"),
DEFAULT_IMAGE_TEMPLATE_SCALE("defaultImageTemplateScale");
DEFAULT_IMAGE_TEMPLATE_SCALE("defaultImageTemplateScale"),
GET_MATCHED_IMAGE_RESULT("getMatchedImageResult");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,18 @@ default HasAndroidSettings shutdownOnPowerDisconnect(boolean enabled) {
setSetting(Setting.SHUTDOWN_ON_POWER_DISCONNECT, enabled);
return this;
}

/**
* Turn on or off the tracking of scroll events as they happen.
* If {@code true}, a field, {@code lastScrollData}, is added to the results of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commas are redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed :)

* {@code getSession}, which can then be used to check on scroll progress.
* Turning this feature off significantly increases touch action performance.
*
* @param enabled Either true or false. The default value if true.
* @return self instance for chaining
*/
default HasAndroidSettings setTrackScrollEvents(boolean enabled) {
setSetting(Setting.TRACK_SCROLL_EVENTS, enabled);
return this;
}
}
22 changes: 22 additions & 0 deletions src/main/java/io/appium/java_client/ios/HasIOSSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,26 @@ default HasIOSSettings setMjpegScalingFactor(int scale) {
setSetting(Setting.MJPEG_SCALING_FACTOR, scale);
return this;
}

/**
* Changes the 'Auto-Correction' preference in Keyboards setting.
*
* @param enabled Either true or false. Defaults to false when WDA starts as xctest.
* @return self instance for chaining
*/
default HasIOSSettings setKeyboardAutocorrection(boolean enabled) {
setSetting(Setting.KEYBOARD_AUTOCORRECTION, enabled);
return this;
}

/**
* Changes the 'Predictive' preference in Keyboards setting.
*
* @param enabled Either true or false. Defaults to false when WDA starts as xctest.
* @return self instance for chaining
*/
default HasIOSSettings setKeyboardPrediction(boolean enabled) {
setSetting(Setting.KEYBOARD_PREDICTION, enabled);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ public class SettingTest extends BaseAndroidTest {
.get(Setting.SHUTDOWN_ON_POWER_DISCONNECT.toString()));
}

@Test public void testSetTrackScrollEvents() {
assertEquals(true, driver.getSettings()
.get(Setting.TRACK_SCROLL_EVENTS.toString()));
driver.setTrackScrollEvents(false);
assertEquals(false, driver.getSettings()
.get(Setting.TRACK_SCROLL_EVENTS.toString()));
}

private void assertJSONElementContains(Setting setting, long value) {
assertEquals(driver.getSettings().get(setting.toString()), value);
}
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/io/appium/java_client/ios/SettingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,17 @@ public class SettingTest extends AppIOSTest {
.get(Setting.MJPEG_SCALING_FACTOR.toString()));
}

@Test public void testSetKeyboardAutocorrection() {
driver.setKeyboardAutocorrection(true);
assertEquals(true, driver.getSettings()
.get(Setting.KEYBOARD_AUTOCORRECTION.toString()));
}

@Test public void testSetKeyboardPrediction() {
driver.setKeyboardPrediction(true);
assertEquals(true, driver.getSettings()
.get(Setting.KEYBOARD_PREDICTION.toString()));
}


}