From 2f879f8e9d46ceed957199e0328605d567be1040 Mon Sep 17 00:00:00 2001 From: Arturo Mejia Date: Wed, 9 Jun 2021 15:38:23 -0400 Subject: [PATCH] Fix site permissions breaking changes --- .../fenix/browser/BaseBrowserFragment.kt | 4 +-- .../mozilla/fenix/browser/BrowserFragment.kt | 2 +- .../mozilla/fenix/components/Components.kt | 6 ---- .../java/org/mozilla/fenix/components/Core.kt | 30 +++++++++++-------- .../fenix/components/PermissionStorage.kt | 8 ++--- .../customtabs/ExternalAppBrowserFragment.kt | 2 +- .../org/mozilla/fenix/settings/Extensions.kt | 2 +- .../mozilla/fenix/settings/PhoneFeature.kt | 2 +- .../quicksettings/QuickSettingsController.kt | 2 +- .../QuickSettingsFragmentState.kt | 4 +-- .../QuickSettingsFragmentStore.kt | 2 +- .../quicksettings/ext/PhoneFeatureExt.kt | 2 +- ...itePermissionsDetailsExceptionsFragment.kt | 2 +- .../SitePermissionsExceptionsFragment.kt | 30 +++++++++++-------- ...onsManageExceptionsPhoneFeatureFragment.kt | 6 ++-- app/src/main/res/navigation/nav_graph.xml | 6 ++-- .../fenix/browser/BaseBrowserFragmentTest.kt | 2 +- .../fenix/components/PermissionStorageTest.kt | 24 +++++++-------- .../fenix/settings/PhoneFeatureTest.kt | 4 +-- .../quicksettings/AutoplayValueTest.kt | 4 +-- .../DefaultQuickSettingsControllerTest.kt | 4 +-- .../QuickSettingsFragmentStoreTest.kt | 2 +- .../ext/PhoneFeatureExtKtTest.kt | 2 +- ...ermissionsDetailsExceptionsFragmentTest.kt | 2 +- ...anageExceptionsPhoneFeatureFragmentTest.kt | 4 +-- 25 files changed, 82 insertions(+), 76 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt index 4d2d856354..5ddfd13271 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt @@ -78,7 +78,7 @@ import mozilla.components.feature.session.FullScreenFeature import mozilla.components.feature.session.PictureInPictureFeature import mozilla.components.feature.session.SessionFeature import mozilla.components.feature.session.SwipeRefreshFeature -import mozilla.components.feature.sitepermissions.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions import mozilla.components.feature.sitepermissions.SitePermissionsFeature import mozilla.components.lib.state.ext.consumeFlow import mozilla.components.lib.state.ext.flowScoped @@ -650,7 +650,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit sitePermissionsFeature.set( feature = SitePermissionsFeature( context = context, - storage = context.components.core.permissionStorage.permissionsStorage, + storage = context.components.core.geckoSitePermissionsStorage, fragmentManager = parentFragmentManager, promptsStyling = SitePermissionsFeature.PromptsStyling( gravity = getAppropriateLayoutGravity(), diff --git a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt index 13ae90f60a..4f6b62ada0 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt @@ -24,7 +24,7 @@ import mozilla.components.browser.toolbar.BrowserToolbar import mozilla.components.feature.app.links.AppLinksUseCases import mozilla.components.feature.contextmenu.ContextMenuCandidate import mozilla.components.feature.readerview.ReaderViewFeature -import mozilla.components.feature.sitepermissions.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions import mozilla.components.feature.tab.collections.TabCollection import mozilla.components.feature.tabs.WindowFeature import mozilla.components.support.base.feature.UserInteractionHandler diff --git a/app/src/main/java/org/mozilla/fenix/components/Components.kt b/app/src/main/java/org/mozilla/fenix/components/Components.kt index 13bdf93223..19738419bc 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Components.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Components.kt @@ -16,7 +16,6 @@ import mozilla.components.feature.addons.migration.SupportedAddonsChecker import mozilla.components.feature.addons.update.AddonUpdater import mozilla.components.feature.addons.update.DefaultAddonUpdater import mozilla.components.feature.autofill.AutofillConfiguration -import mozilla.components.feature.sitepermissions.SitePermissionsStorage import mozilla.components.lib.publicsuffixlist.PublicSuffixList import mozilla.components.support.migration.state.MigrationStore import org.mozilla.fenix.BuildConfig @@ -26,7 +25,6 @@ import org.mozilla.fenix.R import org.mozilla.fenix.autofill.AutofillConfirmActivity import org.mozilla.fenix.autofill.AutofillUnlockActivity import org.mozilla.fenix.components.metrics.AppStartupTelemetry -import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.settings import org.mozilla.fenix.perf.AppStartReasonProvider import org.mozilla.fenix.perf.StartupActivityLog @@ -143,10 +141,6 @@ class Components(private val context: Context) { AddonManager(core.store, core.engine, addonCollectionProvider, addonUpdater) } - val sitePermissionsStorage by lazyMonitored { - SitePermissionsStorage(context, context.components.core.engine) - } - val analytics by lazyMonitored { Analytics(context) } val publicSuffixList by lazyMonitored { PublicSuffixList(context) } val clipboardHandler by lazyMonitored { ClipboardHandler(context) } diff --git a/app/src/main/java/org/mozilla/fenix/components/Core.kt b/app/src/main/java/org/mozilla/fenix/components/Core.kt index 169fb72153..17ba9b6127 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Core.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Core.kt @@ -13,6 +13,7 @@ import androidx.core.content.ContextCompat import io.sentry.Sentry import mozilla.components.browser.engine.gecko.GeckoEngine import mozilla.components.browser.engine.gecko.fetch.GeckoViewFetchClient +import mozilla.components.browser.engine.gecko.permission.GeckoSitePermissionsStorage import mozilla.components.browser.icons.BrowserIcons import mozilla.components.browser.state.engine.EngineMiddleware import mozilla.components.browser.session.storage.SessionStorage @@ -43,6 +44,7 @@ import mozilla.components.feature.search.region.RegionMiddleware import mozilla.components.feature.session.HistoryDelegate import mozilla.components.feature.session.middleware.LastAccessMiddleware import mozilla.components.feature.session.middleware.undo.UndoMiddleware +import mozilla.components.feature.sitepermissions.OnDiskSitePermissionsStorage import mozilla.components.feature.top.sites.DefaultTopSitesStorage import mozilla.components.feature.top.sites.PinnedSiteStorage import mozilla.components.feature.webcompat.WebCompatFeature @@ -77,6 +79,7 @@ import org.mozilla.fenix.settings.advanced.getSelectedLocale import org.mozilla.fenix.telemetry.TelemetryMiddleware import org.mozilla.fenix.utils.Mockable import org.mozilla.fenix.utils.getUndoDelay +import org.mozilla.geckoview.GeckoRuntime /** * Component group for all core browser functionality. @@ -116,12 +119,7 @@ class Core( GeckoEngine( context, defaultSettings, - GeckoProvider.getOrCreateRuntime( - context, - lazyAutofillStorage, - lazyPasswordsStorage, - trackingProtectionPolicyFactory.createTrackingProtectionPolicy() - ) + geckoRuntime ).also { WebCompatFeature.install(it) @@ -152,15 +150,23 @@ class Core( val client: Client by lazyMonitored { GeckoViewFetchClient( context, - GeckoProvider.getOrCreateRuntime( - context, - lazyAutofillStorage, - lazyPasswordsStorage, - trackingProtectionPolicyFactory.createTrackingProtectionPolicy() - ) + geckoRuntime ) } + val geckoRuntime: GeckoRuntime by lazyMonitored { + GeckoProvider.getOrCreateRuntime( + context, + lazyAutofillStorage, + lazyPasswordsStorage, + trackingProtectionPolicyFactory.createTrackingProtectionPolicy() + ) + } + + val geckoSitePermissionsStorage by lazyMonitored { + GeckoSitePermissionsStorage(geckoRuntime, OnDiskSitePermissionsStorage(context)) + } + val sessionStorage: SessionStorage by lazyMonitored { SessionStorage(context, engine = engine) } diff --git a/app/src/main/java/org/mozilla/fenix/components/PermissionStorage.kt b/app/src/main/java/org/mozilla/fenix/components/PermissionStorage.kt index 6a3f6940a6..c9d1d3e38b 100644 --- a/app/src/main/java/org/mozilla/fenix/components/PermissionStorage.kt +++ b/app/src/main/java/org/mozilla/fenix/components/PermissionStorage.kt @@ -9,8 +9,8 @@ import androidx.annotation.VisibleForTesting import androidx.paging.DataSource import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext -import mozilla.components.feature.sitepermissions.SitePermissions -import mozilla.components.feature.sitepermissions.SitePermissionsStorage +import mozilla.components.concept.engine.permission.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissionsStorage import org.mozilla.fenix.ext.components import org.mozilla.fenix.utils.Mockable import kotlin.coroutines.CoroutineContext @@ -20,7 +20,7 @@ class PermissionStorage( private val context: Context, @VisibleForTesting internal val dispatcher: CoroutineContext = Dispatchers.IO, @VisibleForTesting internal val permissionsStorage: SitePermissionsStorage = - context.components.sitePermissionsStorage + context.components.core.geckoSitePermissionsStorage ) { suspend fun add(sitePermissions: SitePermissions) = withContext(dispatcher) { @@ -35,7 +35,7 @@ class PermissionStorage( permissionsStorage.update(sitePermissions) } - fun getSitePermissionsPaged(): DataSource.Factory { + suspend fun getSitePermissionsPaged(): DataSource.Factory { return permissionsStorage.getSitePermissionsPaged() } diff --git a/app/src/main/java/org/mozilla/fenix/customtabs/ExternalAppBrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/customtabs/ExternalAppBrowserFragment.kt index e89aed2d88..85f01d40a0 100644 --- a/app/src/main/java/org/mozilla/fenix/customtabs/ExternalAppBrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/customtabs/ExternalAppBrowserFragment.kt @@ -23,7 +23,7 @@ import mozilla.components.feature.pwa.feature.ManifestUpdateFeature import mozilla.components.feature.pwa.feature.WebAppActivityFeature import mozilla.components.feature.pwa.feature.WebAppHideToolbarFeature import mozilla.components.feature.pwa.feature.WebAppSiteControlsFeature -import mozilla.components.feature.sitepermissions.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions import mozilla.components.support.base.feature.UserInteractionHandler import mozilla.components.support.base.feature.ViewBoundFeatureWrapper import mozilla.components.support.ktx.android.arch.lifecycle.addObservers diff --git a/app/src/main/java/org/mozilla/fenix/settings/Extensions.kt b/app/src/main/java/org/mozilla/fenix/settings/Extensions.kt index 8372490682..c8fd2a9427 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/Extensions.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/Extensions.kt @@ -9,7 +9,7 @@ import androidx.annotation.StringRes import androidx.appcompat.content.res.AppCompatResources import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat -import mozilla.components.feature.sitepermissions.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions import mozilla.components.support.ktx.android.content.res.resolveAttribute import mozilla.components.support.ktx.android.view.putCompoundDrawablesRelative import org.mozilla.fenix.ext.getPreferenceKey diff --git a/app/src/main/java/org/mozilla/fenix/settings/PhoneFeature.kt b/app/src/main/java/org/mozilla/fenix/settings/PhoneFeature.kt index dc1579f745..83aafb535d 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/PhoneFeature.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/PhoneFeature.kt @@ -11,7 +11,7 @@ import android.content.Context import android.os.Parcelable import androidx.annotation.StringRes import kotlinx.android.parcel.Parcelize -import mozilla.components.feature.sitepermissions.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions import mozilla.components.feature.sitepermissions.SitePermissionsRules import mozilla.components.support.ktx.android.content.isPermissionGranted import org.mozilla.fenix.R diff --git a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsController.kt b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsController.kt index 1008d7cd38..20b74494b0 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsController.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsController.kt @@ -13,7 +13,7 @@ import kotlinx.coroutines.launch import mozilla.components.browser.state.selector.findTabOrCustomTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.feature.session.SessionUseCases.ReloadUrlUseCase -import mozilla.components.feature.sitepermissions.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions import mozilla.components.feature.tabs.TabsUseCases.AddNewTabUseCase import mozilla.components.support.base.feature.OnNeedToRequestPermissions import org.mozilla.fenix.components.PermissionStorage diff --git a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentState.kt b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentState.kt index 2caf3fc60c..0d9e8c75d9 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentState.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentState.kt @@ -8,8 +8,8 @@ import android.content.Context import androidx.annotation.ColorRes import androidx.annotation.DrawableRes import androidx.annotation.StringRes -import mozilla.components.feature.sitepermissions.SitePermissions -import mozilla.components.feature.sitepermissions.SitePermissions.AutoplayStatus +import mozilla.components.concept.engine.permission.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions.AutoplayStatus import mozilla.components.feature.sitepermissions.SitePermissionsRules import mozilla.components.feature.sitepermissions.SitePermissionsRules.AutoplayAction import mozilla.components.lib.state.State diff --git a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStore.kt b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStore.kt index ba4efd1aa9..cbf36b871e 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStore.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStore.kt @@ -7,7 +7,7 @@ package org.mozilla.fenix.settings.quicksettings import android.content.Context import androidx.annotation.VisibleForTesting import mozilla.components.browser.state.state.content.PermissionHighlightsState -import mozilla.components.feature.sitepermissions.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions import mozilla.components.lib.state.Action import mozilla.components.lib.state.Reducer import mozilla.components.lib.state.State diff --git a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/ext/PhoneFeatureExt.kt b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/ext/PhoneFeatureExt.kt index 4169e1eb63..d803a8ea9c 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/ext/PhoneFeatureExt.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/ext/PhoneFeatureExt.kt @@ -5,7 +5,7 @@ package org.mozilla.fenix.settings.quicksettings.ext import android.content.Context -import mozilla.components.feature.sitepermissions.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions import org.mozilla.fenix.settings.PhoneFeature import org.mozilla.fenix.utils.Settings diff --git a/app/src/main/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsDetailsExceptionsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsDetailsExceptionsFragment.kt index dcb2bcc9c5..8dddc6b45c 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsDetailsExceptionsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsDetailsExceptionsFragment.kt @@ -17,7 +17,7 @@ import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import mozilla.components.feature.sitepermissions.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions import org.mozilla.fenix.R import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.navigateBlockingForAsyncNavGraph diff --git a/app/src/main/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsExceptionsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsExceptionsFragment.kt index 352b71150b..8faaeec7e6 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsExceptionsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsExceptionsFragment.kt @@ -24,9 +24,11 @@ import androidx.paging.PagedListAdapter import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.launch -import mozilla.components.feature.sitepermissions.SitePermissions +import kotlinx.coroutines.withContext +import mozilla.components.concept.engine.permission.SitePermissions import org.mozilla.fenix.NavHostActivity import org.mozilla.fenix.R import org.mozilla.fenix.ext.components @@ -57,20 +59,24 @@ class SitePermissionsExceptionsFragment : recyclerView = rootView.findViewById(R.id.exceptions) recyclerView.layoutManager = LinearLayoutManager(requireContext()) - val sitePermissionsPaged = requireContext().components.core.permissionStorage.getSitePermissionsPaged() + viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) { + val sitePermissionsPaged = requireContext().components.core.permissionStorage.getSitePermissionsPaged() - val adapter = ExceptionsAdapter(this) - val liveData = LivePagedListBuilder(sitePermissionsPaged, MAX_ITEMS_PER_PAGE).build() + withContext(Main) { + val adapter = ExceptionsAdapter(this@SitePermissionsExceptionsFragment) + val liveData = LivePagedListBuilder(sitePermissionsPaged, MAX_ITEMS_PER_PAGE).build() - liveData.observe(viewLifecycleOwner, Observer> { - if (it.isEmpty()) { - showEmptyListMessage() - } else { - hideEmptyListMessage() - adapter.submitList(it) - recyclerView.adapter = adapter + liveData.observe(viewLifecycleOwner, Observer> { + if (it.isEmpty()) { + showEmptyListMessage() + } else { + hideEmptyListMessage() + adapter.submitList(it) + recyclerView.adapter = adapter + } + }) } - }) + } } private fun hideEmptyListMessage() { diff --git a/app/src/main/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsManageExceptionsPhoneFeatureFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsManageExceptionsPhoneFeatureFragment.kt index 97c4a63d3c..398f6c6e14 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsManageExceptionsPhoneFeatureFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsManageExceptionsPhoneFeatureFragment.kt @@ -23,9 +23,9 @@ import androidx.lifecycle.lifecycleScope import androidx.navigation.fragment.navArgs import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.launch -import mozilla.components.feature.sitepermissions.SitePermissions -import mozilla.components.feature.sitepermissions.SitePermissions.Status.ALLOWED -import mozilla.components.feature.sitepermissions.SitePermissions.Status.BLOCKED +import mozilla.components.concept.engine.permission.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions.Status.ALLOWED +import mozilla.components.concept.engine.permission.SitePermissions.Status.BLOCKED import org.mozilla.fenix.R import org.mozilla.fenix.ext.requireComponents import org.mozilla.fenix.ext.settings diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index cfc4d08b71..71b28b4a1f 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -754,7 +754,7 @@ app:argType="boolean" /> + app:argType="mozilla.components.concept.engine.permission.SitePermissions" /> + app:argType="mozilla.components.concept.engine.permission.SitePermissions" /> diff --git a/app/src/test/java/org/mozilla/fenix/browser/BaseBrowserFragmentTest.kt b/app/src/test/java/org/mozilla/fenix/browser/BaseBrowserFragmentTest.kt index c0d486e175..a018419bba 100644 --- a/app/src/test/java/org/mozilla/fenix/browser/BaseBrowserFragmentTest.kt +++ b/app/src/test/java/org/mozilla/fenix/browser/BaseBrowserFragmentTest.kt @@ -21,7 +21,7 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.concept.engine.EngineView import mozilla.components.feature.contextmenu.ContextMenuCandidate import mozilla.components.feature.session.behavior.EngineViewBrowserToolbarBehavior -import mozilla.components.feature.sitepermissions.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions import mozilla.components.support.test.robolectric.testContext import mozilla.components.ui.widgets.VerticalSwipeRefreshLayout import org.junit.Before diff --git a/app/src/test/java/org/mozilla/fenix/components/PermissionStorageTest.kt b/app/src/test/java/org/mozilla/fenix/components/PermissionStorageTest.kt index 6313966477..630818deb6 100644 --- a/app/src/test/java/org/mozilla/fenix/components/PermissionStorageTest.kt +++ b/app/src/test/java/org/mozilla/fenix/components/PermissionStorageTest.kt @@ -5,13 +5,13 @@ package org.mozilla.fenix.components import androidx.paging.DataSource -import io.mockk.every +import io.mockk.coEvery +import io.mockk.coVerify import io.mockk.mockk -import io.mockk.verify import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runBlockingTest -import mozilla.components.feature.sitepermissions.SitePermissions -import mozilla.components.feature.sitepermissions.SitePermissionsStorage +import mozilla.components.concept.engine.permission.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissionsStorage import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertEquals import org.junit.Test @@ -30,7 +30,7 @@ class PermissionStorageTest { storage.add(sitePermissions) - verify { sitePermissionsStorage.save(sitePermissions) } + coVerify { sitePermissionsStorage.save(sitePermissions) } } @Test @@ -39,11 +39,11 @@ class PermissionStorageTest { val sitePermissionsStorage: SitePermissionsStorage = mockk(relaxed = true) val storage = PermissionStorage(testContext, this.coroutineContext, sitePermissionsStorage) - every { sitePermissionsStorage.findSitePermissionsBy(any()) } returns sitePermissions + coEvery { sitePermissionsStorage.findSitePermissionsBy(any()) } returns sitePermissions val result = storage.findSitePermissionsBy("origin") - verify { sitePermissionsStorage.findSitePermissionsBy("origin") } + coVerify { sitePermissionsStorage.findSitePermissionsBy("origin") } assertEquals(sitePermissions, result) } @@ -56,7 +56,7 @@ class PermissionStorageTest { storage.updateSitePermissions(sitePermissions) - verify { sitePermissionsStorage.update(sitePermissions) } + coVerify { sitePermissionsStorage.update(sitePermissions) } } @Test @@ -65,11 +65,11 @@ class PermissionStorageTest { val sitePermissionsStorage: SitePermissionsStorage = mockk(relaxed = true) val storage = PermissionStorage(testContext, this.coroutineContext, sitePermissionsStorage) - every { sitePermissionsStorage.getSitePermissionsPaged() } returns dataSource + coEvery { sitePermissionsStorage.getSitePermissionsPaged() } returns dataSource val result = storage.getSitePermissionsPaged() - verify { sitePermissionsStorage.getSitePermissionsPaged() } + coVerify { sitePermissionsStorage.getSitePermissionsPaged() } assertEquals(dataSource, result) } @@ -82,7 +82,7 @@ class PermissionStorageTest { storage.deleteSitePermissions(sitePermissions) - verify { sitePermissionsStorage.remove(sitePermissions) } + coVerify { sitePermissionsStorage.remove(sitePermissions) } } @Test @@ -92,6 +92,6 @@ class PermissionStorageTest { storage.deleteAllSitePermissions() - verify { sitePermissionsStorage.removeAll() } + coVerify { sitePermissionsStorage.removeAll() } } } diff --git a/app/src/test/java/org/mozilla/fenix/settings/PhoneFeatureTest.kt b/app/src/test/java/org/mozilla/fenix/settings/PhoneFeatureTest.kt index f378a174ce..d8e9f99e6d 100644 --- a/app/src/test/java/org/mozilla/fenix/settings/PhoneFeatureTest.kt +++ b/app/src/test/java/org/mozilla/fenix/settings/PhoneFeatureTest.kt @@ -8,8 +8,8 @@ import android.Manifest import io.mockk.MockKAnnotations import io.mockk.every import io.mockk.impl.annotations.MockK -import mozilla.components.feature.sitepermissions.SitePermissions -import mozilla.components.feature.sitepermissions.SitePermissions.Status +import mozilla.components.concept.engine.permission.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions.Status import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertEquals diff --git a/app/src/test/java/org/mozilla/fenix/settings/quicksettings/AutoplayValueTest.kt b/app/src/test/java/org/mozilla/fenix/settings/quicksettings/AutoplayValueTest.kt index 34800805c0..e325713e23 100644 --- a/app/src/test/java/org/mozilla/fenix/settings/quicksettings/AutoplayValueTest.kt +++ b/app/src/test/java/org/mozilla/fenix/settings/quicksettings/AutoplayValueTest.kt @@ -7,8 +7,8 @@ package org.mozilla.fenix.settings.quicksettings import io.mockk.MockKAnnotations import io.mockk.every import io.mockk.impl.annotations.MockK -import mozilla.components.feature.sitepermissions.SitePermissions -import mozilla.components.feature.sitepermissions.SitePermissions.AutoplayStatus +import mozilla.components.concept.engine.permission.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions.AutoplayStatus import mozilla.components.feature.sitepermissions.SitePermissionsRules import mozilla.components.feature.sitepermissions.SitePermissionsRules.AutoplayAction import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action diff --git a/app/src/test/java/org/mozilla/fenix/settings/quicksettings/DefaultQuickSettingsControllerTest.kt b/app/src/test/java/org/mozilla/fenix/settings/quicksettings/DefaultQuickSettingsControllerTest.kt index 57f7e8d6dd..b777c60017 100644 --- a/app/src/test/java/org/mozilla/fenix/settings/quicksettings/DefaultQuickSettingsControllerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/settings/quicksettings/DefaultQuickSettingsControllerTest.kt @@ -23,8 +23,8 @@ import mozilla.components.browser.state.state.TabSessionState import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.feature.session.SessionUseCases -import mozilla.components.feature.sitepermissions.SitePermissions -import mozilla.components.feature.sitepermissions.SitePermissions.Status.NO_DECISION +import mozilla.components.concept.engine.permission.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions.Status.NO_DECISION import mozilla.components.feature.tabs.TabsUseCases import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext diff --git a/app/src/test/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStoreTest.kt b/app/src/test/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStoreTest.kt index a5cff8b24d..7ff135006a 100644 --- a/app/src/test/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStoreTest.kt +++ b/app/src/test/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStoreTest.kt @@ -14,7 +14,7 @@ import io.mockk.verify import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import mozilla.components.browser.state.state.content.PermissionHighlightsState -import mozilla.components.feature.sitepermissions.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions import mozilla.components.feature.sitepermissions.SitePermissionsRules import mozilla.components.feature.sitepermissions.SitePermissionsRules.AutoplayAction import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action diff --git a/app/src/test/java/org/mozilla/fenix/settings/quicksettings/ext/PhoneFeatureExtKtTest.kt b/app/src/test/java/org/mozilla/fenix/settings/quicksettings/ext/PhoneFeatureExtKtTest.kt index 73d80f8ad9..30511630db 100644 --- a/app/src/test/java/org/mozilla/fenix/settings/quicksettings/ext/PhoneFeatureExtKtTest.kt +++ b/app/src/test/java/org/mozilla/fenix/settings/quicksettings/ext/PhoneFeatureExtKtTest.kt @@ -8,7 +8,7 @@ import android.content.Context import android.content.pm.PackageManager import io.mockk.every import io.mockk.mockk -import mozilla.components.feature.sitepermissions.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test diff --git a/app/src/test/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsDetailsExceptionsFragmentTest.kt b/app/src/test/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsDetailsExceptionsFragmentTest.kt index 262cd08d97..f0ceca6b3a 100644 --- a/app/src/test/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsDetailsExceptionsFragmentTest.kt +++ b/app/src/test/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsDetailsExceptionsFragmentTest.kt @@ -10,7 +10,7 @@ import io.mockk.every import io.mockk.impl.annotations.MockK import io.mockk.spyk import io.mockk.verify -import mozilla.components.feature.sitepermissions.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertEquals import org.junit.Before diff --git a/app/src/test/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsManageExceptionsPhoneFeatureFragmentTest.kt b/app/src/test/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsManageExceptionsPhoneFeatureFragmentTest.kt index 76450ce189..cd0a96b07f 100644 --- a/app/src/test/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsManageExceptionsPhoneFeatureFragmentTest.kt +++ b/app/src/test/java/org/mozilla/fenix/settings/sitepermissions/SitePermissionsManageExceptionsPhoneFeatureFragmentTest.kt @@ -14,8 +14,8 @@ import io.mockk.spyk import io.mockk.verify import io.mockk.MockKAnnotations import io.mockk.impl.annotations.MockK -import mozilla.components.feature.sitepermissions.SitePermissions -import mozilla.components.feature.sitepermissions.SitePermissions.AutoplayStatus +import mozilla.components.concept.engine.permission.SitePermissions +import mozilla.components.concept.engine.permission.SitePermissions.AutoplayStatus import mozilla.components.feature.sitepermissions.SitePermissionsRules import mozilla.components.feature.sitepermissions.SitePermissionsRules.AutoplayAction import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action