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,11 +16,11 @@

package io.appium.java_client.android.options.mjpeg;

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.net.MalformedURLException;
import java.net.URL;
import java.util.Optional;

Expand Down Expand Up @@ -59,12 +59,6 @@ default T setMjpegScreenshotUrl(String url) {
*/
default Optional<URL> getMjpegScreenshotUrl() {
return Optional.ofNullable(getCapability(MJPEG_SCREENSHOT_URL_OPTION))
.map((v) -> {
try {
return new URL(String.valueOf(v));
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
});
.map(CapabilityHelpers::toUrl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.openqa.selenium.Capabilities;

import javax.annotation.Nullable;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -75,8 +77,8 @@ public static Boolean toSafeBoolean(Object value) {
* Converts generic capability value to integer.
*
* @param value The capability value.
* @throws NumberFormatException If the given value cannot be parsed to a valid integer.
* @return null is the passed value is null otherwise the converted value.
* @throws NumberFormatException If the given value cannot be parsed to a valid integer.
*/
@Nullable
public static Integer toInteger(Object value) {
Expand All @@ -90,12 +92,11 @@ public static Integer toInteger(Object value) {
}

/**
* Converts generic capability value to long without
* throwing exceptions.
* Converts generic capability value to long.
*
* @param value The capability value.
* @throws NumberFormatException If the given value cannot be parsed to a valid long.
* @return null is the passed value is null otherwise the converted value.
* @throws NumberFormatException If the given value cannot be parsed to a valid long.
*/
@Nullable
public static Long toLong(Object value) {
Expand All @@ -109,32 +110,69 @@ public static Long toLong(Object value) {
}

/**
* Converts generic capability value to duration without
* throwing exceptions. The value is assumed to be
* Converts generic capability value to double.
*
* @param value The capability value.
* @return null is the passed value is null otherwise the converted value.
* @throws NumberFormatException If the given value cannot be parsed to a valid long.
*/
@Nullable
public static Double toDouble(Object value) {
if (value == null) {
return null;
} else if (value instanceof Number) {
return ((Number) value).doubleValue();
} else {
return Double.parseDouble(String.valueOf(value));
}
}

/**
* Converts generic capability value to duration. The value is assumed to be
* measured in milliseconds.
*
* @param value The capability value.
* @throws NumberFormatException If the given value cannot be parsed to a valid number.
* @return null is the passed value is null otherwise the converted value.
* @throws NumberFormatException If the given value cannot be parsed to a valid number.
*/
@Nullable
public static Duration toDuration(Object value) {
return toDuration(value, Duration::ofMillis);
}

/**
* Converts generic capability value to duration without
* throwing exceptions.
* Converts generic capability value to duration.
*
* @param value The capability value.
* @param converter Converts the numeric value to a Duration instance.
* @throws NumberFormatException If the given value cannot be parsed to a valid number.
* @return null is the passed value is null otherwise the converted value.
* @throws NumberFormatException If the given value cannot be parsed to a valid number.
*/
@Nullable
public static Duration toDuration(Object value,
Function<Long, Duration> converter) {
Long v = toLong(value);
return v == null ? null : converter.apply(v);
}

/**
* Converts generic capability value to a url.
*
* @param value The capability value.
* @throws IllegalArgumentException If the given value cannot be parsed to a valid url.
* @return null is the passed value is null otherwise the converted value.
*/
@Nullable
public static URL toUrl(Object value) {
if (value == null) {
return null;
}
try {
return (value instanceof URL)
? (URL) value :
new URL(String.valueOf(value));
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,39 @@
import io.appium.java_client.ios.options.app.SupportsLocalizableStringsDirOption;
import io.appium.java_client.ios.options.general.SupportsIncludeDeviceCapsToSessionInfoOption;
import io.appium.java_client.ios.options.general.SupportsResetLocationServiceOption;
import io.appium.java_client.ios.options.wda.SupportsAllowProvisioningDeviceRegistrationOption;
import io.appium.java_client.ios.options.wda.SupportsAutoAcceptAlertsOption;
import io.appium.java_client.ios.options.wda.SupportsAutoDismissAlertsOption;
import io.appium.java_client.ios.options.wda.SupportsDerivedDataPathOption;
import io.appium.java_client.ios.options.wda.SupportsDisableAutomaticScreenshotsOption;
import io.appium.java_client.ios.options.wda.SupportsForceAppLaunchOption;
import io.appium.java_client.ios.options.wda.SupportsKeychainOptions;
import io.appium.java_client.ios.options.wda.SupportsMaxTypingFrequencyOption;
import io.appium.java_client.ios.options.wda.SupportsMjpegServerPortOption;
import io.appium.java_client.ios.options.wda.SupportsProcessArgumentsOption;
import io.appium.java_client.ios.options.wda.SupportsResultBundlePathOption;
import io.appium.java_client.ios.options.wda.SupportsScreenshotQualityOption;
import io.appium.java_client.ios.options.wda.SupportsShouldTerminateAppOption;
import io.appium.java_client.ios.options.wda.SupportsShouldUseSingletonTestManagerOption;
import io.appium.java_client.ios.options.wda.SupportsShowXcodeLogOption;
import io.appium.java_client.ios.options.wda.SupportsSimpleIsVisibleCheckOption;
import io.appium.java_client.ios.options.wda.SupportsUpdatedWdaBundleIdOption;
import io.appium.java_client.ios.options.wda.SupportsUseNativeCachingStrategyOption;
import io.appium.java_client.ios.options.wda.SupportsUseNewWdaOption;
import io.appium.java_client.ios.options.wda.SupportsUsePrebuiltWdaOption;
import io.appium.java_client.ios.options.wda.SupportsUseSimpleBuildTestOption;
import io.appium.java_client.ios.options.wda.SupportsUseXctestrunFileOption;
import io.appium.java_client.ios.options.wda.SupportsWaitForIdleTimeoutOption;
import io.appium.java_client.ios.options.wda.SupportsWaitForQuiescenceOption;
import io.appium.java_client.ios.options.wda.SupportsWdaBaseUrlOption;
import io.appium.java_client.ios.options.wda.SupportsWdaConnectionTimeoutOption;
import io.appium.java_client.ios.options.wda.SupportsWdaEventloopIdleDelayOption;
import io.appium.java_client.ios.options.wda.SupportsWdaLaunchTimeoutOption;
import io.appium.java_client.ios.options.wda.SupportsWdaLocalPortOption;
import io.appium.java_client.ios.options.wda.SupportsWdaStartupRetriesOption;
import io.appium.java_client.ios.options.wda.SupportsWdaStartupRetryIntervalOption;
import io.appium.java_client.ios.options.wda.SupportsWebDriverAgentUrlOption;
import io.appium.java_client.ios.options.wda.SupportsXcodeCertificateOptions;
import io.appium.java_client.remote.AutomationName;
import io.appium.java_client.remote.MobilePlatform;
import io.appium.java_client.remote.options.BaseOptions;
Expand Down Expand Up @@ -56,7 +89,40 @@ public class XCUITestOptions extends BaseOptions<XCUITestOptions> implements
SupportsOtherAppsOption<XCUITestOptions>,
SupportsAppPushTimeoutOption<XCUITestOptions>,
SupportsAppInstallStrategyOption<XCUITestOptions>,
// TODO: WebDriverAgent options: https://github.com/appium/appium-xcuitest-driver#webdriveragent
// WebDriverAgent options: https://github.com/appium/appium-xcuitest-driver#webdriveragent
SupportsXcodeCertificateOptions<XCUITestOptions>,
SupportsKeychainOptions<XCUITestOptions>,
SupportsUpdatedWdaBundleIdOption<XCUITestOptions>,
SupportsDerivedDataPathOption<XCUITestOptions>,
SupportsWebDriverAgentUrlOption<XCUITestOptions>,
SupportsUseNewWdaOption<XCUITestOptions>,
SupportsWdaLaunchTimeoutOption<XCUITestOptions>,
SupportsWdaConnectionTimeoutOption<XCUITestOptions>,
SupportsWdaStartupRetriesOption<XCUITestOptions>,
SupportsWdaStartupRetryIntervalOption<XCUITestOptions>,
SupportsWdaLocalPortOption<XCUITestOptions>,
SupportsWdaBaseUrlOption<XCUITestOptions>,
SupportsShowXcodeLogOption<XCUITestOptions>,
SupportsUsePrebuiltWdaOption<XCUITestOptions>,
SupportsShouldUseSingletonTestManagerOption<XCUITestOptions>,
SupportsWaitForIdleTimeoutOption<XCUITestOptions>,
SupportsUseXctestrunFileOption<XCUITestOptions>,
SupportsUseSimpleBuildTestOption<XCUITestOptions>,
SupportsWdaEventloopIdleDelayOption<XCUITestOptions>,
SupportsProcessArgumentsOption<XCUITestOptions>,
SupportsAllowProvisioningDeviceRegistrationOption<XCUITestOptions>,
SupportsResultBundlePathOption<XCUITestOptions>,
SupportsMaxTypingFrequencyOption<XCUITestOptions>,
SupportsSimpleIsVisibleCheckOption<XCUITestOptions>,
SupportsWaitForQuiescenceOption<XCUITestOptions>,
SupportsMjpegServerPortOption<XCUITestOptions>,
SupportsScreenshotQualityOption<XCUITestOptions>,
SupportsAutoAcceptAlertsOption<XCUITestOptions>,
SupportsAutoDismissAlertsOption<XCUITestOptions>,
SupportsDisableAutomaticScreenshotsOption<XCUITestOptions>,
SupportsShouldTerminateAppOption<XCUITestOptions>,
SupportsForceAppLaunchOption<XCUITestOptions>,
SupportsUseNativeCachingStrategyOption<XCUITestOptions>,
// TODO: Simulator options: https://github.com/appium/appium-xcuitest-driver#simulator
SupportsOrientationOption<XCUITestOptions>,
// TODO: Web context options: https://github.com/appium/appium-xcuitest-driver#web-context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,13 @@ public interface SupportsAppInstallStrategyOption<T extends BaseOptions<T>> exte
/**
* Select application installation strategy for real devices. The following
* strategies are supported:
*
* serial (default) - pushes app files to the device in a sequential order;
* * serial (default) - pushes app files to the device in a sequential order;
* this is the least performant strategy, although the most reliable;
*
* parallel - pushes app files simultaneously; this is usually the
* * parallel - pushes app files simultaneously; this is usually the
* most performant strategy, but sometimes could not be very stable;
*
* ios-deploy - tells the driver to use a third-party tool ios-deploy to
* * ios-deploy - tells the driver to use a third-party tool ios-deploy to
* install the app; obviously the tool must be installed separately
* first and must be present in PATH before it could be used.
*
* @param strategy App installation strategy.
* @return self instance for chaining.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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.ios.options.wda;

import lombok.Data;
import lombok.ToString;

@ToString()
@Data()
public class Keychain {
private final String path;
private final String password;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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.ios.options.wda;

import lombok.ToString;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

@ToString()
public class ProcessArguments {
private final List<String> args;
private final Map<String, Object> env;

public ProcessArguments(List<String> args, Map<String, Object> env) {
this.args = args;
this.env = env;
}

public ProcessArguments(List<String> args) {
this(args, null);
}

public ProcessArguments(Map<String, Object> env) {
this(null, env);
}

/**
* Returns the data object content as a map.
*
* @return Properties as a map.
*/
public Map<String, Object> toMap() {
Map<String, Object> result = new HashMap<>();
Optional.ofNullable(args).ifPresent((v) -> result.put("args", v));
Optional.ofNullable(env).ifPresent((v) -> result.put("env", v));
Comment on lines +52 to +53
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: parenthesis could be removed

Suggested change
Optional.ofNullable(args).ifPresent((v) -> result.put("args", v));
Optional.ofNullable(env).ifPresent((v) -> result.put("env", v));
Optional.ofNullable(args).ifPresent(v -> result.put("args", v));
Optional.ofNullable(env).ifPresent(v -> result.put("env", v));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep them for better readability

return Collections.unmodifiableMap(result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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.ios.options.wda;

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 SupportsAllowProvisioningDeviceRegistrationOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String ALLOW_PROVISIONING_DEVICE_REGISTRATION_OPTION = "allowProvisioningDeviceRegistration";

/**
* Allows xcodebuild to register your destination device on the developer portal.
*
* @return self instance for chaining.
*/
default T allowProvisioningDeviceRegistration() {
return amend(ALLOW_PROVISIONING_DEVICE_REGISTRATION_OPTION, true);
}

/**
* Allow xcodebuild to register your destination device on the developer portal
* if necessary. Requires a developer account to have been added in Xcode's Accounts
* preference pane. Defaults to false.
*
* @param value Whether to allow xcodebuild to register your destination device on the developer portal.
* @return self instance for chaining.
*/
default T setAllowProvisioningDeviceRegistration(boolean value) {
return amend(ALLOW_PROVISIONING_DEVICE_REGISTRATION_OPTION, value);
}

/**
* Get whether to allow xcodebuild to register your destination device on the developer portal.
*
* @return True or false.
*/
default Optional<Boolean> doesAllowProvisioningDeviceRegistration() {
return Optional.ofNullable(toSafeBoolean(getCapability(ALLOW_PROVISIONING_DEVICE_REGISTRATION_OPTION)));
}
}
Loading