Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIA-649 - Implement method to clear app state after each test #34

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
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ dependencies {
androidTestImplementation 'com.github.gmazzo:okhttp-mock:1.3.2'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:core:1.4.0'
androidTestUtil 'androidx.test:orchestrator:1.4.2'

// EventBus
implementation 'org.greenrobot:eventbus:3.1.1'
Expand Down Expand Up @@ -139,6 +140,7 @@ android {
useSupportLibrary = true
}
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
testInstrumentationRunnerArguments clearPackageData: 'true'
}

sourceSets {
Expand Down Expand Up @@ -188,6 +190,7 @@ android {
}

testOptions { //Used for testing as TextUtils isn't available when testing.
execution 'ANDROIDX_TEST_ORCHESTRATOR'
unitTests {
all {
jvmArgs '-noverify'
Expand Down
3 changes: 2 additions & 1 deletion app/src/androidTest/java/helpers/ActionHelpers.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.privateinternetaccess.android.helpers

import androidx.test.uiautomator.UiObject
import com.privateinternetaccess.android.core.BaseUiAutomatorClass.Companion.defaultTimeOut

object ActionHelpers {

fun clickIfExists(primaryUiObject : UiObject, secondaryUiObj: UiObject? = null) {
if (primaryUiObject.exists()) {
(secondaryUiObj ?: primaryUiObject).click()
(secondaryUiObj ?: primaryUiObject).clickAndWaitForNewWindow(defaultTimeOut)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SignInStepObjects {
private val signInPageObjects = SignInPageObjects()

fun allowNotifications() {
clickIfExists(signInPageObjects.notificationPrompt, signInPageObjects.allowNotifications)
clickIfExists(signInPageObjects.allowNotifications, signInPageObjects.allowNotifications)
}

fun reachSignInScreen() {
Expand Down