-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'create-a-pop-wip-poc-pr-droid-1435'
- Loading branch information
Showing
5 changed files
with
119 additions
and
18 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/page/ConnectPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package net.mullvad.mullvadvpn.test.common.page | ||
|
||
import androidx.test.uiautomator.By | ||
import net.mullvad.mullvadvpn.test.common.extension.findObjectWithTimeout | ||
|
||
class ConnectPage internal constructor() : Page() { | ||
override fun assertIsDisplayed() { | ||
uiDevice.findObjectWithTimeout(By.res("connect_card_header_test_tag")) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/page/LoginPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package net.mullvad.mullvadvpn.test.common.page | ||
|
||
import android.widget.Button | ||
import androidx.test.uiautomator.By | ||
import androidx.test.uiautomator.Until | ||
import net.mullvad.mullvadvpn.test.common.constant.DEFAULT_TIMEOUT | ||
import net.mullvad.mullvadvpn.test.common.constant.EXTREMELY_LONG_TIMEOUT | ||
import net.mullvad.mullvadvpn.test.common.extension.findObjectWithTimeout | ||
|
||
class LoginPage internal constructor() : Page() { | ||
fun enterAccountNumber(accountNumber: String) { | ||
uiDevice.findObjectWithTimeout(By.clazz("android.widget.EditText")).text = accountNumber | ||
} | ||
|
||
fun tapLoginButton() { | ||
val accountTextField = uiDevice.findObjectWithTimeout(By.clazz("android.widget.EditText")) | ||
val loginButton = accountTextField.parent.findObject(By.clazz(Button::class.java)) | ||
loginButton.wait(Until.enabled(true), DEFAULT_TIMEOUT) | ||
loginButton.click() | ||
} | ||
|
||
fun verifyShowingInvalidAccount() { | ||
uiDevice.findObjectWithTimeout(By.text("Invalid account number"), EXTREMELY_LONG_TIMEOUT) | ||
} | ||
|
||
override fun assertIsDisplayed() { | ||
uiDevice.findObjectWithTimeout(By.text("Login")) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/page/Page.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package net.mullvad.mullvadvpn.test.common.page | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.uiautomator.UiDevice | ||
|
||
sealed class Page { | ||
protected val uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | ||
|
||
abstract fun assertIsDisplayed() | ||
} | ||
|
||
inline fun <reified T : Page> on(scope: T.() -> Unit = {}) { | ||
val page = T::class.java.getConstructor().newInstance() | ||
page.assertIsDisplayed() | ||
return page.scope() | ||
} |
38 changes: 38 additions & 0 deletions
38
android/test/common/src/main/kotlin/net/mullvad/mullvadvpn/test/common/page/PrivacyPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package net.mullvad.mullvadvpn.test.common.page | ||
|
||
import android.os.Build | ||
import androidx.test.uiautomator.By | ||
import androidx.test.uiautomator.Until | ||
import net.mullvad.mullvadvpn.test.common.constant.DEFAULT_TIMEOUT | ||
import net.mullvad.mullvadvpn.test.common.extension.findObjectWithTimeout | ||
|
||
class PrivacyPage internal constructor() : Page() { | ||
override fun assertIsDisplayed() { | ||
uiDevice.findObjectWithTimeout(By.text("Privacy")) | ||
} | ||
|
||
fun clickAgreeOnPrivacyDisclaimer() { | ||
uiDevice.findObjectWithTimeout(By.text("Agree and continue")).click() | ||
} | ||
|
||
fun clickAllowOnNotificationPermissionPromptIfApiLevel33AndAbove( | ||
timeout: Long = DEFAULT_TIMEOUT | ||
) { | ||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { | ||
// Skipping as notification permissions are not shown. | ||
return | ||
} | ||
|
||
val selector = By.text("Allow") | ||
|
||
uiDevice.wait(Until.hasObject(selector), timeout) | ||
|
||
try { | ||
uiDevice.findObjectWithTimeout(selector).click() | ||
} catch (e: IllegalArgumentException) { | ||
throw IllegalArgumentException( | ||
"Failed to allow notification permission within timeout ($timeout)" | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters