summaryrefslogtreecommitdiffhomepage
path: root/android/test/common
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2023-03-22 09:07:53 +0100
committerAlbin <albin@mullvad.net>2023-03-22 10:39:58 +0100
commit68c356e5afa2165cadef86d43966e51d9203102c (patch)
tree0a172dacad334066be40ea1239691ed963139dac /android/test/common
parente5d106c9260e0f282c75d105da7b0247535cdfdd (diff)
downloadmullvadvpn-68c356e5afa2165cadef86d43966e51d9203102c.tar.xz
mullvadvpn-68c356e5afa2165cadef86d43966e51d9203102c.zip
Apply project-wide `kotlinLangStyle` formatting
Diffstat (limited to 'android/test/common')
-rw-r--r--android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/extension/UiAutomatorExtensions.kt15
-rw-r--r--android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/interactor/AppInteractor.kt28
-rw-r--r--android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/rule/CaptureScreenshotOnFailedTestRule.kt33
3 files changed, 31 insertions, 45 deletions
diff --git a/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/extension/UiAutomatorExtensions.kt b/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/extension/UiAutomatorExtensions.kt
index 59905d72e2..19cc5a8b93 100644
--- a/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/extension/UiAutomatorExtensions.kt
+++ b/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/extension/UiAutomatorExtensions.kt
@@ -22,10 +22,7 @@ fun UiDevice.findObjectWithTimeout(
timeout: Long = DEFAULT_INTERACTION_TIMEOUT
): UiObject2 {
- wait(
- Until.hasObject(selector),
- timeout
- )
+ wait(Until.hasObject(selector), timeout)
return try {
findObject(selector)
@@ -50,10 +47,7 @@ fun UiDevice.clickAllowOnNotificationPermissionPromptIfApiLevel31AndAbove(
val selector = By.text("Allow")
- wait(
- Until.hasObject(selector),
- timeout
- )
+ wait(Until.hasObject(selector), timeout)
try {
findObjectWithTimeout(selector).click()
@@ -69,10 +63,7 @@ fun UiObject2.findObjectWithTimeout(
timeout: Long = DEFAULT_INTERACTION_TIMEOUT
): UiObject2 {
- wait(
- Until.hasObject(selector),
- timeout
- )
+ wait(Until.hasObject(selector), timeout)
return try {
findObject(selector)
diff --git a/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/interactor/AppInteractor.kt b/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/interactor/AppInteractor.kt
index d3b2abe7ae..d5a2e5176b 100644
--- a/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/interactor/AppInteractor.kt
+++ b/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/interactor/AppInteractor.kt
@@ -20,10 +20,7 @@ import net.mullvad.mullvadvpn.test.common.extension.clickAgreeOnPrivacyDisclaime
import net.mullvad.mullvadvpn.test.common.extension.clickAllowOnNotificationPermissionPromptIfApiLevel31AndAbove
import net.mullvad.mullvadvpn.test.common.extension.findObjectWithTimeout
-class AppInteractor(
- private val device: UiDevice,
- private val targetContext: Context
-) {
+class AppInteractor(private val device: UiDevice, private val targetContext: Context) {
fun launch(customApiEndpointConfiguration: CustomApiEndpointConfiguration? = null) {
device.pressHome()
// Wait for launcher
@@ -41,10 +38,7 @@ class AppInteractor(
}
}
targetContext.startActivity(intent)
- device.wait(
- Until.hasObject(By.pkg(MULLVAD_PACKAGE).depth(0)),
- APP_LAUNCH_TIMEOUT
- )
+ device.wait(Until.hasObject(By.pkg(MULLVAD_PACKAGE).depth(0)), APP_LAUNCH_TIMEOUT)
}
fun launchAndEnsureLoggedIn(accountToken: String) {
@@ -56,8 +50,10 @@ class AppInteractor(
}
fun attemptLogin(accountToken: String) {
- val loginObject = device.findObjectWithTimeout(By.clazz("android.widget.EditText"))
- .apply { text = accountToken }
+ val loginObject =
+ device.findObjectWithTimeout(By.clazz("android.widget.EditText")).apply {
+ text = accountToken
+ }
loginObject.parent.findObject(By.clazz(ImageButton::class.java)).click()
}
@@ -67,10 +63,10 @@ class AppInteractor(
fun extractIpAddress(): String {
device.findObjectWithTimeout(By.res(TUNNEL_INFO_ID)).click()
- return device.findObjectWithTimeout(
- By.res(TUNNEL_OUT_ADDRESS_ID),
- CONNECTION_TIMEOUT
- ).text.extractIpAddress()
+ return device
+ .findObjectWithTimeout(By.res(TUNNEL_OUT_ADDRESS_ID), CONNECTION_TIMEOUT)
+ .text
+ .extractIpAddress()
}
fun clickSettingsCog() {
@@ -85,9 +81,7 @@ class AppInteractor(
device.findObjectWithTimeout(By.text(text)).click()
}
- fun waitForLoginPrompt(
- timeout: Long = LOGIN_PROMPT_TIMEOUT
- ) {
+ fun waitForLoginPrompt(timeout: Long = LOGIN_PROMPT_TIMEOUT) {
device.findObjectWithTimeout(By.text("Login"), timeout)
}
diff --git a/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/rule/CaptureScreenshotOnFailedTestRule.kt b/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/rule/CaptureScreenshotOnFailedTestRule.kt
index 138d09cc28..c7b8992292 100644
--- a/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/rule/CaptureScreenshotOnFailedTestRule.kt
+++ b/android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/rule/CaptureScreenshotOnFailedTestRule.kt
@@ -60,10 +60,7 @@ class CaptureScreenshotOnFailedTestRule(private val testTag: String) : TestWatch
) {
contentValues.apply {
put(MediaStore.MediaColumns.DISPLAY_NAME, filename)
- put(
- MediaStore.Images.Media.RELATIVE_PATH,
- "$DIRECTORY_PICTURES/$baseDir"
- )
+ put(MediaStore.Images.Media.RELATIVE_PATH, "$DIRECTORY_PICTURES/$baseDir")
}
val uri =
@@ -89,14 +86,17 @@ class CaptureScreenshotOnFailedTestRule(private val testTag: String) : TestWatch
baseDir: String,
filename: String
) {
- val screenshotBaseDirectory = Paths.get(
- Environment.getExternalStoragePublicDirectory(DIRECTORY_PICTURES).path,
- baseDir,
- ).toFile().apply {
- if (exists().not()) {
- mkdirs()
- }
- }
+ val screenshotBaseDirectory =
+ Paths.get(
+ Environment.getExternalStoragePublicDirectory(DIRECTORY_PICTURES).path,
+ baseDir,
+ )
+ .toFile()
+ .apply {
+ if (exists().not()) {
+ mkdirs()
+ }
+ }
FileOutputStream(File(screenshotBaseDirectory, filename)).use { outputStream ->
try {
this.compress(Bitmap.CompressFormat.JPEG, 50, outputStream)
@@ -107,8 +107,9 @@ class CaptureScreenshotOnFailedTestRule(private val testTag: String) : TestWatch
contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues)
}
- private fun createBaseScreenshotContentValues() = ContentValues().apply {
- put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg")
- put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis())
- }
+ private fun createBaseScreenshotContentValues() =
+ ContentValues().apply {
+ put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg")
+ put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis())
+ }
}