Create a robot and test class for Customize Settings menu
This commit is contained in:
parent
826cbdbaae
commit
b22fe8d3e5
|
@ -4,7 +4,8 @@
|
|||
|
||||
package org.mozilla.fenix.ui
|
||||
|
||||
import android.content.res.Configuration
|
||||
import java.time.LocalDate
|
||||
import java.util.Locale
|
||||
import okhttp3.mockwebserver.MockWebServer
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
|
@ -36,8 +37,6 @@ import org.mozilla.fenix.ui.util.FRENCH_LANGUAGE_HEADER
|
|||
import org.mozilla.fenix.ui.util.FRENCH_SYSTEM_LOCALE_OPTION
|
||||
import org.mozilla.fenix.ui.util.FR_SETTINGS
|
||||
import org.mozilla.fenix.ui.util.ROMANIAN_LANGUAGE_HEADER
|
||||
import java.time.LocalDate
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Tests for verifying the General section of the Settings menu
|
||||
|
@ -71,17 +70,6 @@ class SettingsBasicsTest {
|
|||
mockWebServer.shutdown()
|
||||
}
|
||||
|
||||
private fun getUiTheme(): Boolean {
|
||||
val mode =
|
||||
activityIntentTestRule.activity.resources?.configuration?.uiMode?.and(Configuration.UI_MODE_NIGHT_MASK)
|
||||
|
||||
return when (mode) {
|
||||
Configuration.UI_MODE_NIGHT_YES -> true // dark theme is set
|
||||
Configuration.UI_MODE_NIGHT_NO -> false // dark theme is not set, using light theme
|
||||
else -> false // default option is light theme
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun settingsGeneralItemsTests() {
|
||||
homeScreen {
|
||||
|
@ -101,21 +89,6 @@ class SettingsBasicsTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun changeThemeSetting() {
|
||||
// Goes through the settings and changes the default search engine, then verifies it changes.
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openCustomizeSubMenu {
|
||||
verifyThemes()
|
||||
selectDarkMode()
|
||||
verifyDarkThemeApplied(getUiTheme())
|
||||
selectLightMode()
|
||||
verifyLightThemeApplied(getUiTheme())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun changeAccessibiltySettings() {
|
||||
// Goes through the settings and changes the default text on a webpage, then verifies if the text has changed.
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package org.mozilla.fenix.ui
|
||||
|
||||
import android.content.res.Configuration
|
||||
import okhttp3.mockwebserver.MockWebServer
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
|
||||
import org.mozilla.fenix.ui.robots.homeScreen
|
||||
|
||||
class SettingsCustomizeTest {
|
||||
private lateinit var mockWebServer: MockWebServer
|
||||
|
||||
@get:Rule
|
||||
val activityIntentTestRule = HomeActivityIntentTestRule.withDefaultSettingsOverrides()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
mockWebServer = MockWebServer().apply {
|
||||
dispatcher = AndroidAssetDispatcher()
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
mockWebServer.shutdown()
|
||||
}
|
||||
|
||||
private fun getUiTheme(): Boolean {
|
||||
val mode =
|
||||
activityIntentTestRule.activity.resources?.configuration?.uiMode?.and(Configuration.UI_MODE_NIGHT_MASK)
|
||||
|
||||
return when (mode) {
|
||||
Configuration.UI_MODE_NIGHT_YES -> true // dark theme is set
|
||||
Configuration.UI_MODE_NIGHT_NO -> false // dark theme is not set, using light theme
|
||||
else -> false // default option is light theme
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun changeThemeSetting() {
|
||||
// Goes through the settings and changes the default search engine, then verifies it changes.
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openCustomizeSubMenu {
|
||||
verifyThemes()
|
||||
selectDarkMode()
|
||||
verifyDarkThemeApplied(getUiTheme())
|
||||
selectLightMode()
|
||||
verifyLightThemeApplied(getUiTheme())
|
||||
}
|
||||
}
|
||||
}
|
|
@ -147,12 +147,12 @@ class SettingsRobot {
|
|||
return SettingsSubMenuSearchRobot.Transition()
|
||||
}
|
||||
|
||||
fun openCustomizeSubMenu(interact: SettingsSubMenuThemeRobot.() -> Unit): SettingsSubMenuThemeRobot.Transition {
|
||||
fun openCustomizeSubMenu(interact: SettingsSubMenuCustomizeRobot.() -> Unit): SettingsSubMenuCustomizeRobot.Transition {
|
||||
fun customizeButton() = onView(withText("Customize"))
|
||||
customizeButton().click()
|
||||
|
||||
SettingsSubMenuThemeRobot().interact()
|
||||
return SettingsSubMenuThemeRobot.Transition()
|
||||
SettingsSubMenuCustomizeRobot().interact()
|
||||
return SettingsSubMenuCustomizeRobot.Transition()
|
||||
}
|
||||
|
||||
fun openTabsSubMenu(interact: SettingsSubMenuTabsRobot.() -> Unit): SettingsSubMenuTabsRobot.Transition {
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.mozilla.fenix.helpers.click
|
|||
/**
|
||||
* Implementation of Robot Pattern for the settings Theme sub menu.
|
||||
*/
|
||||
class SettingsSubMenuThemeRobot {
|
||||
class SettingsSubMenuCustomizeRobot {
|
||||
|
||||
fun verifyThemes() = assertThemes()
|
||||
|
Loading…
Reference in New Issue