Bug 1837378 - New system notification settings UI tests

fenix/116.0
AndiAJ 1 year ago committed by mergify[bot]
parent 1451e607ee
commit 97c3ac49e4

@ -91,7 +91,7 @@ class MediaNotificationTest {
mDevice.openNotification()
notificationShade {
verifySystemNotificationGone(videoTestPage.title)
verifySystemNotificationDoesNotExist(videoTestPage.title)
}
// close notification shade before the next test
@ -125,7 +125,7 @@ class MediaNotificationTest {
mDevice.openNotification()
notificationShade {
verifySystemNotificationGone(audioTestPage.title)
verifySystemNotificationDoesNotExist(audioTestPage.title)
}
// close notification shade before the next test
@ -162,7 +162,7 @@ class MediaNotificationTest {
mDevice.openNotification()
notificationShade {
verifySystemNotificationGone("A site is playing media")
verifySystemNotificationDoesNotExist("A site is playing media")
}
// close notification shade before and go back to regular mode before the next test

@ -13,7 +13,10 @@ import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar
import org.mozilla.fenix.ui.robots.notificationShade
/**
* Tests for verifying the the privacy and security section of the Settings menu
@ -144,4 +147,40 @@ class SettingsPrivacyTest {
verifySitePermissionOption("Exceptions")
}
}
@Test
fun verifyNotificationsSettingsTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
// Clear all existing notifications
notificationShade {
mDevice.openNotification()
clearNotifications()
}
homeScreen {
}.togglePrivateBrowsingMode()
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openNotificationShade {
verifySystemNotificationExists("Close private tabs")
}.closeNotificationTray {
}.openThreeDotMenu {
}.openSettings {
verifySettingsOptionSummary("Notifications", "Allowed")
}.openSettingsSubMenuNotifications {
verifyAllSystemNotificationsToggleState(true)
verifyPrivateBrowsingSystemNotificationsToggleState(true)
clickPrivateBrowsingSystemNotificationsToggle()
verifyPrivateBrowsingSystemNotificationsToggleState(false)
clickAllSystemNotificationsToggle()
verifyAllSystemNotificationsToggleState(false)
}.goBack {
verifySettingsOptionSummary("Notifications", "Not allowed")
}.goBackToBrowser {
}.openNotificationShade {
verifySystemNotificationDoesNotExist("Close private tabs")
}
}
}

@ -51,7 +51,7 @@ class NotificationRobot {
cancelAll()
}
fun verifySystemNotificationGone(notificationMessage: String) {
fun verifySystemNotificationDoesNotExist(notificationMessage: String) {
mDevice.waitNotNull(
Until.gone(text(notificationMessage)),
waitingTime,
@ -128,6 +128,13 @@ class NotificationRobot {
HomeScreenRobot().interact()
return HomeScreenRobot.Transition()
}
fun closeNotificationTray(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.pressBack()
BrowserRobot().interact()
return BrowserRobot.Transition()
}
}
}

@ -7,7 +7,9 @@ package org.mozilla.fenix.ui.robots
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction
import androidx.test.uiautomator.UiSelector
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndDescription
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.helpers.TestHelper.mDevice
@ -22,6 +24,26 @@ class SystemSettingsRobot {
Intents.intended(hasAction(SettingsRobot.DEFAULT_APPS_SETTINGS_ACTION))
}
fun verifyAllSystemNotificationsToggleState(enabled: Boolean) {
if (enabled) {
assertTrue(allSystemSettingsNotificationsToggle.isChecked)
} else {
assertFalse(allSystemSettingsNotificationsToggle.isChecked)
}
}
fun verifyPrivateBrowsingSystemNotificationsToggleState(enabled: Boolean) {
if (enabled) {
assertTrue(privateBrowsingSystemSettingsNotificationsToggle.isChecked)
} else {
assertFalse(privateBrowsingSystemSettingsNotificationsToggle.isChecked)
}
}
fun clickPrivateBrowsingSystemNotificationsToggle() = privateBrowsingSystemSettingsNotificationsToggle.click()
fun clickAllSystemNotificationsToggle() = allSystemSettingsNotificationsToggle.click()
class Transition {
// Difficult to know where this will go
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
@ -46,3 +68,15 @@ private fun assertSystemNotificationsView() {
.waitForExists(waitingTime),
)
}
private val allSystemSettingsNotificationsToggle =
mDevice.findObject(
UiSelector().resourceId("com.android.settings:id/switch_bar")
.childSelector(
UiSelector()
.resourceId("com.android.settings:id/switch_widget")
.index(1),
),
)
private val privateBrowsingSystemSettingsNotificationsToggle =
itemWithResIdAndDescription("com.android.settings:id/switchWidget", "Private browsing session")

Loading…
Cancel
Save