summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorDavid Göransson <david.goransson@mullvad.net>2024-11-14 08:32:38 +0100
committerDavid Göransson <david.goransson@mullvad.net>2024-11-18 11:47:05 +0100
commite2124a742e6d16c8ccb8c55b297a8df45250cca7 (patch)
tree2711577a37ea01a833eb29fd75b0f6255d03d761 /android
parent0b91d6513bda18d9a753c51465129eba23145d75 (diff)
downloadmullvadvpn-e2124a742e6d16c8ccb8c55b297a8df45250cca7.tar.xz
mullvadvpn-e2124a742e6d16c8ccb8c55b297a8df45250cca7.zip
Convert build to runtime arguments
Diffstat (limited to 'android')
-rwxr-xr-xandroid/scripts/run-instrumented-tests.sh4
-rw-r--r--android/test/e2e/build.gradle.kts4
-rw-r--r--android/test/e2e/e2e.properties2
-rw-r--r--android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HasDependencyOnLocalAPI.kt10
-rw-r--r--android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HighlyRateLimited.kt12
-rw-r--r--android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/constant/Constants.kt3
6 files changed, 23 insertions, 12 deletions
diff --git a/android/scripts/run-instrumented-tests.sh b/android/scripts/run-instrumented-tests.sh
index fb80995739..055112fb43 100755
--- a/android/scripts/run-instrumented-tests.sh
+++ b/android/scripts/run-instrumented-tests.sh
@@ -132,8 +132,8 @@ case "$TEST_TYPE" in
echo "Error: The variable PARTNER_AUTH or VALID_TEST_ACCOUNT_NUMBER must be set."
exit 1
fi
- OPTIONAL_TEST_ARGUMENTS+=" -e ENABLE_HIGHLY_RATE_LIMITED_TESTS $ENABLE_HIGHLY_RATE_LIMITED_TESTS"
- OPTIONAL_TEST_ARGUMENTS+=" -e ENABLE_ACCESS_TO_LOCAL_API_TESTS $ENABLE_ACCESS_TO_LOCAL_API_TESTS"
+ OPTIONAL_TEST_ARGUMENTS+=" -e enable_access_to_local_api_tests $ENABLE_ACCESS_TO_LOCAL_API_TESTS"
+ OPTIONAL_TEST_ARGUMENTS+=" -e enable_highly_rate_limited_tests $ENABLE_HIGHLY_RATE_LIMITED_TESTS"
USE_ORCHESTRATOR="true"
PACKAGE_NAME="net.mullvad.mullvadvpn"
if [[ "$INFRA_FLAVOR" =~ ^(devmole|stagemole)$ ]]; then
diff --git a/android/test/e2e/build.gradle.kts b/android/test/e2e/build.gradle.kts
index 83df4008be..4b1b2b9d60 100644
--- a/android/test/e2e/build.gradle.kts
+++ b/android/test/e2e/build.gradle.kts
@@ -35,8 +35,6 @@ android {
Properties().apply {
load(project.file("e2e.properties").inputStream())
addRequiredPropertyAsBuildConfigField("API_VERSION")
- addRequiredPropertyAsBuildConfigField("ENABLE_HIGHLY_RATE_LIMITED_TESTS")
- addRequiredPropertyAsBuildConfigField("ENABLE_ACCESS_TO_LOCAL_API_TESTS")
addRequiredPropertyAsBuildConfigField("TRAFFIC_GENERATION_IP_ADDRESS")
addRequiredPropertyAsBuildConfigField("PACKET_CAPTURE_API_HOST")
}
@@ -54,6 +52,8 @@ android {
testInstrumentationRunnerArguments +=
mutableMapOf<String, String>().apply {
put("clearPackageData", "true")
+ addOptionalPropertyAsArgument("enable_access_to_local_api_tests")
+ addOptionalPropertyAsArgument("enable_highly_rate_limited_tests")
addOptionalPropertyAsArgument("valid_test_account_number")
addOptionalPropertyAsArgument("invalid_test_account_number")
}
diff --git a/android/test/e2e/e2e.properties b/android/test/e2e/e2e.properties
index 5f880bd2c1..db9bdd29a5 100644
--- a/android/test/e2e/e2e.properties
+++ b/android/test/e2e/e2e.properties
@@ -1,5 +1,3 @@
API_VERSION=v1
-ENABLE_HIGHLY_RATE_LIMITED_TESTS=false
-ENABLE_ACCESS_TO_LOCAL_API_TESTS=false
TRAFFIC_GENERATION_IP_ADDRESS=45.83.223.209
PACKET_CAPTURE_API_HOST=192.168.105.1
diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HasDependencyOnLocalAPI.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HasDependencyOnLocalAPI.kt
index d1381c05f1..c6c9a70ee9 100644
--- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HasDependencyOnLocalAPI.kt
+++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HasDependencyOnLocalAPI.kt
@@ -1,6 +1,8 @@
package net.mullvad.mullvadvpn.test.e2e.annotations
-import net.mullvad.mullvadvpn.test.e2e.BuildConfig
+import androidx.test.platform.app.InstrumentationRegistry
+import net.mullvad.mullvadvpn.test.e2e.constant.ENABLE_ACCESS_TO_LOCAL_API_TESTS
+import net.mullvad.mullvadvpn.test.e2e.extension.getRequiredArgument
import org.junit.jupiter.api.extension.ConditionEvaluationResult
import org.junit.jupiter.api.extension.ExecutionCondition
import org.junit.jupiter.api.extension.ExtendWith
@@ -17,7 +19,11 @@ annotation class HasDependencyOnLocalAPI {
override fun evaluateExecutionCondition(
context: ExtensionContext?
): ConditionEvaluationResult {
- val enable = BuildConfig.ENABLE_ACCESS_TO_LOCAL_API_TESTS.toBoolean()
+
+ val enable =
+ InstrumentationRegistry.getArguments()
+ .getRequiredArgument(ENABLE_ACCESS_TO_LOCAL_API_TESTS)
+ .toBoolean()
return if (enable) {
ConditionEvaluationResult.enabled(
diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HighlyRateLimited.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HighlyRateLimited.kt
index 27b139a5a8..12280fcaf1 100644
--- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HighlyRateLimited.kt
+++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HighlyRateLimited.kt
@@ -1,6 +1,8 @@
package net.mullvad.mullvadvpn.test.e2e.annotations
-import net.mullvad.mullvadvpn.test.e2e.BuildConfig
+import androidx.test.platform.app.InstrumentationRegistry
+import net.mullvad.mullvadvpn.test.e2e.constant.ENABLE_HIGHLY_RATE_LIMITED_TESTS
+import net.mullvad.mullvadvpn.test.e2e.extension.getRequiredArgument
import org.junit.jupiter.api.extension.ConditionEvaluationResult
import org.junit.jupiter.api.extension.ExecutionCondition
import org.junit.jupiter.api.extension.ExtendWith
@@ -17,10 +19,12 @@ annotation class HighlyRateLimited {
override fun evaluateExecutionCondition(
context: ExtensionContext?
): ConditionEvaluationResult {
- val enableHighlyRateLimited =
- BuildConfig.ENABLE_HIGHLY_RATE_LIMITED_TESTS.toBoolean() ?: false
+ val enable =
+ InstrumentationRegistry.getArguments()
+ .getRequiredArgument(ENABLE_HIGHLY_RATE_LIMITED_TESTS)
+ .toBoolean()
- return if (enableHighlyRateLimited) {
+ return if (enable) {
ConditionEvaluationResult.enabled("Running test highly affected by rate limiting.")
} else {
ConditionEvaluationResult.disabled(
diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/constant/Constants.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/constant/Constants.kt
index baf3dcae3d..0c221f8ddf 100644
--- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/constant/Constants.kt
+++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/constant/Constants.kt
@@ -4,3 +4,6 @@ const val LOG_TAG = "mullvad-e2e"
const val PARTNER_AUTH = "partner_auth"
const val VALID_TEST_ACCOUNT_NUMBER_ARGUMENT_KEY = "valid_test_account_number"
const val INVALID_TEST_ACCOUNT_NUMBER_ARGUMENT_KEY = "invalid_test_account_number"
+
+const val ENABLE_ACCESS_TO_LOCAL_API_TESTS = "enable_access_to_local_api_tests"
+const val ENABLE_HIGHLY_RATE_LIMITED_TESTS = "enable_highly_rate_limited_tests"