2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-17 15:26:23 +00:00

[fenix] Close https://github.com/mozilla-mobile/fenix/issues/20792: Fix intermittent test failures in QuickSettingsFragmentReducerTest

This commit is contained in:
Jonathan Almeida 2021-08-11 17:12:48 -04:00 committed by Jonathan Almeida
parent 2722a662de
commit 9b20f9c1c0
2 changed files with 19 additions and 10 deletions

View File

@ -7,7 +7,7 @@ package org.mozilla.fenix.settings.quicksettings
/** /**
* Parent Reducer for all [QuickSettingsFragmentState]s of all Views shown in this Fragment. * Parent Reducer for all [QuickSettingsFragmentState]s of all Views shown in this Fragment.
*/ */
fun quickSettingsFragmentReducer( internal fun quickSettingsFragmentReducer(
state: QuickSettingsFragmentState, state: QuickSettingsFragmentState,
action: QuickSettingsFragmentAction action: QuickSettingsFragmentAction
): QuickSettingsFragmentState { ): QuickSettingsFragmentState {

View File

@ -4,16 +4,14 @@
package org.mozilla.fenix.settings.quicksettings package org.mozilla.fenix.settings.quicksettings
import mozilla.components.support.test.mock import mozilla.components.feature.sitepermissions.SitePermissionsRules
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Ignore
import org.junit.Test import org.junit.Test
import org.mozilla.fenix.settings.PhoneFeature import org.mozilla.fenix.settings.PhoneFeature
class QuickSettingsFragmentReducerTest { class QuickSettingsFragmentReducerTest {
@Ignore("See https://github.com/mozilla-mobile/fenix/issues/20792")
@Test @Test
fun `WebsitePermissionAction - TogglePermission`() { fun `WebsitePermissionAction - TogglePermission`() {
val toggleablePermission = WebsitePermission.Toggleable( val toggleablePermission = WebsitePermission.Toggleable(
@ -26,8 +24,8 @@ class QuickSettingsFragmentReducerTest {
val map = val map =
mapOf<PhoneFeature, WebsitePermission>(PhoneFeature.CAMERA to toggleablePermission) mapOf<PhoneFeature, WebsitePermission>(PhoneFeature.CAMERA to toggleablePermission)
val infoState = WebsiteInfoState("", "", WebsiteSecurityUiValues.SECURE, "")
val state = QuickSettingsFragmentState(mock(), map) val state = QuickSettingsFragmentState(infoState, map)
val newState = quickSettingsFragmentReducer( val newState = quickSettingsFragmentReducer(
state, state,
WebsitePermissionAction.TogglePermission( WebsitePermissionAction.TogglePermission(
@ -46,7 +44,7 @@ class QuickSettingsFragmentReducerTest {
val permissionPermission = WebsitePermission.Autoplay( val permissionPermission = WebsitePermission.Autoplay(
autoplayValue = AutoplayValue.BlockAll( autoplayValue = AutoplayValue.BlockAll(
label = "label", label = "label",
rules = mock(), rules = createTestRule(),
sitePermission = null sitePermission = null
), ),
options = emptyList(), options = emptyList(),
@ -55,11 +53,11 @@ class QuickSettingsFragmentReducerTest {
val map = val map =
mapOf<PhoneFeature, WebsitePermission>(PhoneFeature.AUTOPLAY to permissionPermission) mapOf<PhoneFeature, WebsitePermission>(PhoneFeature.AUTOPLAY to permissionPermission)
val infoState = WebsiteInfoState("", "", WebsiteSecurityUiValues.SECURE, "")
val state = QuickSettingsFragmentState(mock(), map) val state = QuickSettingsFragmentState(infoState, map)
val autoplayValue = AutoplayValue.AllowAll( val autoplayValue = AutoplayValue.AllowAll(
label = "newLabel", label = "newLabel",
rules = mock(), rules = createTestRule(),
sitePermission = null sitePermission = null
) )
val newState = quickSettingsFragmentReducer( val newState = quickSettingsFragmentReducer(
@ -71,4 +69,15 @@ class QuickSettingsFragmentReducerTest {
newState.websitePermissionsState[PhoneFeature.AUTOPLAY] as WebsitePermission.Autoplay newState.websitePermissionsState[PhoneFeature.AUTOPLAY] as WebsitePermission.Autoplay
assertEquals(autoplayValue, result.autoplayValue) assertEquals(autoplayValue, result.autoplayValue)
} }
private fun createTestRule() = SitePermissionsRules(
SitePermissionsRules.Action.ALLOWED,
SitePermissionsRules.Action.ALLOWED,
SitePermissionsRules.Action.ALLOWED,
SitePermissionsRules.Action.ALLOWED,
SitePermissionsRules.AutoplayAction.ALLOWED,
SitePermissionsRules.AutoplayAction.ALLOWED,
SitePermissionsRules.Action.ALLOWED,
SitePermissionsRules.Action.ALLOWED,
)
} }