Bug 1850493 - The tracking protection divider should be gone if all the views are gone.

fenix/119.0
iorgamgabriel 9 months ago committed by mergify[bot]
parent 37d14cf870
commit 89489c6e8e

@ -117,7 +117,12 @@ class QuickSettingsSheetDialogFragment : FenixDialogFragment() {
websitePermissionsView =
WebsitePermissionsView(binding.websitePermissionsLayout, interactor)
protectionsView =
ProtectionsView(binding.trackingProtectionLayout, interactor, context.settings())
ProtectionsView(
binding.trackingProtectionLayout,
binding.trackingProtectionDivider,
interactor,
context.settings(),
)
clearSiteDataView = ClearSiteDataView(
context = context,
ioScope = viewLifecycleOwner.lifecycleScope + Dispatchers.IO,

@ -5,6 +5,7 @@
package org.mozilla.fenix.settings.quicksettings.protections
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.VisibleForTesting
import androidx.compose.foundation.background
@ -40,12 +41,15 @@ import org.mozilla.fenix.utils.Settings
* to additional tracking protection details.
*
* @param containerView [ViewGroup] in which this View will inflate itself.
* @param trackingProtectionDivider trackingProtectionDivider The divider line between tracking protection layout
* and other views from [QuickSettingsSheetDialogFragment].
* @param interactor [ProtectionsInteractor] which will have delegated to all user
* @param settings [Settings] application settings.
* interactions.
*/
class ProtectionsView(
val containerView: ViewGroup,
private val trackingProtectionDivider: View,
val interactor: ProtectionsInteractor,
val settings: Settings,
) {
@ -63,11 +67,21 @@ class ProtectionsView(
binding.trackingProtectionDetails.setOnClickListener {
interactor.onTrackingProtectionDetailsClicked()
}
updateDividerVisibility()
}
private fun updateDividerVisibility() {
trackingProtectionDivider.isVisible = !(
!binding.trackingProtectionSwitch.isVisible &&
!binding.trackingProtectionDetails.isVisible &&
!binding.cookieBannerItem.isVisible
)
}
@VisibleForTesting
internal fun updateDetailsSection(show: Boolean) {
binding.trackingProtectionDetails.isVisible = show
updateDividerVisibility()
}
private fun bindTrackingProtectionInfo(isTrackingProtectionEnabled: Boolean) {

@ -4,6 +4,7 @@
package org.mozilla.fenix.settings.quicksettings
import android.view.View
import android.widget.FrameLayout
import androidx.core.view.isVisible
import io.mockk.MockKAnnotations
@ -32,6 +33,7 @@ class ProtectionsViewTest {
private lateinit var view: ProtectionsView
private lateinit var binding: QuicksettingsProtectionsPanelBinding
private lateinit var interactor: ProtectionsInteractor
private var trackingProtectionDivider: View = spyk(View(testContext))
@MockK(relaxed = true)
private lateinit var settings: Settings
@ -40,7 +42,14 @@ class ProtectionsViewTest {
fun setup() {
MockKAnnotations.init(this)
interactor = mockk(relaxed = true)
view = spyk(ProtectionsView(FrameLayout(testContext), interactor, settings))
view = spyk(
ProtectionsView(
FrameLayout(testContext),
trackingProtectionDivider,
interactor,
settings,
),
)
binding = view.binding
}
@ -160,4 +169,25 @@ class ProtectionsViewTest {
assertTrue(binding.trackingProtectionDetails.isVisible)
}
@Test
fun `WHEN all the views from protectionView are gone THEN tracking protection divider is gone`() {
val websiteUrl = "https://mozilla.org"
val state = ProtectionsState(
tab = createTab(url = websiteUrl),
url = websiteUrl,
isTrackingProtectionEnabled = false,
cookieBannerUIMode = CookieBannerUIMode.HIDE,
listTrackers = listOf(),
mode = ProtectionsState.Mode.Normal,
lastAccessedCategory = "",
)
every { settings.shouldShowCookieBannerUI } returns true
every { settings.shouldUseCookieBanner } returns true
view.update(state)
assertFalse(trackingProtectionDivider.isVisible)
}
}

Loading…
Cancel
Save