|
|
@ -14,6 +14,7 @@ import io.mockk.verify
|
|
|
|
import io.mockk.mockkStatic
|
|
|
|
import io.mockk.mockkStatic
|
|
|
|
import io.mockk.unmockkStatic
|
|
|
|
import io.mockk.unmockkStatic
|
|
|
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
|
|
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
|
|
|
|
|
|
|
import kotlinx.coroutines.test.TestCoroutineDispatcher
|
|
|
|
import kotlinx.coroutines.test.runBlockingTest
|
|
|
|
import kotlinx.coroutines.test.runBlockingTest
|
|
|
|
import mozilla.components.browser.state.state.BrowserState
|
|
|
|
import mozilla.components.browser.state.state.BrowserState
|
|
|
|
import mozilla.components.browser.state.state.TabSessionState
|
|
|
|
import mozilla.components.browser.state.state.TabSessionState
|
|
|
@ -21,6 +22,7 @@ import mozilla.components.browser.state.state.createTab as createStateTab
|
|
|
|
import mozilla.components.browser.state.store.BrowserStore
|
|
|
|
import mozilla.components.browser.state.store.BrowserStore
|
|
|
|
import mozilla.components.concept.tabstray.Tab
|
|
|
|
import mozilla.components.concept.tabstray.Tab
|
|
|
|
import mozilla.components.service.fxa.manager.FxaAccountManager
|
|
|
|
import mozilla.components.service.fxa.manager.FxaAccountManager
|
|
|
|
|
|
|
|
import mozilla.components.support.test.rule.MainCoroutineRule
|
|
|
|
import org.junit.Assert.assertTrue
|
|
|
|
import org.junit.Assert.assertTrue
|
|
|
|
import org.junit.Before
|
|
|
|
import org.junit.Before
|
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Rule
|
|
|
@ -34,6 +36,7 @@ import org.mozilla.fenix.components.metrics.Event
|
|
|
|
import org.mozilla.fenix.components.metrics.MetricController
|
|
|
|
import org.mozilla.fenix.components.metrics.MetricController
|
|
|
|
import org.mozilla.fenix.tabstray.browser.createTab as createTrayTab
|
|
|
|
import org.mozilla.fenix.tabstray.browser.createTab as createTrayTab
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ExperimentalCoroutinesApi
|
|
|
|
class NavigationInteractorTest {
|
|
|
|
class NavigationInteractorTest {
|
|
|
|
private lateinit var store: BrowserStore
|
|
|
|
private lateinit var store: BrowserStore
|
|
|
|
private lateinit var tabsTrayStore: TabsTrayStore
|
|
|
|
private lateinit var tabsTrayStore: TabsTrayStore
|
|
|
@ -48,9 +51,14 @@ class NavigationInteractorTest {
|
|
|
|
private val collectionStorage: TabCollectionStorage = mockk(relaxed = true)
|
|
|
|
private val collectionStorage: TabCollectionStorage = mockk(relaxed = true)
|
|
|
|
private val accountManager: FxaAccountManager = mockk(relaxed = true)
|
|
|
|
private val accountManager: FxaAccountManager = mockk(relaxed = true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val testDispatcher = TestCoroutineDispatcher()
|
|
|
|
|
|
|
|
|
|
|
|
@get:Rule
|
|
|
|
@get:Rule
|
|
|
|
val disableNavGraphProviderAssertionRule = DisableNavGraphProviderAssertionRule()
|
|
|
|
val disableNavGraphProviderAssertionRule = DisableNavGraphProviderAssertionRule()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@get:Rule
|
|
|
|
|
|
|
|
val coroutinesTestRule = MainCoroutineRule(testDispatcher)
|
|
|
|
|
|
|
|
|
|
|
|
@Before
|
|
|
|
@Before
|
|
|
|
fun setup() {
|
|
|
|
fun setup() {
|
|
|
|
store = BrowserStore(initialState = BrowserState(tabs = listOf(testTab)))
|
|
|
|
store = BrowserStore(initialState = BrowserState(tabs = listOf(testTab)))
|
|
|
@ -65,7 +73,8 @@ class NavigationInteractorTest {
|
|
|
|
bookmarksUseCase,
|
|
|
|
bookmarksUseCase,
|
|
|
|
tabsTrayStore,
|
|
|
|
tabsTrayStore,
|
|
|
|
collectionStorage,
|
|
|
|
collectionStorage,
|
|
|
|
accountManager
|
|
|
|
accountManager,
|
|
|
|
|
|
|
|
testDispatcher
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -206,9 +215,21 @@ class NavigationInteractorTest {
|
|
|
|
unmockkStatic("org.mozilla.fenix.collections.CollectionsDialogKt")
|
|
|
|
unmockkStatic("org.mozilla.fenix.collections.CollectionsDialogKt")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalCoroutinesApi::class)
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
fun `onBookmarkTabs calls navigation on DefaultNavigationInteractor`() = runBlockingTest {
|
|
|
|
fun `onBookmarkTabs calls navigation on DefaultNavigationInteractor`() = runBlockingTest {
|
|
|
|
|
|
|
|
navigationInteractor = DefaultNavigationInteractor(
|
|
|
|
|
|
|
|
context,
|
|
|
|
|
|
|
|
store,
|
|
|
|
|
|
|
|
navController,
|
|
|
|
|
|
|
|
metrics,
|
|
|
|
|
|
|
|
dismissTabTray,
|
|
|
|
|
|
|
|
dismissTabTrayAndNavigateHome,
|
|
|
|
|
|
|
|
bookmarksUseCase,
|
|
|
|
|
|
|
|
tabsTrayStore,
|
|
|
|
|
|
|
|
collectionStorage,
|
|
|
|
|
|
|
|
accountManager,
|
|
|
|
|
|
|
|
coroutineContext
|
|
|
|
|
|
|
|
)
|
|
|
|
navigationInteractor.onSaveToBookmarks(listOf(createTrayTab()))
|
|
|
|
navigationInteractor.onSaveToBookmarks(listOf(createTrayTab()))
|
|
|
|
coVerify(exactly = 1) { bookmarksUseCase.addBookmark(any(), any(), any()) }
|
|
|
|
coVerify(exactly = 1) { bookmarksUseCase.addBookmark(any(), any(), any()) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|