mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
[fenix] Create a robot and test class for Customize Settings menu
This commit is contained in:
parent
6faaeefd59
commit
3e0d4da3b9
@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
package org.mozilla.fenix.ui
|
package org.mozilla.fenix.ui
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import java.time.LocalDate
|
||||||
|
import java.util.Locale
|
||||||
import okhttp3.mockwebserver.MockWebServer
|
import okhttp3.mockwebserver.MockWebServer
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
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.FRENCH_SYSTEM_LOCALE_OPTION
|
||||||
import org.mozilla.fenix.ui.util.FR_SETTINGS
|
import org.mozilla.fenix.ui.util.FR_SETTINGS
|
||||||
import org.mozilla.fenix.ui.util.ROMANIAN_LANGUAGE_HEADER
|
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
|
* Tests for verifying the General section of the Settings menu
|
||||||
@ -71,17 +70,6 @@ class SettingsBasicsTest {
|
|||||||
mockWebServer.shutdown()
|
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
|
@Test
|
||||||
fun settingsGeneralItemsTests() {
|
fun settingsGeneralItemsTests() {
|
||||||
homeScreen {
|
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
|
@Test
|
||||||
fun changeAccessibiltySettings() {
|
fun changeAccessibiltySettings() {
|
||||||
// Goes through the settings and changes the default text on a webpage, then verifies if the text has changed.
|
// 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()
|
return SettingsSubMenuSearchRobot.Transition()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openCustomizeSubMenu(interact: SettingsSubMenuThemeRobot.() -> Unit): SettingsSubMenuThemeRobot.Transition {
|
fun openCustomizeSubMenu(interact: SettingsSubMenuCustomizeRobot.() -> Unit): SettingsSubMenuCustomizeRobot.Transition {
|
||||||
fun customizeButton() = onView(withText("Customize"))
|
fun customizeButton() = onView(withText("Customize"))
|
||||||
customizeButton().click()
|
customizeButton().click()
|
||||||
|
|
||||||
SettingsSubMenuThemeRobot().interact()
|
SettingsSubMenuCustomizeRobot().interact()
|
||||||
return SettingsSubMenuThemeRobot.Transition()
|
return SettingsSubMenuCustomizeRobot.Transition()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openTabsSubMenu(interact: SettingsSubMenuTabsRobot.() -> Unit): SettingsSubMenuTabsRobot.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.
|
* Implementation of Robot Pattern for the settings Theme sub menu.
|
||||||
*/
|
*/
|
||||||
class SettingsSubMenuThemeRobot {
|
class SettingsSubMenuCustomizeRobot {
|
||||||
|
|
||||||
fun verifyThemes() = assertThemes()
|
fun verifyThemes() = assertThemes()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user