-
-
Notifications
You must be signed in to change notification settings - Fork 758
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
Android setting engine #477
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0042636
Refactoring of setting engine
TikhomirovSergey 0db2636
The new API refactoring
TikhomirovSergey 283950b
Interpretation of #410 to new architecture
263a0c5
Test coverage
TikhomirovSergey c005127
Check style issue fix
TikhomirovSergey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/io/appium/java_client/android/ConfiguratorParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.appium.java_client.android; | ||
|
||
enum ConfiguratorParameters { | ||
WAIT_FOR_IDLE_TIMEOUT("setWaitForIdleTimeout"), | ||
WAIT_FOR_SELECTOR_TIMEOUT("setWaitForSelectorTimeout"), | ||
WAIT_SCROLL_ACKNOWLEDGMENT_TIMEOUT("setScrollAcknowledgmentTimeout"), | ||
WAIT_ACTION_ACKNOWLEDGMENT_TIMEOUT("setActionAcknowledgmentTimeout"), | ||
KEY_INJECTION_DELAY("setKeyInjectionDelay"); | ||
|
||
private final String name; | ||
|
||
ConfiguratorParameters(String name) { | ||
this.name = name; | ||
} | ||
|
||
String format(int value) { | ||
return String.format("{\"method\":\"%s\",\"value\":%d}", name, value); | ||
} | ||
} |
122 changes: 122 additions & 0 deletions
122
src/main/java/io/appium/java_client/android/HasSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.appium.java_client.android; | ||
|
||
import static io.appium.java_client.android.AndroidMobileCommandHelper.getSettingsCommand; | ||
import static io.appium.java_client.android.AndroidMobileCommandHelper.setSettingsCommand; | ||
|
||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonParser; | ||
|
||
import io.appium.java_client.CommandExecutionHelper; | ||
import io.appium.java_client.ExecutesMethod; | ||
|
||
import org.openqa.selenium.remote.Response; | ||
|
||
import java.util.Map; | ||
|
||
interface HasSettings extends ExecutesMethod { | ||
/** | ||
* Set a setting for this test session It's probably better to use a | ||
* convenience function, rather than use this function directly. Try finding | ||
* the method for the specific setting you want to change. | ||
* | ||
* @param setting Setting you wish to set. | ||
* @param value value of the setting. | ||
*/ | ||
default void setSetting(Setting setting, Object value) { | ||
CommandExecutionHelper.execute(this, setSettingsCommand(setting, value)); | ||
} | ||
|
||
/** | ||
* Get settings stored for this test session It's probably better to use a | ||
* convenience function, rather than use this function directly. Try finding | ||
* the method for the specific setting you want to read. | ||
* | ||
* @return JsonObject, a straight-up hash of settings. | ||
*/ | ||
default JsonObject getSettings() { | ||
Map.Entry<String, Map<String, ?>> keyValuePair = getSettingsCommand(); | ||
Response response = execute(keyValuePair.getKey(), keyValuePair.getValue()); | ||
|
||
JsonParser parser = new JsonParser(); | ||
return (JsonObject) parser.parse(response.getValue().toString()); | ||
} | ||
|
||
/** | ||
* Set the `ignoreUnimportantViews` setting. *Android-only method*. | ||
* Sets whether Android devices should use `setCompressedLayoutHeirarchy()` | ||
* which ignores all views which are marked IMPORTANT_FOR_ACCESSIBILITY_NO | ||
* or IMPORTANT_FOR_ACCESSIBILITY_AUTO (and have been deemed not important | ||
* by the system), in an attempt to make things less confusing or faster. | ||
* | ||
* @param compress ignores unimportant views if true, doesn't ignore otherwise. | ||
*/ | ||
default void ignoreUnimportantViews(Boolean compress) { | ||
setSetting(Setting.IGNORE_UNIMPORTANT_VIEWS, compress); | ||
} | ||
|
||
/** | ||
* invoke {@code setWaitForIdleTimeout} in {@code com.android.uiautomator.core.Configurator} | ||
* | ||
* @param timeout in milliseconds, 0 would reset to its default value | ||
*/ | ||
default void configuratorSetWaitForIdleTimeout(int timeout) { | ||
setSetting(Setting.CONFIGURATOR, | ||
ConfiguratorParameters.WAIT_FOR_IDLE_TIMEOUT.format(timeout)); | ||
} | ||
|
||
/** | ||
* invoke {@code setWaitForSelectorTimeout} in {@code com.android.uiautomator.core.Configurator} | ||
* | ||
* @param timeout in milliseconds, 0 would reset to its default value | ||
*/ | ||
default void configuratorSetWaitForSelectorTimeout(int timeout) { | ||
setSetting(Setting.CONFIGURATOR, | ||
ConfiguratorParameters.WAIT_FOR_SELECTOR_TIMEOUT.format(timeout)); | ||
} | ||
|
||
/** | ||
* invoke {@code setScrollAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator} | ||
* | ||
* @param timeout in milliseconds, 0 would reset to its default value | ||
*/ | ||
default void configuratorSetScrollAcknowledgmentTimeout(int timeout) { | ||
setSetting(Setting.CONFIGURATOR, | ||
ConfiguratorParameters.WAIT_SCROLL_ACKNOWLEDGMENT_TIMEOUT.format(timeout)); | ||
} | ||
|
||
/** | ||
* invoke {@code configuratorSetKeyInjectionDelay} in {@code com.android.uiautomator.core.Configurator} | ||
* | ||
* @param delay in milliseconds, 0 would reset to its default value | ||
*/ | ||
default void configuratorSetKeyInjectionDelay(int delay) { | ||
setSetting(Setting.CONFIGURATOR, | ||
ConfiguratorParameters.KEY_INJECTION_DELAY.format(delay)); | ||
} | ||
|
||
/** | ||
* invoke {@code setActionAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator} | ||
* | ||
* @param timeout in milliseconds, 0 would reset to its default value | ||
*/ | ||
default void configuratorSetActionAcknowledgmentTimeout(int timeout) { | ||
setSetting(Setting.CONFIGURATOR, | ||
ConfiguratorParameters.WAIT_ACTION_ACKNOWLEDGMENT_TIMEOUT.format(timeout)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.appium.java_client.android; | ||
|
||
/** | ||
* Enums defining constants for Appium Settings which can be set and toggled during a test session. | ||
*/ | ||
public enum Setting { | ||
|
||
IGNORE_UNIMPORTANT_VIEWS("ignoreUnimportantViews"), | ||
CONFIGURATOR("configurator"); | ||
|
||
private String name; | ||
|
||
Setting(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String toString() { | ||
return this.name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, this code is still the two level configurator. Now it should be like
ignoreUnimportantViews
. Every setting here for configurators should be individivual