-
-
Notifications
You must be signed in to change notification settings - Fork 768
chore: Start adding UiAutomator2 options #1543
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
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e33e3a0
Start adding UiAutomator2 options
mykola-mokhnach 4ae0812
Address comments
mykola-mokhnach 440d30e
Rename
mykola-mokhnach e791ab7
Make converters more strict
mykola-mokhnach 950213f
Tune toBoolean conversion
mykola-mokhnach 3005b1d
Fix styling
mykola-mokhnach 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
52 changes: 52 additions & 0 deletions
52
src/main/java/io/appium/java_client/android/options/SupportsSystemPortOption.java
This file contains hidden or 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,52 @@ | ||
/* | ||
* 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.options; | ||
|
||
import io.appium.java_client.remote.options.BaseOptions; | ||
import io.appium.java_client.remote.options.CanSetCapability; | ||
import org.openqa.selenium.Capabilities; | ||
|
||
import java.util.Optional; | ||
|
||
import static io.appium.java_client.internal.CapabilityHelpers.toSafeInteger; | ||
|
||
public interface SupportsSystemPortOption<T extends BaseOptions<T>> extends | ||
Capabilities, CanSetCapability<T> { | ||
String SYSTEM_PORT_OPTION = "systemPort"; | ||
|
||
/** | ||
* The number of the port the UiAutomator2 server is listening on. | ||
* By default, the first free port from 8200..8299 range is selected. | ||
* It is recommended to set this value if you are running parallel | ||
* tests on the same machine. | ||
* | ||
* @param port port number in range 0..65535 | ||
* @return self instance for chaining. | ||
*/ | ||
default T setSystemPort(int port) { | ||
return amend(SYSTEM_PORT_OPTION, port); | ||
} | ||
|
||
/** | ||
* Get the system port value. | ||
* | ||
* @return System port value | ||
*/ | ||
default Optional<Integer> getSystemPort() { | ||
return Optional.ofNullable(toSafeInteger(getCapability(SYSTEM_PORT_OPTION))); | ||
} | ||
} |
This file contains hidden or 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
61 changes: 61 additions & 0 deletions
61
src/main/java/io/appium/java_client/android/options/app/SupportsAllowTestPackagesOption.java
This file contains hidden or 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,61 @@ | ||
/* | ||
* 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.options.app; | ||
|
||
import io.appium.java_client.remote.options.BaseOptions; | ||
import io.appium.java_client.remote.options.CanSetCapability; | ||
import org.openqa.selenium.Capabilities; | ||
|
||
import java.util.Optional; | ||
|
||
import static io.appium.java_client.internal.CapabilityHelpers.toSafeBoolean; | ||
|
||
public interface SupportsAllowTestPackagesOption<T extends BaseOptions<T>> extends | ||
Capabilities, CanSetCapability<T> { | ||
String ALLOW_TEST_PACKAGES_OPTION = "allowTestPackages"; | ||
|
||
/** | ||
* Enables usage of packages built with the test flag for | ||
* the automated testing (literally adds -t flag to the adb install command). | ||
* | ||
* @return self instance for chaining. | ||
*/ | ||
default T setAllowTestPackages() { | ||
return amend(ALLOW_TEST_PACKAGES_OPTION, true); | ||
} | ||
|
||
/** | ||
* If set to true then it would be possible to use packages built with the test flag for | ||
* the automated testing (literally adds -t flag to the adb install command). false by default. | ||
* | ||
* @param value True to allow test packages installation. | ||
* @return self instance for chaining. | ||
*/ | ||
default T setAllowTestPackages(boolean value) { | ||
return amend(ALLOW_TEST_PACKAGES_OPTION, value); | ||
} | ||
|
||
/** | ||
* Get whether it is possible to use packages built with the test flag for | ||
* the automated testing (literally adds -t flag to the adb install command). | ||
* | ||
* @return True or false. | ||
*/ | ||
default Optional<Boolean> doesAllowTestPackages() { | ||
return Optional.ofNullable(toSafeBoolean(getCapability(ALLOW_TEST_PACKAGES_OPTION))); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...n/java/io/appium/java_client/android/options/app/SupportsAndroidInstallTimeoutOption.java
This file contains hidden or 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,52 @@ | ||
/* | ||
* 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.options.app; | ||
|
||
import io.appium.java_client.remote.options.BaseOptions; | ||
import io.appium.java_client.remote.options.CanSetCapability; | ||
import org.openqa.selenium.Capabilities; | ||
|
||
import java.time.Duration; | ||
import java.util.Optional; | ||
|
||
import static io.appium.java_client.internal.CapabilityHelpers.toSafeLong; | ||
|
||
public interface SupportsAndroidInstallTimeoutOption<T extends BaseOptions<T>> extends | ||
Capabilities, CanSetCapability<T> { | ||
String ANDROID_INSTALL_TIMEOUT_OPTION = "androidInstallTimeout"; | ||
|
||
/** | ||
* Maximum amount of time to wait until the application under test is installed. | ||
* 90000 ms by default | ||
* | ||
* @param installTimeout App install timeout. | ||
* @return self instance for chaining. | ||
*/ | ||
default T setAndroidInstallTimeout(Duration installTimeout) { | ||
return amend(ANDROID_INSTALL_TIMEOUT_OPTION, installTimeout.toMillis()); | ||
} | ||
|
||
/** | ||
* Get maximum amount of time to wait until the application under test is installed. | ||
* | ||
* @return Timeout value. | ||
*/ | ||
default Optional<Duration> getAndroidInstallTimeout() { | ||
Long value = toSafeLong(getCapability(ANDROID_INSTALL_TIMEOUT_OPTION)); | ||
return Optional.ofNullable(value == null ? null : Duration.ofMillis(value)); | ||
mykola-mokhnach marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/io/appium/java_client/android/options/app/SupportsAppActivityOption.java
This file contains hidden or 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,48 @@ | ||
/* | ||
* 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.options.app; | ||
|
||
import io.appium.java_client.remote.options.BaseOptions; | ||
import io.appium.java_client.remote.options.CanSetCapability; | ||
import org.openqa.selenium.Capabilities; | ||
|
||
import java.util.Optional; | ||
|
||
public interface SupportsAppActivityOption<T extends BaseOptions<T>> extends | ||
Capabilities, CanSetCapability<T> { | ||
String APP_ACTIVITY_OPTION = "appActivity"; | ||
|
||
/** | ||
* Main application activity identifier. If not provided then UiAutomator2 | ||
* will try to detect it automatically from the package provided by the app capability. | ||
* | ||
* @param appActivity Fully qualified app activity class name. | ||
* @return self instance for chaining. | ||
*/ | ||
default T setAppActivity(String appActivity) { | ||
return amend(APP_ACTIVITY_OPTION, appActivity); | ||
} | ||
|
||
/** | ||
* Get the name of the main app activity. | ||
* | ||
* @return Activity class name. | ||
*/ | ||
default Optional<String> getAppActivity() { | ||
return Optional.ofNullable((String) getCapability(APP_ACTIVITY_OPTION)); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/io/appium/java_client/android/options/app/SupportsAppDurationOption.java
This file contains hidden or 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,52 @@ | ||
/* | ||
* 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.options.app; | ||
|
||
import io.appium.java_client.remote.options.BaseOptions; | ||
import io.appium.java_client.remote.options.CanSetCapability; | ||
import org.openqa.selenium.Capabilities; | ||
|
||
import java.time.Duration; | ||
import java.util.Optional; | ||
|
||
import static io.appium.java_client.internal.CapabilityHelpers.toSafeLong; | ||
|
||
public interface SupportsAppDurationOption<T extends BaseOptions<T>> extends | ||
Capabilities, CanSetCapability<T> { | ||
String APP_WAIT_DURATION_OPTION = "appWaitDuration"; | ||
|
||
/** | ||
* Maximum amount of time to wait until the application under test is started | ||
* (e.g. an activity returns the control to the caller). 20000 ms by default. | ||
* | ||
* @param appWaitDuration Package identifier to wait for. | ||
* @return self instance for chaining. | ||
*/ | ||
default T setAppWaitDuration(Duration appWaitDuration) { | ||
return amend(APP_WAIT_DURATION_OPTION, appWaitDuration.toMillis()); | ||
} | ||
|
||
/** | ||
* Get the identifier of the app package to wait for. | ||
* | ||
* @return Package identifier. | ||
*/ | ||
default Optional<Duration> getAppWaitDuration() { | ||
Long value = toSafeLong(getCapability(APP_WAIT_DURATION_OPTION)); | ||
return Optional.ofNullable(value == null ? null : Duration.ofMillis(value)); | ||
} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.