From 6de92c6f177b393ac2b190480664f051849d13d9 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Wed, 29 Apr 2020 10:21:11 -0500 Subject: [PATCH] For issue #9949 - Inconsistencies between deleting bookmark and history items - Added the undo action for deleting individual history items by creating a new field to the history state containing the id's of the history items that are pending for deletion; This field is used inside the update function from the view to show/hide the items. - Added a new check inside the "deleteMulti" method from BookmarkFragment that calls the showRemoveFoldersDialog to prevent the user from being able to delete one or more bookmark folders without being asked for confirmation, as in #8648. --- .../java/org/mozilla/fenix/ui/HistoryTest.kt | 2 + .../mozilla/fenix/ui/robots/HistoryRobot.kt | 5 + .../library/bookmarks/BookmarkController.kt | 8 +- .../library/bookmarks/BookmarkFragment.kt | 46 ++++--- .../bookmarks/BookmarkFragmentInteractor.kt | 2 +- .../fenix/library/history/HistoryAdapter.kt | 7 +- .../fenix/library/history/HistoryFragment.kt | 120 +++++++++++++----- .../library/history/HistoryFragmentStore.kt | 15 ++- .../fenix/library/history/HistoryView.kt | 2 + .../viewholders/HistoryListItemViewHolder.kt | 18 ++- app/src/main/res/values/strings.xml | 6 +- .../bookmarks/BookmarkControllerTest.kt | 6 +- .../BookmarkFragmentInteractorTest.kt | 2 +- 13 files changed, 178 insertions(+), 61 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/HistoryTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/HistoryTest.kt index 2bc03ed5d9db..d8370bb14c90 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/HistoryTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/HistoryTest.kt @@ -157,6 +157,7 @@ class HistoryTest { }.openHistory { }.openThreeDotMenu { }.clickDelete { + verifyDeleteSnackbarText("Deleted") verifyEmptyHistoryView() } } @@ -173,6 +174,7 @@ class HistoryTest { clickDeleteHistoryButton() verifyDeleteConfirmationMessage() confirmDeleteAllHistory() + verifyDeleteSnackbarText("Browsing data deleted") verifyEmptyHistoryView() } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HistoryRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HistoryRobot.kt index d88b6f277f33..61f5e4d9b34e 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HistoryRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HistoryRobot.kt @@ -83,6 +83,8 @@ class HistoryRobot { .click() } + fun verifyDeleteSnackbarText(text: String) = assertSnackBarText(text) + class Transition { fun goBack(interact: HistoryRobot.() -> Unit): Transition { goBackButton().click() @@ -152,3 +154,6 @@ private fun assertDeleteConfirmationMessage() = .check(matches(isDisplayed())) private fun assertCopySnackBarText() = snackBarText().check(matches(withText("URL copied"))) + +private fun assertSnackBarText(text: String) = + snackBarText().check(matches(withText(Matchers.containsString(text)))) diff --git a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkController.kt b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkController.kt index 5a52f148c1c9..19c64df510dc 100644 --- a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkController.kt +++ b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkController.kt @@ -35,7 +35,7 @@ interface BookmarkController { fun handleBookmarkSharing(item: BookmarkNode) fun handleOpeningBookmark(item: BookmarkNode, mode: BrowsingMode) fun handleBookmarkDeletion(nodes: Set, eventType: Event) - fun handleBookmarkFolderDeletion(node: BookmarkNode) + fun handleBookmarkFolderDeletion(nodes: Set) fun handleBackPressed() } @@ -45,7 +45,7 @@ class DefaultBookmarkController( private val navController: NavController, private val showSnackbar: (String) -> Unit, private val deleteBookmarkNodes: (Set, Event) -> Unit, - private val deleteBookmarkFolder: (BookmarkNode) -> Unit, + private val deleteBookmarkFolder: (Set) -> Unit, private val invokePendingDeletion: () -> Unit ) : BookmarkController { @@ -94,8 +94,8 @@ class DefaultBookmarkController( deleteBookmarkNodes(nodes, eventType) } - override fun handleBookmarkFolderDeletion(node: BookmarkNode) { - deleteBookmarkFolder(node) + override fun handleBookmarkFolderDeletion(nodes: Set) { + deleteBookmarkFolder(nodes) } override fun handleBackPressed() { diff --git a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt index e1a56e0a579c..c916e7a8da7e 100644 --- a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt @@ -269,13 +269,17 @@ class BookmarkFragment : LibraryPageFragment(), UserInteractionHan } private fun deleteMulti(selected: Set, eventType: Event = Event.RemoveBookmarks) { + selected.forEach { if (it.type == BookmarkNodeType.FOLDER) { + showRemoveFolderDialog(selected) + return + } } updatePendingBookmarksToDelete(selected) pendingBookmarkDeletionJob = getDeleteOperation(eventType) val message = when (eventType) { is Event.RemoveBookmarks -> { - getRemoveBookmarksSnackBarMessage(selected) + getRemoveBookmarksSnackBarMessage(selected, false) } is Event.RemoveBookmarkFolder, is Event.RemoveBookmark -> { @@ -296,9 +300,16 @@ class BookmarkFragment : LibraryPageFragment(), UserInteractionHan ) } - private fun getRemoveBookmarksSnackBarMessage(selected: Set): String { + private fun getRemoveBookmarksSnackBarMessage( + selected: Set, + containsFolders: Boolean + ): String { return if (selected.size > 1) { - getString(R.string.bookmark_deletion_multiple_snackbar_message_2) + return if (containsFolders) { + getString(R.string.bookmark_deletion_multiple_snackbar_message_3) + } else { + getString(R.string.bookmark_deletion_multiple_snackbar_message_2) + } } else { val bookmarkNode = selected.first() getString( @@ -309,29 +320,38 @@ class BookmarkFragment : LibraryPageFragment(), UserInteractionHan } } + private fun getDialogConfirmationMessage(selected: Set): String { + return if (selected.size > 1) { + getString(R.string.bookmark_delete_multiple_folders_confirmation_dialog, getString(R.string.app_name)) + } else { + getString(R.string.bookmark_delete_folder_confirmation_dialog) + } + } + override fun onDestroyView() { super.onDestroyView() _bookmarkInteractor = null } - private fun showRemoveFolderDialog(selected: BookmarkNode) { + private fun showRemoveFolderDialog(selected: Set) { activity?.let { activity -> AlertDialog.Builder(activity).apply { - setMessage(R.string.bookmark_delete_folder_confirmation_dialog) + val dialogConfirmationMessage = getDialogConfirmationMessage(selected) + setMessage(dialogConfirmationMessage) setNegativeButton(R.string.delete_browsing_data_prompt_cancel) { dialog: DialogInterface, _ -> dialog.cancel() } setPositiveButton(R.string.delete_browsing_data_prompt_allow) { dialog: DialogInterface, _ -> - updatePendingBookmarksToDelete(setOf(selected)) + updatePendingBookmarksToDelete(selected) pendingBookmarkDeletionJob = getDeleteOperation(Event.RemoveBookmarkFolder) dialog.dismiss() - val message = getDeleteDialogString(selected) + val snackbarMessage = getRemoveBookmarksSnackBarMessage(selected, true) viewLifecycleOwner.lifecycleScope.allowUndo( requireView(), - message, + snackbarMessage, getString(R.string.bookmark_undo_deletion), { - undoPendingDeletion(setOf(selected)) + undoPendingDeletion(selected) }, operation = getDeleteOperation(Event.RemoveBookmarkFolder) ) @@ -348,14 +368,6 @@ class BookmarkFragment : LibraryPageFragment(), UserInteractionHan bookmarkInteractor.onBookmarksChanged(bookmarkTree) } - private fun getDeleteDialogString(selected: BookmarkNode): String { - return getString( - R.string.bookmark_deletion_snackbar_message, - context?.components?.publicSuffixList?.let { selected.url?.toShortUrl(it) } - ?: selected.title - ) - } - private suspend fun undoPendingDeletion(selected: Set) { pendingBookmarksToDelete.removeAll(selected) pendingBookmarkDeletionJob = null diff --git a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractor.kt b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractor.kt index e8fac64b49bb..395c4f106bae 100644 --- a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractor.kt +++ b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractor.kt @@ -90,7 +90,7 @@ class BookmarkFragmentInteractor( null -> Event.RemoveBookmarks } if (eventType == Event.RemoveBookmarkFolder) { - bookmarksController.handleBookmarkFolderDeletion(nodes.first()) + bookmarksController.handleBookmarkFolderDeletion(nodes) } else { bookmarksController.handleBookmarkDeletion(nodes, eventType) } diff --git a/app/src/main/java/org/mozilla/fenix/library/history/HistoryAdapter.kt b/app/src/main/java/org/mozilla/fenix/library/history/HistoryAdapter.kt index 5f970334ac9d..e14d52119458 100644 --- a/app/src/main/java/org/mozilla/fenix/library/history/HistoryAdapter.kt +++ b/app/src/main/java/org/mozilla/fenix/library/history/HistoryAdapter.kt @@ -33,6 +33,7 @@ class HistoryAdapter( private var mode: HistoryFragmentState.Mode = HistoryFragmentState.Mode.Normal override val selectedItems get() = mode.selectedItems + var pendingDeletionIds = emptySet() override fun getItemViewType(position: Int): Int = HistoryListItemViewHolder.LAYOUT_ID @@ -54,7 +55,11 @@ class HistoryAdapter( val previousHeader = previous?.let(::timeGroupForHistoryItem) val currentHeader = timeGroupForHistoryItem(current) val timeGroup = if (currentHeader != previousHeader) currentHeader else null - holder.bind(current, timeGroup, position == 0, mode) + holder.bind(current, timeGroup, position == 0, mode, pendingDeletionIds.contains(current.id)) + } + + fun updatePendingDeletionIds(pendingDeletionIds: Set) { + this.pendingDeletionIds = pendingDeletionIds } companion object { diff --git a/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt b/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt index 18d48197077d..381679be2c1f 100644 --- a/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt @@ -17,8 +17,11 @@ import android.view.ViewGroup import androidx.appcompat.app.AlertDialog import androidx.lifecycle.Observer import androidx.lifecycle.lifecycleScope +import androidx.navigation.NavDirections import androidx.navigation.fragment.findNavController import kotlinx.android.synthetic.main.fragment_history.view.* +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.launch @@ -36,11 +39,13 @@ import org.mozilla.fenix.components.StoreProvider import org.mozilla.fenix.components.history.createSynchronousPagedHistoryProvider import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.ext.components +import org.mozilla.fenix.ext.getStringWithArgSafe import org.mozilla.fenix.ext.nav import org.mozilla.fenix.ext.requireComponents import org.mozilla.fenix.ext.showToolbar import org.mozilla.fenix.ext.toShortUrl import org.mozilla.fenix.library.LibraryPageFragment +import org.mozilla.fenix.utils.allowUndo @SuppressWarnings("TooManyFunctions", "LargeClass") class HistoryFragment : LibraryPageFragment(), UserInteractionHandler { @@ -49,6 +54,9 @@ class HistoryFragment : LibraryPageFragment(), UserInteractionHandl private lateinit var historyInteractor: HistoryInteractor private lateinit var viewModel: HistoryViewModel + private var pendingHistoryDeletionJob: (suspend () -> Unit)? = null + private var pendingHistoryToDelete: MutableSet = mutableSetOf() + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -108,18 +116,16 @@ class HistoryFragment : LibraryPageFragment(), UserInteractionHandl } private fun deleteHistoryItems(items: Set) { - val message = getMultiSelectSnackBarMessage(items) - viewLifecycleOwner.lifecycleScope.launch { - context?.components?.run { - for (item in items) { - analytics.metrics.track(Event.HistoryItemRemoved) - core.historyStorage.deleteVisit(item.url, item.visitedAt) - } - } - viewModel.invalidate() - showSnackBar(requireView(), message) - historyStore.dispatch(HistoryFragmentAction.ExitDeletionMode) - } + updatePendingHistoryToDelete(items) + CoroutineScope(IO).allowUndo( + requireView(), + getMultiSelectSnackBarMessage(items), + getString(R.string.bookmark_undo_deletion), + { + undoPendingDeletion(items) + }, + getDeleteHistoryItemsOperation() + ) } @ExperimentalCoroutinesApi @@ -159,13 +165,7 @@ class HistoryFragment : LibraryPageFragment(), UserInteractionHandl true } R.id.delete_history_multi_select -> { - val message = getMultiSelectSnackBarMessage(selectedItems) - viewLifecycleOwner.lifecycleScope.launch(Main) { - deleteSelectedHistory(historyStore.state.mode.selectedItems, requireComponents) - viewModel.invalidate() - historyStore.dispatch(HistoryFragmentAction.ExitDeletionMode) - showSnackBar(requireView(), message) - } + deleteHistoryItems(historyStore.state.mode.selectedItems) true } R.id.open_history_in_new_tabs_multi_select -> { @@ -174,10 +174,7 @@ class HistoryFragment : LibraryPageFragment(), UserInteractionHandl selectedItem.url } - nav( - R.id.historyFragment, - HistoryFragmentDirections.actionGlobalHome() - ) + navigate(HistoryFragmentDirections.actionGlobalHome()) true } R.id.open_history_in_private_tabs_multi_select -> { @@ -190,10 +187,7 @@ class HistoryFragment : LibraryPageFragment(), UserInteractionHandl browsingModeManager.mode = BrowsingMode.Private supportActionBar?.hide() } - nav( - R.id.historyFragment, - HistoryFragmentDirections.actionGlobalHome() - ) + navigate(HistoryFragmentDirections.actionGlobalHome()) true } else -> super.onOptionsItemSelected(item) @@ -203,14 +197,22 @@ class HistoryFragment : LibraryPageFragment(), UserInteractionHandl return if (historyItems.size > 1) { getString(R.string.history_delete_multiple_items_snackbar) } else { - getString( + requireContext().getStringWithArgSafe( R.string.history_delete_single_item_snackbar, historyItems.first().url.toShortUrl(requireComponents.publicSuffixList) ) } } - override fun onBackPressed(): Boolean = historyView.onBackPressed() + override fun onPause() { + invokePendingDeletion() + super.onPause() + } + + override fun onBackPressed(): Boolean { + invokePendingDeletion() + return historyView.onBackPressed() + } private fun openItem(item: HistoryItem, mode: BrowsingMode? = null) { requireComponents.analytics.metrics.track(Event.HistoryItemOpened) @@ -266,6 +268,64 @@ class HistoryFragment : LibraryPageFragment(), UserInteractionHandl val directions = HistoryFragmentDirections.actionGlobalShareFragment( data = data.toTypedArray() ) - nav(R.id.historyFragment, directions) + navigate(directions) + } + + private fun navigate(directions: NavDirections) { + invokePendingDeletion() + findNavController().nav( + R.id.historyFragment, + directions + ) + } + + private fun getDeleteHistoryItemsOperation(): (suspend () -> Unit) { + return { + CoroutineScope(IO).launch { + historyStore.dispatch(HistoryFragmentAction.EnterDeletionMode) + context?.components?.run { + for (item in pendingHistoryToDelete) { + analytics.metrics.track(Event.HistoryItemRemoved) + core.historyStorage.deleteVisit(item.url, item.visitedAt) + } + } + historyStore.dispatch(HistoryFragmentAction.ExitDeletionMode) + viewModel.invalidate() + pendingHistoryToDelete.clear() + pendingHistoryDeletionJob = null + }.invokeOnCompletion { + val pendingDeletionIds: Set = + pendingHistoryToDelete.map { item -> item.id }.toSet() + historyStore.dispatch( + HistoryFragmentAction.RemovePendingDeletionIds( + pendingDeletionIds + ) + ) + } + } + } + + private fun updatePendingHistoryToDelete(items: Set) { + pendingHistoryToDelete.addAll(items) + pendingHistoryDeletionJob = getDeleteHistoryItemsOperation() + val pendingDeletionIds: Set = items.map { item -> item.id }.toSet() + historyStore.dispatch(HistoryFragmentAction.AddPendingDeletionIds(pendingDeletionIds)) + } + + private fun undoPendingDeletion(items: Set) { + pendingHistoryToDelete.removeAll(items) + pendingHistoryDeletionJob = null + val pendingDeletionIds: Set = items.map { item -> item.id }.toSet() + historyStore.dispatch(HistoryFragmentAction.RemovePendingDeletionIds(pendingDeletionIds)) + } + + private fun invokePendingDeletion() { + pendingHistoryDeletionJob?.let { + viewLifecycleOwner.lifecycleScope.launch { + it.invoke() + }.invokeOnCompletion { + pendingHistoryDeletionJob = null + } + } } } diff --git a/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragmentStore.kt b/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragmentStore.kt index 44ea6e1ccb15..52b89b5789b6 100644 --- a/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragmentStore.kt +++ b/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragmentStore.kt @@ -30,6 +30,8 @@ sealed class HistoryFragmentAction : Action { object ExitEditMode : HistoryFragmentAction() data class AddItemForRemoval(val item: HistoryItem) : HistoryFragmentAction() data class RemoveItemForRemoval(val item: HistoryItem) : HistoryFragmentAction() + data class AddPendingDeletionIds(val itemIds: Set) : HistoryFragmentAction() + data class RemovePendingDeletionIds(val itemIds: Set) : HistoryFragmentAction() object EnterDeletionMode : HistoryFragmentAction() object ExitDeletionMode : HistoryFragmentAction() } @@ -39,7 +41,11 @@ sealed class HistoryFragmentAction : Action { * @property items List of HistoryItem to display * @property mode Current Mode of History */ -data class HistoryFragmentState(val items: List, val mode: Mode) : State { +data class HistoryFragmentState( + val items: List, + val mode: Mode, + val pendingDeletionIds: Set = emptySet() +) : State { sealed class Mode { open val selectedItems = emptySet() @@ -72,5 +78,12 @@ private fun historyStateReducer( is HistoryFragmentAction.ExitEditMode -> state.copy(mode = HistoryFragmentState.Mode.Normal) is HistoryFragmentAction.EnterDeletionMode -> state.copy(mode = HistoryFragmentState.Mode.Deleting) is HistoryFragmentAction.ExitDeletionMode -> state.copy(mode = HistoryFragmentState.Mode.Normal) + is HistoryFragmentAction.AddPendingDeletionIds -> + state.copy( + pendingDeletionIds = state.pendingDeletionIds + action.itemIds, + mode = HistoryFragmentState.Mode.Normal + ) + is HistoryFragmentAction.RemovePendingDeletionIds -> + state.copy(pendingDeletionIds = state.pendingDeletionIds - action.itemIds) } } diff --git a/app/src/main/java/org/mozilla/fenix/library/history/HistoryView.kt b/app/src/main/java/org/mozilla/fenix/library/history/HistoryView.kt index c56a1b76ae0c..9e83d1cf7f8c 100644 --- a/app/src/main/java/org/mozilla/fenix/library/history/HistoryView.kt +++ b/app/src/main/java/org/mozilla/fenix/library/history/HistoryView.kt @@ -106,6 +106,8 @@ class HistoryView( items = state.items mode = state.mode + historyAdapter.updatePendingDeletionIds(state.pendingDeletionIds) + historyAdapter.updateMode(state.mode) val first = layoutManager.findFirstVisibleItemPosition() val last = layoutManager.findLastVisibleItemPosition() + 1 diff --git a/app/src/main/java/org/mozilla/fenix/library/history/viewholders/HistoryListItemViewHolder.kt b/app/src/main/java/org/mozilla/fenix/library/history/viewholders/HistoryListItemViewHolder.kt index 685081167c79..61b84460b4b7 100644 --- a/app/src/main/java/org/mozilla/fenix/library/history/viewholders/HistoryListItemViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/library/history/viewholders/HistoryListItemViewHolder.kt @@ -5,19 +5,20 @@ package org.mozilla.fenix.library.history.viewholders import android.view.View +import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import kotlinx.android.synthetic.main.history_list_item.view.* import kotlinx.android.synthetic.main.library_site_item.view.* import org.mozilla.fenix.R import org.mozilla.fenix.ext.hideAndDisable import org.mozilla.fenix.ext.showAndEnable -import org.mozilla.fenix.utils.Do import org.mozilla.fenix.library.SelectionHolder import org.mozilla.fenix.library.history.HistoryFragmentState import org.mozilla.fenix.library.history.HistoryInteractor import org.mozilla.fenix.library.history.HistoryItem import org.mozilla.fenix.library.history.HistoryItemMenu import org.mozilla.fenix.library.history.HistoryItemTimeGroup +import org.mozilla.fenix.utils.Do class HistoryListItemViewHolder( view: View, @@ -44,8 +45,21 @@ class HistoryListItemViewHolder( item: HistoryItem, timeGroup: HistoryItemTimeGroup?, showDeleteButton: Boolean, - mode: HistoryFragmentState.Mode + mode: HistoryFragmentState.Mode, + isPendingDeletion: Boolean = false ) { + if (isPendingDeletion) { + itemView.visibility = View.GONE + itemView.layoutParams = RecyclerView.LayoutParams(0, 0) + return + } else { + itemView.visibility = View.VISIBLE + itemView.layoutParams = RecyclerView.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ) + } + itemView.history_layout.titleView.text = item.title itemView.history_layout.urlView.text = item.url diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7301dde3526a..2be322f6977d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -530,6 +530,8 @@ Select folder Are you sure you want to delete this folder? + + %s will delete the selected items. Deleted %1$s @@ -584,8 +586,10 @@ Deleted %1$s - + Bookmarks deleted + + Deleting selected folders UNDO diff --git a/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkControllerTest.kt b/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkControllerTest.kt index 71cf57e16f8d..8faf7e314438 100644 --- a/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkControllerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkControllerTest.kt @@ -42,7 +42,7 @@ class BookmarkControllerTest { private val navController: NavController = mockk(relaxed = true) private val showSnackbar: (String) -> Unit = mockk(relaxed = true) private val deleteBookmarkNodes: (Set, Event) -> Unit = mockk(relaxed = true) - private val deleteBookmarkFolder: (BookmarkNode) -> Unit = mockk(relaxed = true) + private val deleteBookmarkFolder: (Set) -> Unit = mockk(relaxed = true) private val invokePendingDeletion: () -> Unit = mockk(relaxed = true) private val homeActivity: HomeActivity = mockk(relaxed = true) @@ -240,10 +240,10 @@ class BookmarkControllerTest { @Test fun `handleBookmarkDeletion for a folder should properly call the delete folder delegate`() { - controller.handleBookmarkFolderDeletion(subfolder) + controller.handleBookmarkFolderDeletion(setOf(subfolder)) verify { - deleteBookmarkFolder(subfolder) + deleteBookmarkFolder(setOf(subfolder)) } } diff --git a/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractorTest.kt b/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractorTest.kt index c0129e961a51..2ffbe3f4b0ae 100644 --- a/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractorTest.kt +++ b/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkFragmentInteractorTest.kt @@ -196,7 +196,7 @@ class BookmarkFragmentInteractorTest { interactor.onDelete(setOf(subfolder)) verify { - bookmarkController.handleBookmarkFolderDeletion(subfolder) + bookmarkController.handleBookmarkFolderDeletion(setOf(subfolder)) } }