Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,29 @@

package io.appium.java_client.android.options;

import io.appium.java_client.android.options.app.SupportsAllowTestPackagesOption;
import io.appium.java_client.android.options.app.SupportsAndroidInstallTimeoutOption;
import io.appium.java_client.android.options.app.SupportsAppActivityOption;
import io.appium.java_client.android.options.app.SupportsAppDurationOption;
import io.appium.java_client.android.options.app.SupportsAppPackageOption;
import io.appium.java_client.android.options.app.SupportsAppWaitActivityOption;
import io.appium.java_client.android.options.app.SupportsAppWaitForLaunchOption;
import io.appium.java_client.android.options.app.SupportsAppWaitPackageOption;
import io.appium.java_client.android.options.app.SupportsAutoGrantPermissionsOption;
import io.appium.java_client.android.options.app.SupportsEnforceAppInstallOption;
import io.appium.java_client.android.options.app.SupportsIntentActionOption;
import io.appium.java_client.android.options.app.SupportsIntentCategoryOption;
import io.appium.java_client.android.options.app.SupportsIntentFlagsOption;
import io.appium.java_client.android.options.app.SupportsOptionalIntentArgumentsOption;
import io.appium.java_client.android.options.app.SupportsRemoteAppsCacheLimitOption;
import io.appium.java_client.android.options.app.SupportsUninstallOtherPackagesOption;
import io.appium.java_client.android.options.server.SupportsDisableWindowAnimationOption;
import io.appium.java_client.android.options.server.SupportsSkipDeviceInitializationOption;
import io.appium.java_client.android.options.server.SupportsSkipServerInstallationOption;
import io.appium.java_client.android.options.server.SupportsSystemPortOption;
import io.appium.java_client.android.options.server.SupportsUiautomator2ServerInstallTimeoutOption;
import io.appium.java_client.android.options.server.SupportsUiautomator2ServerLaunchTimeoutOption;
import io.appium.java_client.android.options.server.SupportsUiautomator2ServerReadTimeoutOption;
import io.appium.java_client.remote.AutomationName;
import io.appium.java_client.remote.MobilePlatform;
import io.appium.java_client.remote.options.BaseOptions;
Expand All @@ -31,12 +54,55 @@
import io.appium.java_client.remote.options.SupportsUdidOption;
import org.openqa.selenium.Capabilities;

/**
* https://github.com/appium/appium-uiautomator2-driver#capabilities
*/
public class UiAutomator2Options extends BaseOptions<UiAutomator2Options> implements
SupportsAppOption<UiAutomator2Options>, SupportsAutoWebViewOption<UiAutomator2Options>,
SupportsClearSystemFilesOption<UiAutomator2Options>, SupportsDeviceNameOption<UiAutomator2Options>,
SupportsEnablePerformanceLoggingOption<UiAutomator2Options>, SupportsLanguageOption<UiAutomator2Options>,
SupportsLocaleOption<UiAutomator2Options>, SupportsOrientationOption<UiAutomator2Options>,
SupportsOtherAppsOption<UiAutomator2Options>, SupportsUdidOption<UiAutomator2Options> {
// TODO: ADB options: https://github.com/appium/appium-uiautomator2-driver#adb
// TODO: AVD options: https://github.com/appium/appium-uiautomator2-driver#emulator-android-virtual-device
// TODO: App signing options: https://github.com/appium/appium-uiautomator2-driver#app-signing
// TODO: Device locking options: https://github.com/appium/appium-uiautomator2-driver#device-locking
// TODO: MJPEG options: https://github.com/appium/appium-uiautomator2-driver#mjpeg
// TODO: Web Context options: https://github.com/appium/appium-uiautomator2-driver#web-context
// TODO: Other options: https://github.com/appium/appium-uiautomator2-driver#other
// TODO: Shared options
SupportsAutoWebViewOption<UiAutomator2Options>,
// General options: https://github.com/appium/appium-uiautomator2-driver#general
SupportsDeviceNameOption<UiAutomator2Options>,
SupportsUdidOption<UiAutomator2Options>,
// Driver/Server options: https://github.com/appium/appium-uiautomator2-driver#driverserver
SupportsSystemPortOption<UiAutomator2Options>,
SupportsSkipServerInstallationOption<UiAutomator2Options>,
SupportsUiautomator2ServerLaunchTimeoutOption<UiAutomator2Options>,
SupportsUiautomator2ServerInstallTimeoutOption<UiAutomator2Options>,
SupportsUiautomator2ServerReadTimeoutOption<UiAutomator2Options>,
SupportsDisableWindowAnimationOption<UiAutomator2Options>,
SupportsSkipDeviceInitializationOption<UiAutomator2Options>,
SupportsOrientationOption<UiAutomator2Options>,
SupportsClearSystemFilesOption<UiAutomator2Options>,
SupportsEnablePerformanceLoggingOption<UiAutomator2Options>,
// App options: https://github.com/appium/appium-uiautomator2-driver#app
SupportsAppOption<UiAutomator2Options>,
SupportsAppPackageOption<UiAutomator2Options>,
SupportsAppActivityOption<UiAutomator2Options>,
SupportsAppWaitActivityOption<UiAutomator2Options>,
SupportsAppWaitPackageOption<UiAutomator2Options>,
SupportsAppDurationOption<UiAutomator2Options>,
SupportsAndroidInstallTimeoutOption<UiAutomator2Options>,
SupportsAppWaitForLaunchOption<UiAutomator2Options>,
SupportsIntentCategoryOption<UiAutomator2Options>,
SupportsIntentActionOption<UiAutomator2Options>,
SupportsIntentFlagsOption<UiAutomator2Options>,
SupportsOptionalIntentArgumentsOption<UiAutomator2Options>,
SupportsAutoGrantPermissionsOption<UiAutomator2Options>,
SupportsOtherAppsOption<UiAutomator2Options>,
SupportsUninstallOtherPackagesOption<UiAutomator2Options>,
SupportsAllowTestPackagesOption<UiAutomator2Options>,
SupportsRemoteAppsCacheLimitOption<UiAutomator2Options>,
SupportsEnforceAppInstallOption<UiAutomator2Options>,
// TODO: App localization options: https://github.com/appium/appium-uiautomator2-driver#app-localization
SupportsLanguageOption<UiAutomator2Options>,
SupportsLocaleOption<UiAutomator2Options> {
public UiAutomator2Options() {
setCommonOptions();
}
Expand Down
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 allowTestPackages() {
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)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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.internal.CapabilityHelpers;
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.toDuration;

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() {
return Optional.ofNullable(
CapabilityHelpers.toDuration(getCapability(ANDROID_INSTALL_TIMEOUT_OPTION))
);
}
}
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));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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.toDuration;

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() {
return Optional.ofNullable(toDuration(getCapability(APP_WAIT_DURATION_OPTION)));
}
}
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 SupportsAppPackageOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String APP_PACKAGE_OPTION = "appPackage";

/**
* Application package identifier to be started. If not provided then UiAutomator2 will
* try to detect it automatically from the package provided by the app capability.
*
* @param appPackage App package identifier.
* @return self instance for chaining.
*/
default T setAppPackage(String appPackage) {
return amend(APP_PACKAGE_OPTION, appPackage);
}

/**
* Get the app package identifier.
*
* @return Identifier value.
*/
default Optional<String> getAppPackage() {
return Optional.ofNullable((String) getCapability(APP_PACKAGE_OPTION));
}
}
Loading