For #27455 - Rename all reference names to `AppStore` as appStore
This commit is contained in:
parent
7d39494c06
commit
0c13a5aa5d
|
@ -12,11 +12,11 @@ import org.mozilla.fenix.components.appstate.AppAction.MessagingAction
|
|||
/**
|
||||
* A message observer that updates the provided.
|
||||
*/
|
||||
class MessagingFeature(val store: AppStore) : LifecycleAwareFeature {
|
||||
class MessagingFeature(val appStore: AppStore) : LifecycleAwareFeature {
|
||||
|
||||
override fun start() {
|
||||
if (FeatureFlags.messagingFeature) {
|
||||
store.dispatch(MessagingAction.Evaluate)
|
||||
appStore.dispatch(MessagingAction.Evaluate)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ class HomeFragment : Fragment() {
|
|||
if (requireContext().settings().isExperimentationEnabled) {
|
||||
messagingFeature.set(
|
||||
feature = MessagingFeature(
|
||||
store = requireComponents.appStore,
|
||||
appStore = requireComponents.appStore,
|
||||
),
|
||||
owner = viewLifecycleOwner,
|
||||
view = binding.root,
|
||||
|
@ -265,7 +265,7 @@ class HomeFragment : Fragment() {
|
|||
topSitesFeature.set(
|
||||
feature = TopSitesFeature(
|
||||
view = DefaultTopSitesView(
|
||||
store = components.appStore,
|
||||
appStore = components.appStore,
|
||||
settings = components.settings,
|
||||
),
|
||||
storage = components.core.topSitesStorage,
|
||||
|
|
|
@ -17,14 +17,14 @@ import mozilla.components.lib.crash.CrashReporter
|
|||
* Process the [Intent] from [CrashReporter] through which the app is informed about
|
||||
* recoverable native crashes.
|
||||
*/
|
||||
class CrashReporterIntentProcessor(private val store: AppStore) : HomeIntentProcessor {
|
||||
class CrashReporterIntentProcessor(private val appStore: AppStore) : HomeIntentProcessor {
|
||||
|
||||
override fun process(intent: Intent, navController: NavController, out: Intent): Boolean {
|
||||
return if (Crash.isCrashIntent(intent)) {
|
||||
val crash = Crash.fromIntent(intent)
|
||||
// If only a child process crashed we can handle this gracefully.
|
||||
if ((crash as? NativeCodeCrash)?.isFatal == false) {
|
||||
store.dispatch(AppAction.AddNonFatalCrash(crash))
|
||||
appStore.dispatch(AppAction.AddNonFatalCrash(crash))
|
||||
} else {
|
||||
// A fatal crash means the app's main process is affected.
|
||||
// An UncaughtExceptionCrash refers to a [Throwable] that would otherwise crash the app
|
||||
|
|
|
@ -309,7 +309,7 @@ class SessionControlAdapter(
|
|||
TopPlaceholderViewHolder.LAYOUT_ID -> TopPlaceholderViewHolder(view)
|
||||
TopSitePagerViewHolder.LAYOUT_ID -> TopSitePagerViewHolder(
|
||||
view = view,
|
||||
store = components.appStore,
|
||||
appStore = components.appStore,
|
||||
viewLifecycleOwner = viewLifecycleOwner,
|
||||
interactor = interactor,
|
||||
)
|
||||
|
|
|
@ -12,12 +12,12 @@ import org.mozilla.fenix.ext.sort
|
|||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
class DefaultTopSitesView(
|
||||
val store: AppStore,
|
||||
val appStore: AppStore,
|
||||
val settings: Settings,
|
||||
) : TopSitesView {
|
||||
|
||||
override fun displayTopSites(topSites: List<TopSite>) {
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.TopSitesChange(
|
||||
if (!settings.showContileFeature) {
|
||||
topSites
|
||||
|
|
|
@ -39,7 +39,7 @@ import org.mozilla.fenix.utils.view.ViewHolder
|
|||
@SuppressLint("ClickableViewAccessibility")
|
||||
class TopSiteItemViewHolder(
|
||||
view: View,
|
||||
store: AppStore,
|
||||
appStore: AppStore,
|
||||
private val viewLifecycleOwner: LifecycleOwner,
|
||||
private val interactor: TopSiteInteractor,
|
||||
) : ViewHolder(view) {
|
||||
|
@ -78,7 +78,7 @@ class TopSiteItemViewHolder(
|
|||
true
|
||||
}
|
||||
|
||||
store.flowScoped(viewLifecycleOwner) { flow ->
|
||||
appStore.flowScoped(viewLifecycleOwner) { flow ->
|
||||
flow.map { state -> state.wallpaperState }
|
||||
.ifChanged()
|
||||
.collect { currentState ->
|
||||
|
|
|
@ -19,13 +19,13 @@ import org.mozilla.fenix.home.sessioncontrol.TopSiteInteractor
|
|||
|
||||
class TopSitePagerViewHolder(
|
||||
view: View,
|
||||
store: AppStore,
|
||||
appStore: AppStore,
|
||||
viewLifecycleOwner: LifecycleOwner,
|
||||
interactor: TopSiteInteractor,
|
||||
) : RecyclerView.ViewHolder(view) {
|
||||
|
||||
private val binding = ComponentTopSitesPagerBinding.bind(view)
|
||||
private val topSitesPagerAdapter = TopSitesPagerAdapter(store, viewLifecycleOwner, interactor)
|
||||
private val topSitesPagerAdapter = TopSitesPagerAdapter(appStore, viewLifecycleOwner, interactor)
|
||||
private val pageIndicator = binding.pageIndicator
|
||||
private var currentPage = 0
|
||||
|
||||
|
|
|
@ -16,12 +16,12 @@ import org.mozilla.fenix.utils.AccessibilityGridLayoutManager
|
|||
|
||||
class TopSiteViewHolder(
|
||||
view: View,
|
||||
store: AppStore,
|
||||
appStore: AppStore,
|
||||
viewLifecycleOwner: LifecycleOwner,
|
||||
interactor: TopSiteInteractor,
|
||||
) : RecyclerView.ViewHolder(view) {
|
||||
|
||||
private val topSitesAdapter = TopSitesAdapter(store, viewLifecycleOwner, interactor)
|
||||
private val topSitesAdapter = TopSitesAdapter(appStore, viewLifecycleOwner, interactor)
|
||||
val binding = ComponentTopSitesBinding.bind(view)
|
||||
|
||||
init {
|
||||
|
|
|
@ -15,14 +15,14 @@ import org.mozilla.fenix.home.sessioncontrol.TopSiteInteractor
|
|||
import org.mozilla.fenix.perf.StartupTimeline
|
||||
|
||||
class TopSitesAdapter(
|
||||
private val store: AppStore,
|
||||
private val appStore: AppStore,
|
||||
private val viewLifecycleOwner: LifecycleOwner,
|
||||
private val interactor: TopSiteInteractor,
|
||||
) : ListAdapter<TopSite, TopSiteItemViewHolder>(TopSitesDiffCallback) {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TopSiteItemViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(TopSiteItemViewHolder.LAYOUT_ID, parent, false)
|
||||
return TopSiteItemViewHolder(view, store, viewLifecycleOwner, interactor)
|
||||
return TopSiteItemViewHolder(view, appStore, viewLifecycleOwner, interactor)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: TopSiteItemViewHolder, position: Int) {
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.mozilla.fenix.home.sessioncontrol.TopSiteInteractor
|
|||
import org.mozilla.fenix.home.topsites.TopSitePagerViewHolder.Companion.TOP_SITES_PER_PAGE
|
||||
|
||||
class TopSitesPagerAdapter(
|
||||
private val store: AppStore,
|
||||
private val appStore: AppStore,
|
||||
private val viewLifecycleOwner: LifecycleOwner,
|
||||
private val interactor: TopSiteInteractor,
|
||||
) : ListAdapter<List<TopSite>, TopSiteViewHolder>(TopSiteListDiffCallback) {
|
||||
|
@ -25,7 +25,7 @@ class TopSitesPagerAdapter(
|
|||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TopSiteViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(TopSiteViewHolder.LAYOUT_ID, parent, false)
|
||||
return TopSiteViewHolder(view, store, viewLifecycleOwner, interactor)
|
||||
return TopSiteViewHolder(view, appStore, viewLifecycleOwner, interactor)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Date
|
|||
* Contains use cases related to the wallpaper feature.
|
||||
*
|
||||
* @param context Used for various file and configuration checks.
|
||||
* @param store Will receive dispatches of metadata updates like the currently selected wallpaper.
|
||||
* @param appStore Will receive dispatches of metadata updates like the currently selected wallpaper.
|
||||
* @param client Handles downloading wallpapers and their metadata.
|
||||
* @param storageRootDirectory The top level app-local storage directory.
|
||||
* @param currentLocale The locale currently being used on the device.
|
||||
|
@ -38,7 +38,7 @@ import java.util.Date
|
|||
*/
|
||||
class WallpapersUseCases(
|
||||
context: Context,
|
||||
store: AppStore,
|
||||
appStore: AppStore,
|
||||
client: Client,
|
||||
storageRootDirectory: File,
|
||||
currentLocale: String,
|
||||
|
@ -54,7 +54,7 @@ class WallpapersUseCases(
|
|||
selectWallpaper::invoke,
|
||||
)
|
||||
DefaultInitializeWallpaperUseCase(
|
||||
store = store,
|
||||
appStore = appStore,
|
||||
downloader = downloader,
|
||||
fileManager = fileManager,
|
||||
metadataFetcher = metadataFetcher,
|
||||
|
@ -66,7 +66,7 @@ class WallpapersUseCases(
|
|||
val fileManager = LegacyWallpaperFileManager(storageRootDirectory)
|
||||
val downloader = LegacyWallpaperDownloader(context, client)
|
||||
LegacyInitializeWallpaperUseCase(
|
||||
store = store,
|
||||
appStore = appStore,
|
||||
downloader = downloader,
|
||||
fileManager = fileManager,
|
||||
settings = context.settings(),
|
||||
|
@ -90,9 +90,9 @@ class WallpapersUseCases(
|
|||
}
|
||||
val selectWallpaper: SelectWallpaperUseCase by lazy {
|
||||
if (FeatureFlags.wallpaperV2Enabled) {
|
||||
DefaultSelectWallpaperUseCase(context.settings(), store, fileManager, downloader)
|
||||
DefaultSelectWallpaperUseCase(context.settings(), appStore, fileManager, downloader)
|
||||
} else {
|
||||
LegacySelectWallpaperUseCase(context.settings(), store)
|
||||
LegacySelectWallpaperUseCase(context.settings(), appStore)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ class WallpapersUseCases(
|
|||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
internal class LegacyInitializeWallpaperUseCase(
|
||||
private val store: AppStore,
|
||||
private val appStore: AppStore,
|
||||
private val downloader: LegacyWallpaperDownloader,
|
||||
private val fileManager: LegacyWallpaperFileManager,
|
||||
private val settings: Settings,
|
||||
|
@ -119,7 +119,7 @@ class WallpapersUseCases(
|
|||
|
||||
/**
|
||||
* Downloads the currently available wallpaper metadata from a remote source.
|
||||
* Updates the [store] with that metadata and with the selected wallpaper found in storage.
|
||||
* Updates the [appStore] with that metadata and with the selected wallpaper found in storage.
|
||||
* Removes any unused promotional or time-limited assets from local storage.
|
||||
* Should usually be called early the app's lifetime to ensure that metadata and thumbnails
|
||||
* are available as soon as they are needed.
|
||||
|
@ -131,7 +131,7 @@ class WallpapersUseCases(
|
|||
withContext(Dispatchers.IO) {
|
||||
val dispatchedCurrent = Wallpaper.getCurrentWallpaperFromSettings(settings)?.let {
|
||||
// Dispatch this ASAP so the home screen can render.
|
||||
store.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(it))
|
||||
appStore.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(it))
|
||||
true
|
||||
} ?: false
|
||||
val availableWallpapers = possibleWallpapers.getAvailableWallpapers()
|
||||
|
@ -145,9 +145,9 @@ class WallpapersUseCases(
|
|||
possibleWallpapers,
|
||||
)
|
||||
downloadAllRemoteWallpapers(availableWallpapers)
|
||||
store.dispatch(AppAction.WallpaperAction.UpdateAvailableWallpapers(availableWallpapers))
|
||||
appStore.dispatch(AppAction.WallpaperAction.UpdateAvailableWallpapers(availableWallpapers))
|
||||
if (!dispatchedCurrent) {
|
||||
store.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(currentWallpaper))
|
||||
appStore.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(currentWallpaper))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ class WallpapersUseCases(
|
|||
@Suppress("LongParameterList")
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
internal class DefaultInitializeWallpaperUseCase(
|
||||
private val store: AppStore,
|
||||
private val appStore: AppStore,
|
||||
private val downloader: WallpaperDownloader,
|
||||
private val fileManager: WallpaperFileManager,
|
||||
private val metadataFetcher: WallpaperMetadataFetcher,
|
||||
|
@ -247,7 +247,7 @@ class WallpapersUseCases(
|
|||
) : InitializeWallpapersUseCase {
|
||||
override suspend fun invoke() {
|
||||
Wallpaper.getCurrentWallpaperFromSettings(settings)?.let {
|
||||
store.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(it))
|
||||
appStore.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(it))
|
||||
}
|
||||
val currentWallpaperName = if (settings.shouldMigrateLegacyWallpaper) {
|
||||
val migratedWallpaperName =
|
||||
|
@ -267,7 +267,7 @@ class WallpapersUseCases(
|
|||
|
||||
// Dispatching this early will make it accessible to the home screen ASAP. If it has been
|
||||
// dispatched above, we may still need to update other metadata about it.
|
||||
store.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(currentWallpaper))
|
||||
appStore.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(currentWallpaper))
|
||||
|
||||
fileManager.clean(
|
||||
currentWallpaper,
|
||||
|
@ -280,7 +280,7 @@ class WallpapersUseCases(
|
|||
}
|
||||
|
||||
val defaultIncluded = listOf(Wallpaper.Default) + wallpapersWithUpdatedThumbnailState
|
||||
store.dispatch(AppAction.WallpaperAction.UpdateAvailableWallpapers(defaultIncluded))
|
||||
appStore.dispatch(AppAction.WallpaperAction.UpdateAvailableWallpapers(defaultIncluded))
|
||||
}
|
||||
|
||||
private fun Wallpaper.isExpired(): Boolean = when (this) {
|
||||
|
@ -445,10 +445,10 @@ class WallpapersUseCases(
|
|||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
internal class LegacySelectWallpaperUseCase(
|
||||
private val settings: Settings,
|
||||
private val store: AppStore,
|
||||
private val appStore: AppStore,
|
||||
) : SelectWallpaperUseCase {
|
||||
/**
|
||||
* Select a new wallpaper. Storage and the store will be updated appropriately.
|
||||
* Select a new wallpaper. Storage and the app store will be updated appropriately.
|
||||
*
|
||||
* @param wallpaper The selected wallpaper.
|
||||
*/
|
||||
|
@ -457,7 +457,7 @@ class WallpapersUseCases(
|
|||
settings.currentWallpaperTextColor = wallpaper.textColor ?: 0
|
||||
settings.currentWallpaperCardColorLight = wallpaper.cardColorLight ?: 0
|
||||
settings.currentWallpaperCardColorDark = wallpaper.cardColorDark ?: 0
|
||||
store.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(wallpaper))
|
||||
appStore.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(wallpaper))
|
||||
return Wallpaper.ImageFileState.Downloaded
|
||||
}
|
||||
}
|
||||
|
@ -465,12 +465,12 @@ class WallpapersUseCases(
|
|||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
internal class DefaultSelectWallpaperUseCase(
|
||||
private val settings: Settings,
|
||||
private val store: AppStore,
|
||||
private val appStore: AppStore,
|
||||
private val fileManager: WallpaperFileManager,
|
||||
private val downloader: WallpaperDownloader,
|
||||
) : SelectWallpaperUseCase {
|
||||
/**
|
||||
* Select a new wallpaper. Storage and the store will be updated appropriately.
|
||||
* Select a new wallpaper. Storage and the app store will be updated appropriately.
|
||||
*
|
||||
* @param wallpaper The selected wallpaper.
|
||||
*/
|
||||
|
@ -496,11 +496,11 @@ class WallpapersUseCases(
|
|||
settings.currentWallpaperTextColor = wallpaper.textColor ?: 0L
|
||||
settings.currentWallpaperCardColorLight = wallpaper.cardColorLight ?: 0L
|
||||
settings.currentWallpaperCardColorDark = wallpaper.cardColorDark ?: 0L
|
||||
store.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(wallpaper))
|
||||
appStore.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(wallpaper))
|
||||
}
|
||||
|
||||
private fun dispatchDownloadState(wallpaper: Wallpaper, downloadState: Wallpaper.ImageFileState) {
|
||||
store.dispatch(AppAction.WallpaperAction.UpdateWallpaperDownloadState(wallpaper, downloadState))
|
||||
appStore.dispatch(AppAction.WallpaperAction.UpdateWallpaperDownloadState(wallpaper, downloadState))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,14 +14,14 @@ import org.mozilla.fenix.components.AppStore
|
|||
class AppActionTest {
|
||||
|
||||
private val capture = CaptureActionsMiddleware<AppState, AppAction>()
|
||||
private val store = AppStore(middlewares = listOf(capture))
|
||||
private val appStore = AppStore(middlewares = listOf(capture))
|
||||
|
||||
@Test
|
||||
fun `WHEN UpdateInactiveExpanded is dispatched THEN update inactiveTabsExpanded`() {
|
||||
assertFalse(store.state.inactiveTabsExpanded)
|
||||
assertFalse(appStore.state.inactiveTabsExpanded)
|
||||
|
||||
store.dispatch(AppAction.UpdateInactiveExpanded(true)).joinBlocking()
|
||||
appStore.dispatch(AppAction.UpdateInactiveExpanded(true)).joinBlocking()
|
||||
|
||||
assertTrue(store.state.inactiveTabsExpanded)
|
||||
assertTrue(appStore.state.inactiveTabsExpanded)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,19 +36,19 @@ class DefaultMessageControllerTest {
|
|||
private val activity: HomeActivity = mockk(relaxed = true)
|
||||
private val storageNimbus: NimbusMessagingStorage = mockk(relaxed = true)
|
||||
private lateinit var controller: DefaultMessageController
|
||||
private val store: AppStore = mockk(relaxed = true)
|
||||
private val appStore: AppStore = mockk(relaxed = true)
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
controller = DefaultMessageController(
|
||||
messagingStorage = storageNimbus,
|
||||
appStore = store,
|
||||
appStore = appStore,
|
||||
homeActivity = activity,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `WHEN calling onMessagePressed THEN update the store and handle the action`() {
|
||||
fun `WHEN calling onMessagePressed THEN update the app store and handle the action`() {
|
||||
val customController = spyk(controller)
|
||||
val message = mockMessage()
|
||||
every { customController.handleAction(any()) } returns mockk()
|
||||
|
@ -63,7 +63,7 @@ class DefaultMessageControllerTest {
|
|||
assertEquals(message.id, event.single().extra!!["message_key"])
|
||||
assertEquals("uuid", event.single().extra!!["action_uuid"])
|
||||
verify { customController.handleAction(any()) }
|
||||
verify { store.dispatch(MessageClicked(message)) }
|
||||
verify { appStore.dispatch(MessageClicked(message)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -99,7 +99,7 @@ class DefaultMessageControllerTest {
|
|||
val event = Messaging.messageDismissed.testGetValue()!!
|
||||
assertEquals(1, event.size)
|
||||
assertEquals(message.id, event.single().extra!!["message_key"])
|
||||
verify { store.dispatch(AppAction.MessagingAction.MessageDismissed(message)) }
|
||||
verify { appStore.dispatch(AppAction.MessagingAction.MessageDismissed(message)) }
|
||||
}
|
||||
|
||||
private fun mockMessage(data: MessageData = MessageData()) = Message(
|
||||
|
|
|
@ -20,11 +20,11 @@ class MessagingFeatureTest {
|
|||
|
||||
@Test
|
||||
fun `WHEN start is called THEN evaluate messages`() {
|
||||
val store: AppStore = spyk(AppStore())
|
||||
val binding = MessagingFeature(store)
|
||||
val appStore: AppStore = spyk(AppStore())
|
||||
val binding = MessagingFeature(appStore)
|
||||
|
||||
binding.start()
|
||||
|
||||
verify { store.dispatch(MessagingAction.Evaluate) }
|
||||
verify { appStore.dispatch(MessagingAction.Evaluate) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class MessagingMiddlewareTest {
|
|||
@get:Rule
|
||||
val coroutinesTestRule = MainCoroutineRule()
|
||||
private val coroutineScope = coroutinesTestRule.scope
|
||||
private lateinit var store: AppStore
|
||||
private lateinit var appStore: AppStore
|
||||
private lateinit var middleware: MessagingMiddleware
|
||||
private lateinit var messagingStorage: NimbusMessagingStorage
|
||||
private lateinit var middlewareContext: MiddlewareContext<AppState, AppAction>
|
||||
|
@ -54,10 +54,10 @@ class MessagingMiddlewareTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
store = mockk(relaxed = true)
|
||||
appStore = mockk(relaxed = true)
|
||||
messagingStorage = mockk(relaxed = true)
|
||||
middlewareContext = mockk(relaxed = true)
|
||||
every { middlewareContext.store } returns store
|
||||
every { middlewareContext.store } returns appStore
|
||||
|
||||
middleware = MessagingMiddleware(
|
||||
messagingStorage,
|
||||
|
@ -73,7 +73,7 @@ class MessagingMiddlewareTest {
|
|||
|
||||
middleware.invoke(middlewareContext, {}, Restore)
|
||||
|
||||
verify { store.dispatch(UpdateMessages(messages)) }
|
||||
verify { appStore.dispatch(UpdateMessages(messages)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -36,25 +36,25 @@ class BlocklistMiddlewareTest {
|
|||
|
||||
every { mockSettings.homescreenBlocklist } returns setOf()
|
||||
val middleware = BlocklistMiddleware(blocklistHandler)
|
||||
val store = AppStore(
|
||||
val appStore = AppStore(
|
||||
AppState(),
|
||||
middlewares = listOf(middleware),
|
||||
)
|
||||
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.Change(
|
||||
topSites = store.state.topSites,
|
||||
mode = store.state.mode,
|
||||
collections = store.state.collections,
|
||||
showCollectionPlaceholder = store.state.showCollectionPlaceholder,
|
||||
recentTabs = store.state.recentTabs,
|
||||
topSites = appStore.state.topSites,
|
||||
mode = appStore.state.mode,
|
||||
collections = appStore.state.collections,
|
||||
showCollectionPlaceholder = appStore.state.showCollectionPlaceholder,
|
||||
recentTabs = appStore.state.recentTabs,
|
||||
recentBookmarks = listOf(updatedBookmark),
|
||||
recentHistory = store.state.recentHistory,
|
||||
recentSyncedTabState = store.state.recentSyncedTabState,
|
||||
recentHistory = appStore.state.recentHistory,
|
||||
recentSyncedTabState = appStore.state.recentSyncedTabState,
|
||||
),
|
||||
).joinBlocking()
|
||||
|
||||
assertEquals(updatedBookmark, store.state.recentBookmarks[0])
|
||||
assertEquals(updatedBookmark, appStore.state.recentBookmarks[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -63,25 +63,25 @@ class BlocklistMiddlewareTest {
|
|||
|
||||
every { mockSettings.homescreenBlocklist } returns setOf("https://www.github.org/".stripAndHash())
|
||||
val middleware = BlocklistMiddleware(blocklistHandler)
|
||||
val store = AppStore(
|
||||
val appStore = AppStore(
|
||||
AppState(),
|
||||
middlewares = listOf(middleware),
|
||||
)
|
||||
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.Change(
|
||||
topSites = store.state.topSites,
|
||||
mode = store.state.mode,
|
||||
collections = store.state.collections,
|
||||
showCollectionPlaceholder = store.state.showCollectionPlaceholder,
|
||||
recentTabs = store.state.recentTabs,
|
||||
topSites = appStore.state.topSites,
|
||||
mode = appStore.state.mode,
|
||||
collections = appStore.state.collections,
|
||||
showCollectionPlaceholder = appStore.state.showCollectionPlaceholder,
|
||||
recentTabs = appStore.state.recentTabs,
|
||||
recentBookmarks = listOf(updatedBookmark),
|
||||
recentHistory = store.state.recentHistory,
|
||||
recentSyncedTabState = store.state.recentSyncedTabState,
|
||||
recentHistory = appStore.state.recentHistory,
|
||||
recentSyncedTabState = appStore.state.recentSyncedTabState,
|
||||
),
|
||||
).joinBlocking()
|
||||
|
||||
assertEquals(updatedBookmark, store.state.recentBookmarks[0])
|
||||
assertEquals(updatedBookmark, appStore.state.recentBookmarks[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -90,25 +90,25 @@ class BlocklistMiddlewareTest {
|
|||
|
||||
every { mockSettings.homescreenBlocklist } returns setOf("https://github.com/mozilla-mobile/fenix".stripAndHash())
|
||||
val middleware = BlocklistMiddleware(blocklistHandler)
|
||||
val store = AppStore(
|
||||
val appStore = AppStore(
|
||||
AppState(),
|
||||
middlewares = listOf(middleware),
|
||||
)
|
||||
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.Change(
|
||||
topSites = store.state.topSites,
|
||||
mode = store.state.mode,
|
||||
collections = store.state.collections,
|
||||
showCollectionPlaceholder = store.state.showCollectionPlaceholder,
|
||||
recentTabs = store.state.recentTabs,
|
||||
topSites = appStore.state.topSites,
|
||||
mode = appStore.state.mode,
|
||||
collections = appStore.state.collections,
|
||||
showCollectionPlaceholder = appStore.state.showCollectionPlaceholder,
|
||||
recentTabs = appStore.state.recentTabs,
|
||||
recentBookmarks = listOf(updatedBookmark),
|
||||
recentHistory = store.state.recentHistory,
|
||||
recentSyncedTabState = store.state.recentSyncedTabState,
|
||||
recentHistory = appStore.state.recentHistory,
|
||||
recentSyncedTabState = appStore.state.recentSyncedTabState,
|
||||
),
|
||||
).joinBlocking()
|
||||
|
||||
assertEquals(updatedBookmark, store.state.recentBookmarks[0])
|
||||
assertEquals(updatedBookmark, appStore.state.recentBookmarks[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -117,25 +117,25 @@ class BlocklistMiddlewareTest {
|
|||
|
||||
every { mockSettings.homescreenBlocklist } returns setOf("https://www.mozilla.org/".stripAndHash())
|
||||
val middleware = BlocklistMiddleware(blocklistHandler)
|
||||
val store = AppStore(
|
||||
val appStore = AppStore(
|
||||
AppState(),
|
||||
middlewares = listOf(middleware),
|
||||
)
|
||||
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.Change(
|
||||
topSites = store.state.topSites,
|
||||
mode = store.state.mode,
|
||||
collections = store.state.collections,
|
||||
showCollectionPlaceholder = store.state.showCollectionPlaceholder,
|
||||
recentTabs = store.state.recentTabs,
|
||||
topSites = appStore.state.topSites,
|
||||
mode = appStore.state.mode,
|
||||
collections = appStore.state.collections,
|
||||
showCollectionPlaceholder = appStore.state.showCollectionPlaceholder,
|
||||
recentTabs = appStore.state.recentTabs,
|
||||
recentBookmarks = listOf(updatedBookmark),
|
||||
recentHistory = store.state.recentHistory,
|
||||
recentSyncedTabState = store.state.recentSyncedTabState,
|
||||
recentHistory = appStore.state.recentHistory,
|
||||
recentSyncedTabState = appStore.state.recentSyncedTabState,
|
||||
),
|
||||
).joinBlocking()
|
||||
|
||||
assertTrue(store.state.recentBookmarks.isEmpty())
|
||||
assertTrue(appStore.state.recentBookmarks.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -146,26 +146,26 @@ class BlocklistMiddlewareTest {
|
|||
|
||||
every { mockSettings.homescreenBlocklist } returns setOf(blockedUrl.stripAndHash())
|
||||
val middleware = BlocklistMiddleware(blocklistHandler)
|
||||
val store = AppStore(
|
||||
val appStore = AppStore(
|
||||
AppState(),
|
||||
middlewares = listOf(middleware),
|
||||
)
|
||||
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.Change(
|
||||
topSites = store.state.topSites,
|
||||
mode = store.state.mode,
|
||||
collections = store.state.collections,
|
||||
showCollectionPlaceholder = store.state.showCollectionPlaceholder,
|
||||
topSites = appStore.state.topSites,
|
||||
mode = appStore.state.mode,
|
||||
collections = appStore.state.collections,
|
||||
showCollectionPlaceholder = appStore.state.showCollectionPlaceholder,
|
||||
recentTabs = updatedRecentTabs,
|
||||
recentBookmarks = updatedBookmarks,
|
||||
recentHistory = store.state.recentHistory,
|
||||
recentSyncedTabState = store.state.recentSyncedTabState,
|
||||
recentHistory = appStore.state.recentHistory,
|
||||
recentSyncedTabState = appStore.state.recentSyncedTabState,
|
||||
),
|
||||
).joinBlocking()
|
||||
|
||||
assertTrue(store.state.recentBookmarks.isEmpty())
|
||||
assertTrue(store.state.recentTabs.isEmpty())
|
||||
assertTrue(appStore.state.recentBookmarks.isEmpty())
|
||||
assertTrue(appStore.state.recentTabs.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -184,26 +184,26 @@ class BlocklistMiddlewareTest {
|
|||
every { mockSettings.homescreenBlocklist } returns setOf(blockedUrl.stripAndHash())
|
||||
every { mockSettings.frecencyFilterQuery } returns ""
|
||||
val middleware = BlocklistMiddleware(blocklistHandler)
|
||||
val store = AppStore(
|
||||
val appStore = AppStore(
|
||||
AppState(),
|
||||
middlewares = listOf(middleware),
|
||||
)
|
||||
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.Change(
|
||||
topSites = store.state.topSites,
|
||||
mode = store.state.mode,
|
||||
collections = store.state.collections,
|
||||
showCollectionPlaceholder = store.state.showCollectionPlaceholder,
|
||||
topSites = appStore.state.topSites,
|
||||
mode = appStore.state.mode,
|
||||
collections = appStore.state.collections,
|
||||
showCollectionPlaceholder = appStore.state.showCollectionPlaceholder,
|
||||
recentTabs = updatedRecentTabs,
|
||||
recentBookmarks = updatedBookmarks,
|
||||
recentHistory = store.state.recentHistory,
|
||||
recentSyncedTabState = store.state.recentSyncedTabState,
|
||||
recentHistory = appStore.state.recentHistory,
|
||||
recentSyncedTabState = appStore.state.recentSyncedTabState,
|
||||
),
|
||||
).joinBlocking()
|
||||
|
||||
assertEquals(unblockedBookmark, store.state.recentBookmarks[0])
|
||||
assertEquals(unblockedRecentTab, store.state.recentTabs[0])
|
||||
assertEquals(unblockedBookmark, appStore.state.recentBookmarks[0])
|
||||
assertEquals(unblockedRecentTab, appStore.state.recentTabs[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -216,12 +216,12 @@ class BlocklistMiddlewareTest {
|
|||
every { mockSettings.homescreenBlocklist } returns setOf() andThen setOf(removedUrl.stripAndHash())
|
||||
every { mockSettings.homescreenBlocklist = capture(updateSlot) } returns Unit
|
||||
val middleware = BlocklistMiddleware(blocklistHandler)
|
||||
val store = AppStore(
|
||||
val appStore = AppStore(
|
||||
AppState(recentBookmarks = listOf(removedBookmark)),
|
||||
middlewares = listOf(middleware, captureMiddleware),
|
||||
)
|
||||
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.RemoveRecentBookmark(removedBookmark),
|
||||
).joinBlocking()
|
||||
|
||||
|
@ -237,25 +237,25 @@ class BlocklistMiddlewareTest {
|
|||
|
||||
every { mockSettings.homescreenBlocklist } returns setOf("https://$host".stripAndHash())
|
||||
val middleware = BlocklistMiddleware(blocklistHandler)
|
||||
val store = AppStore(
|
||||
val appStore = AppStore(
|
||||
AppState(),
|
||||
middlewares = listOf(middleware),
|
||||
)
|
||||
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.Change(
|
||||
topSites = store.state.topSites,
|
||||
mode = store.state.mode,
|
||||
collections = store.state.collections,
|
||||
showCollectionPlaceholder = store.state.showCollectionPlaceholder,
|
||||
recentTabs = store.state.recentTabs,
|
||||
topSites = appStore.state.topSites,
|
||||
mode = appStore.state.mode,
|
||||
collections = appStore.state.collections,
|
||||
showCollectionPlaceholder = appStore.state.showCollectionPlaceholder,
|
||||
recentTabs = appStore.state.recentTabs,
|
||||
recentBookmarks = listOf(updatedBookmark),
|
||||
recentHistory = store.state.recentHistory,
|
||||
recentSyncedTabState = store.state.recentSyncedTabState,
|
||||
recentHistory = appStore.state.recentHistory,
|
||||
recentSyncedTabState = appStore.state.recentSyncedTabState,
|
||||
),
|
||||
).joinBlocking()
|
||||
|
||||
assertTrue(store.state.recentBookmarks.isEmpty())
|
||||
assertTrue(appStore.state.recentBookmarks.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -265,25 +265,25 @@ class BlocklistMiddlewareTest {
|
|||
|
||||
every { mockSettings.homescreenBlocklist } returns setOf(host.stripAndHash())
|
||||
val middleware = BlocklistMiddleware(blocklistHandler)
|
||||
val store = AppStore(
|
||||
val appStore = AppStore(
|
||||
AppState(),
|
||||
middlewares = listOf(middleware),
|
||||
)
|
||||
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.Change(
|
||||
topSites = store.state.topSites,
|
||||
mode = store.state.mode,
|
||||
collections = store.state.collections,
|
||||
showCollectionPlaceholder = store.state.showCollectionPlaceholder,
|
||||
recentTabs = store.state.recentTabs,
|
||||
topSites = appStore.state.topSites,
|
||||
mode = appStore.state.mode,
|
||||
collections = appStore.state.collections,
|
||||
showCollectionPlaceholder = appStore.state.showCollectionPlaceholder,
|
||||
recentTabs = appStore.state.recentTabs,
|
||||
recentBookmarks = listOf(updatedBookmark),
|
||||
recentHistory = store.state.recentHistory,
|
||||
recentSyncedTabState = store.state.recentSyncedTabState,
|
||||
recentHistory = appStore.state.recentHistory,
|
||||
recentSyncedTabState = appStore.state.recentSyncedTabState,
|
||||
),
|
||||
).joinBlocking()
|
||||
|
||||
assertTrue(store.state.recentBookmarks.isEmpty())
|
||||
assertTrue(appStore.state.recentBookmarks.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -293,25 +293,25 @@ class BlocklistMiddlewareTest {
|
|||
|
||||
every { mockSettings.homescreenBlocklist } returns setOf("https://$host".stripAndHash())
|
||||
val middleware = BlocklistMiddleware(blocklistHandler)
|
||||
val store = AppStore(
|
||||
val appStore = AppStore(
|
||||
AppState(),
|
||||
middlewares = listOf(middleware),
|
||||
)
|
||||
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.Change(
|
||||
topSites = store.state.topSites,
|
||||
mode = store.state.mode,
|
||||
collections = store.state.collections,
|
||||
showCollectionPlaceholder = store.state.showCollectionPlaceholder,
|
||||
recentTabs = store.state.recentTabs,
|
||||
topSites = appStore.state.topSites,
|
||||
mode = appStore.state.mode,
|
||||
collections = appStore.state.collections,
|
||||
showCollectionPlaceholder = appStore.state.showCollectionPlaceholder,
|
||||
recentTabs = appStore.state.recentTabs,
|
||||
recentBookmarks = listOf(updatedBookmark),
|
||||
recentHistory = store.state.recentHistory,
|
||||
recentSyncedTabState = store.state.recentSyncedTabState,
|
||||
recentHistory = appStore.state.recentHistory,
|
||||
recentSyncedTabState = appStore.state.recentSyncedTabState,
|
||||
),
|
||||
).joinBlocking()
|
||||
|
||||
assertTrue(store.state.recentBookmarks.isEmpty())
|
||||
assertTrue(appStore.state.recentBookmarks.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -335,12 +335,12 @@ class BlocklistMiddlewareTest {
|
|||
every { mockSettings.homescreenBlocklist } returns setOf(blockedHost.stripAndHash())
|
||||
every { mockSettings.frecencyFilterQuery } returns ""
|
||||
val middleware = BlocklistMiddleware(blocklistHandler)
|
||||
val store = AppStore(
|
||||
val appStore = AppStore(
|
||||
AppState(),
|
||||
middlewares = listOf(middleware),
|
||||
)
|
||||
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.RecentSyncedTabStateChange(
|
||||
RecentSyncedTabState.Success(
|
||||
listOf(
|
||||
|
@ -353,7 +353,7 @@ class BlocklistMiddlewareTest {
|
|||
|
||||
assertEquals(
|
||||
allowedTab,
|
||||
(store.state.recentSyncedTabState as RecentSyncedTabState.Success).tabs.single(),
|
||||
(appStore.state.recentSyncedTabState as RecentSyncedTabState.Success).tabs.single(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -362,18 +362,18 @@ class BlocklistMiddlewareTest {
|
|||
val blockedHost = "https://www.mozilla.org"
|
||||
every { mockSettings.homescreenBlocklist } returns setOf(blockedHost.stripAndHash())
|
||||
val middleware = BlocklistMiddleware(blocklistHandler)
|
||||
val store = AppStore(
|
||||
val appStore = AppStore(
|
||||
AppState(),
|
||||
middlewares = listOf(middleware),
|
||||
)
|
||||
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.RecentSyncedTabStateChange(
|
||||
RecentSyncedTabState.None,
|
||||
),
|
||||
).joinBlocking()
|
||||
|
||||
assertEquals(RecentSyncedTabState.None, store.state.recentSyncedTabState)
|
||||
assertEquals(RecentSyncedTabState.None, appStore.state.recentSyncedTabState)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -389,12 +389,12 @@ class BlocklistMiddlewareTest {
|
|||
|
||||
every { mockSettings.homescreenBlocklist } returns setOf(blockedHost.stripAndHash())
|
||||
val middleware = BlocklistMiddleware(blocklistHandler)
|
||||
val store = AppStore(
|
||||
val appStore = AppStore(
|
||||
AppState(),
|
||||
middlewares = listOf(middleware),
|
||||
)
|
||||
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.RecentSyncedTabStateChange(
|
||||
RecentSyncedTabState.Success(
|
||||
listOf(blockedTab),
|
||||
|
@ -404,7 +404,7 @@ class BlocklistMiddlewareTest {
|
|||
|
||||
assertEquals(
|
||||
RecentSyncedTabState.None,
|
||||
store.state.recentSyncedTabState,
|
||||
appStore.state.recentSyncedTabState,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ class BlocklistMiddlewareTest {
|
|||
previewImageUrl = null,
|
||||
),
|
||||
)
|
||||
val store = AppStore(
|
||||
val appStore = AppStore(
|
||||
AppState(recentSyncedTabState = RecentSyncedTabState.Success(currentTabs)),
|
||||
middlewares = listOf(BlocklistMiddleware(blocklistHandler)),
|
||||
)
|
||||
|
@ -443,7 +443,7 @@ class BlocklistMiddlewareTest {
|
|||
every { mockSettings.homescreenBlocklist } returns setOf(tabUrls[0].stripAndHash())
|
||||
every { mockSettings.frecencyFilterQuery } returns ""
|
||||
|
||||
store.dispatch(
|
||||
appStore.dispatch(
|
||||
AppAction.RemoveRecentSyncedTab(
|
||||
currentTabs.first(),
|
||||
),
|
||||
|
@ -451,12 +451,12 @@ class BlocklistMiddlewareTest {
|
|||
|
||||
assertEquals(
|
||||
2,
|
||||
(store.state.recentSyncedTabState as RecentSyncedTabState.Success).tabs.size,
|
||||
(appStore.state.recentSyncedTabState as RecentSyncedTabState.Success).tabs.size,
|
||||
)
|
||||
assertEquals(setOf(tabUrls[0].stripAndHash()), updateSlot.captured)
|
||||
assertEquals(
|
||||
currentTabs[1],
|
||||
(store.state.recentSyncedTabState as RecentSyncedTabState.Success).tabs.firstOrNull(),
|
||||
(appStore.state.recentSyncedTabState as RecentSyncedTabState.Success).tabs.firstOrNull(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,25 +23,25 @@ import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
|||
|
||||
@RunWith(FenixRobolectricTestRunner::class)
|
||||
class CrashReporterIntentProcessorTest {
|
||||
private val store: AppStore = mockk(relaxed = true)
|
||||
private val appStore: AppStore = mockk(relaxed = true)
|
||||
private val navController: NavController = mockk()
|
||||
private val out: Intent = mockk()
|
||||
|
||||
@Test
|
||||
fun `GIVEN a blank Intent WHEN processing it THEN do nothing and return false`() {
|
||||
val processor = CrashReporterIntentProcessor(store)
|
||||
val processor = CrashReporterIntentProcessor(appStore)
|
||||
|
||||
val result = processor.process(Intent(), navController, out)
|
||||
|
||||
assertFalse(result)
|
||||
verify { navController wasNot Called }
|
||||
verify { out wasNot Called }
|
||||
verify { store wasNot Called }
|
||||
verify { appStore wasNot Called }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN a crash Intent WHEN processing it THEN update crash details and return true`() {
|
||||
val processor = CrashReporterIntentProcessor(store)
|
||||
val processor = CrashReporterIntentProcessor(appStore)
|
||||
val intent = Intent()
|
||||
val crash = mockk<NativeCodeCrash>(relaxed = true)
|
||||
|
||||
|
@ -54,7 +54,7 @@ class CrashReporterIntentProcessorTest {
|
|||
assertTrue(result)
|
||||
verify { navController wasNot Called }
|
||||
verify { out wasNot Called }
|
||||
verify { store.dispatch(AppAction.AddNonFatalCrash(crash)) }
|
||||
verify { appStore.dispatch(AppAction.AddNonFatalCrash(crash)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class TopSiteItemViewHolderTest {
|
|||
private lateinit var binding: TopSiteItemBinding
|
||||
private lateinit var interactor: TopSiteInteractor
|
||||
private lateinit var lifecycleOwner: LifecycleOwner
|
||||
private lateinit var store: AppStore
|
||||
private lateinit var appStore: AppStore
|
||||
|
||||
private val pocket = TopSite.Default(
|
||||
id = 1L,
|
||||
|
@ -52,14 +52,14 @@ class TopSiteItemViewHolderTest {
|
|||
binding = TopSiteItemBinding.inflate(LayoutInflater.from(testContext))
|
||||
interactor = mockk(relaxed = true)
|
||||
lifecycleOwner = mockk(relaxed = true)
|
||||
store = mockk(relaxed = true)
|
||||
appStore = mockk(relaxed = true)
|
||||
|
||||
every { testContext.components.core.icons } returns BrowserIcons(testContext, mockk(relaxed = true))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `calls interactor on click`() {
|
||||
TopSiteItemViewHolder(binding.root, store, lifecycleOwner, interactor).bind(pocket, position = 0)
|
||||
TopSiteItemViewHolder(binding.root, appStore, lifecycleOwner, interactor).bind(pocket, position = 0)
|
||||
|
||||
binding.root.performClick()
|
||||
verify { interactor.onSelectTopSite(pocket, position = 0) }
|
||||
|
@ -68,7 +68,7 @@ class TopSiteItemViewHolderTest {
|
|||
@Test
|
||||
fun `calls interactor on long click`() {
|
||||
every { testContext.components.analytics } returns mockk(relaxed = true)
|
||||
TopSiteItemViewHolder(binding.root, store, lifecycleOwner, interactor).bind(pocket, position = 0)
|
||||
TopSiteItemViewHolder(binding.root, appStore, lifecycleOwner, interactor).bind(pocket, position = 0)
|
||||
|
||||
binding.root.performLongClick()
|
||||
verify { interactor.onTopSiteMenuOpened() }
|
||||
|
@ -83,7 +83,7 @@ class TopSiteItemViewHolderTest {
|
|||
createdAt = 0,
|
||||
)
|
||||
|
||||
TopSiteItemViewHolder(binding.root, store, lifecycleOwner, interactor).bind(defaultTopSite, position = 0)
|
||||
TopSiteItemViewHolder(binding.root, appStore, lifecycleOwner, interactor).bind(defaultTopSite, position = 0)
|
||||
val pinIndicator = binding.topSiteTitle.compoundDrawables[0]
|
||||
|
||||
assertNotNull(pinIndicator)
|
||||
|
@ -98,7 +98,7 @@ class TopSiteItemViewHolderTest {
|
|||
createdAt = 0,
|
||||
)
|
||||
|
||||
TopSiteItemViewHolder(binding.root, store, lifecycleOwner, interactor).bind(pinnedTopSite, position = 0)
|
||||
TopSiteItemViewHolder(binding.root, appStore, lifecycleOwner, interactor).bind(pinnedTopSite, position = 0)
|
||||
val pinIndicator = binding.topSiteTitle.compoundDrawables[0]
|
||||
|
||||
assertNotNull(pinIndicator)
|
||||
|
@ -113,7 +113,7 @@ class TopSiteItemViewHolderTest {
|
|||
createdAt = 0,
|
||||
)
|
||||
|
||||
TopSiteItemViewHolder(binding.root, store, lifecycleOwner, interactor).bind(frecentTopSite, position = 0)
|
||||
TopSiteItemViewHolder(binding.root, appStore, lifecycleOwner, interactor).bind(frecentTopSite, position = 0)
|
||||
val pinIndicator = binding.topSiteTitle.compoundDrawables[0]
|
||||
|
||||
assertNull(pinIndicator)
|
||||
|
@ -147,7 +147,7 @@ class TopSiteItemViewHolderTest {
|
|||
topSiteImpressionSubmitted = true
|
||||
}
|
||||
|
||||
TopSiteItemViewHolder(binding.root, store, lifecycleOwner, interactor).submitTopSitesImpressionPing(topSite, position)
|
||||
TopSiteItemViewHolder(binding.root, appStore, lifecycleOwner, interactor).submitTopSitesImpressionPing(topSite, position)
|
||||
|
||||
assertNotNull(TopSites.contileImpression.testGetValue())
|
||||
|
||||
|
|
|
@ -24,19 +24,19 @@ class TopSiteViewHolderTest {
|
|||
private lateinit var binding: ComponentTopSitesBinding
|
||||
private lateinit var lifecycleOwner: LifecycleOwner
|
||||
private lateinit var interactor: TopSiteInteractor
|
||||
private lateinit var store: AppStore
|
||||
private lateinit var appStore: AppStore
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
binding = ComponentTopSitesBinding.inflate(LayoutInflater.from(testContext))
|
||||
interactor = mockk(relaxed = true)
|
||||
lifecycleOwner = mockk(relaxed = true)
|
||||
store = mockk(relaxed = true)
|
||||
appStore = mockk(relaxed = true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `binds list of top sites`() {
|
||||
TopSiteViewHolder(binding.root, store, lifecycleOwner, interactor).bind(
|
||||
TopSiteViewHolder(binding.root, appStore, lifecycleOwner, interactor).bind(
|
||||
listOf(
|
||||
TopSite.Default(
|
||||
id = 1L,
|
||||
|
|
|
@ -45,7 +45,7 @@ internal class HomeSettingsFragmentTest {
|
|||
private lateinit var appPrefs: SharedPreferences
|
||||
private lateinit var appPrefsEditor: SharedPreferences.Editor
|
||||
private lateinit var pocketService: PocketStoriesService
|
||||
private lateinit var store: AppStore
|
||||
private lateinit var appStore: AppStore
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
|
@ -60,10 +60,10 @@ internal class HomeSettingsFragmentTest {
|
|||
every { preferences } returns appPrefs
|
||||
}
|
||||
every { any<Context>().settings() } returns appSettings
|
||||
store = mockk(relaxed = true)
|
||||
appStore = mockk(relaxed = true)
|
||||
pocketService = mockk(relaxed = true)
|
||||
every { any<Context>().components } returns mockk {
|
||||
every { appStore } returns store
|
||||
every { appStore } returns this@HomeSettingsFragmentTest.appStore
|
||||
every { core.pocketStoriesService } returns pocketService
|
||||
}
|
||||
|
||||
|
@ -149,6 +149,6 @@ internal class HomeSettingsFragmentTest {
|
|||
assertTrue(result)
|
||||
verify { appPrefsEditor.putBoolean(testContext.getString(R.string.pref_key_pocket_sponsored_stories), false) }
|
||||
verify { pocketService.deleteProfile() }
|
||||
verify { store.dispatch(AppAction.PocketSponsoredStoriesChange(emptyList())) }
|
||||
verify { appStore.dispatch(AppAction.PocketSponsoredStoriesChange(emptyList())) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ class WallpapersUseCasesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN legacy use case and a wallpaper has not been selected WHEN invoking initialize use case THEN store contains default`() = runTest {
|
||||
fun `GIVEN legacy use case and a wallpaper has not been selected WHEN invoking initialize use case THEN app store contains default`() = runTest {
|
||||
val fakeRemoteWallpapers = listOf("first", "second", "third").map { name ->
|
||||
makeFakeRemoteWallpaper(TimeRelation.LATER, name)
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ class WallpapersUseCasesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN legacy use case a wallpaper is selected and there are available wallpapers WHEN invoking initialize use case THEN these are dispatched to the store`() = runTest {
|
||||
fun `GIVEN legacy use case a wallpaper is selected and there are available wallpapers WHEN invoking initialize use case THEN these are dispatched to the app store`() = runTest {
|
||||
val selectedWallpaper = makeFakeRemoteWallpaper(TimeRelation.LATER, "selected")
|
||||
val fakeRemoteWallpapers = listOf("first", "second", "third").map { name ->
|
||||
makeFakeRemoteWallpaper(TimeRelation.LATER, name)
|
||||
|
@ -402,7 +402,7 @@ class WallpapersUseCasesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN available wallpapers WHEN invoking initialize use case THEN thumbnails downloaded and the store state is updated to reflect that`() = runTest {
|
||||
fun `GIVEN available wallpapers WHEN invoking initialize use case THEN thumbnails downloaded and the app store state is updated to reflect that`() = runTest {
|
||||
val fakeRemoteWallpapers = listOf("first", "second", "third").map { name ->
|
||||
makeFakeRemoteWallpaper(TimeRelation.LATER, name)
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ class WallpapersUseCasesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN thumbnail download fails WHEN invoking initialize use case THEN the store state is updated to reflect that`() = runTest {
|
||||
fun `GIVEN thumbnail download fails WHEN invoking initialize use case THEN the app store state is updated to reflect that`() = runTest {
|
||||
val fakeRemoteWallpapers = listOf("first", "second", "third").map { name ->
|
||||
makeFakeRemoteWallpaper(TimeRelation.LATER, name)
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ class WallpapersUseCasesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN a wallpaper has not been selected WHEN invoking initialize use case THEN store contains default`() = runTest {
|
||||
fun `GIVEN a wallpaper has not been selected WHEN invoking initialize use case THEN app store contains default`() = runTest {
|
||||
val fakeRemoteWallpapers = listOf("first", "second", "third").map { name ->
|
||||
makeFakeRemoteWallpaper(TimeRelation.LATER, name)
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ class WallpapersUseCasesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN a wallpaper is selected and there are available wallpapers WHEN invoking initialize use case THEN these are dispatched to the store`() = runTest {
|
||||
fun `GIVEN a wallpaper is selected and there are available wallpapers WHEN invoking initialize use case THEN these are dispatched to the app store`() = runTest {
|
||||
val selectedWallpaper = makeFakeRemoteWallpaper(TimeRelation.LATER, "selected")
|
||||
val fakeRemoteWallpapers = listOf("first", "second", "third").map { name ->
|
||||
makeFakeRemoteWallpaper(TimeRelation.LATER, name)
|
||||
|
@ -514,7 +514,7 @@ class WallpapersUseCasesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `WHEN legacy selected wallpaper usecase invoked THEN storage updated and store receives dispatch`() = runTest {
|
||||
fun `WHEN legacy selected wallpaper usecase invoked THEN storage updated and app store receives dispatch`() = runTest {
|
||||
val selectedWallpaper = makeFakeRemoteWallpaper(TimeRelation.LATER, "selected")
|
||||
every { mockSettings.currentWallpaperName = any() } just Runs
|
||||
|
||||
|
@ -532,7 +532,7 @@ class WallpapersUseCasesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN wallpaper downloaded WHEN selecting a wallpaper THEN storage updated and store receives dispatch`() = runTest {
|
||||
fun `GIVEN wallpaper downloaded WHEN selecting a wallpaper THEN storage updated and app store receives dispatch`() = runTest {
|
||||
val selectedWallpaper = makeFakeRemoteWallpaper(TimeRelation.LATER, "selected")
|
||||
val slot = slot<String>()
|
||||
coEvery { mockFileManager.lookupExpiredWallpaper(any()) } returns null
|
||||
|
@ -554,10 +554,10 @@ class WallpapersUseCasesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN wallpaper is not downloaded WHEN selecting a wallpaper and download succeeds THEN storage updated and store receives dispatch`() = runTest {
|
||||
fun `GIVEN wallpaper is not downloaded WHEN selecting a wallpaper and download succeeds THEN storage updated and app store receives dispatch`() = runTest {
|
||||
val selectedWallpaper = makeFakeRemoteWallpaper(TimeRelation.LATER, "selected")
|
||||
val slot = slot<String>()
|
||||
val mockStore = mockk<AppStore>(relaxed = true)
|
||||
val mockAppStore = mockk<AppStore>(relaxed = true)
|
||||
coEvery { mockFileManager.lookupExpiredWallpaper(any()) } returns null
|
||||
every { mockSettings.currentWallpaperName } returns ""
|
||||
every { mockSettings.currentWallpaperName = capture(slot) } just runs
|
||||
|
@ -566,22 +566,22 @@ class WallpapersUseCasesTest {
|
|||
|
||||
val wallpaperFileState = WallpapersUseCases.DefaultSelectWallpaperUseCase(
|
||||
mockSettings,
|
||||
mockStore,
|
||||
mockAppStore,
|
||||
mockFileManager,
|
||||
mockDownloader,
|
||||
).invoke(selectedWallpaper)
|
||||
|
||||
verify { mockStore.dispatch(AppAction.WallpaperAction.UpdateWallpaperDownloadState(selectedWallpaper, Wallpaper.ImageFileState.Downloading)) }
|
||||
verify { mockStore.dispatch(AppAction.WallpaperAction.UpdateWallpaperDownloadState(selectedWallpaper, Wallpaper.ImageFileState.Downloaded)) }
|
||||
verify { mockStore.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(selectedWallpaper)) }
|
||||
verify { mockAppStore.dispatch(AppAction.WallpaperAction.UpdateWallpaperDownloadState(selectedWallpaper, Wallpaper.ImageFileState.Downloading)) }
|
||||
verify { mockAppStore.dispatch(AppAction.WallpaperAction.UpdateWallpaperDownloadState(selectedWallpaper, Wallpaper.ImageFileState.Downloaded)) }
|
||||
verify { mockAppStore.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(selectedWallpaper)) }
|
||||
assertEquals(wallpaperFileState, Wallpaper.ImageFileState.Downloaded)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN wallpaper is not downloaded WHEN selecting a wallpaper and any download fails THEN wallpaper not set and store receives dispatch`() = runTest {
|
||||
fun `GIVEN wallpaper is not downloaded WHEN selecting a wallpaper and any download fails THEN wallpaper not set and app store receives dispatch`() = runTest {
|
||||
val selectedWallpaper = makeFakeRemoteWallpaper(TimeRelation.LATER, "selected")
|
||||
val slot = slot<String>()
|
||||
val mockStore = mockk<AppStore>(relaxed = true)
|
||||
val mockAppStore = mockk<AppStore>(relaxed = true)
|
||||
coEvery { mockFileManager.lookupExpiredWallpaper(any()) } returns null
|
||||
every { mockSettings.currentWallpaperName } returns ""
|
||||
every { mockSettings.currentWallpaperName = capture(slot) } just runs
|
||||
|
@ -590,23 +590,23 @@ class WallpapersUseCasesTest {
|
|||
|
||||
val wallpaperFileState = WallpapersUseCases.DefaultSelectWallpaperUseCase(
|
||||
mockSettings,
|
||||
mockStore,
|
||||
mockAppStore,
|
||||
mockFileManager,
|
||||
mockDownloader,
|
||||
).invoke(selectedWallpaper)
|
||||
|
||||
verify { mockStore.dispatch(AppAction.WallpaperAction.UpdateWallpaperDownloadState(selectedWallpaper, Wallpaper.ImageFileState.Downloading)) }
|
||||
verify { mockStore.dispatch(AppAction.WallpaperAction.UpdateWallpaperDownloadState(selectedWallpaper, Wallpaper.ImageFileState.Error)) }
|
||||
verify { mockAppStore.dispatch(AppAction.WallpaperAction.UpdateWallpaperDownloadState(selectedWallpaper, Wallpaper.ImageFileState.Downloading)) }
|
||||
verify { mockAppStore.dispatch(AppAction.WallpaperAction.UpdateWallpaperDownloadState(selectedWallpaper, Wallpaper.ImageFileState.Error)) }
|
||||
assertEquals(wallpaperFileState, Wallpaper.ImageFileState.Error)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN a wallpaper with no text color WHEN it is is selected THEN persist the wallpaper name and missing text color and dispatch the update`() {
|
||||
every { mockSettings.currentWallpaperName = any() } just Runs
|
||||
val store = mockk<AppStore>(relaxed = true)
|
||||
val appStore = mockk<AppStore>(relaxed = true)
|
||||
val wallpaperFileState = WallpapersUseCases.DefaultSelectWallpaperUseCase(
|
||||
settings = mockSettings,
|
||||
store = store,
|
||||
appStore = appStore,
|
||||
fileManager = mockk(),
|
||||
downloader = mockk(),
|
||||
)
|
||||
|
@ -621,16 +621,16 @@ class WallpapersUseCasesTest {
|
|||
|
||||
verify { mockSettings.currentWallpaperName = "Test" }
|
||||
verify { mockSettings.currentWallpaperTextColor = 0L }
|
||||
verify { store.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(wallpaper)) }
|
||||
verify { appStore.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(wallpaper)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN a wallpaper with available text color WHEN it is is selected THEN persist the wallpaper name and text color and dispatch the update`() {
|
||||
every { mockSettings.currentWallpaperName = any() } just Runs
|
||||
val store = mockk<AppStore>(relaxed = true)
|
||||
val appStore = mockk<AppStore>(relaxed = true)
|
||||
val wallpaperFileState = WallpapersUseCases.DefaultSelectWallpaperUseCase(
|
||||
settings = mockSettings,
|
||||
store = store,
|
||||
appStore = appStore,
|
||||
fileManager = mockk(),
|
||||
downloader = mockk(),
|
||||
)
|
||||
|
@ -645,7 +645,7 @@ class WallpapersUseCasesTest {
|
|||
|
||||
verify { mockSettings.currentWallpaperName = "Test" }
|
||||
verify { mockSettings.currentWallpaperTextColor = 321L }
|
||||
verify { store.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(wallpaper)) }
|
||||
verify { appStore.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(wallpaper)) }
|
||||
}
|
||||
|
||||
private enum class TimeRelation {
|
||||
|
|
Loading…
Reference in New Issue