diff --git a/app/src/main/java/org/mozilla/fenix/addons/InstalledAddonDetailsFragment.kt b/app/src/main/java/org/mozilla/fenix/addons/InstalledAddonDetailsFragment.kt index 984cc3859d..1e4f084350 100644 --- a/app/src/main/java/org/mozilla/fenix/addons/InstalledAddonDetailsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/addons/InstalledAddonDetailsFragment.kt @@ -132,7 +132,11 @@ class InstalledAddonDetailsFragment : Fragment() { switch.setState(addon.isEnabled()) // When the ad-on is blocklisted or not correctly signed, we do not want to enable the toggle switch // because users shouldn't be able to re-enable an add-on in this state. - if (addon.isDisabledAsBlocklisted() || addon.isDisabledAsNotCorrectlySigned()) { + if ( + addon.isDisabledAsBlocklisted() || + addon.isDisabledAsNotCorrectlySigned() || + addon.isDisabledAsIncompatible() + ) { switch.isEnabled = false return } @@ -321,6 +325,7 @@ class InstalledAddonDetailsFragment : Fragment() { ) } } + private fun bindRemoveButton() { binding.removeAddOn.setOnClickListener { setAllInteractiveViewsClickable(binding, false) diff --git a/app/src/test/java/org/mozilla/fenix/addons/InstalledAddonDetailsFragmentTest.kt b/app/src/test/java/org/mozilla/fenix/addons/InstalledAddonDetailsFragmentTest.kt index 1031e25d1a..6ffff57672 100644 --- a/app/src/test/java/org/mozilla/fenix/addons/InstalledAddonDetailsFragmentTest.kt +++ b/app/src/test/java/org/mozilla/fenix/addons/InstalledAddonDetailsFragmentTest.kt @@ -91,6 +91,7 @@ class InstalledAddonDetailsFragmentTest { every { fragment.providePrivateBrowsingSwitch() } returns privateBrowsingSwitch every { addon.isDisabledAsBlocklisted() } returns false every { addon.isDisabledAsNotCorrectlySigned() } returns false + every { addon.isDisabledAsIncompatible() } returns false every { addon.isEnabled() } returns true every { fragment.addon } returns addon @@ -116,4 +117,23 @@ class InstalledAddonDetailsFragmentTest { verify { enableSwitch.isEnabled = false } } + + @Test + fun `GIVEN incompatible addon WHEN biding the enable switch THEN disable the switch`() { + val addon = mockk() + val enableSwitch = mockk(relaxed = true) + val privateBrowsingSwitch = mockk(relaxed = true) + + every { fragment.provideEnableSwitch() } returns enableSwitch + every { fragment.providePrivateBrowsingSwitch() } returns privateBrowsingSwitch + every { addon.isEnabled() } returns true + every { addon.isDisabledAsBlocklisted() } returns false + every { addon.isDisabledAsNotCorrectlySigned() } returns false + every { addon.isDisabledAsIncompatible() } returns true + every { fragment.addon } returns addon + + fragment.bindEnableSwitch() + + verify { enableSwitch.isEnabled = false } + } }