Skip to content
Closed
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 @@ -90,6 +90,7 @@
import io.appium.java_client.remote.MobilePlatform;
import io.appium.java_client.remote.options.BaseOptions;
import io.appium.java_client.remote.options.SupportsAppOption;
import io.appium.java_client.remote.options.SupportsAutoLaunchOption;
import io.appium.java_client.remote.options.SupportsAutoWebViewOption;
import io.appium.java_client.remote.options.SupportsClearSystemFilesOption;
import io.appium.java_client.remote.options.SupportsDeviceNameOption;
Expand Down Expand Up @@ -141,6 +142,7 @@ public class UiAutomator2Options extends BaseOptions<UiAutomator2Options> implem
SupportsIntentFlagsOption<UiAutomator2Options>,
SupportsOptionalIntentArgumentsOption<UiAutomator2Options>,
SupportsAutoGrantPermissionsOption<UiAutomator2Options>,
SupportsAutoLaunchOption<UiAutomator2Options>,
SupportsOtherAppsOption<UiAutomator2Options>,
SupportsUninstallOtherPackagesOption<UiAutomator2Options>,
SupportsAllowTestPackagesOption<UiAutomator2Options>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
import io.appium.java_client.remote.MobilePlatform;
import io.appium.java_client.remote.options.BaseOptions;
import io.appium.java_client.remote.options.SupportsAppOption;
import io.appium.java_client.remote.options.SupportsAutoLaunchOption;
import io.appium.java_client.remote.options.SupportsAutoWebViewOption;
import io.appium.java_client.remote.options.SupportsClearSystemFilesOption;
import io.appium.java_client.remote.options.SupportsDeviceNameOption;
Expand Down Expand Up @@ -142,6 +143,7 @@ public class XCUITestOptions extends BaseOptions<XCUITestOptions> implements
SupportsOtherAppsOption<XCUITestOptions>,
SupportsAppPushTimeoutOption<XCUITestOptions>,
SupportsAppInstallStrategyOption<XCUITestOptions>,
SupportsAutoLaunchOption<XCUITestOptions>,
SupportsEnforceAppInstallOption<XCUITestOptions>,
// WebDriverAgent options: https://github.com/appium/appium-xcuitest-driver#webdriveragent
SupportsXcodeCertificateOptions<XCUITestOptions>,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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.remote.options;

import org.openqa.selenium.Capabilities;

import java.util.Optional;

import static io.appium.java_client.internal.CapabilityHelpers.toSafeBoolean;

/**
* Provides getters and setters for the {@code autoLaunch} capability.
*
* @param <T> options type, used for chaining.
*/
public interface SupportsAutoLaunchOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
/**
* Name of the {@code autoLaunch} capability.
*/
String AUTO_LAUNCH_OPTION = "autoLaunch";

/**
* Enables launching of the application under test automatically
* when a test starts.
*
* @return self instance for chaining.
*/
default T autoLaunch() {
return amend(AUTO_LAUNCH_OPTION, true);
}

/**
* Whether to launch the application under test automatically
* when a test starts (true, the default value).
*
* @param value Whether to enable or disable automatic app launching.
* @return self instance for chaining.
*/
default T setAutoLaunch(boolean value) {
return amend(AUTO_LAUNCH_OPTION, value);
}

/**
* Get whether to launch the application under test automatically
* when a test starts.
*
* @return True if the app should be launched automatically.
*/
default Optional<Boolean> doesAutoLaunch() {
return Optional.ofNullable(toSafeBoolean(getCapability(AUTO_LAUNCH_OPTION)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,26 @@ public void canBuildUiAutomator2Options() throws MalformedURLException {
assertTrue(options.doesSuppressKillServer().orElse(false));
}

@Test
public void canSetAutoLaunchOnUiAutomator2Options() {
UiAutomator2Options options = new UiAutomator2Options();
assertFalse(options.doesAutoLaunch().isPresent());
options.autoLaunch();
assertTrue(options.doesAutoLaunch().orElse(false));
options.setAutoLaunch(false);
assertFalse(options.doesAutoLaunch().orElse(true));
}

@Test
public void canSetAutoLaunchOnXcuiTestOptions() {
XCUITestOptions options = new XCUITestOptions();
assertFalse(options.doesAutoLaunch().isPresent());
options.setAutoLaunch(false);
assertFalse(options.doesAutoLaunch().orElse(true));
options.autoLaunch();
assertTrue(options.doesAutoLaunch().orElse(false));
}

@Test
public void canBuildEspressoOptions() {
EspressoOptions options = new EspressoOptions();
Expand Down
Loading