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,18 @@

package io.appium.java_client.android.options;

import io.appium.java_client.android.options.adb.SupportsAdbExecTimeoutOption;
import io.appium.java_client.android.options.adb.SupportsAdbPortOption;
import io.appium.java_client.android.options.adb.SupportsAllowDelayAdbOption;
import io.appium.java_client.android.options.adb.SupportsBuildToolsVersionOption;
import io.appium.java_client.android.options.adb.SupportsClearDeviceLogsOnStartOption;
import io.appium.java_client.android.options.adb.SupportsIgnoreHiddenApiPolicyErrorOption;
import io.appium.java_client.android.options.adb.SupportsLogcatFilterSpecsOption;
import io.appium.java_client.android.options.adb.SupportsLogcatFormatOption;
import io.appium.java_client.android.options.adb.SupportsMockLocationAppOption;
import io.appium.java_client.android.options.adb.SupportsRemoteAdbHostOption;
import io.appium.java_client.android.options.adb.SupportsSkipLogcatCaptureOption;
import io.appium.java_client.android.options.adb.SupportsSuppressKillServerOption;
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;
Expand All @@ -32,13 +44,24 @@
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.avd.SupportsAvdArgsOption;
import io.appium.java_client.android.options.avd.SupportsAvdEnvOption;
import io.appium.java_client.android.options.avd.SupportsAvdLaunchTimeoutOption;
import io.appium.java_client.android.options.avd.SupportsAvdOption;
import io.appium.java_client.android.options.avd.SupportsAvdReadyTimeoutOption;
import io.appium.java_client.android.options.avd.SupportsGpsEnabledOption;
import io.appium.java_client.android.options.avd.SupportsIsHeadlessOption;
import io.appium.java_client.android.options.avd.SupportsNetworkSpeedOption;
import io.appium.java_client.android.options.localization.SupportsLocaleScriptOption;
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.android.options.signing.SupportsKeystoreOptions;
import io.appium.java_client.android.options.signing.SupportsNoSignOption;
import io.appium.java_client.remote.AutomationName;
import io.appium.java_client.remote.MobilePlatform;
import io.appium.java_client.remote.options.BaseOptions;
Expand All @@ -58,9 +81,6 @@
* https://github.com/appium/appium-uiautomator2-driver#capabilities
*/
public class UiAutomator2Options extends BaseOptions<UiAutomator2Options> implements
// 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
Expand Down Expand Up @@ -100,9 +120,35 @@ public class UiAutomator2Options extends BaseOptions<UiAutomator2Options> implem
SupportsAllowTestPackagesOption<UiAutomator2Options>,
SupportsRemoteAppsCacheLimitOption<UiAutomator2Options>,
SupportsEnforceAppInstallOption<UiAutomator2Options>,
// TODO: App localization options: https://github.com/appium/appium-uiautomator2-driver#app-localization
// App localization options: https://github.com/appium/appium-uiautomator2-driver#app-localization
SupportsLocaleScriptOption<UiAutomator2Options>,
SupportsLanguageOption<UiAutomator2Options>,
SupportsLocaleOption<UiAutomator2Options> {
SupportsLocaleOption<UiAutomator2Options>,
// ADB options: https://github.com/appium/appium-uiautomator2-driver#adb
SupportsAdbPortOption<UiAutomator2Options>,
SupportsRemoteAdbHostOption<UiAutomator2Options>,
SupportsAdbExecTimeoutOption<UiAutomator2Options>,
SupportsClearDeviceLogsOnStartOption<UiAutomator2Options>,
SupportsBuildToolsVersionOption<UiAutomator2Options>,
SupportsSkipLogcatCaptureOption<UiAutomator2Options>,
SupportsSuppressKillServerOption<UiAutomator2Options>,
SupportsIgnoreHiddenApiPolicyErrorOption<UiAutomator2Options>,
SupportsMockLocationAppOption<UiAutomator2Options>,
SupportsLogcatFormatOption<UiAutomator2Options>,
SupportsLogcatFilterSpecsOption<UiAutomator2Options>,
SupportsAllowDelayAdbOption<UiAutomator2Options>,
// AVD options: https://github.com/appium/appium-uiautomator2-driver#emulator-android-virtual-device
SupportsAvdOption<UiAutomator2Options>,
SupportsAvdLaunchTimeoutOption<UiAutomator2Options>,
SupportsAvdReadyTimeoutOption<UiAutomator2Options>,
SupportsAvdArgsOption<UiAutomator2Options>,
SupportsAvdEnvOption<UiAutomator2Options>,
SupportsNetworkSpeedOption<UiAutomator2Options>,
SupportsGpsEnabledOption<UiAutomator2Options>,
SupportsIsHeadlessOption<UiAutomator2Options>,
// App signing options: https://github.com/appium/appium-uiautomator2-driver#app-signing
SupportsKeystoreOptions<UiAutomator2Options>,
SupportsNoSignOption<UiAutomator2Options> {
public UiAutomator2Options() {
setCommonOptions();
}
Expand Down
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.adb;

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 SupportsAdbExecTimeoutOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String ADB_EXEC_TIMEOUT_OPTION = "adbExecTimeout";

/**
* Maximum time to wait until single ADB command is executed.
* 20000 ms by default.
*
* @param timeout ADB commands timeout.
* @return self instance for chaining.
*/
default T setAdbExecTimeout(Duration timeout) {
return amend(ADB_EXEC_TIMEOUT_OPTION, timeout.toMillis());
}

/**
* Get maximum time to wait until single ADB command is executed.
*
* @return Timeout value.
*/
default Optional<Duration> getAdbExecTimeout() {
return Optional.ofNullable(toDuration(getCapability(ADB_EXEC_TIMEOUT_OPTION)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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.adb;

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.toInteger;

public interface SupportsAdbPortOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String ADB_PORT_OPTION = "adbPort";

/**
* Set number of the port where ADB is running. 5037 by default
*
* @param port port number in range 0..65535
* @return self instance for chaining.
*/
default T setAdbPort(int port) {
return amend(ADB_PORT_OPTION, port);
}

/**
* Get number of the port where ADB is running.
*
* @return Adb port value
*/
default Optional<Integer> getAdbPort() {
return Optional.ofNullable(toInteger(getCapability(ADB_PORT_OPTION)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.adb;

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 SupportsAllowDelayAdbOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String ALLOW_DELAY_ADB_OPTION = "allowDelayAdb";

/**
* Being set to false prevents emulator to use -delay-adb feature to detect its startup.
* See https://github.com/appium/appium/issues/14773 for more details.
*
* @param value Set it to false in order to prevent the emulator to use -delay-adb feature.
* @return self instance for chaining.
*/
default T setAllowDelayAdb(boolean value) {
return amend(ALLOW_DELAY_ADB_OPTION, value);
}

/**
* Get whether to prevent the emulator to use -delay-adb feature.
*
* @return True or false.
*/
default Optional<Boolean> doesAllowDelayAdb() {
return Optional.ofNullable(toSafeBoolean(getCapability(ALLOW_DELAY_ADB_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.adb;

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 SupportsBuildToolsVersionOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String BUILD_TOOLS_VERSION_OPTION = "buildToolsVersion";

/**
* The version of Android build tools to use. By default, UiAutomator2
* driver uses the most recent version of build tools installed on
* the machine, but sometimes it might be necessary to give it a hint
* (let say if there is a known bug in the most recent tools version).
* Example: 28.0.3
*
* @param version The build tools version to use.
* @return self instance for chaining.
*/
default T setBuildToolsVersion(String version) {
return amend(BUILD_TOOLS_VERSION_OPTION, version);
}

/**
* Get the version of Android build tools to use.
*
* @return Build tools version.
*/
default Optional<String> getBuildToolsVersion() {
return Optional.ofNullable((String) getCapability(BUILD_TOOLS_VERSION_OPTION));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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.adb;

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 SupportsClearDeviceLogsOnStartOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String CLEAR_DEVICE_LOGS_ON_START_OPTION = "clearDeviceLogsOnStart";

/**
* Makes UiAutomator2 to delete all the existing logs in the
* device buffer before starting a new test.
*
* @return self instance for chaining.
*/
default T clearDeviceLogsOnStart() {
return amend(CLEAR_DEVICE_LOGS_ON_START_OPTION, true);
}


/**
* If set to true then UiAutomator2 deletes all the existing logs in the
* device buffer before starting a new test.
*
* @param value Set to false if you don't want to wait for the app to finish its launch.
* @return self instance for chaining.
*/
default T setClearDeviceLogsOnStart(boolean value) {
return amend(CLEAR_DEVICE_LOGS_ON_START_OPTION, value);
}

/**
* Get whether to delete all the existing logs in the
* device buffer before starting a new test.
*
* @return True or false.
*/
default Optional<Boolean> doesClearDeviceLogsOnStart() {
return Optional.ofNullable(toSafeBoolean(getCapability(CLEAR_DEVICE_LOGS_ON_START_OPTION)));
}
}
Loading