|
|
|
@ -7,9 +7,10 @@
|
|
|
|
|
package org.mozilla.fenix.ui.robots
|
|
|
|
|
|
|
|
|
|
import android.os.Build
|
|
|
|
|
import android.util.Log
|
|
|
|
|
import androidx.test.espresso.Espresso.onView
|
|
|
|
|
import androidx.test.espresso.ViewInteraction
|
|
|
|
|
import androidx.test.espresso.action.ViewActions
|
|
|
|
|
import androidx.test.espresso.action.ViewActions.click
|
|
|
|
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers
|
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.hasSibling
|
|
|
|
@ -21,6 +22,7 @@ import androidx.test.espresso.matcher.ViewMatchers.withText
|
|
|
|
|
import org.hamcrest.CoreMatchers.allOf
|
|
|
|
|
import org.hamcrest.Matchers.endsWith
|
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
|
import org.mozilla.fenix.helpers.Constants.TAG
|
|
|
|
|
import org.mozilla.fenix.helpers.DataGenerationHelper.getStringResource
|
|
|
|
|
import org.mozilla.fenix.helpers.TestHelper.hasCousin
|
|
|
|
|
import org.mozilla.fenix.helpers.TestHelper.mDevice
|
|
|
|
@ -31,26 +33,66 @@ import org.mozilla.fenix.helpers.click
|
|
|
|
|
*/
|
|
|
|
|
class SettingsSubMenuCustomizeRobot {
|
|
|
|
|
|
|
|
|
|
fun verifyThemes() = assertThemes()
|
|
|
|
|
fun verifyThemes() {
|
|
|
|
|
Log.i(TAG, "verifyThemes: Trying to verify that the \"Light\" mode option is visible")
|
|
|
|
|
lightModeToggle()
|
|
|
|
|
.check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
|
|
|
|
Log.i(TAG, "verifyThemes: Verified that the \"Light\" mode option is visible")
|
|
|
|
|
Log.i(TAG, "verifyThemes: Trying to verify that the \"Dark\" mode option is visible")
|
|
|
|
|
darkModeToggle()
|
|
|
|
|
.check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
|
|
|
|
Log.i(TAG, "verifyThemes: Verified that the \"Dark\" mode option is visible")
|
|
|
|
|
Log.i(TAG, "verifyThemes: Trying to verify that the \"Follow device theme\" option is visible")
|
|
|
|
|
deviceModeToggle()
|
|
|
|
|
.check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
|
|
|
|
Log.i(TAG, "verifyThemes: Verified that the \"Follow device theme\" option is visible")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun selectDarkMode() = darkModeToggle().click()
|
|
|
|
|
fun selectDarkMode() {
|
|
|
|
|
Log.i(TAG, "selectDarkMode: Trying to click the \"Dark\" mode option")
|
|
|
|
|
darkModeToggle().click()
|
|
|
|
|
Log.i(TAG, "selectDarkMode: Clicked the \"Dark\" mode option")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun selectLightMode() = lightModeToggle().click()
|
|
|
|
|
fun selectLightMode() {
|
|
|
|
|
Log.i(TAG, "selectLightMode: Trying to click the \"Light\" mode option")
|
|
|
|
|
lightModeToggle().click()
|
|
|
|
|
Log.i(TAG, "selectLightMode: Clicked the \"Light\" mode option")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickTopToolbarToggle() = topToolbarToggle().click()
|
|
|
|
|
fun clickTopToolbarToggle() {
|
|
|
|
|
Log.i(TAG, "clickTopToolbarToggle: Trying to click the \"Top\" toolbar option")
|
|
|
|
|
topToolbarToggle().click()
|
|
|
|
|
Log.i(TAG, "clickTopToolbarToggle: Clicked the \"Top\" toolbar option")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickBottomToolbarToggle() = bottomToolbarToggle().click()
|
|
|
|
|
fun clickBottomToolbarToggle() {
|
|
|
|
|
Log.i(TAG, "clickBottomToolbarToggle: Trying to click the \"Bottom\" toolbar option")
|
|
|
|
|
bottomToolbarToggle().click()
|
|
|
|
|
Log.i(TAG, "clickBottomToolbarToggle: Clicked the \"Bottom\" toolbar option")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifyToolbarPositionPreference(selectedPosition: String) {
|
|
|
|
|
Log.i(TAG, "verifyToolbarPositionPreference: Trying to verify that the $selectedPosition toolbar option is checked")
|
|
|
|
|
onView(withText(selectedPosition))
|
|
|
|
|
.check(matches(hasSibling(allOf(withId(R.id.radio_button), isChecked()))))
|
|
|
|
|
Log.i(TAG, "verifyToolbarPositionPreference: Verified that the $selectedPosition toolbar option is checked")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickSwipeToolbarToSwitchTabToggle() = swipeToolbarToggle().click()
|
|
|
|
|
fun clickSwipeToolbarToSwitchTabToggle() {
|
|
|
|
|
Log.i(TAG, "clickSwipeToolbarToSwitchTabToggle: Trying to click the \"Swipe toolbar sideways to switch tabs\" toggle")
|
|
|
|
|
swipeToolbarToggle().click()
|
|
|
|
|
Log.i(TAG, "clickSwipeToolbarToSwitchTabToggle: Clicked the \"Swipe toolbar sideways to switch tabs\" toggle")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickPullToRefreshToggle() = pullToRefreshToggle().click()
|
|
|
|
|
fun clickPullToRefreshToggle() {
|
|
|
|
|
Log.i(TAG, "clickPullToRefreshToggle: Trying to click the \"Pull to refresh\" toggle")
|
|
|
|
|
pullToRefreshToggle().click()
|
|
|
|
|
Log.i(TAG, "clickPullToRefreshToggle: Clicked the \"Pull to refresh\" toggle")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifySwipeToolbarGesturePrefState(isEnabled: Boolean) {
|
|
|
|
|
Log.i(TAG, "verifySwipeToolbarGesturePrefState: Trying to verify that the \"Swipe toolbar sideways to switch tabs\" toggle is checked: $isEnabled")
|
|
|
|
|
swipeToolbarToggle()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
@ -66,9 +108,11 @@ class SettingsSubMenuCustomizeRobot {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
Log.i(TAG, "verifySwipeToolbarGesturePrefState: Verified that the \"Swipe toolbar sideways to switch tabs\" toggle is checked: $isEnabled")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun verifyPullToRefreshGesturePrefState(isEnabled: Boolean) {
|
|
|
|
|
Log.i(TAG, "verifyPullToRefreshGesturePrefState: Trying to verify that the \"Pull to refresh\" toggle is checked: $isEnabled")
|
|
|
|
|
pullToRefreshToggle()
|
|
|
|
|
.check(
|
|
|
|
|
matches(
|
|
|
|
@ -84,12 +128,17 @@ class SettingsSubMenuCustomizeRobot {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
Log.i(TAG, "verifyPullToRefreshGesturePrefState: Verified that the \"Pull to refresh\" toggle is checked: $isEnabled")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Transition {
|
|
|
|
|
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
|
|
|
|
|
Log.i(TAG, "goBack: Waiting for device to be idle")
|
|
|
|
|
mDevice.waitForIdle()
|
|
|
|
|
goBackButton().perform(ViewActions.click())
|
|
|
|
|
Log.i(TAG, "goBack: Waited for device to be idle")
|
|
|
|
|
Log.i(TAG, "goBack: Trying to click the navigate up toolbar button")
|
|
|
|
|
goBackButton().perform(click())
|
|
|
|
|
Log.i(TAG, "goBack: Clicked the navigate up toolbar button")
|
|
|
|
|
|
|
|
|
|
SettingsRobot().interact()
|
|
|
|
|
return SettingsRobot.Transition()
|
|
|
|
@ -97,15 +146,6 @@ class SettingsSubMenuCustomizeRobot {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun assertThemes() {
|
|
|
|
|
lightModeToggle()
|
|
|
|
|
.check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
|
|
|
|
darkModeToggle()
|
|
|
|
|
.check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
|
|
|
|
deviceModeToggle()
|
|
|
|
|
.check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun darkModeToggle() = onView(withText("Dark"))
|
|
|
|
|
|
|
|
|
|
private fun lightModeToggle() = onView(withText("Light"))
|
|
|
|
|