1
0
Fork 0

For #6479: Update UI test for new ETP screen

master
mcarare 2020-02-13 15:37:20 +02:00 committed by Jeff Boek
parent bba563b5f9
commit ccf4722c5f
1 changed files with 25 additions and 2 deletions

View File

@ -6,13 +6,18 @@
package org.mozilla.fenix.ui.robots package org.mozilla.fenix.ui.robots
import android.view.View
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.UiController
import androidx.test.espresso.ViewAction
import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withResourceName import androidx.test.espresso.matcher.ViewMatchers.withResourceName
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiDevice
import org.hamcrest.CoreMatchers import org.hamcrest.CoreMatchers
import org.hamcrest.Matcher
import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.helpers.click import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.isChecked import org.mozilla.fenix.helpers.isChecked
@ -38,8 +43,26 @@ class SettingsSubMenuEnhancedTrackingProtectionRobot {
return SettingsRobot.Transition() return SettingsRobot.Transition()
} }
fun openExceptions(interact: SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot.() -> Unit): SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot.Transition { fun openExceptions(
openExceptions().click() interact: SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot.() -> Unit
): SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot.Transition {
TestHelper.scrollToElementByText("Exceptions")
openExceptions().perform(
object : ViewAction {
override fun getConstraints(): Matcher<View> {
// do not check constraints, check if enabled
return ViewMatchers.isEnabled()
}
override fun getDescription(): String {
return "Exceptions"
}
override fun perform(uiController: UiController?, view: View) {
view.performClick()
}
}
)
SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot().interact() SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot().interact()
return SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot.Transition() return SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot.Transition()