Fix merge

pull/543/head
Adam Novak 2 years ago
parent 7dcbf8c542
commit 1ebeca1e19

@ -17,6 +17,7 @@ class ReviewManager {
fun requestReviewFlow(): FakeReviewFlowTask {
return FakeReviewFlowTask()
}
@Suppress("UNUSED_PARAMETER", "UNUSED_EXPRESSION")
fun launchReviewFlow(ignored1: Any, ignored2: Any) {
1

@ -57,7 +57,7 @@ class PagedAddonCollectionProvider(
private val context: Context,
private val client: Client,
private val serverURL: String = DEFAULT_SERVER_URL,
private val maxCacheAgeInMinutes: Long = -1
private val maxCacheAgeInMinutes: Long = -1,
) : AddonsProvider {
private val logger = Logger("PagedAddonCollectionProvider")
@ -72,11 +72,11 @@ class PagedAddonCollectionProvider(
if (Config.channel.isNightlyOrDebug && context.settings().amoCollectionOverrideConfigured()) {
result = context.settings().overrideAmoUser
}
logger.info("Determined collection account: ${result}")
logger.info("Determined collection account: $result")
return result
}
/**
* Get the collection name we should be fetching addons from.
*/
@ -85,8 +85,8 @@ class PagedAddonCollectionProvider(
if (Config.channel.isNightlyOrDebug && context.settings().amoCollectionOverrideConfigured()) {
result = context.settings().overrideAmoCollection
}
logger.info("Determined collection name: ${result}")
logger.info("Determined collection name: $result")
return result
}
@ -108,22 +108,22 @@ class PagedAddonCollectionProvider(
override suspend fun getAvailableAddons(
allowCache: Boolean,
readTimeoutInSeconds: Long?,
language: String?
language: String?,
): List<Addon> {
val cachedAddons = if (allowCache && !cacheExpired(context)) {
readFromDiskCache()
} else {
null
}
val collectionAccount = getCollectionAccount()
val collectionName = getCollectionName()
if (cachedAddons != null) {
logger.info("Providing cached list of addons for ${collectionAccount} collection ${collectionName}")
logger.info("Providing cached list of addons for $collectionAccount collection $collectionName")
return cachedAddons
} else {
logger.info("Fetching fresh list of addons for ${collectionAccount} collection ${collectionName}")
logger.info("Fetching fresh list of addons for $collectionAccount collection $collectionName")
return getAllPages(
listOf(
serverURL,
@ -132,9 +132,9 @@ class PagedAddonCollectionProvider(
collectionAccount,
"collections",
collectionName,
"addons"
"addons",
).joinToString("/"),
readTimeoutInSeconds ?: DEFAULT_READ_TIMEOUT_IN_SECONDS
readTimeoutInSeconds ?: DEFAULT_READ_TIMEOUT_IN_SECONDS,
).also {
// Cache the JSON object before we parse out the addons
if (maxCacheAgeInMinutes > 0) {
@ -164,8 +164,8 @@ class PagedAddonCollectionProvider(
client.fetch(
Request(
url = nextURL,
readTimeout = Pair(readTimeoutInSeconds, TimeUnit.SECONDS)
)
readTimeout = Pair(readTimeoutInSeconds, TimeUnit.SECONDS),
),
)
.use { response ->
if (!response.isSuccess) {
@ -201,7 +201,7 @@ class PagedAddonCollectionProvider(
var bitmap: Bitmap? = null
if (addon.iconUrl != "") {
client.fetch(
Request(url = addon.iconUrl.sanitizeURL())
Request(url = addon.iconUrl.sanitizeURL()),
).use { response ->
if (response.isSuccess) {
response.body.useStream {
@ -288,7 +288,7 @@ internal fun JSONObject.toAddons(): Addon {
iconUrl = getSafeString("icon_url"),
siteUrl = getSafeString("url"),
rating = getRating(),
defaultLocale = getSafeString("default_locale").ifEmpty { Addon.DEFAULT_LOCALE }
defaultLocale = getSafeString("default_locale").ifEmpty { Addon.DEFAULT_LOCALE },
)
}
}
@ -298,7 +298,7 @@ internal fun JSONObject.getRating(): Addon.Rating? {
return if (jsonRating != null) {
Addon.Rating(
reviews = jsonRating.optInt("count"),
average = jsonRating.optDouble("average").toFloat()
average = jsonRating.optDouble("average").toFloat(),
)
} else {
null
@ -357,7 +357,7 @@ internal fun JSONObject.getAuthors(): List<Addon.Author> {
id = authorJson.getSafeString("id"),
name = authorJson.getSafeString("name"),
username = authorJson.getSafeString("username"),
url = authorJson.getSafeString("url")
url = authorJson.getSafeString("url"),
)
}
}

@ -46,6 +46,7 @@ private const val KEY_DIALOG_WIDTH_MATCH_PARENT = "KEY_DIALOG_WIDTH_MATCH_PARENT
private const val KEY_CONFIRM_BUTTON_BACKGROUND_COLOR = "KEY_CONFIRM_BUTTON_BACKGROUND_COLOR"
private const val KEY_CONFIRM_BUTTON_TEXT_COLOR = "KEY_CONFIRM_BUTTON_TEXT_COLOR"
private const val KEY_CONFIRM_BUTTON_RADIUS = "KEY_CONFIRM_BUTTON_RADIUS"
@VisibleForTesting internal const val KEY_ICON = "KEY_ICON"
private const val DEFAULT_VALUE = Int.MAX_VALUE
@ -59,8 +60,10 @@ private const val DEFAULT_VALUE = Int.MAX_VALUE
@SuppressLint("all")
class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
private val scope = CoroutineScope(Dispatchers.IO)
@VisibleForTesting internal var iconJob: Job? = null
private val logger = Logger("PagedAddonInstallationDialogFragment")
/**
* A lambda called when the confirm button is clicked.
*/
@ -84,7 +87,7 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
get() =
safeArguments.getInt(
KEY_DIALOG_GRAVITY,
DEFAULT_VALUE
DEFAULT_VALUE,
)
internal val dialogShouldWidthMatchParent: Boolean
get() =
@ -94,14 +97,14 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
get() =
safeArguments.getInt(
KEY_CONFIRM_BUTTON_BACKGROUND_COLOR,
DEFAULT_VALUE
DEFAULT_VALUE,
)
internal val confirmButtonTextColor
get() =
safeArguments.getInt(
KEY_CONFIRM_BUTTON_TEXT_COLOR,
DEFAULT_VALUE
DEFAULT_VALUE,
)
override fun onStop() {
@ -141,8 +144,8 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
rootView,
LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT
)
LinearLayout.LayoutParams.MATCH_PARENT,
),
)
}
}
@ -152,7 +155,7 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
val rootView = LayoutInflater.from(requireContext()).inflate(
R.layout.mozac_feature_addons_fragment_dialog_addon_installed,
null,
false
false,
)
val binding = MozacFeatureAddonsFragmentDialogAddonInstalledBinding.bind(rootView)
@ -161,7 +164,7 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
requireContext().getString(
R.string.mozac_feature_addons_installed_dialog_title,
addon.translateName(requireContext()),
requireContext().appName
requireContext().appName,
)
val icon = safeArguments.getParcelable<Bitmap>(KEY_ICON)
@ -199,8 +202,8 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
shape.setColor(
ContextCompat.getColor(
requireContext(),
confirmButtonBackgroundColor
)
confirmButtonBackgroundColor,
),
)
shape.cornerRadius = confirmButtonRadius
confirmButton.background = shape
@ -226,7 +229,7 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
val att = context.theme.resolveAttribute(android.R.attr.textColorPrimary)
iconView.setColorFilter(ContextCompat.getColor(context, att))
iconView.setImageDrawable(
ContextCompat.getDrawable(context, R.drawable.mozac_ic_extensions)
ContextCompat.getDrawable(context, R.drawable.mozac_ic_extensions),
)
}
logger.error("Attempt to fetch the ${addon.id} icon failed", e)
@ -260,11 +263,10 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
addonCollectionProvider: PagedAddonCollectionProvider,
promptsStyling: PromptsStyling? = PromptsStyling(
gravity = Gravity.BOTTOM,
shouldWidthMatchParent = true
shouldWidthMatchParent = true,
),
onConfirmButtonClicked: ((Addon, Boolean) -> Unit)? = null
onConfirmButtonClicked: ((Addon, Boolean) -> Unit)? = null,
): PagedAddonInstallationDialogFragment {
val fragment = PagedAddonInstallationDialogFragment()
val arguments = fragment.arguments ?: Bundle()
@ -302,7 +304,7 @@ class PagedAddonInstallationDialogFragment : AppCompatDialogFragment() {
val confirmButtonBackgroundColor: Int? = null,
@ColorRes
val confirmButtonTextColor: Int? = null,
val confirmButtonRadius: Float? = null
val confirmButtonRadius: Float? = null,
)
}

@ -70,6 +70,7 @@ class PagedAddonsManagerAdapter(
) : ListAdapter<Any, CustomViewHolder>(DifferCallback) {
private val scope = CoroutineScope(Dispatchers.IO)
private val logger = Logger("PagedAddonsManagerAdapter")
/**
* Represents all the add-ons that will be distributed in multiple headers like
* enabled, recommended and unsupported, this help have the data source of the items,
@ -106,7 +107,7 @@ class PagedAddonsManagerAdapter(
val view = inflater.inflate(
R.layout.mozac_feature_addons_section_unsupported_section_item,
parent,
false
false,
)
val titleView = view.findViewById<TextView>(R.id.title)
val descriptionView = view.findViewById<TextView>(R.id.description)
@ -135,7 +136,7 @@ class PagedAddonsManagerAdapter(
ratingAccessibleView,
userCountView,
addButton,
allowedInPrivateBrowsingLabel
allowedInPrivateBrowsingLabel,
)
}
@ -156,7 +157,7 @@ class PagedAddonsManagerAdapter(
is AddonViewHolder -> bindAddon(holder, item as Addon)
is UnsupportedSectionViewHolder -> bindNotYetSupportedSection(
holder,
item as NotYetSupportedSection
item as NotYetSupportedSection,
)
}
}
@ -171,7 +172,7 @@ class PagedAddonsManagerAdapter(
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun bindNotYetSupportedSection(
holder: UnsupportedSectionViewHolder,
section: NotYetSupportedSection
section: NotYetSupportedSection,
) {
val unsupportedAddons = addonsMap.values.filter { it.inUnsupportedSection() }
val context = holder.itemView.context
@ -182,7 +183,7 @@ class PagedAddonsManagerAdapter(
} else {
context.getString(
R.string.mozac_feature_addons_unsupported_caption_plural,
unsupportedAddons.size.toString()
unsupportedAddons.size.toString(),
)
}
@ -199,7 +200,7 @@ class PagedAddonsManagerAdapter(
val ratingContentDescription =
String.format(
context.getString(R.string.mozac_feature_addons_rating_content_description),
it.average
it.average,
)
holder.ratingView.contentDescription = ratingContentDescription
// Android RatingBar is not very accessibility-friendly, we will use non visible TextView
@ -337,7 +338,7 @@ class PagedAddonsManagerAdapter(
val addonSummaryTextColor: Int? = null,
val sectionsTypeFace: Typeface? = null,
@DrawableRes
val addonAllowPrivateBrowsingLabelDrawableRes: Int? = null
val addonAllowPrivateBrowsingLabelDrawableRes: Int? = null,
) {
internal fun maybeSetSectionsTextColor(textView: TextView) {
sectionsTextColor?.let {

@ -21,8 +21,7 @@ object FeatureFlags {
/**
* Enables the Sync Addresses feature.
*/
<<<<<<< HEAD
const val syncAddressesFeature = false
const val syncAddressesFeature = true
/**
* Enables the onboarding sync CFR on the home screen.
@ -38,9 +37,6 @@ object FeatureFlags {
* Enables the first run onboarding updates.
*/
const val showFirstRunOnboardingUpdates = false
=======
const val addressesFeature = true
>>>>>>> e1281c453... Do all of Iceraven in one commit
/**
* Enables the "recent" tabs feature in the home screen.

@ -52,9 +52,9 @@ import java.util.concurrent.CancellationException
*/
@Suppress("TooManyFunctions", "LargeClass")
class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management) {
private val logger = Logger("AddonsManagementFragment")
private val args by navArgs<AddonsManagementFragmentArgs>()
private var binding: FragmentAddOnsManagementBinding? = null
@ -64,6 +64,7 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
*/
private var isInstallationInProgress = false
private var adapter: PagedAddonsManagerAdapter? = null
// We must save the add-on list in the class, or we won't have it
// downloaded for the non-suspending search function
private var addons: List<Addon>? = null
@ -71,7 +72,7 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
savedInstanceState: Bundle?,
): View? {
logger.info("Creating view for AddonsManagementFragment")
setHasOptionsMenu(true)
@ -108,7 +109,7 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
override fun onQueryTextChange(newText: String): Boolean {
return searchAddons(newText.trim())
}
})
},)
}
private fun searchAddons(addonNameSubStr: String): Boolean {
@ -167,17 +168,17 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
private fun bindRecyclerView() {
logger.info("Binding recycler view for AddonsManagementFragment")
val managementView = AddonsManagementView(
navController = findNavController(),
showPermissionDialog = ::showPermissionDialog,
)
val recyclerView = binding?.addOnsList
recyclerView?.layoutManager = LinearLayoutManager(requireContext())
val shouldRefresh = adapter != null
logger.info("AddonsManagementFragment should refresh? ${shouldRefresh}")
logger.info("AddonsManagementFragment should refresh? $shouldRefresh")
// If the fragment was launched to install an "external" add-on from AMO, we deactivate
// the cache to get the most up-to-date list of add-ons to match against.
@ -193,7 +194,7 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
requireContext().components.addonCollectionProvider,
managementView,
addons!!,
style = createAddonStyle(requireContext())
style = createAddonStyle(requireContext()),
)
}
isInstallationInProgress = false

@ -108,7 +108,7 @@ class Components(private val context: Context) {
context,
core.client,
serverURL = BuildConfig.AMO_SERVER_URL,
maxCacheAgeInMinutes = AMO_COLLECTION_MAX_CACHE_AGE
maxCacheAgeInMinutes = AMO_COLLECTION_MAX_CACHE_AGE,
)
}

@ -114,11 +114,15 @@ class BrowserToolbarView(
display.urlFormatter =
if (settings.shouldStripUrl) {
url ->
URLStringUtils.toDisplayUrl(url)
{
url ->
URLStringUtils.toDisplayUrl(url)
}
} else {
url ->
url
{
url ->
url
}
}
display.colors = display.colors.copy(

@ -91,7 +91,7 @@ class TopSheetBehavior<V : View?>
STATE_COLLAPSED,
STATE_DRAGGING,
STATE_SETTLING,
STATE_HIDDEN
STATE_HIDDEN,
)
@kotlin.annotation.Retention(AnnotationRetention.SOURCE)
annotation class State
@ -115,7 +115,7 @@ class TopSheetBehavior<V : View?>
if (mViewRef != null && mViewRef!!.get() != null) {
mMinOffset =
(-mViewRef!!.get()!!.height).coerceAtLeast(
-(mViewRef!!.get()!!.height - mPeekHeight)
-(mViewRef!!.get()!!.height - mPeekHeight),
)
}
}
@ -150,7 +150,7 @@ class TopSheetBehavior<V : View?>
init {
val a = context.obtainStyledAttributes(
attrs,
R.styleable.BottomSheetBehavior_Layout
R.styleable.BottomSheetBehavior_Layout,
)
shapeThemingEnabled =
a.hasValue(R.styleable.BottomSheetBehavior_Layout_shapeAppearance)
@ -159,11 +159,11 @@ class TopSheetBehavior<V : View?>
peekHeight = (context.resources.displayMetrics.heightPixels * PEEK_HEIGHT_RATIO).toInt()
isHideable = a.getBoolean(
R.styleable.BottomSheetBehavior_Layout_behavior_hideable,
false
false,
)
skipCollapsed = a.getBoolean(
R.styleable.BottomSheetBehavior_Layout_behavior_skipCollapsed,
false
false,
)
a.recycle()
val configuration =
@ -175,16 +175,16 @@ class TopSheetBehavior<V : View?>
return SavedState(
super.onSaveInstanceState(
parent,
child!!
child!!,
),
mState
mState,
)
}
override fun onRestoreInstanceState(
parent: CoordinatorLayout,
child: V,
state: Parcelable
state: Parcelable,
) {
val ss =
state as SavedState
@ -201,7 +201,7 @@ class TopSheetBehavior<V : View?>
override fun onLayoutChild(
parent: CoordinatorLayout,
child: V,
layoutDirection: Int
layoutDirection: Int,
): Boolean {
if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child as View)) {
child.fitsSystemWindows = true
@ -252,7 +252,7 @@ class TopSheetBehavior<V : View?>
override fun onInterceptTouchEvent(
parent: CoordinatorLayout,
child: V,
event: MotionEvent
event: MotionEvent,
): Boolean {
if (!child!!.isShown) {
return false
@ -300,14 +300,14 @@ class TopSheetBehavior<V : View?>
!parent.isPointInChildBounds(
scroll,
event.x.toInt(),
event.y.toInt()
event.y.toInt(),
) && abs(mInitialY - event.y) > mViewDragHelper!!.touchSlop
}
override fun onTouchEvent(
parent: CoordinatorLayout,
child: V,
event: MotionEvent
event: MotionEvent,
): Boolean {
if (!child!!.isShown) {
return false
@ -334,7 +334,7 @@ class TopSheetBehavior<V : View?>
) {
mViewDragHelper!!.captureChildView(
child,
event.getPointerId(event.actionIndex)
event.getPointerId(event.actionIndex),
)
}
}
@ -346,7 +346,7 @@ class TopSheetBehavior<V : View?>
child: V,
directTargetChild: View,
target: View,
nestedScrollAxes: Int
nestedScrollAxes: Int,
): Boolean {
mLastNestedScrollDy = 0
mNestedScrolled = false
@ -359,7 +359,7 @@ class TopSheetBehavior<V : View?>
target: View,
dx: Int,
dy: Int,
consumed: IntArray
consumed: IntArray,
) {
val scrollingChild = mNestedScrollingChildRef!!.get()
if (target !== scrollingChild) {
@ -399,7 +399,7 @@ class TopSheetBehavior<V : View?>
override fun onStopNestedScroll(
coordinatorLayout: CoordinatorLayout,
child: V,
target: View
target: View,
) {
if (child!!.top == mMaxOffset) {
setStateInternal(STATE_EXPANDED)
@ -435,8 +435,8 @@ class TopSheetBehavior<V : View?>
child,
SettleRunnable(
child,
targetState
)
targetState,
),
)
} else {
setStateInternal(targetState)
@ -449,14 +449,17 @@ class TopSheetBehavior<V : View?>
child: V,
target: View,
velocityX: Float,
velocityY: Float
velocityY: Float,
): Boolean {
return target === mNestedScrollingChildRef!!.get() &&
(
mState != STATE_EXPANDED ||
super.onNestedPreFling(
coordinatorLayout, child!!, target,
velocityX, velocityY
coordinatorLayout,
child!!,
target,
velocityX,
velocityY,
)
)
}
@ -508,7 +511,7 @@ class TopSheetBehavior<V : View?>
if (mViewDragHelper!!.smoothSlideViewTo(child, child.left, top)) {
ViewCompat.postOnAnimation(
child,
SettleRunnable(child, state)
SettleRunnable(child, state),
)
}
}
@ -596,7 +599,7 @@ class TopSheetBehavior<V : View?>
@Suppress("ReturnCount")
override fun tryCaptureView(
child: View,
pointerId: Int
pointerId: Int,
): Boolean {
if (mState == STATE_DRAGGING) {
return false
@ -619,7 +622,7 @@ class TopSheetBehavior<V : View?>
left: Int,
top: Int,
dx: Int,
dy: Int
dy: Int,
) {
dispatchOnSlide(top)
}
@ -633,9 +636,10 @@ class TopSheetBehavior<V : View?>
override fun onViewReleased(
releasedChild: View,
xvel: Float,
yvel: Float
yvel: Float,
) {
val top: Int
@State val targetState: Int
if (yvel > 0) { // Moving up
top = mMaxOffset
@ -662,8 +666,8 @@ class TopSheetBehavior<V : View?>
releasedChild,
SettleRunnable(
releasedChild,
targetState
)
targetState,
),
)
} else {
setStateInternal(targetState)
@ -673,19 +677,19 @@ class TopSheetBehavior<V : View?>
override fun clampViewPositionVertical(
child: View,
top: Int,
dy: Int
dy: Int,
): Int {
return constrain(
top,
if (isHideable) -child.height else mMinOffset,
mMaxOffset
mMaxOffset,
)
}
override fun clampViewPositionHorizontal(
child: View,
left: Int,
dx: Int
dx: Int,
): Int {
return child.left
}
@ -701,14 +705,14 @@ class TopSheetBehavior<V : View?>
private fun createMaterialShapeDrawable(
context: Context,
attrs: AttributeSet
attrs: AttributeSet,
) {
if (shapeThemingEnabled) {
shapeAppearanceModelDefault = ShapeAppearanceModel.builder(
context,
attrs,
R.attr.bottomSheetStyle,
DEF_STYLE_RES
DEF_STYLE_RES,
)
.build()
materialShapeDrawable = MaterialShapeDrawable(shapeAppearanceModelDefault!!)
@ -739,12 +743,13 @@ class TopSheetBehavior<V : View?>
mCallback!!.onSlide(
topSheet,
(top - mMinOffset).toFloat() / mPeekHeight,
isOpening
isOpening,
)
} else {
mCallback!!.onSlide(
topSheet,
(top - mMinOffset).toFloat() / (mMaxOffset - mMinOffset), isOpening
(top - mMinOffset).toFloat() / (mMaxOffset - mMinOffset),
isOpening,
)
}
}
@ -752,7 +757,8 @@ class TopSheetBehavior<V : View?>
private inner class SettleRunnable internal constructor(
private val mView: View,
@field:State @param:State private val mTargetState: Int
@field:State @param:State
private val mTargetState: Int,
) :
Runnable {

@ -181,7 +181,7 @@ class CustomizationFragment : PreferenceFragmentCompat() {
onPreferenceChangeListener = SharedPreferenceUpdater()
}
}
companion object {
// Used to send telemetry data about toolbar position changes
enum class Position { TOP, BOTTOM }

@ -16,9 +16,9 @@ import org.mozilla.fenix.ext.settings
* The preference key is used as the shared preference key.
*/
open class SharedPreferenceUpdater : Preference.OnPreferenceChangeListener {
private val logger = Logger("SharedPreferenceUpdater")
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
if (newValue is Boolean) {
preference.context.settings().preferences.edit {
@ -28,14 +28,13 @@ open class SharedPreferenceUpdater : Preference.OnPreferenceChangeListener {
preference.context.settings().preferences.edit {
putString(preference.key, newValue)
}
logger.info("Set string preference ${preference.key} to ${newValue}")
logger.info("Set string preference ${preference.key} to $newValue")
if (preference.key == preference.context.getString(R.string.pref_key_addons_custom_account) ||
preference.key == preference.context.getString(R.string.pref_key_addons_custom_collection)
) {
logger.info("Preference suggests clearing add-on cache")
preference.context.components.clearAddonCache()
}
}
return true

@ -16,7 +16,7 @@ class ReleaseChannelTest {
fun `isReleased and isDebug channels are mutually exclusive`() {
val debugChannels = setOf(
Debug,
ForkDebug
ForkDebug,
)
val nonDebugChannels = ReleaseChannel.values().toSet() - debugChannels

@ -62,7 +62,7 @@ class AppStoreTest {
currentMode = CurrentMode(
context,
onboarding,
browsingModeManager
browsingModeManager,
) {}
appState = AppState(
@ -72,7 +72,7 @@ class AppStoreTest {
topSites = emptyList(),
showCollectionPlaceholder = true,
showSetAsDefaultBrowserCard = true,
recentTabs = emptyList()
recentTabs = emptyList(),
)
appStore = AppStore(appState)
@ -122,8 +122,8 @@ class AppStoreTest {
val highlight = RecentHistoryHighlight(title = group2.title, "")
appStore = AppStore(
AppState(
recentHistory = listOf(group1, group2, group3, highlight)
)
recentHistory = listOf(group1, group2, group3, highlight),
),
)
assertEquals(0, appStore.state.recentTabs.size)
@ -155,7 +155,7 @@ class AppStoreTest {
val h1 = RecentHistoryHighlight(title = "highlight One", url = "url1")
val h2 = RecentHistoryHighlight(title = "highlight two", url = "url2")
val recentHistoryState = AppState(
recentHistory = listOf(g1, g2, h1, h2)
recentHistory = listOf(g1, g2, h1, h2),
)
appStore = AppStore(recentHistoryState)
@ -168,7 +168,7 @@ class AppStoreTest {
appStore.dispatch(AppAction.RemoveRecentHistoryHighlight(h1.url)).join()
assertEquals(
recentHistoryState.copy(recentHistory = listOf(g1, g2, h2)),
appStore.state
appStore.state,
)
}
@ -251,8 +251,8 @@ class AppStoreTest {
showCollectionPlaceholder = true,
recentTabs = recentTabs,
recentBookmarks = recentBookmarks,
recentHistory = recentHistory
)
recentHistory = recentHistory,
),
).join()
assertEquals(collections, appStore.state.collections)
@ -273,8 +273,8 @@ class AppStoreTest {
pocketStoriesCategories = listOf(otherStoriesCategory, anotherStoriesCategory),
pocketStoriesCategoriesSelections = listOf(
PocketRecommendedStoriesSelectedCategory(otherStoriesCategory.name),
)
)
),
),
)
mockkStatic("org.mozilla.fenix.ext.AppStateKt") {
@ -301,9 +301,9 @@ class AppStoreTest {
pocketStoriesCategories = listOf(otherStoriesCategory, anotherStoriesCategory),
pocketStoriesCategoriesSelections = listOf(
PocketRecommendedStoriesSelectedCategory(otherStoriesCategory.name),
PocketRecommendedStoriesSelectedCategory(anotherStoriesCategory.name)
)
)
PocketRecommendedStoriesSelectedCategory(anotherStoriesCategory.name),
),
),
)
mockkStatic("org.mozilla.fenix.ext.AppStateKt") {
@ -346,13 +346,13 @@ class AppStoreTest {
every { any<AppState>().getFilteredStories(any()) } returns firstFilteredStories
appStore.dispatch(
AppAction.PocketStoriesCategoriesChange(listOf(otherStoriesCategory, anotherStoriesCategory))
AppAction.PocketStoriesCategoriesChange(listOf(otherStoriesCategory, anotherStoriesCategory)),
).join()
verify { any<AppState>().getFilteredStories(POCKET_STORIES_TO_SHOW_COUNT) }
assertTrue(
appStore.state.pocketStoriesCategories.containsAll(
listOf(otherStoriesCategory, anotherStoriesCategory)
)
listOf(otherStoriesCategory, anotherStoriesCategory),
),
)
assertSame(firstFilteredStories, appStore.state.pocketStories)
@ -361,8 +361,8 @@ class AppStoreTest {
every { any<AppState>().getFilteredStories(any()) } returns secondFilteredStories
appStore.dispatch(
AppAction.PocketStoriesCategoriesChange(
updatedCategories
)
updatedCategories,
),
).join()
verify(exactly = 2) { any<AppState>().getFilteredStories(POCKET_STORIES_TO_SHOW_COUNT) }
assertTrue(updatedCategories.containsAll(appStore.state.pocketStoriesCategories))
@ -384,17 +384,17 @@ class AppStoreTest {
appStore.dispatch(
AppAction.PocketStoriesCategoriesSelectionsChange(
storiesCategories = listOf(otherStoriesCategory, anotherStoriesCategory),
categoriesSelected = listOf(selectedCategory)
)
categoriesSelected = listOf(selectedCategory),
),
).join()
verify { any<AppState>().getFilteredStories(POCKET_STORIES_TO_SHOW_COUNT) }
assertTrue(
appStore.state.pocketStoriesCategories.containsAll(
listOf(otherStoriesCategory, anotherStoriesCategory)
)
listOf(otherStoriesCategory, anotherStoriesCategory),
),
)
assertTrue(
appStore.state.pocketStoriesCategoriesSelections.containsAll(listOf(selectedCategory))
appStore.state.pocketStoriesCategoriesSelections.containsAll(listOf(selectedCategory)),
)
assertSame(firstFilteredStories, appStore.state.pocketStories)
}

Loading…
Cancel
Save