[fenix] Create a robot and test class for Customize Settings menu
parent
6faaeefd59
commit
3e0d4da3b9
@ -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())
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue