1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 package org.mozilla.fenix.ui
7 import android.content.res.Configuration
10 import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
11 import org.mozilla.fenix.helpers.TestAssetHelper
12 import org.mozilla.fenix.helpers.TestHelper.exitMenu
13 import org.mozilla.fenix.helpers.TestHelper.verifyDarkThemeApplied
14 import org.mozilla.fenix.helpers.TestHelper.verifyLightThemeApplied
15 import org.mozilla.fenix.helpers.TestSetup
16 import org.mozilla.fenix.ui.robots.homeScreen
17 import org.mozilla.fenix.ui.robots.navigationToolbar
19 class SettingsCustomizeTest : TestSetup() {
21 val activityIntentTestRule = HomeActivityIntentTestRule.withDefaultSettingsOverrides()
23 private fun getUiTheme(): Boolean {
25 activityIntentTestRule.activity.resources?.configuration?.uiMode?.and(Configuration.UI_MODE_NIGHT_MASK)
28 Configuration.UI_MODE_NIGHT_YES -> true // dark theme is set
29 Configuration.UI_MODE_NIGHT_NO -> false // dark theme is not set, using light theme
30 else -> false // default option is light theme
34 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/344212
36 fun changeThemeOfTheAppTest() {
37 // Goes through the settings and changes the default search engine, then verifies it changes.
41 }.openCustomizeSubMenu {
44 verifyDarkThemeApplied(getUiTheme())
46 verifyLightThemeApplied(getUiTheme())
50 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/466571
52 fun setToolbarPositionTest() {
56 }.openCustomizeSubMenu {
57 verifyToolbarPositionPreference("Bottom")
58 clickTopToolbarToggle()
59 verifyToolbarPositionPreference("Top")
62 verifyToolbarPosition(defaultPosition = false)
65 }.openCustomizeSubMenu {
66 clickBottomToolbarToggle()
67 verifyToolbarPositionPreference("Bottom")
71 verifyToolbarPosition(defaultPosition = true)
75 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/1058682
77 fun turnOffSwipeToSwitchTabsPreferenceTest() {
78 val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
79 val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)
84 }.openCustomizeSubMenu {
85 verifySwipeToolbarGesturePrefState(true)
86 clickSwipeToolbarToSwitchTabToggle()
87 verifySwipeToolbarGesturePrefState(false)
91 }.enterURLAndEnterToBrowser(firstWebPage.url) {
94 }.submitQuery(secondWebPage.url.toString()) {
95 swipeNavBarRight(secondWebPage.url.toString())
96 verifyUrl(secondWebPage.url.toString())
97 swipeNavBarLeft(secondWebPage.url.toString())
98 verifyUrl(secondWebPage.url.toString())
102 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/1992289
104 fun pullToRefreshPreferenceTest() {
108 }.openCustomizeSubMenu {
109 verifyPullToRefreshGesturePrefState(isEnabled = true)
110 clickPullToRefreshToggle()
111 verifyPullToRefreshGesturePrefState(isEnabled = false)