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
13 changes: 12 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ variables:

jobs:
- job: Android_E2E_Tests
# timeoutInMinutes: '90'
steps:
- template: .azure-templates/bootstrap_steps.yml
- script: |
Expand Down Expand Up @@ -61,3 +60,15 @@ jobs:
publishJUnitResults: true
tasks: 'build'
options: 'xcuiTest -x checkstyleTest -x test'
- job: Misc_Tests
steps:
- task: Gradle@2
inputs:
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: "$(JDK_VERSION)"
jdkArchitectureOption: 'x64'
publishJUnitResults: true
tasks: 'build'
options: 'miscTest -x checkstyleTest -x test -x signMavenJavaPublication'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
options: 'miscTest -x checkstyleTest -x test -x signMavenJavaPublication'
options: 'miscTest -x checkstyleTest -x test'

it seems exclusion of signMavenJavaPublication is not needed anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

was not sure about this one. How do you see it's not needed?

Copy link
Collaborator

@valfirst valfirst Oct 29, 2021

Choose a reason for hiding this comment

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

I'm running it locally without exclusion and it doesn't fail

Copy link
Collaborator

Choose a reason for hiding this comment

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

but CI could differ, so it's just my assumption

Copy link
Collaborator

Choose a reason for hiding this comment

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

Created PR to check the assumption: #1568, all builds are passed.

23 changes: 18 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,11 @@ task xcuiTest( type: Test ) {
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
filter {
includeTestsMatching '*.appium.element.generation.ios.*'
includeTestsMatching '*.appium.AppiumFluentWaitTest'
includeTestsMatching 'io.appium.java_client.ios.*'
includeTestsMatching '*.pagefactory_tests.XCUITModeTest'
includeTestsMatching '*.pagefactory_tests.widget.tests.combined.*'
includeTestsMatching '*.pagefactory_tests.widget.tests.ios.*'
includeTestsMatching '*.StartingAppLocallyTest.startingIOSAppWithCapabilitiesAndServiceTest'
includeTestsMatching '*.StartingAppLocallyTest.startingIOSAppWithCapabilitiesAndFlagsOnServerSideTest'
exclude '**/UIAutomationTest.class'
includeTestsMatching 'io.appium.java_client.service.local.StartingAppLocallyIosTest'
exclude '**/IOSScreenRecordTest.class'
exclude '**/ImagesComparisonTest.class'
}
Expand All @@ -211,5 +207,22 @@ task uiAutomationTest( type: Test ) {
includeTestsMatching 'io.appium.java_client.android.SettingTest'
includeTestsMatching 'io.appium.java_client.android.ClipboardTest'
includeTestsMatching '*.AndroidAppStringsTest'
includeTestsMatching '*.pagefactory_tests.widget.tests.android.*'
includeTestsMatching '*.pagefactory_tests.widget.tests.AndroidPageObjectTest'
includeTestsMatching 'io.appium.java_client.service.local.StartingAppLocallyAndroidTest'
includeTestsMatching 'io.appium.java_client.service.local.ServerBuilderTest'
includeTestsMatching 'io.appium.java_client.service.local.ThreadSafetyTest'
}
}

task miscTest( type: Test ) {
useJUnit()
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
filter {
includeTestsMatching 'io.appium.java_client.touch.*'
includeTestsMatching 'io.appium.java_client.events.*'
includeTestsMatching 'io.appium.java_client.remote.*'
includeTestsMatching 'io.appium.java_client.drivers.options.*'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import io.appium.java_client.android.options.mjpeg.SupportsMjpegScreenshotUrlOption;
import io.appium.java_client.android.options.mjpeg.SupportsMjpegServerPortOption;
import io.appium.java_client.android.options.other.SupportsDisableSuppressAccessibilityServiceOption;
import io.appium.java_client.android.options.server.SupportsEspressoBuildConfigOption;
import io.appium.java_client.android.options.server.SupportsEspressoServerLaunchTimeoutOption;
import io.appium.java_client.android.options.server.SupportsForceEspressoRebuildOption;
import io.appium.java_client.android.options.server.SupportsShowGradleLogOption;
Expand Down Expand Up @@ -113,6 +114,7 @@ public class EspressoOptions extends BaseOptions<EspressoOptions> implements
SupportsForceEspressoRebuildOption<EspressoOptions>,
SupportsShowGradleLogOption<EspressoOptions>,
SupportsOrientationOption<EspressoOptions>,
SupportsEspressoBuildConfigOption<EspressoOptions>,
// App options: https://github.com/appium/appium-uiautomator2-driver#app
SupportsAppOption<EspressoOptions>,
SupportsAppPackageOption<EspressoOptions>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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

import io.appium.java_client.internal.CapabilityHelpers;
import io.appium.java_client.remote.options.BaseMapOptionData;

import java.util.Map;
Expand Down Expand Up @@ -48,6 +49,6 @@ public ActivityOptions withLaunchDisplayId(int id) {
*/
public Optional<Integer> getLaunchDisplayId() {
Optional<Object> result = getOptionValue("launchDisplayId");
return result.map((v) -> Integer.parseInt(String.valueOf(v)));
return result.map(CapabilityHelpers::toInteger);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,42 @@

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

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import io.appium.java_client.internal.CapabilityHelpers;
import io.appium.java_client.remote.options.BaseMapOptionData;

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

public class EspressoBuildConfig {
public class EspressoBuildConfig extends BaseMapOptionData<EspressoBuildConfig> {
public static final String TOOLS_VERSION = "toolsVersions";
public static final String ADDITIONAL_APP_DEPENDENCIES = "additionalAppDependencies";
public static final String ADDITIONAL_ANDROID_TEST_DEPENDENCIES
= "additionalAndroidTestDependencies";

private JsonObject json;

public EspressoBuildConfig() {
}

public EspressoBuildConfig(JsonObject json) {
this.json = json;
super();
}

public EspressoBuildConfig(String json) {
this(JsonParser.parseString(json).getAsJsonObject());
super(json);
}

private EspressoBuildConfig assignToolsVersionsField(String name, Object value) {
if (json == null) {
json = new JsonObject();
}
boolean hasTools = json.has(TOOLS_VERSION);
JsonObject toolsVersions = hasTools
? json.getAsJsonObject(TOOLS_VERSION)
: new JsonObject();
if (value instanceof Number) {
toolsVersions.addProperty(name, (Number) value);
} else {
toolsVersions.addProperty(name, String.valueOf(value));
}
if (!hasTools) {
json.add(TOOLS_VERSION, toolsVersions);
Optional<Map<String, Object>> toolsVersionsOptional = getOptionValue(TOOLS_VERSION);
Map<String, Object> toolsVersions = toolsVersionsOptional.orElseGet(HashMap::new);
toolsVersions.put(name, value);
if (!toolsVersionsOptional.isPresent()) {
assignOptionValue(TOOLS_VERSION, toolsVersions);
}
return this;
}

private <R> Optional<R> getToolsVersionsFieldValue(String name) {
Optional<Map<String, Object>> toolsVersionsOptional = getOptionValue(TOOLS_VERSION);
//noinspection unchecked
return json == null || !json.has(TOOLS_VERSION)
? Optional.empty()
: Optional.ofNullable((R) json.getAsJsonObject(TOOLS_VERSION).get(name));
return toolsVersionsOptional.map((v) -> (R) v.getOrDefault(name, null));
}

/**
Expand Down Expand Up @@ -167,7 +152,7 @@ public EspressoBuildConfig withMinSdk(int apiLevel) {
*/
public Optional<Integer> getMinSdkVersion() {
Optional<Object> result = getToolsVersionsFieldValue("minSdk");
return result.map((v) -> Integer.parseInt(String.valueOf(v)));
return result.map(CapabilityHelpers::toInteger);
}

/**
Expand All @@ -188,7 +173,7 @@ public EspressoBuildConfig withTargetSdk(int apiLevel) {
*/
public Optional<Integer> getTargetSdkVersion() {
Optional<Object> result = getToolsVersionsFieldValue("targetSdk");
return result.map((v) -> Integer.parseInt(String.valueOf(v)));
return result.map(CapabilityHelpers::toInteger);
}

/**
Expand All @@ -211,35 +196,6 @@ public Optional<String> getKotlinVersion() {
return getToolsVersionsFieldValue("kotlin");
}

private EspressoBuildConfig assignDependenciesField(String name, List<String> value) {
if (json == null) {
json = new JsonObject();
}
boolean hasField = json.has(name);
JsonArray dependencies = hasField
? json.getAsJsonArray(name)
: new JsonArray();
while (dependencies.size() > 0) {
dependencies.remove(0);
}
value.forEach(dependencies::add);
if (!hasField) {
json.add(name, dependencies);
}
return this;
}

private Optional<List<String>> getDependenciesValue(String name) {
return json == null
? Optional.empty()
: Optional.ofNullable(json.getAsJsonArray(name))
.map((v) -> {
List<String> result = new ArrayList<>();
v.forEach((x) -> result.add(String.valueOf(x)));
return result;
});
}

/**
* Set a non-empty array of dependent module names with their versions.
* The scripts add all these items as "implementation" lines of dependencies
Expand All @@ -249,7 +205,7 @@ private Optional<List<String>> getDependenciesValue(String name) {
* @return self instance for chaining.
*/
public EspressoBuildConfig withAdditionalAppDependencies(List<String> dependencies) {
return assignDependenciesField(ADDITIONAL_APP_DEPENDENCIES, dependencies);
return assignOptionValue(ADDITIONAL_APP_DEPENDENCIES, dependencies);
}

/**
Expand All @@ -258,7 +214,7 @@ public EspressoBuildConfig withAdditionalAppDependencies(List<String> dependenci
* @return Dependent module names with their versions.
*/
public Optional<List<String>> getAdditionalAppDependencies() {
return getDependenciesValue(ADDITIONAL_APP_DEPENDENCIES);
return getOptionValue(ADDITIONAL_APP_DEPENDENCIES);
}

/**
Expand All @@ -270,7 +226,7 @@ public Optional<List<String>> getAdditionalAppDependencies() {
* @return self instance for chaining.
*/
public EspressoBuildConfig withAdditionalAndroidTestDependencies(List<String> dependencies) {
return assignDependenciesField(ADDITIONAL_ANDROID_TEST_DEPENDENCIES, dependencies);
return assignOptionValue(ADDITIONAL_ANDROID_TEST_DEPENDENCIES, dependencies);
}

/**
Expand All @@ -279,15 +235,6 @@ public EspressoBuildConfig withAdditionalAndroidTestDependencies(List<String> de
* @return Dependent module names with their versions.
*/
public Optional<List<String>> getAdditionalAndroidTestDependencies() {
return getDependenciesValue(ADDITIONAL_ANDROID_TEST_DEPENDENCIES);
}

public JsonObject toJson() {
return Optional.ofNullable(json).orElseGet(JsonObject::new);
}

@Override
public String toString() {
return toJson().toString();
return getOptionValue(ADDITIONAL_ANDROID_TEST_DEPENDENCIES);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ default T setEspressoBuildConfig(String configPath) {
* @return self instance for chaining.
*/
default T setEspressoBuildConfig(EspressoBuildConfig config) {
return amend(ESPRESSO_BUILD_CONFIG_OPTION, config.toJson().toString());
return amend(ESPRESSO_BUILD_CONFIG_OPTION, config.toString());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public interface SupportsKeystoreOptions<T extends BaseOptions<T>> extends
* @param keystoreConfig The keystore config to use.
* @return self instance for chaining.
*/
default T useKeystore(KeystoreConfig keystoreConfig) {
default T setKeystoreConfig(KeystoreConfig keystoreConfig) {
return amend(USE_KEYSTORE_OPTION, true)
.amend(KEYSTORE_PATH_OPTION, keystoreConfig.getPath())
.amend(KEYSTORE_PASSWORD_OPTION, keystoreConfig.getPassword())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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.other;

import io.appium.java_client.internal.CapabilityHelpers;
import io.appium.java_client.remote.options.BaseMapOptionData;

import java.time.Duration;
import java.util.Map;
import java.util.Optional;

public class CommandTimeouts extends BaseMapOptionData<CommandTimeouts> {
public static final String DEFAULT_COMMAND = "default";

public CommandTimeouts() {
}

public CommandTimeouts(Map<String, Object> timeouts) {
super(timeouts);
}

public CommandTimeouts(String json) {
super(json);
}

/**
* Sets the timeout for the particular Appium command that
* is proxied to WDA.
* Command names you can find in logs, look for
* "Executing command 'command_name'" records.
* Timeout value is expected to contain max milliseconds to wait for
* the given WDA command to be executed before terminating the session forcefully.
*
* @param commandName The command name.
* @param timeout Command timeout.
* @return self instance for chaining.
*/
public CommandTimeouts withCommandTimeout(String commandName, Duration timeout) {
return assignOptionValue(commandName, timeout.toMillis());
}

/**
* Sets the default timeout for all Appium commands that
* are proxied to WDA.
*
* @param timeout Commands timeout.
* @return self instance for chaining.
*/
public CommandTimeouts withDefaultCommandTimeout(Duration timeout) {
return withCommandTimeout(DEFAULT_COMMAND, timeout);
}

/**
* Get the command timeout.
*
* @param commandName The command name
* @return Timeout value.
*/
public Optional<Duration> getCommandTimeout(String commandName) {
Optional<Object> result = getOptionValue(commandName);
return result.map(CapabilityHelpers::toDuration);
}
}
Loading