Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into count-bookmarks-in-trees
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 12, 2023
2 parents 6e086ac + 83bb99c commit d4a87a7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,10 @@ class SettingsFragment : PreferenceFragmentCompat() {
@VisibleForTesting
internal fun setupInstallAddonFromFilePreference(settings: Settings) {
with(requirePreference<Preference>(R.string.pref_key_install_local_addon)) {
isVisible = settings.showSecretDebugMenuThisSession
// Below Android 10, the OS doesn't seem to recognize
// the "application/x-xpinstall" mime type (for XPI files).
isVisible =
settings.showSecretDebugMenuThisSession && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package org.mozilla.fenix.settings

import android.os.Build
import androidx.core.app.NotificationManagerCompat
import androidx.fragment.app.FragmentActivity
import androidx.preference.Preference
Expand Down Expand Up @@ -98,6 +99,7 @@ class SettingsFragmentTest {
}

@Test
@org.robolectric.annotation.Config(sdk = [Build.VERSION_CODES.Q])
fun `Install add-on from file pref is visible if debug menu active and feature is enabled`() = runTestOnMain {
val settingsFragment = SettingsFragment()
val activity = Robolectric.buildActivity(FragmentActivity::class.java).create().get()
Expand All @@ -124,6 +126,29 @@ class SettingsFragmentTest {
unmockkObject(Config)
}

@Test
@org.robolectric.annotation.Config(sdk = [Build.VERSION_CODES.P])
fun `Install add-on from file pref is invisible below Android 10`() = runTestOnMain {
val settingsFragment = SettingsFragment()
val activity = Robolectric.buildActivity(FragmentActivity::class.java).create().get()

activity.supportFragmentManager.beginTransaction()
.add(settingsFragment, "test")
.commitNow()

advanceUntilIdle()

val preference = settingsFragment.findPreference<Preference>(
settingsFragment.getPreferenceKey(R.string.pref_key_install_local_addon),
)

val settings: Settings = mockk(relaxed = true)

every { settings.showSecretDebugMenuThisSession } returns true
settingsFragment.setupInstallAddonFromFilePreference(settings)
assertFalse(preference!!.isVisible)
}

@Test
fun `Add-on collection override pref is visible if already configured and feature is enabled`() = runTestOnMain {
val settingsFragment = SettingsFragment()
Expand Down

0 comments on commit d4a87a7

Please sign in to comment.