commit e3a00b85356850d1f31954ba40f9b35eb239f119 parent b35ac0e38259bf8c3991414d0e79c80f9eca3ddb Author: pollymce <pmceldowney@mozilla.com> Date: Mon, 17 Nov 2025 13:45:14 +0000 Bug 1980348 - get rid of Store.waitUntilIdle(). r=android-reviewers,007 This was previously just a passthrough method so we can remove it now. This simplifies a lot of tests. Differential Revision: https://phabricator.services.mozilla.com/D268874 Diffstat:
53 files changed, 6 insertions(+), 478 deletions(-)
diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/EngineMiddlewareTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/EngineMiddlewareTest.kt @@ -11,7 +11,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.Engine import mozilla.components.concept.engine.EngineSession -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertTrue @@ -50,7 +49,6 @@ class EngineMiddlewareTest { ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine, Mockito.times(1)).createSession(false, null) } diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/store/BrowserStoreTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/store/BrowserStoreTest.kt @@ -12,7 +12,6 @@ import mozilla.components.browser.state.reducer.BrowserStateReducer import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.state.createTab import mozilla.components.lib.state.Middleware -import mozilla.components.support.test.libstate.ext.waitUntilIdle import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertNull @@ -74,8 +73,7 @@ class BrowserStoreTest { next(action) } - val store = BrowserStore(middleware = listOf(testMiddleware)) - store.waitUntilIdle() + BrowserStore(middleware = listOf(testMiddleware)) assertTrue(initActionObserved) } diff --git a/mobile/android/android-components/components/feature/accounts-push/src/test/java/mozilla/components/feature/accounts/push/CloseTabsCommandReceiverTest.kt b/mobile/android/android-components/components/feature/accounts-push/src/test/java/mozilla/components/feature/accounts/push/CloseTabsCommandReceiverTest.kt @@ -10,7 +10,6 @@ import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.sync.DeviceCommandIncoming import mozilla.components.support.test.any import mozilla.components.support.test.eq -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import org.junit.Assert.assertEquals import org.junit.Assert.assertNull @@ -39,8 +38,6 @@ class CloseTabsCommandReceiverTest { receiver.receive(DeviceCommandIncoming.TabsClosed(null, urls)) - browserStore.waitUntilIdle() - assertTrue(browserStore.state.tabs.isEmpty()) verify(observer).onTabsClosed(any()) verify(observer, never()).onLastTabClosed() @@ -55,8 +52,6 @@ class CloseTabsCommandReceiverTest { receiver.receive(DeviceCommandIncoming.TabsClosed(null, listOf("https://mozilla.org"))) - browserStore.waitUntilIdle() - verify(observer, never()).onTabsClosed(any()) verify(observer, never()).onLastTabClosed() } @@ -77,8 +72,6 @@ class CloseTabsCommandReceiverTest { processor.receive(DeviceCommandIncoming.TabsClosed(null, listOf("https://getfirefox.com"))) - browserStore.waitUntilIdle() - assertEquals(listOf("1"), browserStore.state.tabs.map { it.id }) assertEquals("1", browserStore.state.selectedTabId) verify(observer, never()).onTabsClosed(any()) @@ -101,8 +94,6 @@ class CloseTabsCommandReceiverTest { processor.receive(DeviceCommandIncoming.TabsClosed(null, listOf("https://getfirefox.com"))) - browserStore.waitUntilIdle() - assertTrue(browserStore.state.tabs.isEmpty()) assertNull(browserStore.state.selectedTabId) verify(observer).onTabsClosed(eq(listOf("https://getfirefox.com"))) @@ -141,8 +132,6 @@ class CloseTabsCommandReceiverTest { ), ) - browserStore.waitUntilIdle() - assertEquals(listOf("6"), browserStore.state.tabs.map { it.id }) verify(observer).onTabsClosed( eq( @@ -194,8 +183,6 @@ class CloseTabsCommandReceiverTest { ), ) - browserStore.waitUntilIdle() - assertEquals(listOf("2", "5"), browserStore.state.tabs.map { it.id }) assertNull(browserStore.state.selectedTabId) verify(observer).onTabsClosed( @@ -237,8 +224,6 @@ class CloseTabsCommandReceiverTest { ), ) - browserStore.waitUntilIdle() - assertEquals(listOf("2"), browserStore.state.tabs.map { it.id }) verify(observer).onTabsClosed( eq( diff --git a/mobile/android/android-components/components/feature/addons/src/test/java/mozilla/components/feature/addons/ui/AddonsManagerAdapterTest.kt b/mobile/android/android-components/components/feature/addons/src/test/java/mozilla/components/feature/addons/ui/AddonsManagerAdapterTest.kt @@ -19,7 +19,6 @@ import mozilla.components.feature.addons.R import mozilla.components.feature.addons.ui.AddonsManagerAdapter.DifferCallback import mozilla.components.feature.addons.ui.AddonsManagerAdapter.NotYetSupportedSection import mozilla.components.feature.addons.ui.AddonsManagerAdapter.Section -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule @@ -540,7 +539,6 @@ class AddonsManagerAdapterTest { viewHolder.restartButton.performClick() dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() assertFalse(store.state.extensionsProcessDisabled) verify(adapter).submitList(emptyList()) diff --git a/mobile/android/android-components/components/feature/contextmenu/src/test/java/mozilla/components/feature/contextmenu/ContextMenuCandidateTest.kt b/mobile/android/android-components/components/feature/contextmenu/src/test/java/mozilla/components/feature/contextmenu/ContextMenuCandidateTest.kt @@ -32,7 +32,6 @@ import mozilla.components.feature.tabs.TabsUseCases import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor import mozilla.components.support.test.eq -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext @@ -173,7 +172,6 @@ class ContextMenuCandidateTest { assertEquals("1", store.state.tabs.first().contextId) openInNewTab.action.invoke(store.state.tabs.first(), HitResult.UNKNOWN("https://firefox.com")) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertEquals("https://firefox.com", store.state.tabs.last().content.url) @@ -206,7 +204,6 @@ class ContextMenuCandidateTest { assertFalse(snackbarDelegate.hasShownSnackbar) openInNewTab.action.invoke(store.state.tabs.first(), HitResult.UNKNOWN("https://firefox.com")) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertTrue(snackbarDelegate.hasShownSnackbar) @@ -242,12 +239,10 @@ class ContextMenuCandidateTest { assertFalse(snackbarDelegate.hasShownSnackbar) openInNewTab.action.invoke(store.state.tabs.first(), HitResult.UNKNOWN("https://firefox.com")) - store.waitUntilIdle() assertEquals("https://www.mozilla.org", store.state.selectedTab!!.content.url) snackbarDelegate.lastActionListener!!.invoke(mock()) - store.waitUntilIdle() assertEquals("https://firefox.com", store.state.selectedTab!!.content.url) } @@ -282,7 +277,6 @@ class ContextMenuCandidateTest { store.state.tabs.first(), HitResult.IMAGE_SRC("https://www.mozilla_src.org", "https://www.mozilla_uri.org"), ) - store.waitUntilIdle() assertEquals("https://www.mozilla_uri.org", store.state.tabs.last().content.url) } @@ -316,7 +310,6 @@ class ContextMenuCandidateTest { store.state.tabs.first(), HitResult.UNKNOWN("https://www.mozilla.org"), ) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.LoadUrlAction::class) { action -> assertEquals("https://www.mozilla.org", action.url) @@ -442,7 +435,6 @@ class ContextMenuCandidateTest { assertFalse(snackbarDelegate.hasShownSnackbar) openInPrivateTab.action.invoke(store.state.tabs.first(), HitResult.UNKNOWN("https://firefox.com")) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertTrue(snackbarDelegate.hasShownSnackbar) @@ -478,13 +470,11 @@ class ContextMenuCandidateTest { assertFalse(snackbarDelegate.hasShownSnackbar) openInPrivateTab.action.invoke(store.state.tabs.first(), HitResult.UNKNOWN("https://firefox.com")) - store.waitUntilIdle() assertEquals("https://www.mozilla.org", store.state.selectedTab!!.content.url) assertEquals(2, store.state.tabs.size) snackbarDelegate.lastActionListener!!.invoke(mock()) - store.waitUntilIdle() assertEquals("https://firefox.com", store.state.selectedTab!!.content.url) } @@ -517,7 +507,6 @@ class ContextMenuCandidateTest { store.state.tabs.first(), HitResult.IMAGE_SRC("https://www.mozilla_src.org", "https://www.mozilla_uri.org"), ) - store.waitUntilIdle() assertEquals("https://www.mozilla_uri.org", store.state.tabs.last().content.url) } @@ -593,8 +582,6 @@ class ContextMenuCandidateTest { HitResult.IMAGE_SRC("https://firefox.com", "https://getpocket.com"), ) - store.waitUntilIdle() - assertEquals(2, store.state.tabs.size) assertFalse(store.state.tabs.last().content.private) assertEquals("https://firefox.com", store.state.tabs.last().content.url) @@ -606,7 +593,6 @@ class ContextMenuCandidateTest { assertEquals("https://www.mozilla.org", store.state.selectedTab!!.content.url) snackbarDelegate.lastActionListener!!.invoke(mock()) - store.waitUntilIdle() assertEquals("https://firefox.com", store.state.selectedTab!!.content.url) } @@ -669,7 +655,6 @@ class ContextMenuCandidateTest { store.state.tabs.first(), HitResult.IMAGE_SRC("https://firefox.com", "https://getpocket.com"), ) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertTrue(store.state.tabs.last().content.private) @@ -707,7 +692,6 @@ class ContextMenuCandidateTest { store.state.tabs.first(), HitResult.IMAGE_SRC("https://firefox.com", "https://getpocket.com"), ) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertEquals("https://firefox.com", store.state.tabs.last().content.url) @@ -779,8 +763,6 @@ class ContextMenuCandidateTest { ), ) - store.waitUntilIdle() - assertNotNull(store.state.tabs.first().content.download) assertEquals( "https://www.mozilla.org/media/img/logos/firefox/logo-quantum.9c5e96634f92.png", @@ -889,8 +871,6 @@ class ContextMenuCandidateTest { HitResult.AUDIO("https://developer.mozilla.org/media/examples/t-rex-roar.mp3"), ) - store.waitUntilIdle() - assertNotNull(store.state.tabs.first().content.download) assertEquals( "https://developer.mozilla.org/media/examples/t-rex-roar.mp3", @@ -1031,8 +1011,6 @@ class ContextMenuCandidateTest { ), ) - store.waitUntilIdle() - assertNotNull(store.state.tabs.first().content.download) assertEquals( "https://www.mozilla.org/en-US/privacy-policy.pdf", diff --git a/mobile/android/android-components/components/feature/customtabs/src/test/java/mozilla/components/feature/customtabs/CustomTabIntentProcessorTest.kt b/mobile/android/android-components/components/feature/customtabs/src/test/java/mozilla/components/feature/customtabs/CustomTabIntentProcessorTest.kt @@ -22,7 +22,6 @@ import mozilla.components.feature.intent.ext.EXTRA_SESSION_ID import mozilla.components.feature.session.SessionUseCases import mozilla.components.feature.tabs.CustomTabsUseCases import mozilla.components.support.test.any -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext @@ -61,8 +60,6 @@ class CustomTabIntentProcessorTest { handler.process(intent) - store.waitUntilIdle() - var customTabId: String? = null middleware.assertFirstAction(CustomTabListAction.AddCustomTabAction::class) { action -> @@ -113,8 +110,6 @@ class CustomTabIntentProcessorTest { handler.process(intent) - store.waitUntilIdle() - var customTabId: String? = null middleware.assertFirstAction(CustomTabListAction.AddCustomTabAction::class) { action -> @@ -160,8 +155,6 @@ class CustomTabIntentProcessorTest { handler.process(intent) - store.waitUntilIdle() - var customTabId: String? = null middleware.assertFirstAction(CustomTabListAction.AddCustomTabAction::class) { action -> diff --git a/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/manager/AndroidDownloadManagerTest.kt b/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/manager/AndroidDownloadManagerTest.kt @@ -15,7 +15,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import mozilla.components.browser.state.state.content.DownloadState import mozilla.components.browser.state.store.BrowserStore import mozilla.components.feature.downloads.AbstractFetchDownloadService.Companion.EXTRA_DOWNLOAD_STATUS -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.grantPermission import mozilla.components.support.test.robolectric.testContext @@ -67,7 +66,6 @@ class AndroidDownloadManagerTest { assertTrue(store.state.downloads.isEmpty()) val id = downloadManager.download(download)!! - store.waitUntilIdle() assertEquals(download.copy(id = id), store.state.downloads[id]) notifyDownloadCompleted(id) @@ -83,7 +81,6 @@ class AndroidDownloadManagerTest { grantPermissions() val id = downloadManager.download(download)!! - store.waitUntilIdle() notifyDownloadFailed(id) shadowOf(getMainLooper()).idle() assertTrue(downloadStopped) @@ -138,7 +135,6 @@ class AndroidDownloadManagerTest { downloadWithFileName, cookie = "yummy_cookie=choco", )!! - store.waitUntilIdle() downloadManager.onDownloadStopped = { _, _, status -> downloadStatus = status @@ -166,7 +162,6 @@ class AndroidDownloadManagerTest { downloadWithFileName, cookie = "yummy_cookie=choco", )!! - store.waitUntilIdle() assertEquals(downloadWithFileName.copy(id = id), store.state.downloads[id]) notifyDownloadCompleted(id) diff --git a/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/manager/FetchDownloadManagerTest.kt b/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/manager/FetchDownloadManagerTest.kt @@ -27,7 +27,6 @@ import mozilla.components.feature.downloads.fake.FakeFileSizeFormatter import mozilla.components.feature.downloads.fake.FakePackageNameProvider import mozilla.components.support.base.android.NotificationsDelegate import mozilla.components.support.test.any -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.grantPermission import mozilla.components.support.test.robolectric.testContext @@ -91,7 +90,6 @@ class FetchDownloadManagerTest { assertTrue(store.state.downloads.isEmpty()) val id = downloadManager.download(download)!! - store.waitUntilIdle() assertEquals(download, store.state.downloads[download.id]) notifyDownloadCompleted(id) @@ -110,7 +108,6 @@ class FetchDownloadManagerTest { assertTrue(store.state.downloads.isEmpty()) val id = downloadManager.download(download)!! - store.waitUntilIdle() assertEquals(download, store.state.downloads[download.id]) // Excluding the EXTRA_DOWNLOAD_STATUS @@ -140,7 +137,6 @@ class FetchDownloadManagerTest { grantPermissions() val id = downloadManager.download(download)!! - store.waitUntilIdle() notifyDownloadFailed(id) shadowOf(getMainLooper()).idle() assertTrue(downloadStopped) @@ -238,7 +234,6 @@ class FetchDownloadManagerTest { downloadWithFileName, cookie = "yummy_cookie=choco", )!! - store.waitUntilIdle() notifyDownloadCompleted(id) shadowOf(getMainLooper()).idle() @@ -261,13 +256,11 @@ class FetchDownloadManagerTest { downloadWithFileName, cookie = "yummy_cookie=choco", )!! - store.waitUntilIdle() assertEquals(downloadWithFileName, store.state.downloads[downloadWithFileName.id]) notifyDownloadCompleted(id) shadowOf(getMainLooper()).idle() - store.waitUntilIdle() assertEquals(DownloadState.Status.COMPLETED, downloadStatus) } @@ -289,7 +282,6 @@ class FetchDownloadManagerTest { } val id = downloadManager.download(downloadWithFileName)!! - store.waitUntilIdle() notifyDownloadCompleted(id) shadowOf(getMainLooper()).idle() diff --git a/mobile/android/android-components/components/feature/media/src/test/java/mozilla/components/feature/media/MediaSessionFeatureTest.kt b/mobile/android/android-components/components/feature/media/src/test/java/mozilla/components/feature/media/MediaSessionFeatureTest.kt @@ -23,7 +23,6 @@ import mozilla.components.feature.media.service.MediaSessionServiceDelegate import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor import mozilla.components.support.test.eq -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertEquals @@ -306,7 +305,6 @@ class MediaSessionFeatureTest { feature.start() store.dispatch(MediaSessionAction.DeactivatedMediaSessionAction(store.state.tabs[0].id)) - store.waitUntilIdle() verify(mediaService).handleNoMedia() verify(mockApplicationContext).unbindService(feature.mediaServiceConnection) @@ -333,7 +331,6 @@ class MediaSessionFeatureTest { feature.start() store.dispatch(MediaSessionAction.DeactivatedMediaSessionAction(store.state.customTabs[0].id)) - store.waitUntilIdle() verify(mediaService).handleNoMedia() verify(mockApplicationContext).unbindService(feature.mediaServiceConnection) diff --git a/mobile/android/android-components/components/feature/tab-collections/src/test/java/mozilla/components/feature/tab/collections/ext/TabsUseCasesKtTest.kt b/mobile/android/android-components/components/feature/tab-collections/src/test/java/mozilla/components/feature/tab/collections/ext/TabsUseCasesKtTest.kt @@ -15,7 +15,6 @@ import mozilla.components.concept.engine.EngineSession import mozilla.components.feature.tab.collections.Tab import mozilla.components.feature.tab.collections.TabCollection import mozilla.components.feature.tabs.TabsUseCases -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.whenever @@ -85,8 +84,6 @@ class TabsUseCasesKtTest { fun `RestoreUseCase updates last access when restoring collection`() { tabsUseCases.restore.invoke(filesDir, engine, collection) {} - store.waitUntilIdle() - assertNotEquals(3735928559L, store.state.findTab("123")!!.lastAccess) } @@ -94,8 +91,6 @@ class TabsUseCasesKtTest { fun `RestoreUseCase updates last access when restoring single tab in collection`() { tabsUseCases.restore.invoke(filesDir, engine, tab, onTabRestored = {}, onFailure = {}) - store.waitUntilIdle() - assertNotEquals(3735928559L, store.state.findTab("123")!!.lastAccess) } @@ -103,8 +98,6 @@ class TabsUseCasesKtTest { fun `Restored single tab should be the last in the tabs list`() { tabsUseCases.restore.invoke(filesDir, engine, tab, onTabRestored = {}, onFailure = {}) - store.waitUntilIdle() - assertEquals("123", store.state.tabs.last().id) } } diff --git a/mobile/android/android-components/components/service/firefox-accounts/src/test/java/mozilla/components/service/fxa/store/SyncStoreSupportTest.kt b/mobile/android/android-components/components/service/firefox-accounts/src/test/java/mozilla/components/service/fxa/store/SyncStoreSupportTest.kt @@ -19,7 +19,6 @@ import mozilla.components.service.fxa.manager.SCOPE_PROFILE import mozilla.components.support.test.any import mozilla.components.support.test.coMock import mozilla.components.support.test.eq -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.whenever @@ -80,7 +79,6 @@ class SyncStoreSupportTest { fun `GIVEN sync observer WHEN onStarted observed THEN sync status updated`() { syncObserver.onStarted() - store.waitUntilIdle() assertEquals(SyncStatus.Started, store.state.status) } @@ -88,7 +86,6 @@ class SyncStoreSupportTest { fun `GIVEN sync observer WHEN onIdle observed THEN sync status updated`() { syncObserver.onIdle() - store.waitUntilIdle() assertEquals(SyncStatus.Idle, store.state.status) } @@ -96,7 +93,6 @@ class SyncStoreSupportTest { fun `GIVEN sync observer WHEN onError observed THEN sync status updated`() { syncObserver.onError(Exception()) - store.waitUntilIdle() assertEquals(SyncStatus.Error, store.state.status) } @@ -135,7 +131,6 @@ class SyncStoreSupportTest { "id", "token", ) - store.waitUntilIdle() assertEquals(expected, store.state.account) assertEquals(AccountState.Authenticated, store.state.accountState) } @@ -150,7 +145,6 @@ class SyncStoreSupportTest { accountObserver.onAuthenticated(account, AuthType.Existing) - store.waitUntilIdle() assertNull(store.state.account) assertEquals(AccountState.NotAuthenticated, store.state.accountState) } @@ -165,7 +159,6 @@ class SyncStoreSupportTest { accountObserver.onLoggedOut() - store.waitUntilIdle() assertEquals(SyncStatus.LoggedOut, store.state.status) assertNull(store.state.account) assertEquals(AccountState.NotAuthenticated, store.state.accountState) @@ -177,7 +170,6 @@ class SyncStoreSupportTest { accountObserver.onAuthenticationProblems() - store.waitUntilIdle() assertEquals(AccountState.AuthenticationProblem, store.state.accountState) } @@ -188,7 +180,6 @@ class SyncStoreSupportTest { accountObserver.onFlowError(AuthFlowError.FailedToBeginAuth) - store.waitUntilIdle() assertNull(store.state.account) assertEquals(AccountState.NotAuthenticated, store.state.accountState) } @@ -197,13 +188,10 @@ class SyncStoreSupportTest { fun `GIVEN account observer WHEN onProfileUpdated then update the account state`() = runTest { // Prerequisite is having a non-null account already. store.dispatch(SyncAction.UpdateAccount(Account(null, null, null, null, null, null))) - store.waitUntilIdle() val profile = generateProfile() accountObserver.onProfileUpdated(profile) - store.waitUntilIdle() - assertEquals(profile.uid, store.state.account!!.uid) assertEquals(profile.avatar, store.state.account!!.avatar) assertEquals(profile.email, store.state.account!!.email) @@ -231,14 +219,12 @@ class SyncStoreSupportTest { accountObserver.onReady(authenticatedAccount = authenticatedAccount) - store.waitUntilIdle() assertEquals(initialState, store.state) `when`(authenticatedAccount.checkAuthorizationStatus(eq(SCOPE_PROFILE))).thenReturn(true) accountObserver.onReady(authenticatedAccount = authenticatedAccount) - store.waitUntilIdle() assertEquals(initialState, store.state) } @@ -255,7 +241,6 @@ class SyncStoreSupportTest { accountObserver.onReady(account) - store.waitUntilIdle() assertNull(store.state.account) assertEquals(AccountState.NotAuthenticated, store.state.accountState) } @@ -265,7 +250,6 @@ class SyncStoreSupportTest { val constellation = mock<ConstellationState>() constellationObserver.onDevicesUpdate(constellation) - store.waitUntilIdle() assertEquals(constellation, store.state.constellationState) } diff --git a/mobile/android/android-components/components/support/test-libstate/src/main/java/mozilla/components/support/test/libstate/ext/Store.kt b/mobile/android/android-components/components/support/test-libstate/src/main/java/mozilla/components/support/test/libstate/ext/Store.kt @@ -1,19 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package mozilla.components.support.test.libstate.ext - -import mozilla.components.lib.state.Action -import mozilla.components.lib.state.State -import mozilla.components.lib.state.Store - -/** - * Blocks and returns once all dispatched actions have been processed - * i.e. the reducers have run and all observers have been notified of - * state changes. - */ -fun <S : State, A : Action> Store<S, A>.waitUntilIdle() { - // see https://bugzilla.mozilla.org/show_bug.cgi?id=1980348 - // this is no longer required and will be deleted later in the stack -} diff --git a/mobile/android/android-components/components/support/test-libstate/src/test/java/mozilla/components/support/test/libstate/ext/StoreTest.kt b/mobile/android/android-components/components/support/test-libstate/src/test/java/mozilla/components/support/test/libstate/ext/StoreTest.kt @@ -20,12 +20,10 @@ class StoreTest { ) store.dispatch(TestAction.IncrementAction) - store.waitUntilIdle() assertEquals(24, store.state.counter) store.dispatch(TestAction.DecrementAction) store.dispatch(TestAction.DecrementAction) - store.waitUntilIdle() assertEquals(22, store.state.counter) } } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/AboutHomeBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/AboutHomeBindingTest.kt @@ -13,7 +13,6 @@ import mozilla.components.browser.state.state.TabSessionState import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.utils.ABOUT_HOME_URL -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain @@ -69,9 +68,6 @@ class AboutHomeBindingTest { ), ) - // Wait for ContentAction.UpdateUrlAction - browserStore.waitUntilIdle() - assertEquals(ABOUT_HOME_URL, tab.content.url) verify(navController).navigate(NavGraphDirections.actionGlobalHome()) @@ -97,9 +93,6 @@ class AboutHomeBindingTest { ), ) - // Wait for ContentAction.UpdateUrlAction - browserStore.waitUntilIdle() - assertEquals(ABOUT_HOME_URL, tab.content.url) verify(navController, never()).navigate(NavGraphDirections.actionGlobalHome()) @@ -125,9 +118,6 @@ class AboutHomeBindingTest { ), ) - // Wait for ContentAction.UpdateUrlAction - browserStore.waitUntilIdle() - assertEquals(ABOUT_HOME_URL, tab.content.url) verify(navController, never()).navigate(NavGraphDirections.actionGlobalHome()) @@ -150,9 +140,6 @@ class AboutHomeBindingTest { ), ) - // Wait for ContentAction.UpdateUrlAction - browserStore.waitUntilIdle() - assertEquals(newUrl, tab.content.url) verify(navController, never()).navigate(NavGraphDirections.actionGlobalHome()) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/OpenInFirefoxBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/OpenInFirefoxBindingTest.kt @@ -10,7 +10,6 @@ import junit.framework.TestCase.assertFalse import mozilla.components.feature.session.SessionFeature import mozilla.components.feature.tabs.CustomTabsUseCases import mozilla.components.support.base.feature.ViewBoundFeatureWrapper -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain @@ -64,9 +63,6 @@ class OpenInFirefoxBindingTest { appStore.dispatch(AppAction.OpenInFirefoxStarted) - // Wait for AppAction.OpenInFirefoxStarted - appStore.waitUntilIdle() - verify(getSessionFeature).release() verify(migrateCustomTabsUseCases).invoke("", select = true) verify(activity).startActivity(openInFenixIntent) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/ReaderViewBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/ReaderViewBindingTest.kt @@ -5,7 +5,6 @@ package org.mozilla.fenix import androidx.test.ext.junit.runners.AndroidJUnit4 -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain @@ -45,11 +44,6 @@ class ReaderViewBindingTest { appStore.dispatch(ReaderViewAction.ReaderViewStarted) - // Wait for ReaderViewAction.ReaderViewStarted - appStore.waitUntilIdle() - // Wait for ReaderViewAction.Reset - appStore.waitUntilIdle() - verify(readerModeController).showReaderView() assertEquals(ReaderViewState.None, appStore.state.readerViewState) @@ -69,11 +63,6 @@ class ReaderViewBindingTest { appStore.dispatch(ReaderViewAction.ReaderViewDismissed) - // Wait for ReaderViewAction.ReaderViewDismissed - appStore.waitUntilIdle() - // Wait for ReaderViewAction.Reset - appStore.waitUntilIdle() - verify(readerModeController).hideReaderView() assertEquals(ReaderViewState.None, appStore.state.readerViewState) @@ -93,11 +82,6 @@ class ReaderViewBindingTest { appStore.dispatch(ReaderViewAction.ReaderViewControlsShown) - // Wait for ReaderViewAction.ReaderViewControlsShown - appStore.waitUntilIdle() - // Wait for ReaderViewAction.Reset - appStore.waitUntilIdle() - verify(readerModeController).showControls() assertEquals(ReaderViewState.None, appStore.state.readerViewState) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/addons/ExtensionsProcessDisabledBackgroundControllerTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/addons/ExtensionsProcessDisabledBackgroundControllerTest.kt @@ -7,7 +7,6 @@ package org.mozilla.fenix.addons import mozilla.components.browser.state.action.ExtensionsProcessAction import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.store.BrowserStore -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -40,7 +39,6 @@ class ExtensionsProcessDisabledBackgroundControllerTest { browserStore.dispatch(ExtensionsProcessAction.ShowPromptAction(show = true)) dispatcher.scheduler.advanceUntilIdle() - browserStore.waitUntilIdle() assertTrue(invoked) } @@ -63,7 +61,6 @@ class ExtensionsProcessDisabledBackgroundControllerTest { browserStore.dispatch(ExtensionsProcessAction.ShowPromptAction(show = true)) dispatcher.scheduler.advanceUntilIdle() - browserStore.waitUntilIdle() assertFalse(invoked) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/addons/ExtensionsProcessDisabledForegroundControllerTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/addons/ExtensionsProcessDisabledForegroundControllerTest.kt @@ -11,7 +11,6 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import mozilla.components.browser.state.action.ExtensionsProcessAction import mozilla.components.browser.state.store.BrowserStore import mozilla.components.support.test.argumentCaptor -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.whenever @@ -60,7 +59,6 @@ class ExtensionsProcessDisabledForegroundControllerTest { browserStore.dispatch(ExtensionsProcessAction.DisabledAction) browserStore.dispatch(ExtensionsProcessAction.ShowPromptAction(show = true)) dispatcher.scheduler.advanceUntilIdle() - browserStore.waitUntilIdle() assertTrue(browserStore.state.showExtensionsProcessDisabledPrompt) assertTrue(browserStore.state.extensionsProcessDisabled) @@ -69,8 +67,6 @@ class ExtensionsProcessDisabledForegroundControllerTest { buttonsContainerCaptor.value.findViewById<Button>(R.id.positive).performClick() - browserStore.waitUntilIdle() - assertFalse(browserStore.state.showExtensionsProcessDisabledPrompt) assertFalse(browserStore.state.extensionsProcessDisabled) verify(dialog).dismiss() @@ -101,7 +97,6 @@ class ExtensionsProcessDisabledForegroundControllerTest { browserStore.dispatch(ExtensionsProcessAction.DisabledAction) browserStore.dispatch(ExtensionsProcessAction.ShowPromptAction(show = true)) dispatcher.scheduler.advanceUntilIdle() - browserStore.waitUntilIdle() assertTrue(browserStore.state.showExtensionsProcessDisabledPrompt) assertTrue(browserStore.state.extensionsProcessDisabled) @@ -110,8 +105,6 @@ class ExtensionsProcessDisabledForegroundControllerTest { buttonsContainerCaptor.value.findViewById<Button>(R.id.negative).performClick() - browserStore.waitUntilIdle() - assertFalse(browserStore.state.showExtensionsProcessDisabledPrompt) assertTrue(browserStore.state.extensionsProcessDisabled) verify(dialog).dismiss() @@ -138,18 +131,15 @@ class ExtensionsProcessDisabledForegroundControllerTest { // First dispatch... browserStore.dispatch(ExtensionsProcessAction.ShowPromptAction(show = true)) dispatcher.scheduler.advanceUntilIdle() - browserStore.waitUntilIdle() // Second dispatch... without having dismissed the dialog before! browserStore.dispatch(ExtensionsProcessAction.ShowPromptAction(show = true)) dispatcher.scheduler.advanceUntilIdle() - browserStore.waitUntilIdle() verify(builder).setView(buttonsContainerCaptor.capture()) verify(builder, times(1)).show() // Click a button to dismiss the dialog. buttonsContainerCaptor.value.findViewById<Button>(R.id.negative).performClick() - browserStore.waitUntilIdle() } } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/bindings/ExternalAppLinkStatusBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/bindings/ExternalAppLinkStatusBindingTest.kt @@ -8,7 +8,6 @@ import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.feature.app.links.AppLinksUseCases -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain import org.junit.Before @@ -64,7 +63,6 @@ class ExternalAppLinkStatusBindingTest { browserStore.dispatch( TabListAction.SelectTabAction(tabId = "nonExternal"), ) - browserStore.waitUntilIdle() verify { appStore.dispatch( AppAction.MenuNotification.AddMenuNotification( @@ -96,7 +94,6 @@ class ExternalAppLinkStatusBindingTest { browserStore.dispatch( TabListAction.SelectTabAction(tabId = "external"), ) - browserStore.waitUntilIdle() verify { appStore.dispatch( AppAction.MenuNotification.RemoveMenuNotification( diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/bindings/FindInPageBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/bindings/FindInPageBindingTest.kt @@ -4,7 +4,6 @@ package org.mozilla.fenix.bindings -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain import org.junit.Assert.assertFalse @@ -32,11 +31,6 @@ class FindInPageBindingTest { appStore.dispatch(FindInPageAction.FindInPageStarted) - // Wait for FindInPageAction.FindInPageStarted - appStore.waitUntilIdle() - // Wait for FindInPageAction.FindInPageShown - appStore.waitUntilIdle() - assertFalse(appStore.state.showFindInPage) assertTrue(onFindInPageLaunchCalled) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/bookmarks/BookmarksMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/bookmarks/BookmarksMiddlewareTest.kt @@ -21,7 +21,6 @@ import mozilla.components.concept.storage.BookmarksStorage import mozilla.components.feature.tabs.TabsUseCases import mozilla.components.support.test.any import mozilla.components.support.test.eq -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule @@ -133,7 +132,6 @@ class BookmarksMiddlewareTest { val store = middleware.makeStore() `when`(bookmarksStorage.countBookmarksInTrees(store.state.bookmarkItems.map { it.guid })).thenReturn(35u) store.dispatch(BookmarksListMenuAction.SelectAll) - store.waitUntilIdle() assertEquals(store.state.selectedItems.size, store.state.bookmarkItems.size) assertEquals(35, store.state.recursiveSelectedCount) } @@ -223,7 +221,6 @@ class BookmarksMiddlewareTest { val store = middleware.makeStore() store.dispatch(BookmarksListMenuAction.SortMenu.NewestClicked) - store.waitUntilIdle() assertEquals(BookmarksListSortOrder.Created(true), newSortOrder) } @@ -258,7 +255,6 @@ class BookmarksMiddlewareTest { assertEquals(true, store.state.sortMenuShown) store.dispatch(SelectFolderAction.SortMenu.NewestClicked) - store.waitUntilIdle() assertEquals(BookmarksListSortOrder.Created(true), newSortOrder) } @@ -404,9 +400,7 @@ class BookmarksMiddlewareTest { val store = BookmarksStore( initialState = BookmarksState.default, middleware = listOf(middleware, captorMiddleware), - ).also { - it.waitUntilIdle() - } + ) store.dispatch(SearchClicked) @@ -503,7 +497,6 @@ class BookmarksMiddlewareTest { store.dispatch(AddFolderClicked) store.dispatch(AddFolderAction.TitleChanged(newFolderTitle)) store.dispatch(BackClicked) - store.waitUntilIdle() assertNull(store.state.bookmarksSelectFolderState) verify(bookmarksStorage, times(1)).getTree(BookmarkRoot.Mobile.id, recursive = true) @@ -522,7 +515,6 @@ class BookmarksMiddlewareTest { store.dispatch(AddFolderClicked) store.dispatch(AddFolderAction.TitleChanged("i'm a new folder")) store.dispatch(BackClicked) - store.waitUntilIdle() verify(bookmarksStorage, times(2)).getTree(BookmarkRoot.Mobile.id, recursive = false) verify(navController, times(1)).popBackStack() @@ -858,10 +850,8 @@ class BookmarksMiddlewareTest { ) `when`(bookmarksStorage.countBookmarksInTrees(anyList())).thenReturn(0u) store.dispatch(BookmarksListMenuAction.SelectAll) - store.waitUntilIdle() val bookmarkCount = store.state.selectedItems.size store.dispatch(BookmarksListMenuAction.MultiSelect.OpenInNormalTabsClicked) - store.waitUntilIdle() assertEquals(bookmarkCount, store.state.bookmarksSelectFolderState?.folders?.count()) } @@ -1836,9 +1826,7 @@ class BookmarksMiddlewareTest { initialState = initialState, middleware = listOf(this), bookmarkToLoad = bookmarkToLoad, - ).also { - it.waitUntilIdle() - } + ) private fun generateBookmarkFolders(parentGuid: String) = List(5) { generateBookmarkFolder( diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/browser/StandardSnackbarErrorBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/browser/StandardSnackbarErrorBindingTest.kt @@ -10,7 +10,6 @@ import io.mockk.MockKAnnotations import io.mockk.every import io.mockk.mockk import io.mockk.verify -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Before import org.junit.Rule @@ -64,8 +63,6 @@ class StandardSnackbarErrorBindingTest { ), ), ) - appStore.waitUntilIdle() - verify { snackbar.show() } } @@ -87,8 +84,6 @@ class StandardSnackbarErrorBindingTest { ), ), ) - appStore.waitUntilIdle() - standardSnackbarError.stop() standardSnackbarError.start() diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/VoiceSearchFeatureTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/VoiceSearchFeatureTest.kt @@ -13,7 +13,6 @@ import io.mockk.every import io.mockk.mockk import io.mockk.spyk import io.mockk.verify -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain @@ -44,7 +43,6 @@ class VoiceSearchFeatureTest { every { voiceSearchLauncher.launch(any()) } throws ActivityNotFoundException() appStore.dispatch(VoiceInputRequested) - appStore.waitUntilIdle() verify { appStore.dispatch(VoiceSearchAction.VoiceInputResultReceived(null)) } } @@ -54,7 +52,6 @@ class VoiceSearchFeatureTest { every { voiceSearchLauncher.launch(any()) } throws SecurityException() appStore.dispatch(VoiceSearchAction.VoiceInputRequested) - appStore.waitUntilIdle() verify { appStore.dispatch(VoiceSearchAction.VoiceInputResultReceived(null)) } } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/menu/MenuDialogMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/menu/MenuDialogMiddlewareTest.kt @@ -24,7 +24,6 @@ import mozilla.components.feature.top.sites.TopSite import mozilla.components.feature.top.sites.TopSitesUseCases import mozilla.components.support.test.any import mozilla.components.support.test.eq -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext @@ -374,7 +373,6 @@ class MenuDialogMiddlewareTest { assertTrue(store.state.browserMenuState!!.bookmarkState.isBookmarked) store.dispatch(MenuAction.AddBookmark) - store.waitUntilIdle() verify(addBookmarkUseCase, never()).invoke(url = url, title = title) captureMiddleware.assertNotDispatched(BookmarkAction.BookmarkAdded::class) @@ -502,7 +500,6 @@ class MenuDialogMiddlewareTest { assertTrue(store.state.browserMenuState!!.isPinned) store.dispatch(MenuAction.AddShortcut) - store.waitUntilIdle() verify(addPinnedSiteUseCase, never()).invoke(url = url, title = title) verify(appStore, never()).dispatch( diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/crashes/CrashReporterBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/crashes/CrashReporterBindingTest.kt @@ -8,7 +8,6 @@ import android.content.Context import androidx.test.ext.junit.runners.AndroidJUnit4 import io.mockk.mockk import mozilla.components.lib.crash.store.CrashAction -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain import org.junit.Assert.assertEquals @@ -40,7 +39,6 @@ class CrashReporterBindingTest { binding.start() appStore.dispatch(AppAction.CrashActionWrapper(CrashAction.ShowPrompt())) - appStore.waitUntilIdle() assertTrue(onReportingCalled) } @@ -60,7 +58,6 @@ class CrashReporterBindingTest { binding.start() appStore.dispatch(AppAction.CrashActionWrapper(CrashAction.ShowPrompt(listOf("1", "2")))) - appStore.waitUntilIdle() assertTrue(onReportingCalled) } } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/dataChoicesStore/DataChoicesMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/dataChoicesStore/DataChoicesMiddlewareTest.kt @@ -10,7 +10,6 @@ import mozilla.components.concept.engine.Engine import mozilla.components.lib.crash.store.CrashReportOption import mozilla.components.service.nimbus.NimbusApi import mozilla.components.support.test.argumentCaptor -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertEquals @@ -75,7 +74,6 @@ class DataChoicesMiddlewareTest { store.dispatch(ViewCreated) - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() assertEquals(false, store.state.telemetryEnabled) @@ -93,7 +91,6 @@ class DataChoicesMiddlewareTest { val store = makeStore() store.dispatch(ChoiceAction.TelemetryClicked) - store.waitUntilIdle() verify(settings).isTelemetryEnabled = false assertEquals(false, store.state.telemetryEnabled) @@ -109,7 +106,6 @@ class DataChoicesMiddlewareTest { val store = makeStore() store.dispatch(ChoiceAction.MeasurementDataClicked) - store.waitUntilIdle() verify(settings).isMarketingTelemetryEnabled = true assertEquals(false, store.state.measurementDataEnabled) @@ -122,7 +118,6 @@ class DataChoicesMiddlewareTest { val store = makeStore() store.dispatch(ChoiceAction.UsagePingClicked) - store.waitUntilIdle() verify(settings).isDailyUsagePingEnabled = false assertEquals(false, store.state.usagePingEnabled) @@ -134,7 +129,6 @@ class DataChoicesMiddlewareTest { val store = makeStore() store.dispatch(ChoiceAction.ReportOptionClicked(CrashReportOption.Never)) - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() verify(crashReportCache).setReportOption(CrashReportOption.Never) @@ -149,7 +143,6 @@ class DataChoicesMiddlewareTest { val store = makeStore() store.dispatch(ChoiceAction.StudiesClicked) - store.waitUntilIdle() val directionsCaptor = argumentCaptor<NavDirections>() verify(nav).navigate(directionsCaptor.capture(), isNull<NavOptions>()) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/downloads/listscreen/store/DownloadUIStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/downloads/listscreen/store/DownloadUIStoreTest.kt @@ -13,7 +13,6 @@ import mozilla.components.browser.state.state.content.DownloadState import mozilla.components.browser.state.store.BrowserStore import mozilla.components.feature.downloads.DownloadsUseCases import mozilla.components.feature.downloads.fake.FakeDateTimeProvider -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule @@ -643,8 +642,6 @@ class DownloadUIStoreTest { ), ), ) - downloadsStore.waitUntilIdle() - val expectedList = DownloadUIState.ItemsState.Items( listOf( HeaderItem(TimeCategory.IN_PROGRESS), @@ -703,8 +700,6 @@ class DownloadUIStoreTest { ), ), ) - downloadsStore.waitUntilIdle() - val expectedList = DownloadUIState.ItemsState.Items( listOf( HeaderItem(TimeCategory.OLDER), @@ -763,8 +758,6 @@ class DownloadUIStoreTest { ), ), ) - downloadsStore.waitUntilIdle() - val expectedList = DownloadUIState.ItemsState.Items( listOf( HeaderItem(TimeCategory.IN_PROGRESS), diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/exceptions/trackingprotection/TrackingProtectionExceptionsInteractorTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/exceptions/trackingprotection/TrackingProtectionExceptionsInteractorTest.kt @@ -17,7 +17,6 @@ import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.content.blocking.TrackingProtectionException import mozilla.components.concept.engine.content.blocking.TrackingProtectionExceptionStorage import mozilla.components.feature.session.TrackingProtectionUseCases -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse @@ -117,8 +116,6 @@ class TrackingProtectionExceptionsInteractorTest { assertTrue(removedAll) assertTrue(fetchedAll) - exceptionsStore.waitUntilIdle() - capture.assertLastAction(ExceptionsFragmentAction.Change::class) { assertEquals(results, it.list) } @@ -130,9 +127,6 @@ class TrackingProtectionExceptionsInteractorTest { assertTrue(fetchedAll) - exceptionsStore.waitUntilIdle() - store.waitUntilIdle() - capture.assertLastAction(ExceptionsFragmentAction.Change::class) { assertEquals(results, it.list) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/bookmarks/BookmarksFeatureTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/bookmarks/BookmarksFeatureTest.kt @@ -10,7 +10,6 @@ import io.mockk.mockk import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.advanceUntilIdle import mozilla.components.concept.storage.BookmarkNode -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain @@ -60,7 +59,6 @@ class BookmarksFeatureTest { feature.start() advanceUntilIdle() - appStore.waitUntilIdle() coVerify { bookmarksUseCases.retrieveRecentBookmarks() diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/recentsyncedtabs/RecentSyncedTabFeatureTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/recentsyncedtabs/RecentSyncedTabFeatureTest.kt @@ -33,7 +33,6 @@ import mozilla.components.service.fxa.store.SyncAction import mozilla.components.service.fxa.store.SyncStatus import mozilla.components.service.fxa.store.SyncStore import mozilla.components.service.fxa.sync.SyncReason -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.telemetry.glean.testing.ErrorType @@ -572,7 +571,6 @@ class RecentSyncedTabFeatureTest { account?.let { this.dispatch(SyncAction.UpdateAccount(account)) } - this.waitUntilIdle() } private fun Tab.toVisitInfo(url: String, previewUrl: String?) = VisitInfo( diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/recentsyncedtabs/controller/DefaultRecentSyncedTabControllerTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/recentsyncedtabs/controller/DefaultRecentSyncedTabControllerTest.kt @@ -19,7 +19,6 @@ import mozilla.components.browser.state.state.TabSessionState import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.sync.DeviceType import mozilla.components.feature.tabs.TabsUseCases -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertEquals import org.junit.Assert.assertNotEquals @@ -96,7 +95,6 @@ class DefaultRecentSyncedTabControllerTest { controller.handleRecentSyncedTabClick(tab) - store.waitUntilIdle() assertNotEquals(nonSyncId, store.state.selectedTabId) assertEquals(2, store.state.tabs.size) verify { navController.navigate(R.id.browserFragment) } @@ -162,7 +160,6 @@ class DefaultRecentSyncedTabControllerTest { controller.handleRecentSyncedTabClick(tab) - store.waitUntilIdle() assertEquals(syncId, store.state.selectedTabId) assertEquals(2, store.state.tabs.size) verify { navController.navigate(R.id.browserFragment) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/recentvisits/RecentVisitsFeatureTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/recentvisits/RecentVisitsFeatureTest.kt @@ -19,7 +19,6 @@ import mozilla.components.concept.storage.HistoryHighlightWeights import mozilla.components.concept.storage.HistoryMetadata import mozilla.components.concept.storage.HistoryMetadataKey import mozilla.components.concept.storage.HistoryMetadataStorage -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain @@ -397,7 +396,6 @@ class RecentVisitsFeatureTest { every { feature.getCombinedHistory(any(), any()) } returns expected feature.updateState(emptyList(), emptyList()) - appStore.waitUntilIdle() middleware.assertLastAction(AppAction.RecentHistoryChange::class) { assertEquals(expected, it.recentHistory) @@ -662,7 +660,6 @@ class RecentVisitsFeatureTest { feature.start() scope.advanceUntilIdle() - appStore.waitUntilIdle() coVerify { historyMetadataStorage.getHistoryMetadataSince(any()) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/topsites/DefaultTopSitesBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/topsites/DefaultTopSitesBindingTest.kt @@ -16,7 +16,6 @@ import mozilla.components.browser.state.search.RegionState import mozilla.components.browser.state.store.BrowserStore import mozilla.components.feature.top.sites.DefaultTopSitesStorage import mozilla.components.lib.crash.CrashReporter -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain import org.junit.Assert.assertEquals @@ -66,7 +65,6 @@ class DefaultTopSitesBindingTest { browserStore.dispatch( SearchAction.SetRegionAction(RegionState.Default), ) - browserStore.waitUntilIdle() verify(exactly = 0) { topSitesStorage.addTopSites(topSites = any(), isDefault = any()) @@ -84,7 +82,6 @@ class DefaultTopSitesBindingTest { browserStore.dispatch( SearchAction.SetRegionAction(RegionState.Default), ) - browserStore.waitUntilIdle() val topSites = binding.getTopSites(region = "XX") @@ -105,7 +102,6 @@ class DefaultTopSitesBindingTest { browserStore.dispatch( SearchAction.SetRegionAction(RegionState(home = region, current = region)), ) - browserStore.waitUntilIdle() val topSites = binding.getTopSites(region = region) @@ -126,7 +122,6 @@ class DefaultTopSitesBindingTest { browserStore.dispatch( SearchAction.SetRegionAction(RegionState(home = region, current = region)), ) - browserStore.waitUntilIdle() verify(exactly = 0) { topSitesStorage.addTopSites(topSites = any(), isDefault = any()) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/nimbus/NimbusBranchesControllerTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/nimbus/NimbusBranchesControllerTest.kt @@ -9,7 +9,6 @@ import io.mockk.mockk import io.mockk.verify import io.mockk.verifyAll import mozilla.components.service.nimbus.NimbusApi -import mozilla.components.support.test.libstate.ext.waitUntilIdle import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test @@ -52,8 +51,6 @@ class NimbusBranchesControllerTest { controller.onBranchItemClicked(branch) - nimbusBranchesStore.waitUntilIdle() - verify { experiments.optInWithBranch(experimentId, branch.slug) } @@ -72,8 +69,6 @@ class NimbusBranchesControllerTest { controller.onBranchItemClicked(branch) - nimbusBranchesStore.waitUntilIdle() - verify { experiments.optOut(experimentId) } @@ -88,8 +83,6 @@ class NimbusBranchesControllerTest { controller.onBranchItemClicked(branch) - nimbusBranchesStore.waitUntilIdle() - verify { experiments.optInWithBranch(experimentId, branch.slug) } @@ -115,8 +108,6 @@ class NimbusBranchesControllerTest { controller.onBranchItemClicked(branch) - nimbusBranchesStore.waitUntilIdle() - verifyAll { experiments.getExperimentBranch(experimentId) experiments.optInWithBranch(experimentId, branch.slug) @@ -144,8 +135,6 @@ class NimbusBranchesControllerTest { controller.onBranchItemClicked(branch) - nimbusBranchesStore.waitUntilIdle() - verify { experiments.optInWithBranch(experimentId, branch.slug) } @@ -171,8 +160,6 @@ class NimbusBranchesControllerTest { controller.onBranchItemClicked(branch) - nimbusBranchesStore.waitUntilIdle() - verify { experiments.optInWithBranch(experimentId, branch.slug) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/reviewprompt/ShowPlayStoreReviewPromptTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/reviewprompt/ShowPlayStoreReviewPromptTest.kt @@ -9,7 +9,6 @@ import androidx.navigation.NavDirections import androidx.test.ext.junit.runners.AndroidJUnit4 import io.mockk.coVerify import io.mockk.mockk -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain @@ -62,7 +61,6 @@ class ShowPlayStoreReviewPromptTest { ) feature.start() - appStore.waitUntilIdle() coVerify(exactly = 0) { promptController.tryPromptReview(mockActivity) @@ -96,7 +94,6 @@ class ShowPlayStoreReviewPromptTest { ) feature.start() - appStore.waitUntilIdle() coVerify(exactly = 0) { promptController.tryPromptReview(mockActivity) @@ -124,7 +121,6 @@ class ShowPlayStoreReviewPromptTest { ) feature.start() - appStore.waitUntilIdle() coVerify(exactly = 0) { promptController.tryPromptReview(mockActivity) @@ -150,7 +146,6 @@ class ShowPlayStoreReviewPromptTest { ) feature.start() - appStore.waitUntilIdle() coVerify(exactly = 1) { promptController.tryPromptReview(mockActivity) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/SearchDialogControllerTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/SearchDialogControllerTest.kt @@ -23,7 +23,6 @@ import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession import mozilla.components.feature.tabs.TabsUseCases -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertEquals @@ -113,8 +112,6 @@ class SearchDialogControllerTest { createController().handleUrlCommitted(url) - browserStore.waitUntilIdle() - verifyOrder { navController.navigate(actionGlobalBrowser()) @@ -148,8 +145,6 @@ class SearchDialogControllerTest { createController().handleUrlCommitted(url) - browserStore.waitUntilIdle() - verifyOrder { navController.navigate(actionGlobalBrowser()) @@ -181,8 +176,6 @@ class SearchDialogControllerTest { createController().handleUrlCommitted(url) - browserStore.waitUntilIdle() - verifyOrder { navController.navigate(actionGlobalBrowser()) @@ -216,8 +209,6 @@ class SearchDialogControllerTest { }, ).handleUrlCommitted(url) - browserStore.waitUntilIdle() - assertTrue(dismissDialogInvoked) middleware.assertLastAction(AwesomeBarAction.EngagementFinished::class) { action -> @@ -231,8 +222,6 @@ class SearchDialogControllerTest { createController().handleUrlCommitted(searchTerm) - browserStore.waitUntilIdle() - verifyOrder { navController.navigate(actionGlobalBrowser()) @@ -259,8 +248,6 @@ class SearchDialogControllerTest { createController().handleUrlCommitted(searchTerm) - browserStore.waitUntilIdle() - verifyOrder { navController.navigate(actionGlobalBrowser()) @@ -291,8 +278,6 @@ class SearchDialogControllerTest { }, ).handleUrlCommitted(searchTerm) - browserStore.waitUntilIdle() - verify(exactly = 0) { activity.openToBrowserAndLoad( searchTermOrURL = any(), @@ -314,8 +299,6 @@ class SearchDialogControllerTest { createController().handleUrlCommitted(url) - browserStore.waitUntilIdle() - verify { navController.navigate(directions) } } @@ -326,8 +309,6 @@ class SearchDialogControllerTest { createController().handleUrlCommitted(url) - browserStore.waitUntilIdle() - verify { navController.navigate(directions) } middleware.assertLastAction(AwesomeBarAction.EngagementFinished::class) { action -> @@ -342,8 +323,6 @@ class SearchDialogControllerTest { createController().handleUrlCommitted(url) - browserStore.waitUntilIdle() - verify { navController.navigate(directions) } } @@ -356,8 +335,6 @@ class SearchDialogControllerTest { createController().handleUrlCommitted(url) - browserStore.waitUntilIdle() - verifyOrder { navController.navigate(actionGlobalBrowser()) @@ -407,8 +384,6 @@ class SearchDialogControllerTest { createController().handleTextChanged(text) - browserStore.waitUntilIdle() - verify { store.dispatch(SearchFragmentAction.UpdateQuery(text)) } val actionSlot = mutableListOf<SearchFragmentAction>() @@ -424,8 +399,6 @@ class SearchDialogControllerTest { createController().handleTextChanged(text) - browserStore.waitUntilIdle() - verify { store.dispatch(SearchFragmentAction.UpdateQuery(text)) } middleware.assertNotDispatched(AwesomeBarAction.EngagementFinished::class) @@ -440,8 +413,6 @@ class SearchDialogControllerTest { createController().handleUrlTapped(url, flags) createController().handleUrlTapped(url) - browserStore.waitUntilIdle() - verify { activity.openToBrowserAndLoad( searchTermOrURL = url, @@ -475,8 +446,6 @@ class SearchDialogControllerTest { createController().handleUrlTapped(url, flags) createController().handleUrlTapped(url) - browserStore.waitUntilIdle() - verify { activity.openToBrowserAndLoad( searchTermOrURL = url, @@ -506,8 +475,6 @@ class SearchDialogControllerTest { createController().handleSearchTermsTapped(searchTerms) - browserStore.waitUntilIdle() - verify { activity.openToBrowserAndLoad( searchTermOrURL = searchTerms, @@ -529,8 +496,6 @@ class SearchDialogControllerTest { createController().handleSearchTermsTapped(searchTerms) - browserStore.waitUntilIdle() - verify { activity.openToBrowserAndLoad( searchTermOrURL = searchTerms, @@ -559,8 +524,6 @@ class SearchDialogControllerTest { }, ).handleSearchShortcutEngineSelected(searchEngine) - browserStore.waitUntilIdle() - assertTrue(focusToolbarInvoked) verify { store.dispatch(SearchFragmentAction.SearchShortcutEngineSelected(searchEngine, browsingMode, settings)) } @@ -583,8 +546,6 @@ class SearchDialogControllerTest { }, ).handleSearchShortcutEngineSelected(searchEngine) - browserStore.waitUntilIdle() - assertTrue(focusToolbarInvoked) verify { store.dispatch(SearchFragmentAction.SearchHistoryEngineSelected(searchEngine)) } @@ -608,8 +569,6 @@ class SearchDialogControllerTest { }, ).handleSearchShortcutEngineSelected(searchEngine) - browserStore.waitUntilIdle() - assertTrue(focusToolbarInvoked) verify { store.dispatch(SearchFragmentAction.SearchBookmarksEngineSelected(searchEngine)) } @@ -633,8 +592,6 @@ class SearchDialogControllerTest { }, ).handleSearchShortcutEngineSelected(searchEngine) - browserStore.waitUntilIdle() - assertTrue(focusToolbarInvoked) verify { store.dispatch(SearchFragmentAction.SearchTabsEngineSelected(searchEngine)) } @@ -649,8 +606,6 @@ class SearchDialogControllerTest { createController().handleClickSearchEngineSettings() - browserStore.waitUntilIdle() - verify { navController.navigate(directions) } middleware.assertLastAction(AwesomeBarAction.EngagementFinished::class) { action -> @@ -662,8 +617,6 @@ class SearchDialogControllerTest { fun handleExistingSessionSelected() { createController().handleExistingSessionSelected("selected") - browserStore.waitUntilIdle() - middleware.assertFirstAction(TabListAction.SelectTabAction::class) { action -> assertEquals("selected", action.tabId) } @@ -679,8 +632,6 @@ class SearchDialogControllerTest { fun handleExistingSessionSelected_tabId() { createController().handleExistingSessionSelected("tab-id") - browserStore.waitUntilIdle() - middleware.assertFirstAction(TabListAction.SelectTabAction::class) { action -> assertEquals("tab-id", action.tabId) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/toolbar/SearchSelectorToolbarActionTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/toolbar/SearchSelectorToolbarActionTest.kt @@ -21,7 +21,6 @@ import io.mockk.verify import mozilla.components.browser.state.search.SearchEngine import mozilla.components.browser.state.search.SearchEngine.Type.BUNDLED import mozilla.components.concept.menu.Orientation -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertEquals @@ -116,7 +115,6 @@ class SearchSelectorToolbarActionTest { settings = mockk(relaxed = true), ), ) - store.waitUntilIdle() verify { view.setIcon( @@ -145,8 +143,6 @@ class SearchSelectorToolbarActionTest { settings = mockk(relaxed = true), ), ) - store.waitUntilIdle() - verify(exactly = 1) { view.setIcon( icon = any(), @@ -172,7 +168,6 @@ class SearchSelectorToolbarActionTest { settings = mockk(relaxed = true), ), ) - store.waitUntilIdle() verify(exactly = 1) { view.setIcon( icon = any(), @@ -191,7 +186,6 @@ class SearchSelectorToolbarActionTest { settings = mockk(relaxed = true), ), ) - store.waitUntilIdle() verify(exactly = 1) { view.setIcon( icon = any(), @@ -211,7 +205,6 @@ class SearchSelectorToolbarActionTest { engine = newSearchEngine, ), ) - store.waitUntilIdle() verify(exactly = 1) { view.setIcon( icon = any(), diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/doh/DohSettingsStoreIntegrationTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/doh/DohSettingsStoreIntegrationTest.kt @@ -6,7 +6,6 @@ package org.mozilla.fenix.settings.doh import androidx.navigation.NavController import androidx.test.ext.junit.runners.AndroidJUnit4 -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse @@ -394,7 +393,5 @@ class DohSettingsStoreIntegrationTest { ) = DohSettingsStore( initialState = initialState, middleware = listOf(this), - ).also { - it.waitUntilIdle() - } + ) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/logins/ui/LoginsMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/logins/ui/LoginsMiddlewareTest.kt @@ -9,7 +9,6 @@ import androidx.navigation.NavController import androidx.test.ext.junit.runners.AndroidJUnit4 import mozilla.components.concept.storage.Login import mozilla.components.concept.storage.LoginsStorage -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain @@ -60,7 +59,6 @@ class LoginsMiddlewareTest { `when`(loginsStorage.list()).thenReturn(listOf()) val middleware = buildMiddleware() val store = middleware.makeStore() - store.waitUntilIdle() assertEquals(0, store.state.loginItems.size) } @@ -73,7 +71,6 @@ class LoginsMiddlewareTest { val middleware = buildMiddleware() val store = middleware.makeStore() store.dispatch(AddLoginAction.InitAdd) - store.waitUntilIdle() verify(navController).navigate(LoginsDestinations.ADD_LOGIN) } @@ -95,7 +92,6 @@ class LoginsMiddlewareTest { ), ), ) - store.waitUntilIdle() verify(navController).navigate(LoginsDestinations.LOGIN_DETAILS) } @@ -117,7 +113,6 @@ class LoginsMiddlewareTest { ), ), ) - store.waitUntilIdle() verify(navController).navigate(LoginsDestinations.EDIT_LOGIN) } @@ -132,7 +127,6 @@ class LoginsMiddlewareTest { val store = middleware.makeStore() store.dispatch(LoginsListBackClicked) - store.waitUntilIdle() assertTrue(exited) } @@ -148,7 +142,6 @@ class LoginsMiddlewareTest { val middleware = buildMiddleware() val store = middleware.makeStore() store.dispatch(LoginsListSortMenuAction.OrderByLastUsedClicked) - store.waitUntilIdle() assertEquals(LoginsSortOrder.LastUsed, newSortOrder) } @@ -188,7 +181,5 @@ class LoginsMiddlewareTest { ) = LoginsStore( initialState = initialState, middleware = listOf(this), - ).also { - it.waitUntilIdle() - } + ) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/settingssearch/SettingsSearchMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/settingssearch/SettingsSearchMiddlewareTest.kt @@ -17,7 +17,6 @@ import io.mockk.spyk import io.mockk.verify import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.After @@ -73,9 +72,8 @@ class SettingsSearchMiddlewareTest { ), ), ) - store.waitUntilIdle() store.dispatch(SettingsSearchAction.SearchQueryUpdated(query)) - store.waitUntilIdle() + assert(store.state is SettingsSearchState.NoSearchResults) assert(store.state.searchQuery == query) assert(store.state.searchResults.isEmpty()) } @@ -97,7 +95,6 @@ class SettingsSearchMiddlewareTest { ), ) store.dispatch(SettingsSearchAction.SearchQueryUpdated(query)) - store.waitUntilIdle() assert(store.state is SettingsSearchState.SearchInProgress) assert(store.state.searchQuery == query) } @@ -121,7 +118,6 @@ class SettingsSearchMiddlewareTest { ) store.dispatch(SettingsSearchAction.ResultItemClicked(testItem)) - store.waitUntilIdle() coVerify { recentSearchesRepository.addRecentSearchItem(testItem) } verify { navController.navigate(testItem.preferenceFileInformation.fragmentId, any()) } @@ -144,7 +140,6 @@ class SettingsSearchMiddlewareTest { ) store.dispatch(SettingsSearchAction.RecentSearchesUpdated(updatedRecents)) - store.waitUntilIdle() assert(store.state.recentSearches == updatedRecents) } @@ -165,7 +160,6 @@ class SettingsSearchMiddlewareTest { ) store.dispatch(SettingsSearchAction.ClearRecentSearchesClicked) - store.waitUntilIdle() assert(store.state.recentSearches.isEmpty()) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/settingssearch/SettingsSearchStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/settingssearch/SettingsSearchStoreTest.kt @@ -5,7 +5,6 @@ package org.mozilla.fenix.settings.settingssearch import androidx.test.ext.junit.runners.AndroidJUnit4 -import mozilla.components.support.test.libstate.ext.waitUntilIdle import org.junit.Test import org.junit.runner.RunWith @@ -21,7 +20,6 @@ class SettingsSearchStoreTest { assert(store.state == initialState) store.dispatch(SettingsSearchAction.SearchQueryUpdated(query)) - store.waitUntilIdle() assert(store.state is SettingsSearchState.SearchInProgress) assert(store.state.searchQuery == query) @@ -39,7 +37,6 @@ class SettingsSearchStoreTest { assert(store.state is SettingsSearchState.SearchInProgress) store.dispatch(SettingsSearchAction.SearchQueryUpdated("")) - store.waitUntilIdle() assert(store.state == SettingsSearchState.Default(emptyList())) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/trustpanel/TrustPanelMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/trustpanel/TrustPanelMiddlewareTest.kt @@ -19,7 +19,6 @@ import mozilla.components.feature.sitepermissions.SitePermissionsRules import mozilla.components.lib.publicsuffixlist.PublicSuffixList import mozilla.components.support.ktx.kotlin.getOrigin import mozilla.components.support.test.any -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain @@ -36,7 +35,6 @@ import org.mockito.Mockito.spy import org.mockito.Mockito.verify import org.mozilla.fenix.components.AppStore import org.mozilla.fenix.components.PermissionStorage -import org.mozilla.fenix.components.appstate.AppAction import org.mozilla.fenix.settings.PhoneFeature import org.mozilla.fenix.settings.toggle import org.mozilla.fenix.settings.trustpanel.middleware.TrustPanelMiddleware @@ -96,7 +94,6 @@ class TrustPanelMiddlewareTest { ) store.dispatch(TrustPanelAction.ToggleTrackingProtection) - store.waitUntilIdle() verify(addExceptionUseCase).invoke(sessionId) verify(reloadUrlUseCase).invoke(sessionId) @@ -121,7 +118,6 @@ class TrustPanelMiddlewareTest { ) store.dispatch(TrustPanelAction.ToggleTrackingProtection) - store.waitUntilIdle() verify(removeExceptionUseCase).invoke(sessionId) verify(reloadUrlUseCase).invoke(sessionId) @@ -140,7 +136,6 @@ class TrustPanelMiddlewareTest { ) store.dispatch(TrustPanelAction.UpdateTrackersBlocked(trackerLogList)) - store.waitUntilIdle() verify(bucketedTrackers).updateIfNeeded(trackerLogList) assertEquals(store.state.numberOfTrackersBlocked, 1) @@ -165,8 +160,6 @@ class TrustPanelMiddlewareTest { ) store.dispatch(TrustPanelAction.RequestClearSiteDataDialog) - store.waitUntilIdle() - store.waitUntilIdle() // Wait to ensure no calls to store.dispatch(TrustPanelAction.UpdateBaseDomain(...)) verify(store, never()).dispatch(TrustPanelAction.UpdateBaseDomain(baseDomain)) } @@ -191,9 +184,6 @@ class TrustPanelMiddlewareTest { ) store.dispatch(TrustPanelAction.RequestClearSiteDataDialog) - store.waitUntilIdle() - store.waitUntilIdle() // Wait for call to store.dispatch(TrustPanelAction.UpdateBaseDomain(...)) - assertEquals(store.state.baseDomain, baseDomain) } @@ -212,7 +202,6 @@ class TrustPanelMiddlewareTest { ) store.dispatch(TrustPanelAction.TogglePermission(toggleablePermission)) - store.waitUntilIdle() verify(requestPermissionsLauncher).launch(PhoneFeature.CAMERA.androidPermissionsList) } @@ -232,7 +221,6 @@ class TrustPanelMiddlewareTest { ) store.dispatch(TrustPanelAction.TogglePermission(toggleablePermission)) - store.waitUntilIdle() // Ensure request permissions launcher is not accessed to request permission verify(requestPermissionsLauncher, never()).launch(any()) @@ -276,7 +264,6 @@ class TrustPanelMiddlewareTest { ) store.dispatch(TrustPanelAction.TogglePermission(toggleablePermission)) - store.waitUntilIdle() verify(permissionStorage).updateSitePermissions(updatedSitePermissions, false) verify(reloadUrlUseCase).invoke(sessionId) @@ -326,7 +313,6 @@ class TrustPanelMiddlewareTest { ) store.dispatch(TrustPanelAction.UpdateAutoplayValue(autoplayValue)) - store.waitUntilIdle() verify(permissionStorage).add(updatedSitePermissions, false) verify(reloadUrlUseCase).invoke(sessionId) @@ -370,7 +356,6 @@ class TrustPanelMiddlewareTest { ) store.dispatch(TrustPanelAction.UpdateAutoplayValue(autoplayValue)) - store.waitUntilIdle() verify(permissionStorage).updateSitePermissions(updatedSitePermissions, false) verify(reloadUrlUseCase).invoke(sessionId) @@ -399,7 +384,6 @@ class TrustPanelMiddlewareTest { ) store.dispatch(TrustPanelAction.UpdateAutoplayValue(autoplayValue)) - store.waitUntilIdle() verify(permissionStorage, never()).updateSitePermissions(updatedSitePermissions, false) verify(reloadUrlUseCase, never()).invoke(sessionId) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/share/SaveToPDFMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/share/SaveToPDFMiddlewareTest.kt @@ -16,7 +16,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.Engine import mozilla.components.concept.engine.EngineSession -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain @@ -87,7 +86,6 @@ class SaveToPDFMiddlewareTest { browserStore.dispatch( EngineAction.SaveToPdfExceptionAction("14", exceptionToThrow), ) - browserStore.waitUntilIdle() testScheduler.advanceUntilIdle() val response = Events.saveToPdfFailure.testGetValue()?.firstOrNull() assertNotNull(response) @@ -130,7 +128,6 @@ class SaveToPDFMiddlewareTest { ), ) browserStore.dispatch(EngineAction.SaveToPdfExceptionAction("14", exceptionToThrow)) - browserStore.waitUntilIdle() testScheduler.advanceUntilIdle() val response = Events.saveToPdfFailure.testGetValue()?.firstOrNull() assertNotNull(response) @@ -173,7 +170,6 @@ class SaveToPDFMiddlewareTest { ), ) browserStore.dispatch(EngineAction.SaveToPdfExceptionAction("14", exceptionToThrow)) - browserStore.waitUntilIdle() testScheduler.advanceUntilIdle() val response = Events.saveToPdfFailure.testGetValue()?.firstOrNull() assertNotNull(response) @@ -215,7 +211,6 @@ class SaveToPDFMiddlewareTest { ), ) browserStore.dispatch(EngineAction.SaveToPdfCompleteAction("14")) - browserStore.waitUntilIdle() testScheduler.advanceUntilIdle() val response = Events.saveToPdfCompleted.testGetValue() assertNotNull(response) @@ -250,7 +245,6 @@ class SaveToPDFMiddlewareTest { ), ) browserStore.dispatch(EngineAction.SaveToPdfAction("14")) - browserStore.waitUntilIdle() testScheduler.advanceUntilIdle() val response = Events.saveToPdfTapped.testGetValue() assertNotNull(response) @@ -300,7 +294,6 @@ class SaveToPDFMiddlewareTest { browserStore.dispatch( EngineAction.PrintContentExceptionAction("14", true, exceptionToThrow), ) - browserStore.waitUntilIdle() testScheduler.advanceUntilIdle() val response = Events.printFailure.testGetValue()?.firstOrNull() assertNotNull(response) @@ -342,7 +335,6 @@ class SaveToPDFMiddlewareTest { ), ) browserStore.dispatch(EngineAction.PrintContentExceptionAction("14", true, exceptionToThrow)) - browserStore.waitUntilIdle() testScheduler.advanceUntilIdle() val response = Events.printFailure.testGetValue()?.firstOrNull() assertNotNull(response) @@ -383,7 +375,6 @@ class SaveToPDFMiddlewareTest { ), ) browserStore.dispatch(EngineAction.PrintContentCompletedAction("14")) - browserStore.waitUntilIdle() testScheduler.advanceUntilIdle() val response = Events.printCompleted.testGetValue() assertNotNull(response) @@ -417,7 +408,6 @@ class SaveToPDFMiddlewareTest { ), ) browserStore.dispatch(EngineAction.PrintContentAction("14")) - browserStore.waitUntilIdle() testScheduler.advanceUntilIdle() val response = Events.printTapped.testGetValue() assertNotNull(response) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/snackbar/SnackbarBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/snackbar/SnackbarBindingTest.kt @@ -33,7 +33,6 @@ import mozilla.components.feature.tabs.TabsUseCases.UndoTabRemovalUseCase import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor import mozilla.components.support.test.eq -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule @@ -114,7 +113,6 @@ class SnackbarBindingTest { appStore.dispatch( TranslationsAction.TranslationStarted(sessionId = sessionId), ) - waitForStoreToSettle() verify(snackbarDelegate).show( text = R.string.translation_in_progress_snackbar, @@ -143,7 +141,6 @@ class SnackbarBindingTest { appStore.dispatch( TranslationsAction.TranslationStarted(sessionId = tab2.id), ) - waitForStoreToSettle() verify(snackbarDelegate, never()).show( text = R.string.translation_in_progress_snackbar, @@ -158,7 +155,6 @@ class SnackbarBindingTest { binding.start() appStore.dispatch(SnackbarAction.SnackbarDismissed) - waitForStoreToSettle() assertEquals(None(Dismiss(None())), appStore.state.snackbarState) verify(snackbarDelegate).dismiss() @@ -177,7 +173,6 @@ class SnackbarBindingTest { source = Source.TEST, ), ) - waitForStoreToSettle() assertEquals(None(BookmarkAdded("1", parent)), appStore.state.snackbarState) @@ -208,11 +203,6 @@ class SnackbarBindingTest { ), ) - // Wait for BookmarkAction.BookmarkAdded(guidToEdit = "1"), - appStore.waitUntilIdle() - // Wait for SnackbarAction.SnackbarShown - appStore.waitUntilIdle() - assertEquals(None(BookmarkAdded("1", parent)), appStore.state.snackbarState) val outputMessage = testContext.getString(R.string.bookmark_saved_in_folder_snackbar, "mobile") @@ -238,11 +228,6 @@ class SnackbarBindingTest { BookmarkAction.BookmarkAdded(guidToEdit = null, parentNode = parent, source = Source.TEST), ) - // Wait for BookmarkAction.BookmarkAdded(guidToEdit = null), - appStore.waitUntilIdle() - // Wait for SnackbarAction.SnackbarShown - appStore.waitUntilIdle() - assertEquals(None(BookmarkAdded(null, parent)), appStore.state.snackbarState) verify(snackbarDelegate).show( text = R.string.bookmark_invalid_url_error, @@ -258,7 +243,6 @@ class SnackbarBindingTest { appStore.dispatch( BookmarkAction.BookmarkAdded(guidToEdit = "guid", parentNode = null, source = Source.TEST), ) - waitForStoreToSettle() assertEquals(None(BookmarkAdded("guid", null)), appStore.state.snackbarState) verify(snackbarDelegate).show( @@ -276,7 +260,6 @@ class SnackbarBindingTest { appStore.dispatch( AppAction.ShortcutAction.ShortcutAdded, ) - waitForStoreToSettle() assertEquals(None(ShortcutAdded), appStore.state.snackbarState) verify(snackbarDelegate).show( @@ -294,7 +277,6 @@ class SnackbarBindingTest { appStore.dispatch( AppAction.DeleteAndQuitStarted, ) - waitForStoreToSettle() assertEquals(None(DeletingBrowserDataInProgress), appStore.state.snackbarState) verify(snackbarDelegate).show( @@ -312,7 +294,6 @@ class SnackbarBindingTest { appStore.dispatch( AppAction.UserAccountAuthenticated, ) - waitForStoreToSettle() assertEquals(None(UserAccountAuthenticated), appStore.state.snackbarState) verify(snackbarDelegate).show( @@ -329,7 +310,6 @@ class SnackbarBindingTest { binding.start() appStore.dispatch(ShareAction.ShareToAppFailed) - waitForStoreToSettle() verify(snackbarDelegate).show( text = R.string.share_error_snackbar, @@ -348,7 +328,6 @@ class SnackbarBindingTest { binding.start() appStore.dispatch(ShareAction.SharedTabsSuccessfully(destinations, sharedTabs)) - waitForStoreToSettle() verify(snackbarDelegate).show( text = R.string.sync_sent_tab_snackbar_2, @@ -367,7 +346,6 @@ class SnackbarBindingTest { binding.start() appStore.dispatch(ShareAction.SharedTabsSuccessfully(destinations, sharedTabs)) - waitForStoreToSettle() verify(snackbarDelegate).show( text = R.string.sync_sent_tabs_snackbar_2, @@ -386,7 +364,6 @@ class SnackbarBindingTest { binding.start() appStore.dispatch(ShareAction.ShareTabsFailed(destinations, sharedTabs)) - waitForStoreToSettle() verify(snackbarDelegate).show( text = eq(R.string.sync_sent_tab_error_snackbar), @@ -417,7 +394,6 @@ class SnackbarBindingTest { binding.start() appStore.dispatch(ShareAction.ShareTabsFailed(destinations, sharedTabs)) - waitForStoreToSettle() verify(snackbarDelegate).show( text = eq(R.string.sync_sent_tab_error_snackbar), @@ -429,7 +405,6 @@ class SnackbarBindingTest { ) retryActionCaptor.value.invoke(mock()) - waitForStoreToSettle() verify(snackbarDelegate).show( text = R.string.sync_sent_tab_snackbar_2, @@ -457,7 +432,6 @@ class SnackbarBindingTest { binding.start() appStore.dispatch(ShareAction.ShareTabsFailed(destinations, sharedTabs)) - waitForStoreToSettle() verify(snackbarDelegate).show( text = eq(R.string.sync_sent_tab_error_snackbar), @@ -469,7 +443,6 @@ class SnackbarBindingTest { ) retryActionCaptor.value.invoke(mock()) - waitForStoreToSettle() verify(snackbarDelegate, times(2)).show( text = eq(R.string.sync_sent_tab_error_snackbar), @@ -489,7 +462,6 @@ class SnackbarBindingTest { binding.start() appStore.dispatch(ShareAction.CopyLinkToClipboard) - waitForStoreToSettle() verify(snackbarDelegate).show( text = R.string.toast_copy_link_to_clipboard, @@ -508,7 +480,6 @@ class SnackbarBindingTest { binding.start() appStore.dispatch(AppAction.CurrentTabClosed(isPrivate = false)) - waitForStoreToSettle() verify(snackbarDelegate).show( text = eq(testContext.tabClosedUndoMessage(false)), @@ -533,7 +504,6 @@ class SnackbarBindingTest { binding.start() appStore.dispatch(AppAction.DownloadAction.DownloadFailed(fileName = "fileName")) - waitForStoreToSettle() verify(snackbarDelegate).show( text = eq(testContext.getString(R.string.download_item_status_failed)), @@ -575,7 +545,6 @@ class SnackbarBindingTest { ) appStore.dispatch(AppAction.DownloadAction.DownloadCompleted(downloadState)) - waitForStoreToSettle() verify(snackbarDelegate).show( text = eq(testContext.getString(R.string.download_completed_snackbar)), @@ -609,7 +578,6 @@ class SnackbarBindingTest { ) appStore.dispatch(AppAction.DownloadAction.CannotOpenFile(downloadState)) - waitForStoreToSettle() verify(snackbarDelegate).show( text = "No app found to open files", @@ -634,7 +602,6 @@ class SnackbarBindingTest { binding.start() appStore.dispatch(AppAction.DownloadAction.DownloadInProgress(downloadId = "id")) - waitForStoreToSettle() verify(snackbarDelegate).show( text = eq(testContext.getString(R.string.download_in_progress_snackbar)), @@ -662,7 +629,6 @@ class SnackbarBindingTest { binding.start() appStore.dispatch(WebCompatAction.WebCompatReportSent) - waitForStoreToSettle() verify(snackbarDelegate).show( text = eq(testContext.getString(R.string.webcompat_reporter_success_snackbar_text_2)), @@ -704,13 +670,6 @@ class SnackbarBindingTest { ioDispatcher = ioDispatcher, ) - private fun waitForStoreToSettle() { - // Wait for the trigger action to be handled, - appStore.waitUntilIdle() - // Wait for SnackbarAction.SnackbarShown to be dispatched - appStore.waitUntilIdle() - } - private fun buildParentBookmarkNode( guid: String = "guid", title: String = "title", diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/SecureTabsTrayBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/SecureTabsTrayBindingTest.kt @@ -12,7 +12,6 @@ import io.mockk.every import io.mockk.just import io.mockk.mockk import io.mockk.verify -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Before import org.junit.Rule @@ -52,7 +51,6 @@ class SecureTabsTrayBindingTest { secureTabsTrayBinding.start() tabsTrayStore.dispatch(TabsTrayAction.PageSelected(Page.PrivateTabs)) - tabsTrayStore.waitUntilIdle() verify { fragment.secure() } verify { window.addFlags(WindowManager.LayoutParams.FLAG_SECURE) } @@ -71,7 +69,6 @@ class SecureTabsTrayBindingTest { secureTabsTrayBinding.start() tabsTrayStore.dispatch(TabsTrayAction.PageSelected(Page.PrivateTabs)) - tabsTrayStore.waitUntilIdle() verify { fragment.removeSecure() } verify { window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) } @@ -91,7 +88,6 @@ class SecureTabsTrayBindingTest { secureTabsTrayBinding.start() tabsTrayStore.dispatch(TabsTrayAction.PageSelected(Page.PrivateTabs)) - tabsTrayStore.waitUntilIdle() verify { fragment.removeSecure() } verify { window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) } @@ -110,7 +106,6 @@ class SecureTabsTrayBindingTest { secureTabsTrayBinding.start() tabsTrayStore.dispatch(TabsTrayAction.PageSelected(Page.NormalTabs)) - tabsTrayStore.waitUntilIdle() verify { fragment.removeSecure() } verify { window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) } @@ -129,7 +124,6 @@ class SecureTabsTrayBindingTest { secureTabsTrayBinding.start() tabsTrayStore.dispatch(TabsTrayAction.PageSelected(Page.NormalTabs)) - tabsTrayStore.waitUntilIdle() verify(exactly = 0) { fragment.removeSecure() } verify(exactly = 0) { window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/TabsTrayStateTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/TabsTrayStateTest.kt @@ -7,7 +7,6 @@ package org.mozilla.fenix.tabstray import androidx.test.ext.junit.runners.AndroidJUnit4 import mozilla.components.compose.base.menu.MenuItem import mozilla.components.compose.base.text.Text -import mozilla.components.support.test.libstate.ext.waitUntilIdle import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -32,7 +31,6 @@ class TabsTrayStateTest { @Test fun `WHEN entering select mode THEN isSelected extension method returns true`() { store.dispatch(TabsTrayAction.EnterSelectMode) - store.waitUntilIdle() assertTrue(store.state.mode.isSelect()) } @@ -40,7 +38,6 @@ class TabsTrayStateTest { @Test fun `WHEN entering normal mode THEN isSelected extension method returns false`() { store.dispatch(TabsTrayAction.ExitSelectMode) - store.waitUntilIdle() assertFalse(store.state.mode.isSelect()) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/TabsTrayTelemetryMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/TabsTrayTelemetryMiddlewareTest.kt @@ -5,7 +5,6 @@ package org.mozilla.fenix.tabstray import io.mockk.mockk -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull @@ -45,7 +44,6 @@ class TabsTrayTelemetryMiddlewareTest { assertNull(Metrics.inactiveTabsCount.testGetValue()) store.dispatch(TabsTrayAction.UpdateInactiveTabs(emptyList())) - store.waitUntilIdle() assertNotNull(TabsTray.hasInactiveTabs.testGetValue()) assertNotNull(Metrics.inactiveTabsCount.testGetValue()) assertEquals(0L, Metrics.inactiveTabsCount.testGetValue()) @@ -56,7 +54,6 @@ class TabsTrayTelemetryMiddlewareTest { assertNull(TabsTray.enterMultiselectMode.testGetValue()) store.dispatch(TabsTrayAction.EnterSelectMode) - store.waitUntilIdle() assertNotNull(TabsTray.enterMultiselectMode.testGetValue()) val snapshot = TabsTray.enterMultiselectMode.testGetValue()!! @@ -67,7 +64,6 @@ class TabsTrayTelemetryMiddlewareTest { @Test fun `WHEN multi select mode by long press is entered THEN relevant metrics are collected`() { store.dispatch(TabsTrayAction.AddSelectTab(mockk())) - store.waitUntilIdle() assertNotNull(TabsTray.enterMultiselectMode.testGetValue()) val snapshot = TabsTray.enterMultiselectMode.testGetValue()!! @@ -80,7 +76,6 @@ class TabsTrayTelemetryMiddlewareTest { assertNull(TabsTray.autoCloseSeen.testGetValue()) store.dispatch(TabsTrayAction.TabAutoCloseDialogShown) - store.waitUntilIdle() assertNotNull(TabsTray.autoCloseSeen.testGetValue()) } @@ -90,7 +85,6 @@ class TabsTrayTelemetryMiddlewareTest { assertNull(TabsTray.shareAllTabs.testGetValue()) store.dispatch(TabsTrayAction.ShareAllNormalTabs) - store.waitUntilIdle() assertNotNull(TabsTray.shareAllTabs.testGetValue()) } @@ -100,7 +94,6 @@ class TabsTrayTelemetryMiddlewareTest { assertNull(TabsTray.shareAllTabs.testGetValue()) store.dispatch(TabsTrayAction.ShareAllPrivateTabs) - store.waitUntilIdle() assertNotNull(TabsTray.shareAllTabs.testGetValue()) } @@ -110,7 +103,6 @@ class TabsTrayTelemetryMiddlewareTest { assertNull(TabsTray.closeAllTabs.testGetValue()) store.dispatch(TabsTrayAction.CloseAllNormalTabs) - store.waitUntilIdle() assertNotNull(TabsTray.closeAllTabs.testGetValue()) } @@ -120,7 +112,6 @@ class TabsTrayTelemetryMiddlewareTest { assertNull(TabsTray.closeAllTabs.testGetValue()) store.dispatch(TabsTrayAction.CloseAllPrivateTabs) - store.waitUntilIdle() assertNotNull(TabsTray.closeAllTabs.testGetValue()) } @@ -130,7 +121,6 @@ class TabsTrayTelemetryMiddlewareTest { assertNull(TabsTray.bookmarkSelectedTabs.testGetValue()) store.dispatch(TabsTrayAction.BookmarkSelectedTabs(1)) - store.waitUntilIdle() assertNotNull(TabsTray.bookmarkSelectedTabs.testGetValue()) val snapshot = TabsTray.bookmarkSelectedTabs.testGetValue()!! @@ -146,7 +136,6 @@ class TabsTrayTelemetryMiddlewareTest { assertNull(TabsTray.bookmarkSelectedTabs.testGetValue()) store.dispatch(TabsTrayAction.BookmarkSelectedTabs(2)) - store.waitUntilIdle() assertNotNull(TabsTray.bookmarkSelectedTabs.testGetValue()) val snapshot = TabsTray.bookmarkSelectedTabs.testGetValue()!! @@ -162,7 +151,6 @@ class TabsTrayTelemetryMiddlewareTest { assertNull(TabsTray.menuOpened.testGetValue()) store.dispatch(TabsTrayAction.ThreeDotMenuShown) - store.waitUntilIdle() assertNotNull(TabsTray.menuOpened.testGetValue()) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/binding/SecureTabManagerBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/binding/SecureTabManagerBindingTest.kt @@ -10,7 +10,6 @@ import io.mockk.every import io.mockk.just import io.mockk.mockk import io.mockk.verify -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Before import org.junit.Rule @@ -48,7 +47,6 @@ class SecureTabManagerBindingTest { secureTabManagerBinding.start() tabsTrayStore.dispatch(TabsTrayAction.PageSelected(Page.PrivateTabs)) - tabsTrayStore.waitUntilIdle() verify { fragment.secure() } } @@ -65,7 +63,6 @@ class SecureTabManagerBindingTest { secureTabManagerBinding.start() tabsTrayStore.dispatch(TabsTrayAction.PageSelected(Page.PrivateTabs)) - tabsTrayStore.waitUntilIdle() verify { fragment.removeSecure() } } @@ -83,7 +80,6 @@ class SecureTabManagerBindingTest { secureTabManagerBinding.start() tabsTrayStore.dispatch(TabsTrayAction.PageSelected(Page.PrivateTabs)) - tabsTrayStore.waitUntilIdle() verify { fragment.removeSecure() } } @@ -100,7 +96,6 @@ class SecureTabManagerBindingTest { secureTabManagerBinding.start() tabsTrayStore.dispatch(TabsTrayAction.PageSelected(Page.NormalTabs)) - tabsTrayStore.waitUntilIdle() verify { fragment.removeSecure() } } @@ -117,7 +112,6 @@ class SecureTabManagerBindingTest { secureTabManagerBinding.start() tabsTrayStore.dispatch(TabsTrayAction.PageSelected(Page.NormalTabs)) - tabsTrayStore.waitUntilIdle() verify(exactly = 0) { fragment.removeSecure() } } @@ -134,7 +128,6 @@ class SecureTabManagerBindingTest { secureTabManagerBinding.start() tabsTrayStore.dispatch(TabsTrayAction.PageSelected(Page.NormalTabs)) - tabsTrayStore.waitUntilIdle() secureTabManagerBinding.stop() verify { fragment.removeSecure() } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/browser/TabSorterTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/browser/TabSorterTest.kt @@ -7,7 +7,6 @@ package org.mozilla.fenix.tabstray.browser import io.mockk.every import io.mockk.mockk import mozilla.components.browser.state.state.createTab -import mozilla.components.support.test.libstate.ext.waitUntilIdle import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test @@ -36,8 +35,6 @@ class TabSorterTest { selectedTabId = "tab1", ) - tabsTrayStore.waitUntilIdle() - assertEquals(tabsTrayStore.state.inactiveTabs.size, 0) assertEquals(tabsTrayStore.state.normalTabs.size, 1) } @@ -55,8 +52,6 @@ class TabSorterTest { selectedTabId = "tab1", ) - tabsTrayStore.waitUntilIdle() - assertEquals(tabsTrayStore.state.inactiveTabs.size, 1) assertEquals(tabsTrayStore.state.normalTabs.size, 1) } @@ -80,8 +75,6 @@ class TabSorterTest { selectedTabId = "tab1", ) - tabsTrayStore.waitUntilIdle() - assertEquals(tabsTrayStore.state.inactiveTabs.size, 0) assertEquals(tabsTrayStore.state.normalTabs.size, 2) } @@ -116,8 +109,6 @@ class TabSorterTest { selectedTabId = "tab1", ) - tabsTrayStore.waitUntilIdle() - assertEquals(tabsTrayStore.state.inactiveTabs.size, 0) assertEquals(tabsTrayStore.state.normalTabs.size, 4) } @@ -145,8 +136,6 @@ class TabSorterTest { selectedTabId = "tab4", ) - tabsTrayStore.waitUntilIdle() - assertEquals(expected, tabsTrayStore.state.selectedTabId) } } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/syncedtabs/SyncButtonBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/syncedtabs/SyncButtonBindingTest.kt @@ -4,7 +4,6 @@ package org.mozilla.fenix.tabstray.syncedtabs -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -26,7 +25,6 @@ class SyncButtonBindingTest { binding.start() store.dispatch(TabsTrayAction.SyncNow) - store.waitUntilIdle() assertTrue(invoked) } @@ -39,12 +37,9 @@ class SyncButtonBindingTest { binding.start() - store.waitUntilIdle() - assertFalse(invoked) store.dispatch(TabsTrayAction.SyncCompleted) - store.waitUntilIdle() assertFalse(invoked) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/wallpapers/WallpapersUseCasesTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/wallpapers/WallpapersUseCasesTest.kt @@ -16,7 +16,6 @@ import io.mockk.slot import io.mockk.spyk import io.mockk.verify import kotlinx.coroutines.test.runTest -import mozilla.components.support.test.libstate.ext.waitUntilIdle import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -92,7 +91,6 @@ class WallpapersUseCasesTest { WallpapersUseCases.DefaultFetchCurrentWallpaperUseCase(mockSettings, appStore).invoke() - appStore.waitUntilIdle() assertEquals(chosenWallpaper, appStore.state.wallpaperState.currentWallpaper) } @@ -116,7 +114,6 @@ class WallpapersUseCasesTest { "en-US", ).invoke() - appStore.waitUntilIdle() coVerify(exactly = 0) { mockDownloader.downloadWallpaper(Wallpaper.Default) } } @@ -140,7 +137,6 @@ class WallpapersUseCasesTest { "en-US", ).invoke() - appStore.waitUntilIdle() assertTrue(appStore.state.wallpaperState.availableWallpapers.contains(Wallpaper.Default)) } @@ -169,7 +165,6 @@ class WallpapersUseCasesTest { ).invoke() val expectedFilteredWallpaper = fakeExpiredRemoteWallpapers[0] - appStore.waitUntilIdle() assertFalse(appStore.state.wallpaperState.availableWallpapers.contains(expectedFilteredWallpaper)) coVerify { mockFileManager.clean(Wallpaper.Default, fakeRemoteWallpapers) } } @@ -199,7 +194,6 @@ class WallpapersUseCasesTest { val expectedWallpaper = expiredWallpaper.copy( thumbnailFileState = Wallpaper.ImageFileState.Downloaded, ) - appStore.waitUntilIdle() assertTrue(appStore.state.wallpaperState.availableWallpapers.contains(expectedWallpaper)) assertEquals(expiredWallpaper, appStore.state.wallpaperState.currentWallpaper) } @@ -228,8 +222,6 @@ class WallpapersUseCasesTest { "en-US", ).invoke() - appStore.waitUntilIdle() - verify { mockMigrationHelper.migrateExpiredWallpaperCardColors() } verify { mockSettings.currentWallpaperCardColorLight = TURNING_RED_PANDA_WALLPAPER_CARD_COLOR_LIGHT.toHexColor() } verify { mockSettings.currentWallpaperCardColorDark = TURNING_RED_PANDA_WALLPAPER_CARD_COLOR_DARK.toHexColor() } @@ -255,7 +247,6 @@ class WallpapersUseCasesTest { locale, ).invoke() - appStore.waitUntilIdle() assertEquals(1, appStore.state.wallpaperState.availableWallpapers.size) assertEquals(Wallpaper.Default, appStore.state.wallpaperState.availableWallpapers[0]) } @@ -308,7 +299,6 @@ class WallpapersUseCasesTest { for (fakeRemoteWallpaper in fakeRemoteWallpapers) { coVerify { mockDownloader.downloadThumbnail(fakeRemoteWallpaper) } } - appStore.waitUntilIdle() assertTrue( appStore.state.wallpaperState.availableWallpapers.all { it.thumbnailFileState == Wallpaper.ImageFileState.Downloaded @@ -339,7 +329,6 @@ class WallpapersUseCasesTest { ).invoke() val expectedWallpaper = failedWallpaper.copy(thumbnailFileState = Wallpaper.ImageFileState.Error) - appStore.waitUntilIdle() assertTrue(appStore.state.wallpaperState.availableWallpapers.contains(expectedWallpaper)) } @@ -363,7 +352,6 @@ class WallpapersUseCasesTest { "en-US", ).invoke() - appStore.waitUntilIdle() assertTrue(appStore.state.wallpaperState.currentWallpaper == Wallpaper.Default) } @@ -392,7 +380,6 @@ class WallpapersUseCasesTest { val expectedWallpapers = (listOf(Wallpaper.Default) + possibleWallpapers).map { it.copy(thumbnailFileState = Wallpaper.ImageFileState.Downloaded) } - appStore.waitUntilIdle() assertEquals(selectedWallpaper, appStore.state.wallpaperState.currentWallpaper) assertEquals(expectedWallpapers, appStore.state.wallpaperState.availableWallpapers) } @@ -413,7 +400,6 @@ class WallpapersUseCasesTest { mockDownloader, ).invoke(selectedWallpaper) - appStore.waitUntilIdle() assertEquals(selectedWallpaper.name, slot.captured) assertEquals(selectedWallpaper, appStore.state.wallpaperState.currentWallpaper) assertEquals(wallpaperFileState, Wallpaper.ImageFileState.Downloaded) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/webcompat/middleware/WebCompatReporterStorageMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/webcompat/middleware/WebCompatReporterStorageMiddlewareTest.kt @@ -5,7 +5,6 @@ package org.mozilla.fenix.webcompat.middleware import androidx.test.ext.junit.runners.AndroidJUnit4 -import mozilla.components.support.test.libstate.ext.waitUntilIdle import org.junit.Assert.assertEquals import org.junit.Assert.assertNotEquals import org.junit.Assert.assertNull @@ -82,7 +81,6 @@ class WebCompatReporterStorageMiddlewareTest { ) webCompatReporterStore.dispatch(WebCompatReporterAction.BackPressed) - appStore.waitUntilIdle() assertEquals(expectedUrl, appStore.state.webCompatState!!.tabUrl) assertTrue(appStore.state.webCompatState!!.tabUrl.isNotEmpty()) @@ -102,7 +100,6 @@ class WebCompatReporterStorageMiddlewareTest { ) webCompatReporterStore.dispatch(WebCompatReporterAction.BackPressed) - appStore.waitUntilIdle() assertEquals(savedState.toPersistedState(), appStore.state.webCompatState) } @@ -121,7 +118,6 @@ class WebCompatReporterStorageMiddlewareTest { ) webCompatReporterStore.dispatch(WebCompatReporterAction.BackPressed) - appStore.waitUntilIdle() assertEquals(savedState.toPersistedState(), appStore.state.webCompatState) } @@ -140,7 +136,6 @@ class WebCompatReporterStorageMiddlewareTest { ) webCompatReporterStore.dispatch(WebCompatReporterAction.LearnMoreClicked) - appStore.waitUntilIdle() assertEquals(savedState.toPersistedState(), appStore.state.webCompatState) } @@ -159,7 +154,6 @@ class WebCompatReporterStorageMiddlewareTest { ) webCompatReporterStore.dispatch(WebCompatReporterAction.CancelClicked) - appStore.waitUntilIdle() assertNull(appStore.state.webCompatState) } diff --git a/mobile/android/focus-android/app/src/test/java/org/mozilla/focus/searchwidget/ExternalIntentNavigationTest.kt b/mobile/android/focus-android/app/src/test/java/org/mozilla/focus/searchwidget/ExternalIntentNavigationTest.kt @@ -12,7 +12,6 @@ import mozilla.components.browser.state.selector.findCustomTabOrSelectedTab import mozilla.components.browser.state.selector.privateTabs import mozilla.components.browser.state.state.SessionState import mozilla.components.feature.search.widget.BaseVoiceSearchActivity -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.robolectric.testContext import mozilla.telemetry.glean.testing.GleanTestRule import org.junit.Assert.assertNotNull @@ -52,7 +51,6 @@ internal class ExternalIntentNavigationTest { activity.settings.isFirstRun = true ExternalIntentNavigation.handleAppOpened(null, activity) - appStore.waitUntilIdle() assertEquals(Screen.FirstRun, appStore.state.screen) } @@ -62,11 +60,9 @@ internal class ExternalIntentNavigationTest { fun `GIVEN the onboarding should be shown and the app is used in a performance test WHEN the app is opened THEN show the homescreen`() { // The AppStore is initialized before the test runs. By default isFirstRun is true. Simulate it being false. appStore.dispatch(AppAction.ShowHomeScreen) - appStore.waitUntilIdle() activity.settings.isFirstRun = true ExternalIntentNavigation.handleAppOpened(null, activity) - appStore.waitUntilIdle() assertEquals(Screen.Home, appStore.state.screen) } @@ -76,11 +72,9 @@ internal class ExternalIntentNavigationTest { fun `GIVEN the onboarding should not be shown and in a performance test WHEN the app is opened THEN show the home screen`() { // The AppStore is initialized before the test runs. By default isFirstRun is true. Simulate it being false. appStore.dispatch(AppAction.ShowHomeScreen) - appStore.waitUntilIdle() activity.settings.isFirstRun = false ExternalIntentNavigation.handleAppOpened(null, activity) - appStore.waitUntilIdle() assertEquals(Screen.Home, appStore.state.screen) } @@ -89,11 +83,9 @@ internal class ExternalIntentNavigationTest { fun `GIVEN the onboarding should not be shown and not in a performance test WHEN the app is opened THEN show the home screen`() { // The AppStore is initialized before the test runs. By default isFirstRun is true. Simulate it being false. appStore.dispatch(AppAction.ShowHomeScreen) - appStore.waitUntilIdle() activity.settings.isFirstRun = false ExternalIntentNavigation.handleAppOpened(null, activity) - appStore.waitUntilIdle() assertEquals(Screen.Home, appStore.state.screen) } @@ -101,9 +93,7 @@ internal class ExternalIntentNavigationTest { @Test fun `GIVEN a tab is already open WHEN trying to navigate to the current tab THEN navigate to it and return true`() { activity.components.tabsUseCases.addTab(url = "https://mozilla.com", private = true) - activity.components.store.waitUntilIdle() val result = ExternalIntentNavigation.handleBrowserTabAlreadyOpen(activity) - activity.components.appStore.waitUntilIdle() assertTrue(result) val selectedTabId = activity.components.store.state.selectedTabId!! @@ -114,9 +104,7 @@ internal class ExternalIntentNavigationTest { fun `GIVEN no tabs are currently open WHEN trying to navigate to the current tab THEN navigate home and return false`() { // The AppStore is initialized before the test runs. By default isFirstRun is true. Simulate it being false. appStore.dispatch(AppAction.ShowHomeScreen) - appStore.waitUntilIdle() val result = ExternalIntentNavigation.handleBrowserTabAlreadyOpen(activity) - activity.components.appStore.waitUntilIdle() assertFalse(result) assertEquals(Screen.Home, activity.components.appStore.state.screen) @@ -129,7 +117,6 @@ internal class ExternalIntentNavigationTest { } val result = ExternalIntentNavigation.handleWidgetTextSearch(bundle, activity) - appStore.waitUntilIdle() assertTrue(result) assertNotNull(SearchWidget.newTabButton.testGetValue()) @@ -140,11 +127,9 @@ internal class ExternalIntentNavigationTest { fun `GIVEN no text search from the search widget WHEN handling widget interactions THEN don't record telemetry, show the home screen and false true`() { // The AppStore is initialized before the test runs. By default isFirstRun is true. Simulate it being false. appStore.dispatch(AppAction.ShowHomeScreen) - appStore.waitUntilIdle() val bundle = Bundle() val result = ExternalIntentNavigation.handleWidgetTextSearch(bundle, activity) - appStore.waitUntilIdle() assertFalse(result) assertNull(SearchWidget.newTabButton.testGetValue()) @@ -162,7 +147,6 @@ internal class ExternalIntentNavigationTest { val result = ExternalIntentNavigation.handleWidgetVoiceSearch(bundle, activity) assertTrue(result) - browserStore.waitUntilIdle() assertEquals(1, browserStore.state.allTabs.size) assertEquals(1, browserStore.state.privateTabs.size) val voiceSearchTab = browserStore.state.privateTabs[0] @@ -170,7 +154,6 @@ internal class ExternalIntentNavigationTest { assertEquals(SearchUtils.createSearchUrl(activity, searchArgument), voiceSearchTab.content.url) assertEquals(SessionState.Source.External.ActionSend(null), voiceSearchTab.source) assertEquals(searchArgument, voiceSearchTab.content.searchTerms) - appStore.waitUntilIdle() assertEquals(Screen.Browser(voiceSearchTab.id, false), appStore.state.screen) } @@ -178,16 +161,13 @@ internal class ExternalIntentNavigationTest { fun `GIVEN no voice search WHEN handling widget interactions THEN don't open a new tab and return false`() { // The AppStore is initialized before the test runs. By default isFirstRun is true. Simulate it being false. appStore.dispatch(AppAction.ShowHomeScreen) - appStore.waitUntilIdle() val browserStore = activity.components.store val bundle = Bundle() val result = ExternalIntentNavigation.handleWidgetVoiceSearch(bundle, activity) assertFalse(result) - browserStore.waitUntilIdle() assertEquals(0, browserStore.state.allTabs.size) - appStore.waitUntilIdle() assertEquals(Screen.Home, appStore.state.screen) } }