commit b35ac0e38259bf8c3991414d0e79c80f9eca3ddb parent 494e4e103b81ab19a237ee69b28ce15059ba39f5 Author: pollymce <pmceldowney@mozilla.com> Date: Mon, 17 Nov 2025 13:45:14 +0000 Bug 1980348 - change Store.dispatch() api to no longer return a Job. r=android-reviewers,007 This means we have to delete join() and joinBlocking() everywhere they are appended to Store.dispatch() (mostly in the unit tests) Differential Revision: https://phabricator.services.mozilla.com/D268844 Diffstat:
165 files changed, 1640 insertions(+), 2663 deletions(-)
diff --git a/mobile/android/android-components/components/browser/icons/src/test/java/mozilla/components/browser/icons/extension/IconMessageHandlerTest.kt b/mobile/android/android-components/components/browser/icons/src/test/java/mozilla/components/browser/icons/extension/IconMessageHandlerTest.kt @@ -208,7 +208,6 @@ class IconMessageHandlerTest { } store.dispatch(TrackingProtectionAction.ClearTrackersAction("test-url")) - .join() // Loaded icon will be set on session diff --git a/mobile/android/android-components/components/browser/session-storage/src/test/java/mozilla/components/browser/session/storage/AutoSaveTest.kt b/mobile/android/android-components/components/browser/session-storage/src/test/java/mozilla/components/browser/session/storage/AutoSaveTest.kt @@ -17,7 +17,6 @@ import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.Engine import mozilla.components.support.test.any import mozilla.components.support.test.eq -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule @@ -103,7 +102,7 @@ class AutoSaveTest { TabListAction.AddTabAction( createTab("https://www.mozilla.org"), ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() @@ -139,7 +138,7 @@ class AutoSaveTest { assertNull(autoSave.saveJob) verify(sessionStorage, never()).save(any()) - store.dispatch(TabListAction.RemoveTabAction("mozilla")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("mozilla")) dispatcher.scheduler.advanceUntilIdle() @@ -175,7 +174,7 @@ class AutoSaveTest { assertNull(autoSave.saveJob) verify(sessionStorage, never()).save(any()) - store.dispatch(TabListAction.RemoveAllNormalTabsAction).joinBlocking() + store.dispatch(TabListAction.RemoveAllNormalTabsAction) dispatcher.scheduler.advanceUntilIdle() @@ -208,7 +207,7 @@ class AutoSaveTest { assertNull(autoSave.saveJob) verify(sessionStorage, never()).save(any()) - store.dispatch(TabListAction.RemoveTabAction("firefox")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("firefox")) dispatcher.scheduler.advanceUntilIdle() autoSave.saveJob?.join() @@ -243,7 +242,7 @@ class AutoSaveTest { assertNull(autoSave.saveJob) verify(sessionStorage, never()).save(any()) - store.dispatch(TabListAction.SelectTabAction("mozilla")).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("mozilla")) dispatcher.scheduler.advanceUntilIdle() @@ -278,7 +277,7 @@ class AutoSaveTest { sessionId = "mozilla", loading = true, ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() @@ -290,7 +289,7 @@ class AutoSaveTest { sessionId = "mozilla", loading = false, ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() diff --git a/mobile/android/android-components/components/browser/state/src/androidTest/java/mozilla/components/browser/state/helper/OnDeviceTargetTest.kt b/mobile/android/android-components/components/browser/state/src/androidTest/java/mozilla/components/browser/state/helper/OnDeviceTargetTest.kt @@ -5,8 +5,6 @@ package mozilla.components.browser.state.helper import androidx.compose.ui.test.junit4.createComposeRule -import kotlinx.coroutines.runBlocking -import mozilla.components.browser.state.action.BrowserAction import mozilla.components.browser.state.action.CustomTabListAction import mozilla.components.browser.state.action.TabListAction import mozilla.components.browser.state.state.BrowserState @@ -43,7 +41,7 @@ class OnDeviceTargetTest { assertNull(observedTabId) - store.dispatchBlockingOnIdle( + store.dispatch( TabListAction.AddTabAction(createTab("https://www.mozilla.org", id = "mozilla")), ) @@ -51,7 +49,7 @@ class OnDeviceTargetTest { assertEquals("mozilla", observedTabId) } - store.dispatchBlockingOnIdle( + store.dispatch( TabListAction.AddTabAction(createTab("https://example.org", id = "example")), ) @@ -59,7 +57,7 @@ class OnDeviceTargetTest { assertEquals("mozilla", observedTabId) } - store.dispatchBlockingOnIdle( + store.dispatch( TabListAction.SelectTabAction("example"), ) @@ -67,7 +65,7 @@ class OnDeviceTargetTest { assertEquals("example", observedTabId) } - store.dispatchBlockingOnIdle( + store.dispatch( TabListAction.RemoveTabAction("example"), ) @@ -75,7 +73,7 @@ class OnDeviceTargetTest { assertEquals("mozilla", observedTabId) } - store.dispatchBlockingOnIdle(TabListAction.RemoveAllTabsAction()) + store.dispatch(TabListAction.RemoveAllTabsAction()) rule.runOnIdle { assertNull(observedTabId) @@ -107,13 +105,13 @@ class OnDeviceTargetTest { assertEquals("mozilla", observedTabId) - store.dispatchBlockingOnIdle(TabListAction.SelectTabAction("example")) + store.dispatch(TabListAction.SelectTabAction("example")) rule.runOnIdle { assertEquals("mozilla", observedTabId) } - store.dispatchBlockingOnIdle(TabListAction.RemoveTabAction("mozilla")) + store.dispatch(TabListAction.RemoveTabAction("mozilla")) rule.runOnIdle { assertNull(observedTabId) @@ -149,29 +147,22 @@ class OnDeviceTargetTest { assertEquals("reddit", observedTabId) - store.dispatchBlockingOnIdle(TabListAction.SelectTabAction("example")) + store.dispatch(TabListAction.SelectTabAction("example")) rule.runOnIdle { assertEquals("reddit", observedTabId) } - store.dispatchBlockingOnIdle(TabListAction.RemoveTabAction("mozilla")) + store.dispatch(TabListAction.RemoveTabAction("mozilla")) rule.runOnIdle { assertEquals("reddit", observedTabId) } - store.dispatchBlockingOnIdle(CustomTabListAction.RemoveCustomTabAction("reddit")) + store.dispatch(CustomTabListAction.RemoveCustomTabAction("reddit")) rule.runOnIdle { assertNull(observedTabId) } } - - private fun BrowserStore.dispatchBlockingOnIdle(action: BrowserAction) { - rule.runOnIdle { - val job = dispatch(action) - runBlocking { job.join() } - } - } } diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/EngineObserverTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/EngineObserverTest.kt @@ -7,7 +7,6 @@ package mozilla.components.browser.state.engine import android.content.Intent import android.view.WindowManager import androidx.test.ext.junit.runners.AndroidJUnit4 -import kotlinx.coroutines.Job import kotlinx.coroutines.test.runTest import mozilla.components.browser.state.action.BrowserAction import mozilla.components.browser.state.action.ContentAction @@ -46,7 +45,6 @@ import mozilla.components.concept.fetch.Header import mozilla.components.concept.fetch.Headers.Names.E_TAG import mozilla.components.concept.fetch.MutableHeaders import mozilla.components.concept.fetch.Response -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.whenever @@ -58,7 +56,6 @@ import org.junit.Assert.assertNull import org.junit.Assert.assertTrue import org.junit.Test import org.junit.runner.RunWith -import org.mockito.Mockito.doReturn import org.mockito.Mockito.never import org.mockito.Mockito.verify import org.mockito.Mockito.`when` @@ -148,8 +145,6 @@ class EngineObserverTest { engineSession.loadUrl("http://mozilla.org") engineSession.toggleDesktopMode(true) - store.waitUntilIdle() - assertEquals("http://mozilla.org", store.state.selectedTab?.content?.url) assertEquals(100, store.state.selectedTab?.content?.progress) assertEquals(true, store.state.selectedTab?.content?.loading) @@ -240,11 +235,9 @@ class EngineObserverTest { engineSession.register(EngineObserver("mozilla", store)) engineSession.loadUrl("http://mozilla.org") - store.waitUntilIdle() assertEquals(SecurityInfoState(secure = false), store.state.tabs[0].content.securityInfo) engineSession.loadUrl("https://mozilla.org") - store.waitUntilIdle() assertEquals(SecurityInfoState(secure = true, "host", "issuer"), store.state.tabs[0].content.securityInfo) } @@ -324,12 +317,10 @@ class EngineObserverTest { val tracker2 = Tracker("tracker2", emptyList()) observer.onTrackerBlocked(tracker1) - store.waitUntilIdle() assertEquals(listOf(tracker1), store.state.tabs[0].trackingProtection.blockedTrackers) observer.onTrackerBlocked(tracker2) - store.waitUntilIdle() assertEquals(listOf(tracker1, tracker2), store.state.tabs[0].trackingProtection.blockedTrackers) } @@ -412,7 +403,6 @@ class EngineObserverTest { engineSession.register(EngineObserver("mozilla", store)) engineSession.loadUrl("https://mozilla.org") - store.waitUntilIdle() assertEquals(true, store.state.translationsInitialized) } @@ -495,7 +485,6 @@ class EngineObserverTest { engineSession.register(EngineObserver("mozilla", store)) engineSession.loadUrl("https://mozilla.org") - store.waitUntilIdle() assertEquals(false, store.state.translationsInitialized) } @@ -634,12 +623,10 @@ class EngineObserverTest { val observer = EngineObserver("mozilla", store) observer.onTitleChange("Mozilla") - store.waitUntilIdle() assertEquals("Mozilla", store.state.tabs[0].content.title) observer.onLocationChange("https://getpocket.com", false) - store.waitUntilIdle() assertEquals("", store.state.tabs[0].content.title) } @@ -661,12 +648,10 @@ class EngineObserverTest { val observer = EngineObserver("mozilla", store) observer.onTitleChange("Mozilla") - store.waitUntilIdle() assertEquals("Mozilla", store.state.tabs[0].content.title) observer.onLocationChange("https://www.mozilla.org", false) - store.waitUntilIdle() assertEquals("Mozilla", store.state.tabs[0].content.title) } @@ -688,12 +673,10 @@ class EngineObserverTest { val observer = EngineObserver("mozilla", store) observer.onTitleChange("Mozilla") - store.waitUntilIdle() assertEquals("Mozilla", store.state.tabs[0].content.title) observer.onLocationChange("https://www.mozilla.org/#something", false) - store.waitUntilIdle() assertEquals("Mozilla", store.state.tabs[0].content.title) } @@ -715,12 +698,10 @@ class EngineObserverTest { val observer = EngineObserver("mozilla", store) observer.onPreviewImageChange(previewImageUrl) - store.waitUntilIdle() assertEquals(previewImageUrl, store.state.tabs[0].content.previewImageUrl) observer.onLocationChange("https://getpocket.com", false) - store.waitUntilIdle() assertNull(store.state.tabs[0].content.previewImageUrl) } @@ -743,17 +724,14 @@ class EngineObserverTest { val observer = EngineObserver("mozilla", store) observer.onPreviewImageChange(previewImageUrl) - store.waitUntilIdle() assertEquals(previewImageUrl, store.state.tabs[0].content.previewImageUrl) observer.onLocationChange("https://www.mozilla.org", false) - store.waitUntilIdle() assertEquals(previewImageUrl, store.state.tabs[0].content.previewImageUrl) observer.onLocationChange("https://www.mozilla.org/#something", false) - store.waitUntilIdle() assertEquals(previewImageUrl, store.state.tabs[0].content.previewImageUrl) } @@ -778,12 +756,10 @@ class EngineObserverTest { observer.onTrackerBlocked(tracker1) observer.onTrackerBlocked(tracker2) - store.waitUntilIdle() assertEquals(listOf(tracker1, tracker2), store.state.tabs[0].trackingProtection.blockedTrackers) observer.onLoadingStateChange(true) - store.waitUntilIdle() assertEquals(emptyList<String>(), store.state.tabs[0].trackingProtection.blockedTrackers) } @@ -808,12 +784,10 @@ class EngineObserverTest { observer.onTrackerLoaded(tracker1) observer.onTrackerLoaded(tracker2) - store.waitUntilIdle() assertEquals(listOf(tracker1, tracker2), store.state.tabs[0].trackingProtection.loadedTrackers) observer.onLoadingStateChange(true) - store.waitUntilIdle() assertEquals(emptyList<String>(), store.state.tabs[0].trackingProtection.loadedTrackers) } @@ -836,12 +810,10 @@ class EngineObserverTest { val observer = EngineObserver("mozilla", store) observer.onWebAppManifestLoaded(manifest) - store.waitUntilIdle() assertEquals(manifest, store.state.tabs[0].content.webAppManifest) observer.onLocationChange("https://getpocket.com", false) - store.waitUntilIdle() assertNull(store.state.tabs[0].content.webAppManifest) } @@ -864,12 +836,10 @@ class EngineObserverTest { val request: PermissionRequest = mock() store.dispatch(ContentAction.UpdatePermissionsRequest("mozilla", request)) - store.waitUntilIdle() assertEquals(listOf(request), store.state.tabs[0].content.permissionRequestsList) observer.onLocationChange("https://getpocket.com", false) - store.waitUntilIdle() assertEquals(emptyList<PermissionRequest>(), store.state.tabs[0].content.permissionRequestsList) } @@ -892,12 +862,10 @@ class EngineObserverTest { val request: PermissionRequest = mock() store.dispatch(ContentAction.UpdatePermissionsRequest("mozilla", request)) - store.waitUntilIdle() assertEquals(listOf(request), store.state.tabs[0].content.permissionRequestsList) observer.onLocationChange("https://www.mozilla.org/hello.html", false) - store.waitUntilIdle() assertEquals(listOf(request), store.state.tabs[0].content.permissionRequestsList) } @@ -920,12 +888,10 @@ class EngineObserverTest { val observer = EngineObserver("mozilla", store) observer.onWebAppManifestLoaded(manifest) - store.waitUntilIdle() assertEquals(manifest, store.state.tabs[0].content.webAppManifest) observer.onLocationChange("https://www.mozilla.org/hello.html", false) - store.waitUntilIdle() assertEquals(manifest, store.state.tabs[0].content.webAppManifest) } @@ -952,17 +918,14 @@ class EngineObserverTest { val observer = EngineObserver("mozilla", store) observer.onWebAppManifestLoaded(manifest) - store.waitUntilIdle() assertEquals(manifest, store.state.tabs[0].content.webAppManifest) observer.onLocationChange("https://www.mozilla.org/hello/page2.html", false) - store.waitUntilIdle() assertEquals(manifest, store.state.tabs[0].content.webAppManifest) observer.onLocationChange("https://www.mozilla.org/hello.html", false) - store.waitUntilIdle() assertNull(store.state.tabs[0].content.webAppManifest) } @@ -984,7 +947,6 @@ class EngineObserverTest { val hitResult = HitResult.UNKNOWN("data://foobar") observer.onLongPress(hitResult) - store.waitUntilIdle() assertEquals(hitResult, store.state.tabs[0].content.hitResult) } @@ -998,14 +960,12 @@ class EngineObserverTest { val observer = EngineObserver("tab", store) observer.onFindResult(0, 1, false) - store.waitUntilIdle() middleware.assertFirstAction(ContentAction.AddFindResultAction::class) { action -> assertEquals("tab", action.sessionId) assertEquals(FindResultState(0, 1, false), action.findResult) } observer.onFind("mozilla") - store.waitUntilIdle() middleware.assertLastAction(ContentAction.ClearFindResultsAction::class) { action -> assertEquals("tab", action.sessionId) } @@ -1020,21 +980,18 @@ class EngineObserverTest { val observer = EngineObserver("tab-id", store) observer.onFindResult(0, 1, false) - store.waitUntilIdle() middleware.assertFirstAction(ContentAction.AddFindResultAction::class) { action -> assertEquals("tab-id", action.sessionId) assertEquals(FindResultState(0, 1, false), action.findResult) } observer.onFindResult(1, 2, true) - store.waitUntilIdle() middleware.assertLastAction(ContentAction.AddFindResultAction::class) { action -> assertEquals("tab-id", action.sessionId) assertEquals(FindResultState(1, 2, true), action.findResult) } observer.onLoadingStateChange(true) - store.waitUntilIdle() middleware.assertLastAction(ContentAction.ClearFindResultsAction::class) { action -> assertEquals("tab-id", action.sessionId) } @@ -1049,14 +1006,12 @@ class EngineObserverTest { val observer = EngineObserver("tab-id", store) observer.onRepostPromptCancelled() - store.waitUntilIdle() middleware.assertFirstAction(ContentAction.UpdateRefreshCanceledStateAction::class) { action -> assertEquals("tab-id", action.sessionId) assertTrue(action.refreshCanceled) } observer.onLoadingStateChange(true) - store.waitUntilIdle() middleware.assertLastAction(ContentAction.UpdateRefreshCanceledStateAction::class) { action -> assertEquals("tab-id", action.sessionId) assertFalse(action.refreshCanceled) @@ -1090,14 +1045,12 @@ class EngineObserverTest { val observer = EngineObserver("tab-id", store) observer.onFullScreenChange(true) - store.waitUntilIdle() middleware.assertFirstAction(ContentAction.FullScreenChangedAction::class) { action -> assertEquals("tab-id", action.sessionId) assertTrue(action.fullScreenEnabled) } observer.onFullScreenChange(false) - store.waitUntilIdle() middleware.assertLastAction(ContentAction.FullScreenChangedAction::class) { action -> assertEquals("tab-id", action.sessionId) assertFalse(action.fullScreenEnabled) @@ -1113,14 +1066,12 @@ class EngineObserverTest { val observer = EngineObserver("tab-id", store) observer.onDesktopModeChange(true) - store.waitUntilIdle() middleware.assertFirstAction(ContentAction.UpdateTabDesktopMode::class) { action -> assertEquals("tab-id", action.sessionId) assertTrue(action.enabled) } observer.onDesktopModeChange(false) - store.waitUntilIdle() middleware.assertLastAction(ContentAction.UpdateTabDesktopMode::class) { action -> assertEquals("tab-id", action.sessionId) assertFalse(action.enabled) @@ -1136,7 +1087,6 @@ class EngineObserverTest { val observer = EngineObserver("tab-id", store) observer.onMetaViewportFitChanged(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT) - store.waitUntilIdle() middleware.assertFirstAction(ContentAction.ViewportFitChangedAction::class) { action -> assertEquals("tab-id", action.sessionId) assertEquals( @@ -1146,7 +1096,6 @@ class EngineObserverTest { } observer.onMetaViewportFitChanged(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES) - store.waitUntilIdle() middleware.assertLastAction(ContentAction.ViewportFitChangedAction::class) { action -> assertEquals("tab-id", action.sessionId) assertEquals( @@ -1156,7 +1105,6 @@ class EngineObserverTest { } observer.onMetaViewportFitChanged(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER) - store.waitUntilIdle() middleware.assertLastAction(ContentAction.ViewportFitChangedAction::class) { action -> assertEquals("tab-id", action.sessionId) assertEquals( @@ -1166,7 +1114,6 @@ class EngineObserverTest { } observer.onMetaViewportFitChanged(123) - store.waitUntilIdle() middleware.assertLastAction(ContentAction.ViewportFitChangedAction::class) { action -> assertEquals("tab-id", action.sessionId) assertEquals(123, action.layoutInDisplayCutoutMode) @@ -1193,7 +1140,6 @@ class EngineObserverTest { ) observer.onWebAppManifestLoaded(manifest) - store.waitUntilIdle() assertEquals(manifest, store.state.tabs[0].content.webAppManifest) } @@ -1207,8 +1153,6 @@ class EngineObserverTest { "tab-id", permissionRequest, ) - doReturn(Job()).`when`(store).dispatch(action) - observer.onContentPermissionRequest(permissionRequest) verify(store).dispatch(action) } @@ -1333,7 +1277,6 @@ class EngineObserverTest { assertNull(store.state.tabs[0].mediaSessionState) observer.onMediaActivated(mediaSessionController) - store.waitUntilIdle() val observedMediaSessionState = store.state.tabs[0].mediaSessionState assertNotNull(observedMediaSessionState) @@ -1361,7 +1304,6 @@ class EngineObserverTest { assertNotNull(store.state.findTab("mozilla")?.mediaSessionState) observer.onMediaDeactivated() - store.waitUntilIdle() val observedMediaSessionState = store.state.findTab("mozilla")?.mediaSessionState assertNull(observedMediaSessionState) @@ -1388,9 +1330,7 @@ class EngineObserverTest { val metaData: MediaSession.Metadata = mock() observer.onMediaActivated(mediaSessionController) - store.waitUntilIdle() observer.onMediaMetadataChanged(metaData) - store.waitUntilIdle() val observedMediaSessionState = store.state.findTab("mozilla")?.mediaSessionState assertNotNull(observedMediaSessionState) @@ -1419,9 +1359,7 @@ class EngineObserverTest { val playbackState: MediaSession.PlaybackState = mock() observer.onMediaActivated(mediaSessionController) - store.waitUntilIdle() observer.onMediaPlaybackStateChanged(playbackState) - store.waitUntilIdle() val observedMediaSessionState = store.state.findTab("mozilla")?.mediaSessionState assertNotNull(observedMediaSessionState) @@ -1450,9 +1388,7 @@ class EngineObserverTest { val features: MediaSession.Feature = mock() observer.onMediaActivated(mediaSessionController) - store.waitUntilIdle() observer.onMediaFeatureChanged(features) - store.waitUntilIdle() val observedMediaSessionState = store.state.findTab("mozilla")?.mediaSessionState assertNotNull(observedMediaSessionState) @@ -1481,9 +1417,7 @@ class EngineObserverTest { val positionState: MediaSession.PositionState = mock() observer.onMediaActivated(mediaSessionController) - store.waitUntilIdle() observer.onMediaPositionStateChanged(positionState) - store.waitUntilIdle() val observedMediaSessionState = store.state.findTab("mozilla")?.mediaSessionState assertNotNull(observedMediaSessionState) @@ -1511,9 +1445,7 @@ class EngineObserverTest { val mediaSessionController: MediaSession.Controller = mock() observer.onMediaActivated(mediaSessionController) - store.waitUntilIdle() observer.onMediaMuteChanged(true) - store.waitUntilIdle() val observedMediaSessionState = store.state.findTab("mozilla")?.mediaSessionState assertNotNull(observedMediaSessionState) @@ -1542,9 +1474,7 @@ class EngineObserverTest { val elementMetadata: MediaSession.ElementMetadata = mock() observer.onMediaActivated(mediaSessionController) - store.waitUntilIdle() observer.onMediaFullscreenChanged(true, elementMetadata) - store.waitUntilIdle() val observedMediaSessionState = store.state.findTab("mozilla")?.mediaSessionState assertNotNull(observedMediaSessionState) @@ -1570,12 +1500,10 @@ class EngineObserverTest { val elementMetadata: MediaSession.ElementMetadata = mock() observer.onMediaFullscreenChanged(true, elementMetadata) - store.waitUntilIdle() assertNull(store.state.findTab("mozilla")?.mediaSessionState) observer.onMediaMuteChanged(true) - store.waitUntilIdle() assertNull(store.state.findTab("mozilla")?.mediaSessionState) } @@ -1611,8 +1539,6 @@ class EngineObserverTest { response = response, ) - store.waitUntilIdle() - val tab = store.state.findTab("mozilla")!! assertEquals("mozilla.org/file.txt", tab.content.download?.url) @@ -1645,8 +1571,6 @@ class EngineObserverTest { observer.onExternalResource(url = "mozilla.org/file.txt", contentLength = -1) - store.waitUntilIdle() - val tab = store.state.findTab("test-tab")!! assertNull(tab.content.download?.contentLength) @@ -1676,8 +1600,6 @@ class EngineObserverTest { val observer = EngineObserver("test-id", store) observer.onLocationChange("https://www.mozilla.org/en-US/", false) - store.waitUntilIdle() - middleware.assertNotDispatched(ContentAction.UpdateSearchTermsAction::class) } @@ -1693,8 +1615,6 @@ class EngineObserverTest { val observer = EngineObserver("test-id", store) observer.onLoadRequest(url = url, triggeredByRedirect = false, triggeredByWebContent = true) - store.waitUntilIdle() - middleware.assertFirstAction(ContentAction.UpdateSearchTermsAction::class) { action -> assertEquals("", action.searchTerms) assertEquals("test-id", action.sessionId) @@ -1731,7 +1651,6 @@ class EngineObserverTest { val observer = EngineObserver("test-id", store) observer.onLoadRequest(url = url, triggeredByRedirect = false, triggeredByWebContent = false) - store.waitUntilIdle() middleware.assertNotDispatched(ContentAction.UpdateSearchTermsAction::class) } @@ -1756,7 +1675,6 @@ class EngineObserverTest { val observer = EngineObserver("test-id", store) observer.onNavigateBack() - store.waitUntilIdle() middleware.assertFirstAction(ContentAction.UpdateSearchTermsAction::class) { action -> assertEquals("", action.searchTerms) @@ -1773,7 +1691,6 @@ class EngineObserverTest { val observer = EngineObserver("test-id", store) observer.onNavigateForward() - store.waitUntilIdle() middleware.assertFirstAction(ContentAction.UpdateSearchTermsAction::class) { action -> assertEquals("", action.searchTerms) @@ -1790,7 +1707,6 @@ class EngineObserverTest { val observer = EngineObserver("test-id", store) observer.onGotoHistoryIndex() - store.waitUntilIdle() middleware.assertFirstAction(ContentAction.UpdateSearchTermsAction::class) { action -> assertEquals("", action.searchTerms) @@ -1807,7 +1723,6 @@ class EngineObserverTest { val observer = EngineObserver("test-id", store) observer.onLoadData() - store.waitUntilIdle() middleware.assertFirstAction(ContentAction.UpdateSearchTermsAction::class) { action -> assertEquals("", action.searchTerms) @@ -1828,11 +1743,9 @@ class EngineObserverTest { ) store.dispatch(ContentAction.UpdateIsSearchAction("mozilla", false)) - store.waitUntilIdle() val observer = EngineObserver("test-id", store) observer.onLoadUrl() - store.waitUntilIdle() middleware.assertLastAction(ContentAction.UpdateSearchTermsAction::class) { action -> assertEquals("", action.searchTerms) @@ -1853,11 +1766,9 @@ class EngineObserverTest { ) store.dispatch(ContentAction.UpdateIsSearchAction("test-id", true)) - store.waitUntilIdle() val observer = EngineObserver("test-id", store) observer.onLoadUrl() - store.waitUntilIdle() middleware.assertLastAction(ContentAction.UpdateIsSearchAction::class) { action -> assertEquals(false, action.isSearch) @@ -1878,11 +1789,9 @@ class EngineObserverTest { ) store.dispatch(ContentAction.UpdateIsSearchAction("test-id", true)) - store.waitUntilIdle() val observer = EngineObserver("test-id", store) observer.onLocationChange("testUrl", false) - store.waitUntilIdle() middleware.assertNotDispatched(ContentAction.UpdateSearchTermsAction::class) } diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/CrashMiddlewareTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/CrashMiddlewareTest.kt @@ -12,7 +12,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.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertFalse @@ -59,13 +58,13 @@ class CrashMiddlewareTest { CrashAction.SessionCrashedAction( "tab1", ), - ).joinBlocking() + ) store.dispatch( CrashAction.SessionCrashedAction( "tab3", ), - ).joinBlocking() + ) assertTrue(store.state.tabs[0].engineState.crashed) assertFalse(store.state.tabs[1].engineState.crashed) @@ -76,7 +75,7 @@ class CrashMiddlewareTest { CrashAction.RestoreCrashedSessionAction( "tab1", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() @@ -89,7 +88,7 @@ class CrashMiddlewareTest { CrashAction.RestoreCrashedSessionAction( "tab2", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() @@ -98,7 +97,7 @@ class CrashMiddlewareTest { CrashAction.RestoreCrashedSessionAction( "unknown", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() @@ -129,7 +128,7 @@ class CrashMiddlewareTest { CrashAction.SessionCrashedAction( "tab1", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() @@ -139,7 +138,7 @@ class CrashMiddlewareTest { CrashAction.RestoreCrashedSessionAction( "tab1", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/CreateEngineSessionMiddlewareTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/CreateEngineSessionMiddlewareTest.kt @@ -16,8 +16,6 @@ import mozilla.components.concept.engine.Engine import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.EngineSessionState import mozilla.components.support.test.any -import mozilla.components.support.test.ext.joinBlocking -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 @@ -54,14 +52,12 @@ class CreateEngineSessionMiddlewareTest { ) assertNull(store.state.findTab(tab.id)?.engineState?.engineSession) - store.dispatch(EngineAction.CreateEngineSessionAction(tab.id)).joinBlocking() - store.waitUntilIdle() + store.dispatch(EngineAction.CreateEngineSessionAction(tab.id)) dispatcher.scheduler.advanceUntilIdle() verify(engine, times(1)).createSession(false) assertEquals(engineSession, store.state.findTab(tab.id)?.engineState?.engineSession) - store.dispatch(EngineAction.CreateEngineSessionAction(tab.id)).joinBlocking() - store.waitUntilIdle() + store.dispatch(EngineAction.CreateEngineSessionAction(tab.id)) dispatcher.scheduler.advanceUntilIdle() verify(engine, times(1)).createSession(false) assertEquals(engineSession, store.state.findTab(tab.id)?.engineState?.engineSession) @@ -82,9 +78,8 @@ class CreateEngineSessionMiddlewareTest { ) assertNull(store.state.findTab(tab.id)?.engineState?.engineSession) - store.dispatch(EngineAction.UpdateEngineSessionStateAction(tab.id, engineSessionState)).joinBlocking() - store.dispatch(EngineAction.CreateEngineSessionAction(tab.id)).joinBlocking() - store.waitUntilIdle() + store.dispatch(EngineAction.UpdateEngineSessionStateAction(tab.id, engineSessionState)) + store.dispatch(EngineAction.CreateEngineSessionAction(tab.id)) dispatcher.scheduler.advanceUntilIdle() verify(engineSession).restoreState(engineSessionState) @@ -102,8 +97,7 @@ class CreateEngineSessionMiddlewareTest { middleware = listOf(middleware), ) - store.dispatch(EngineAction.CreateEngineSessionAction("invalid")).joinBlocking() - store.waitUntilIdle() + store.dispatch(EngineAction.CreateEngineSessionAction("invalid")) dispatcher.scheduler.advanceUntilIdle() verify(engine, never()).createSession(anyBoolean(), any()) @@ -125,9 +119,8 @@ class CreateEngineSessionMiddlewareTest { store.dispatch( EngineAction.CreateEngineSessionAction("non-existent"), - ).joinBlocking() + ) - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() verify(engine, never()).createSession(anyBoolean(), any()) @@ -149,9 +142,8 @@ class CreateEngineSessionMiddlewareTest { assertNull(store.state.findTab(tab.id)?.engineState?.engineSession) val followupAction = ContentAction.UpdateTitleAction(tab.id, "test") - store.dispatch(EngineAction.CreateEngineSessionAction(tab.id, followupAction = followupAction)).joinBlocking() + store.dispatch(EngineAction.CreateEngineSessionAction(tab.id, followupAction = followupAction)) - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() verify(engine, times(1)).createSession(false) @@ -179,7 +171,6 @@ class CreateEngineSessionMiddlewareTest { store.dispatch(EngineAction.CreateEngineSessionAction(tab.id)) store.dispatch(EngineAction.CreateEngineSessionAction(tab.id, followupAction = followupAction)) - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() verify(engine, times(1)).createSession(false) @@ -202,9 +193,8 @@ class CreateEngineSessionMiddlewareTest { assertNull(store.state.findCustomTab(customTab.id)?.engineState?.engineSession) val followupAction = ContentAction.UpdateTitleAction(customTab.id, "test") - store.dispatch(EngineAction.CreateEngineSessionAction(customTab.id, followupAction = followupAction)).joinBlocking() + store.dispatch(EngineAction.CreateEngineSessionAction(customTab.id, followupAction = followupAction)) - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() verify(engine, times(1)).createSession(false) @@ -227,9 +217,8 @@ class CreateEngineSessionMiddlewareTest { assertNull(store.state.findCustomTab(customTab.id)?.engineState?.engineSession) val followupAction = ContentAction.UpdateTitleAction(customTab.id, "test") - store.dispatch(EngineAction.CreateEngineSessionAction(customTab.id, followupAction = followupAction)).joinBlocking() + store.dispatch(EngineAction.CreateEngineSessionAction(customTab.id, followupAction = followupAction)) - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() verify(engine, times(1)).createSession(false) @@ -255,8 +244,7 @@ class CreateEngineSessionMiddlewareTest { ) assertNull(store.state.findTab(tabs[0].id)?.engineState?.engineSession) - store.dispatch(EngineAction.CreateEngineSessionAction(tabs[0].id)).joinBlocking() - store.waitUntilIdle() + store.dispatch(EngineAction.CreateEngineSessionAction(tabs[0].id)) dispatcher.scheduler.advanceUntilIdle() verify(engineSession).toggleDesktopMode(eq(true), eq(false)) } @@ -278,8 +266,7 @@ class CreateEngineSessionMiddlewareTest { ) assertNull(store.state.findTab(tabs[0].id)?.engineState?.engineSession) - store.dispatch(EngineAction.CreateEngineSessionAction(tabs[1].id)).joinBlocking() - store.waitUntilIdle() + store.dispatch(EngineAction.CreateEngineSessionAction(tabs[1].id)) dispatcher.scheduler.advanceUntilIdle() verify(engineSession).toggleDesktopMode(eq(false), eq(false)) } diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/EngineDelegateMiddlewareTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/EngineDelegateMiddlewareTest.kt @@ -16,8 +16,6 @@ import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.Engine import mozilla.components.concept.engine.EngineSession import mozilla.components.support.test.any -import mozilla.components.support.test.ext.joinBlocking -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 @@ -60,10 +58,9 @@ class EngineDelegateMiddlewareTest { "test-tab", "https://www.firefox.com", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = false, contextId = null) verify(engineSession, times(1)).loadUrl("https://www.firefox.com") @@ -92,10 +89,9 @@ class EngineDelegateMiddlewareTest { "test-tab", "https://www.firefox.com", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = true, contextId = null) verify(engineSession, times(1)).loadUrl("https://www.firefox.com") @@ -124,10 +120,9 @@ class EngineDelegateMiddlewareTest { "test-tab", "https://www.firefox.com", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = false, contextId = "test-container") verify(engineSession, times(1)).loadUrl("https://www.firefox.com") @@ -158,10 +153,9 @@ class EngineDelegateMiddlewareTest { "test-tab", "https://www.firefox.com", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine, never()).createSession(ArgumentMatchers.anyBoolean(), ArgumentMatchers.anyString()) verify(engineSession, times(1)).loadUrl("https://www.firefox.com") @@ -192,10 +186,9 @@ class EngineDelegateMiddlewareTest { "test-tab", "https://www.firefox.com", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine, never()).createSession(ArgumentMatchers.anyBoolean(), ArgumentMatchers.anyString()) verify(engineSession, times(1)).loadUrl("https://www.firefox.com") @@ -226,10 +219,9 @@ class EngineDelegateMiddlewareTest { "test-tab", "https://www.firefox.com", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine, never()).createSession(ArgumentMatchers.anyBoolean(), ArgumentMatchers.anyString()) verify(engineSession, times(1)).loadUrl("https://www.firefox.com") @@ -265,10 +257,9 @@ class EngineDelegateMiddlewareTest { "https://www.firefox.com", includeParent = false, ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = false, contextId = null) verify(engineSession, times(1)).loadUrl("https://www.firefox.com", null) @@ -305,10 +296,9 @@ class EngineDelegateMiddlewareTest { "https://www.firefox.com", includeParent = true, ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = false, contextId = null) verify(engineSession, times(1)).loadUrl("https://www.firefox.com", parentEngineSession) @@ -340,10 +330,9 @@ class EngineDelegateMiddlewareTest { "test-tab", "https://www.firefox.com", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine, times(1)).createSession(private = false, contextId = null) verify(engineSession, times(1)).loadUrl("https://www.firefox.com") @@ -378,10 +367,9 @@ class EngineDelegateMiddlewareTest { "X-Sugar" to "None", ), ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engineSession, times(1)).loadUrl( "https://www.firefox.com", @@ -417,10 +405,9 @@ class EngineDelegateMiddlewareTest { "test-tab", "https://www.mozilla.org", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = false, contextId = null) verify(engineSession, times(1)).loadUrl("https://www.mozilla.org") @@ -449,10 +436,9 @@ class EngineDelegateMiddlewareTest { "unknown-tab", "https://www.mozilla.org", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine, never()).createSession(ArgumentMatchers.anyBoolean(), ArgumentMatchers.anyString()) assertNull(store.state.tabs[0].engineState.engineSession) @@ -482,10 +468,9 @@ class EngineDelegateMiddlewareTest { mimeType = "something/important", encoding = "UTF-16", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = false, contextId = null) verify(engineSession, times(1)).loadData( @@ -518,10 +503,9 @@ class EngineDelegateMiddlewareTest { "test-tab", flags = EngineSession.LoadUrlFlags.select(EngineSession.LoadUrlFlags.BYPASS_CACHE), ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = false, contextId = null) verify(engineSession, times(1)).reload( @@ -551,10 +535,9 @@ class EngineDelegateMiddlewareTest { EngineAction.GoForwardAction( "test-tab", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = false, contextId = null) verify(engineSession, times(1)).goForward() @@ -582,10 +565,9 @@ class EngineDelegateMiddlewareTest { EngineAction.GoBackAction( "test-tab", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = false, contextId = null) verify(engineSession, times(1)).goBack() @@ -614,10 +596,9 @@ class EngineDelegateMiddlewareTest { "test-tab", index = 42, ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = false, contextId = null) verify(engineSession, times(1)).goToHistoryIndex(42) @@ -646,10 +627,9 @@ class EngineDelegateMiddlewareTest { "test-tab", enable = true, ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = false, contextId = null) verify(engineSession, times(1)).toggleDesktopMode(enable = true, reload = true) @@ -678,10 +658,9 @@ class EngineDelegateMiddlewareTest { "test-tab", enable = false, ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = false, contextId = null) verify(engineSession, times(1)).toggleDesktopMode(enable = false, reload = true) @@ -709,10 +688,9 @@ class EngineDelegateMiddlewareTest { EngineAction.ExitFullScreenModeAction( "test-tab", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = false, contextId = null) verify(engineSession, times(1)).exitFullScreenMode() @@ -741,10 +719,9 @@ class EngineDelegateMiddlewareTest { "test-tab", data = Engine.BrowsingData.allCaches(), ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engine).createSession(private = false, contextId = null) verify(engineSession, times(1)).clearData(Engine.BrowsingData.allCaches()) @@ -781,7 +758,7 @@ class EngineDelegateMiddlewareTest { ), ) - store.dispatch(EngineAction.PurgeHistoryAction).joinBlocking() + store.dispatch(EngineAction.PurgeHistoryAction) dispatcher.scheduler.advanceUntilIdle() @@ -814,10 +791,9 @@ class EngineDelegateMiddlewareTest { toLanguage = "en", options = null, ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engineSession).requestTranslate(any(), any(), any()) assertTrue(store.state.findTab(tab.id)?.translationsState?.isTranslateProcessing!!) @@ -843,10 +819,9 @@ class EngineDelegateMiddlewareTest { store.dispatch( TranslationsAction.TranslateRestoreAction(tabId = tab.id), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engineSession).requestTranslationRestore() assertTrue(store.state.findTab(tab.id)?.translationsState?.isRestoreProcessing!!) @@ -870,10 +845,9 @@ class EngineDelegateMiddlewareTest { store.dispatch( EngineAction.FlushEngineSessionStateAction(tabId = tab.id), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engineSession).flushSessionState() } @@ -896,10 +870,9 @@ class EngineDelegateMiddlewareTest { store.dispatch( EngineAction.FlushEngineSessionStateAction(tabId = tab.id), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(engineSession).flushSessionState() } diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/ExtensionsProcessMiddlewareTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/ExtensionsProcessMiddlewareTest.kt @@ -8,7 +8,6 @@ import mozilla.components.browser.state.action.ExtensionsProcessAction import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.Engine -import mozilla.components.support.test.ext.joinBlocking import org.junit.Before import org.junit.Test import org.mockito.Mockito @@ -28,7 +27,7 @@ class ExtensionsProcessMiddlewareTest { @Test fun `WHEN EnabledAction is dispatched THEN enable the process spawning`() { - store.dispatch(ExtensionsProcessAction.EnabledAction).joinBlocking() + store.dispatch(ExtensionsProcessAction.EnabledAction) Mockito.verify(engine).enableExtensionProcessSpawning() Mockito.verify(engine, Mockito.never()).disableExtensionProcessSpawning() @@ -36,7 +35,7 @@ class ExtensionsProcessMiddlewareTest { @Test fun `WHEN DisabledAction is dispatched THEN disable the process spawning`() { - store.dispatch(ExtensionsProcessAction.DisabledAction).joinBlocking() + store.dispatch(ExtensionsProcessAction.DisabledAction) Mockito.verify(engine).disableExtensionProcessSpawning() Mockito.verify(engine, Mockito.never()).enableExtensionProcessSpawning() diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/LinkingMiddlewareTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/LinkingMiddlewareTest.kt @@ -12,8 +12,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession import mozilla.components.support.test.any -import mozilla.components.support.test.ext.joinBlocking -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 @@ -44,7 +42,7 @@ class LinkingMiddlewareTest { ) val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)) dispatcher.scheduler.advanceUntilIdle() @@ -70,7 +68,7 @@ class LinkingMiddlewareTest { ) val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)) dispatcher.scheduler.advanceUntilIdle() @@ -96,12 +94,12 @@ class LinkingMiddlewareTest { ) val parentEngineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction(parent.id, parentEngineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(parent.id, parentEngineSession)) val childEngineSession: EngineSession = mock() store.dispatch( EngineAction.LinkEngineSessionAction(child.id, childEngineSession, includeParent = true), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() @@ -122,10 +120,10 @@ class LinkingMiddlewareTest { ) val parentEngineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction(parent.id, parentEngineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(parent.id, parentEngineSession)) val childEngineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction(child.id, childEngineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(child.id, childEngineSession)) dispatcher.scheduler.advanceUntilIdle() @@ -143,7 +141,7 @@ class LinkingMiddlewareTest { ) val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession, skipLoading = true)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession, skipLoading = true)) dispatcher.scheduler.advanceUntilIdle() @@ -160,7 +158,7 @@ class LinkingMiddlewareTest { ) val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("invalid", engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("invalid", engineSession)) dispatcher.scheduler.advanceUntilIdle() @@ -181,9 +179,8 @@ class LinkingMiddlewareTest { val engineSession1: EngineSession = mock() val engineSession2: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction(tab1.id, engineSession1)).joinBlocking() - store.dispatch(EngineAction.LinkEngineSessionAction(tab2.id, engineSession2)).joinBlocking() - store.waitUntilIdle() + store.dispatch(EngineAction.LinkEngineSessionAction(tab1.id, engineSession1)) + store.dispatch(EngineAction.LinkEngineSessionAction(tab2.id, engineSession2)) // We only have a session for tab2 so we should only register an observer for tab2 val engineObserver = store.state.findTab(tab2.id)?.engineState?.engineObserver @@ -192,8 +189,6 @@ class LinkingMiddlewareTest { verify(engineSession2).register(engineObserver!!) engineObserver.onTitleChange("test") - store.waitUntilIdle() - assertEquals("test", store.state.tabs[1].content.title) } @@ -210,14 +205,12 @@ class LinkingMiddlewareTest { ) val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction(tab1.id, engineSession)).joinBlocking() - store.waitUntilIdle() + store.dispatch(EngineAction.LinkEngineSessionAction(tab1.id, engineSession)) assertNotNull(store.state.findTab(tab1.id)?.engineState?.engineObserver) assertNull(store.state.findTab(tab2.id)?.engineState?.engineObserver) - store.dispatch(EngineAction.UnlinkEngineSessionAction(tab1.id)).joinBlocking() - store.dispatch(EngineAction.UnlinkEngineSessionAction(tab2.id)).joinBlocking() - store.waitUntilIdle() + store.dispatch(EngineAction.UnlinkEngineSessionAction(tab1.id)) + store.dispatch(EngineAction.UnlinkEngineSessionAction(tab2.id)) assertNull(store.state.findTab(tab1.id)?.engineState?.engineObserver) assertNull(store.state.findTab(tab2.id)?.engineState?.engineObserver) } @@ -235,16 +228,14 @@ class LinkingMiddlewareTest { middleware = listOf(middleware), ) - store.dispatch(TabListAction.AddTabAction(tab1)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab2)).joinBlocking() - store.waitUntilIdle() + store.dispatch(TabListAction.AddTabAction(tab1)) + store.dispatch(TabListAction.AddTabAction(tab2)) // We only have a session for tab2 so we should only register an observer for tab2 val engineObserver = store.state.findTab(tab2.id)?.engineState?.engineObserver assertNotNull(engineObserver) verify(engineSession).register(engineObserver!!) engineObserver.onTitleChange("test") - store.waitUntilIdle() assertEquals("test", store.state.tabs[1].content.title) } diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/PdfStateMiddlewareTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/PdfStateMiddlewareTest.kt @@ -15,7 +15,6 @@ import mozilla.components.browser.state.state.TabSessionState import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession import mozilla.components.support.test.argumentCaptor -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.mock import org.junit.Assert.assertNull @@ -37,10 +36,9 @@ class PdfStateMiddlewareTest { middleware = listOf(PdfStateMiddleware(this), captureActionsMiddleware), ) - store.dispatch(ContentAction.UpdateProgressAction(NORMAL_TAB_ID, 10)).join() - store.dispatch(ContentAction.UpdateProgressAction(NORMAL_TAB_ID, 50)).join() - store.dispatch(ContentAction.UpdateProgressAction(NORMAL_TAB_ID, 99)).join() - store.waitUntilIdle() // wait for the actions dispatched from PdfStateMiddleware to be handled in CaptureActionsMiddleware + store.dispatch(ContentAction.UpdateProgressAction(NORMAL_TAB_ID, 10)) + store.dispatch(ContentAction.UpdateProgressAction(NORMAL_TAB_ID, 50)) + store.dispatch(ContentAction.UpdateProgressAction(NORMAL_TAB_ID, 99)) // If the action is not dispatched then the below call would throw an AssertionError. assertNull(captureActionsMiddleware.findLastAction(ContentAction.EnteredPdfViewer::class)) @@ -53,7 +51,7 @@ class PdfStateMiddlewareTest { middleware = listOf(PdfStateMiddleware(this), captureActionsMiddleware), ) - store.dispatch(ContentAction.UpdateProgressAction(NORMAL_TAB_ID, 100)).join() + store.dispatch(ContentAction.UpdateProgressAction(NORMAL_TAB_ID, 100)) testScheduler.advanceUntilIdle() // wait for the actions dispatched from PdfStateMiddleware to be handled in CaptureActionsMiddleware assertTrue(captureActionsMiddleware.findFirstAction(ContentAction.EnteredPdfViewer::class).tabId == NORMAL_TAB_ID) @@ -66,7 +64,7 @@ class PdfStateMiddlewareTest { middleware = listOf(PdfStateMiddleware(this), captureActionsMiddleware), ) - store.dispatch(ContentAction.UpdateProgressAction(CUSTOM_TAB_ID, 100)).join() + store.dispatch(ContentAction.UpdateProgressAction(CUSTOM_TAB_ID, 100)) testScheduler.advanceUntilIdle() // wait for the actions dispatched from PdfStateMiddleware to be handled in CaptureActionsMiddleware assertTrue(captureActionsMiddleware.findFirstAction(ContentAction.EnteredPdfViewer::class).tabId == CUSTOM_TAB_ID) @@ -82,7 +80,7 @@ class PdfStateMiddlewareTest { middleware = listOf(PdfStateMiddleware(this), captureActionsMiddleware), ) - store.dispatch(ContentAction.UpdateProgressAction(NORMAL_TAB_ID, 100)).join() + store.dispatch(ContentAction.UpdateProgressAction(NORMAL_TAB_ID, 100)) testScheduler.advanceUntilIdle() // wait for the actions dispatched from PdfStateMiddleware to be handled in CaptureActionsMiddleware assertTrue(captureActionsMiddleware.findFirstAction(ContentAction.ExitedPdfViewer::class).tabId == NORMAL_TAB_ID) @@ -98,7 +96,7 @@ class PdfStateMiddlewareTest { middleware = listOf(PdfStateMiddleware(this), captureActionsMiddleware), ) - store.dispatch(ContentAction.UpdateProgressAction(CUSTOM_TAB_ID, 100)).join() + store.dispatch(ContentAction.UpdateProgressAction(CUSTOM_TAB_ID, 100)) testScheduler.advanceUntilIdle() // wait for the actions dispatched from PdfStateMiddleware to be handled in CaptureActionsMiddleware assertTrue(captureActionsMiddleware.findFirstAction(ContentAction.ExitedPdfViewer::class).tabId == CUSTOM_TAB_ID) @@ -126,7 +124,7 @@ class PdfStateMiddlewareTest { middleware = listOf(PdfStateMiddleware(this), captureActionsMiddleware), ) - store.dispatch(ContentAction.UpdateProgressAction(NORMAL_TAB_ID, 100)).join() + store.dispatch(ContentAction.UpdateProgressAction(NORMAL_TAB_ID, 100)) testScheduler.advanceUntilIdle() // wait for the actions dispatched from PdfStateMiddleware to be handled in CaptureActionsMiddleware assertTrue(captureActionsMiddleware.findFirstAction(ContentAction.ExitedPdfViewer::class).tabId == NORMAL_TAB_ID) diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/SessionPrioritizationMiddlewareTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/SessionPrioritizationMiddlewareTest.kt @@ -16,8 +16,6 @@ import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.EngineSession.SessionPriority.DEFAULT import mozilla.components.concept.engine.EngineSession.SessionPriority.HIGH import mozilla.components.support.test.any -import mozilla.components.support.test.ext.joinBlocking -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 @@ -47,8 +45,8 @@ class SessionPrioritizationMiddlewareTest { ) val engineSession1: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)).joinBlocking() - store.dispatch(EngineAction.UnlinkEngineSessionAction("1")).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)) + store.dispatch(EngineAction.UnlinkEngineSessionAction("1")) verify(engineSession1).updateSessionPriority(DEFAULT) assertEquals("", middleware.previousHighestPriorityTabId) @@ -68,15 +66,14 @@ class SessionPrioritizationMiddlewareTest { ) val engineSession1: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)).joinBlocking() - store.dispatch(ContentAction.UpdateHasFormDataAction("1", false)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)) + store.dispatch(ContentAction.UpdateHasFormDataAction("1", false)) verify(engineSession1).updateSessionPriority(DEFAULT) - store.dispatch(ContentAction.UpdateHasFormDataAction("1", true)).joinBlocking() + store.dispatch(ContentAction.UpdateHasFormDataAction("1", true)) verify(engineSession1).updateSessionPriority(HIGH) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() capture.assertLastAction(ContentAction.UpdatePriorityToDefaultAfterTimeoutAction::class) {} } @@ -94,9 +91,9 @@ class SessionPrioritizationMiddlewareTest { ) val engineSession1: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)) - store.dispatch(ContentAction.UpdateHasFormDataAction("1", true, false)).joinBlocking() + store.dispatch(ContentAction.UpdateHasFormDataAction("1", true, false)) verify(engineSession1, never()).updateSessionPriority(any()) } @@ -113,11 +110,11 @@ class SessionPrioritizationMiddlewareTest { ) val engineSession1: EngineSession = mock() - store.dispatch(TabListAction.SelectTabAction("1")).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("1")) assertEquals("", middleware.previousHighestPriorityTabId) - store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)) assertEquals("1", middleware.previousHighestPriorityTabId) verify(engineSession1).updateSessionPriority(HIGH) @@ -138,20 +135,20 @@ class SessionPrioritizationMiddlewareTest { val engineSession1: EngineSession = mock() val engineSession2: EngineSession = mock() - store.dispatch(TabListAction.SelectTabAction("1")).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("1")) assertEquals("", middleware.previousHighestPriorityTabId) - store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)) assertEquals("1", middleware.previousHighestPriorityTabId) verify(engineSession1).updateSessionPriority(HIGH) - store.dispatch(TabListAction.SelectTabAction("2")).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("2")) assertEquals("1", middleware.previousHighestPriorityTabId) - store.dispatch(EngineAction.LinkEngineSessionAction("2", engineSession2)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("2", engineSession2)) assertEquals("2", middleware.previousHighestPriorityTabId) verify(engineSession1).checkForFormData() @@ -171,7 +168,7 @@ class SessionPrioritizationMiddlewareTest { middleware = listOf(middleware), ) - store.dispatch(TabListAction.SelectTabAction("1")).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("1")) assertEquals("", middleware.previousHighestPriorityTabId) } @@ -190,11 +187,11 @@ class SessionPrioritizationMiddlewareTest { val engineSession1: EngineSession = mock() - store.dispatch(TabListAction.SelectTabAction("1")).joinBlocking() - store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("1")) + store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)) verify(engineSession1).updateSessionPriority(HIGH) - store.dispatch(AppLifecycleAction.PauseAction).joinBlocking() + store.dispatch(AppLifecycleAction.PauseAction) verify(engineSession1).checkForFormData(adjustPriority = false) } @@ -212,24 +209,24 @@ class SessionPrioritizationMiddlewareTest { val engineSession1: EngineSession = mock() - store.dispatch(TabListAction.SelectTabAction("1")).joinBlocking() - store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("1")) + store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)) verify(engineSession1).updateSessionPriority(HIGH) assertEquals("1", middleware.previousHighestPriorityTabId) // Previously, `UpdateHasFormDataAction` could be dispatched after `PauseAction` wrongly. - store.dispatch(ContentAction.UpdateHasFormDataAction("1", false)).joinBlocking() + store.dispatch(ContentAction.UpdateHasFormDataAction("1", false)) verify(engineSession1).updateSessionPriority(DEFAULT) assertEquals("1", middleware.previousHighestPriorityTabId) clearInvocations(engineSession1) - store.dispatch(EngineAction.UnlinkEngineSessionAction("1")).joinBlocking() + store.dispatch(EngineAction.UnlinkEngineSessionAction("1")) verify(engineSession1).updateSessionPriority(DEFAULT) assertEquals("", middleware.previousHighestPriorityTabId) // Previously, `updateSessionPriority` will never be called. clearInvocations(engineSession1) - store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)) verify(engineSession1).updateSessionPriority(HIGH) assertEquals("1", middleware.previousHighestPriorityTabId) } diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/SuspendMiddlewareTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/SuspendMiddlewareTest.kt @@ -12,8 +12,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.EngineSessionState -import mozilla.components.support.test.ext.joinBlocking -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 @@ -43,14 +41,13 @@ class SuspendMiddlewareTest { ) val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)) val state: EngineSessionState = mock() - store.dispatch(EngineAction.UpdateEngineSessionStateAction(tab.id, state)).joinBlocking() + store.dispatch(EngineAction.UpdateEngineSessionStateAction(tab.id, state)) - store.dispatch(EngineAction.SuspendEngineSessionAction(tab.id)).joinBlocking() + store.dispatch(EngineAction.SuspendEngineSessionAction(tab.id)) - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() assertNull(store.state.findTabOrCustomTab(tab.id)?.engineState?.engineSession) @@ -69,14 +66,13 @@ class SuspendMiddlewareTest { ) val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)) val state: EngineSessionState = mock() - store.dispatch(EngineAction.UpdateEngineSessionStateAction(tab.id, state)).joinBlocking() + store.dispatch(EngineAction.UpdateEngineSessionStateAction(tab.id, state)) - store.dispatch(EngineAction.SuspendEngineSessionAction(tab.id)).joinBlocking() + store.dispatch(EngineAction.SuspendEngineSessionAction(tab.id)) - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() assertNull(store.state.findTabOrCustomTab(tab.id)?.engineState?.engineSession) @@ -95,7 +91,7 @@ class SuspendMiddlewareTest { ), ) - store.dispatch(EngineAction.SuspendEngineSessionAction("invalid")).joinBlocking() + store.dispatch(EngineAction.SuspendEngineSessionAction("invalid")) verify(store, never()).dispatch(EngineAction.UnlinkEngineSessionAction("invalid")) } @@ -111,7 +107,7 @@ class SuspendMiddlewareTest { ), ) - store.dispatch(EngineAction.SuspendEngineSessionAction(tab.id)).joinBlocking() + store.dispatch(EngineAction.SuspendEngineSessionAction(tab.id)) verify(store, never()).dispatch(EngineAction.UnlinkEngineSessionAction(tab.id)) } @@ -130,18 +126,16 @@ class SuspendMiddlewareTest { ) val engineSession: EngineSession = mock() - suspendStore.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)).joinBlocking() - killStore.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)).joinBlocking() + suspendStore.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)) + killStore.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)) val state: EngineSessionState = mock() - suspendStore.dispatch(EngineAction.UpdateEngineSessionStateAction(tab.id, state)).joinBlocking() - killStore.dispatch(EngineAction.UpdateEngineSessionStateAction(tab.id, state)).joinBlocking() + suspendStore.dispatch(EngineAction.UpdateEngineSessionStateAction(tab.id, state)) + killStore.dispatch(EngineAction.UpdateEngineSessionStateAction(tab.id, state)) - suspendStore.dispatch(EngineAction.SuspendEngineSessionAction(tab.id)).joinBlocking() - killStore.dispatch(EngineAction.KillEngineSessionAction(tab.id)).joinBlocking() + suspendStore.dispatch(EngineAction.SuspendEngineSessionAction(tab.id)) + killStore.dispatch(EngineAction.KillEngineSessionAction(tab.id)) - suspendStore.waitUntilIdle() - killStore.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() assertNull(suspendStore.state.findTabOrCustomTab(tab.id)?.engineState?.engineSession) diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/TabsRemovedMiddlewareTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/TabsRemovedMiddlewareTest.kt @@ -18,8 +18,6 @@ import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession import mozilla.components.lib.state.Middleware import mozilla.components.lib.state.MiddlewareContext -import mozilla.components.support.test.ext.joinBlocking -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 @@ -47,8 +45,7 @@ class TabsRemovedMiddlewareTest { ) val engineSession = linkEngineSession(store, tab.id) - store.dispatch(TabListAction.RemoveTabAction(tab.id)).joinBlocking() - store.waitUntilIdle() + store.dispatch(TabListAction.RemoveTabAction(tab.id)) dispatcher.scheduler.advanceUntilIdle() assertNull(store.state.findTab(tab.id)?.engineState?.engineSession) @@ -72,8 +69,7 @@ class TabsRemovedMiddlewareTest { val engineSession2 = linkEngineSession(store, tab2.id) val engineSession3 = linkEngineSession(store, tab3.id) - store.dispatch(TabListAction.RemoveTabsAction(listOf(tab1.id, tab2.id))).joinBlocking() - store.waitUntilIdle() + store.dispatch(TabListAction.RemoveTabsAction(listOf(tab1.id, tab2.id))) dispatcher.scheduler.advanceUntilIdle() assertNull(store.state.findTab(tab1.id)?.engineState?.engineSession) @@ -100,8 +96,7 @@ class TabsRemovedMiddlewareTest { val engineSession2 = linkEngineSession(store, tab2.id) val engineSession3 = linkEngineSession(store, tab3.id) - store.dispatch(TabListAction.RemoveAllNormalTabsAction).joinBlocking() - store.waitUntilIdle() + store.dispatch(TabListAction.RemoveAllNormalTabsAction) dispatcher.scheduler.advanceUntilIdle() assertNull(store.state.findTab(tab1.id)?.engineState?.engineSession) @@ -128,8 +123,7 @@ class TabsRemovedMiddlewareTest { val engineSession2 = linkEngineSession(store, tab2.id) val engineSession3 = linkEngineSession(store, tab3.id) - store.dispatch(TabListAction.RemoveAllPrivateTabsAction).joinBlocking() - store.waitUntilIdle() + store.dispatch(TabListAction.RemoveAllPrivateTabsAction) dispatcher.scheduler.advanceUntilIdle() assertNull(store.state.findTab(tab1.id)?.engineState?.engineSession) @@ -156,8 +150,7 @@ class TabsRemovedMiddlewareTest { val engineSession2 = linkEngineSession(store, tab2.id) val engineSession3 = linkEngineSession(store, tab3.id) - store.dispatch(TabListAction.RemoveAllTabsAction()).joinBlocking() - store.waitUntilIdle() + store.dispatch(TabListAction.RemoveAllTabsAction()) dispatcher.scheduler.advanceUntilIdle() assertNull(store.state.findTab(tab1.id)?.engineState?.engineSession) @@ -179,8 +172,7 @@ class TabsRemovedMiddlewareTest { ) val engineSession = linkEngineSession(store, tab.id) - store.dispatch(CustomTabListAction.RemoveCustomTabAction(tab.id)).joinBlocking() - store.waitUntilIdle() + store.dispatch(CustomTabListAction.RemoveCustomTabAction(tab.id)) dispatcher.scheduler.advanceUntilIdle() assertNull(store.state.findTab(tab.id)?.engineState?.engineSession) @@ -203,8 +195,7 @@ class TabsRemovedMiddlewareTest { val engineSession2 = linkEngineSession(store, tab2.id) val engineSession3 = linkEngineSession(store, tab3.id) - store.dispatch(CustomTabListAction.RemoveAllCustomTabsAction).joinBlocking() - store.waitUntilIdle() + store.dispatch(CustomTabListAction.RemoveAllCustomTabsAction) dispatcher.scheduler.advanceUntilIdle() assertNull(store.state.findCustomTab(tab1.id)?.engineState?.engineSession) @@ -217,7 +208,7 @@ class TabsRemovedMiddlewareTest { private fun linkEngineSession(store: BrowserStore, tabId: String): EngineSession { val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction(tabId, engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(tabId, engineSession)) assertNotNull(store.state.findTabOrCustomTab(tabId)?.engineState?.engineSession) return engineSession } diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/TranslationsMiddlewareTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/TranslationsMiddlewareTest.kt @@ -38,7 +38,6 @@ import mozilla.components.lib.state.MiddlewareContext import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor import mozilla.components.support.test.eq -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.whenever import org.junit.Before @@ -804,7 +803,7 @@ class TranslationsMiddlewareTest { tabId = tab.id, operation = TranslationOperation.FETCH_NEVER_TRANSLATE_SITES, ), - ).joinBlocking() + ) scope.testScheduler.advanceUntilIdle() verify(store).dispatch( diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/TrimMemoryMiddlewareTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/TrimMemoryMiddlewareTest.kt @@ -15,8 +15,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.EngineSessionState -import mozilla.components.support.test.ext.joinBlocking -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.assertNotNull @@ -132,9 +130,8 @@ class TrimMemoryMiddlewareTest { SystemAction.LowMemoryAction( level = ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN, ), - ).joinBlocking() + ) - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() store.state.findTab("theverge")!!.engineState.apply { @@ -198,9 +195,8 @@ class TrimMemoryMiddlewareTest { SystemAction.LowMemoryAction( level = ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL, ), - ).joinBlocking() + ) - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() store.state.findTab("theverge")!!.engineState.apply { diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/WebExtensionMiddlewareTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/WebExtensionMiddlewareTest.kt @@ -10,7 +10,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.concept.engine.EngineSession -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import org.junit.Assert.assertEquals import org.junit.Assert.assertNull @@ -37,19 +36,19 @@ class WebExtensionMiddlewareTest { val engineSession1: EngineSession = mock() val engineSession2: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)).joinBlocking() - store.dispatch(EngineAction.LinkEngineSessionAction("2", engineSession2)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)) + store.dispatch(EngineAction.LinkEngineSessionAction("2", engineSession2)) assertNull(store.state.activeWebExtensionTabId) verify(engineSession1, never()).markActiveForWebExtensions(anyBoolean()) verify(engineSession2, never()).markActiveForWebExtensions(anyBoolean()) - store.dispatch(TabListAction.SelectTabAction("1")).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("1")) assertEquals("1", store.state.activeWebExtensionTabId) verify(engineSession1).markActiveForWebExtensions(true) verify(engineSession2, never()).markActiveForWebExtensions(anyBoolean()) - store.dispatch(TabListAction.SelectTabAction("2")).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("2")) assertEquals("2", store.state.activeWebExtensionTabId) verify(engineSession1).markActiveForWebExtensions(false) verify(engineSession2).markActiveForWebExtensions(true) @@ -76,7 +75,7 @@ class WebExtensionMiddlewareTest { verify(engineSession1, never()).markActiveForWebExtensions(anyBoolean()) verify(engineSession2, never()).markActiveForWebExtensions(anyBoolean()) - store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)) assertEquals("1", store.state.activeWebExtensionTabId) verify(engineSession1).markActiveForWebExtensions(true) verify(engineSession2, never()).markActiveForWebExtensions(anyBoolean()) @@ -97,11 +96,11 @@ class WebExtensionMiddlewareTest { ) val engineSession1: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)) assertEquals("1", store.state.activeWebExtensionTabId) verify(engineSession1).markActiveForWebExtensions(true) - store.dispatch(EngineAction.UnlinkEngineSessionAction("1")).joinBlocking() + store.dispatch(EngineAction.UnlinkEngineSessionAction("1")) verify(engineSession1).markActiveForWebExtensions(false) } @@ -121,14 +120,14 @@ class WebExtensionMiddlewareTest { val engineSession1: EngineSession = mock() val engineSession2: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)).joinBlocking() - store.dispatch(EngineAction.LinkEngineSessionAction("2", engineSession2)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("1", engineSession1)) + store.dispatch(EngineAction.LinkEngineSessionAction("2", engineSession2)) - store.dispatch(TabListAction.SelectTabAction("1")).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("1")) assertEquals("1", store.state.activeWebExtensionTabId) verify(engineSession2, never()).markActiveForWebExtensions(anyBoolean()) - store.dispatch(TabListAction.RemoveTabAction("1")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("1")) assertEquals("2", store.state.activeWebExtensionTabId) verify(engineSession2).markActiveForWebExtensions(true) } diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/helper/TargetTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/helper/TargetTest.kt @@ -9,7 +9,6 @@ import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.state.createCustomTab import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore -import mozilla.components.support.test.ext.joinBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Test @@ -69,7 +68,7 @@ class TargetTest { store.dispatch( TabListAction.SelectTabAction("example"), - ).joinBlocking() + ) assertEquals( "https://www.example.org", @@ -78,7 +77,7 @@ class TargetTest { store.dispatch( TabListAction.RemoveAllTabsAction(), - ).joinBlocking() + ) assertNull( Target.SelectedTab.lookupIn(store), diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/reducer/ContentStateReducerTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/reducer/ContentStateReducerTest.kt @@ -44,7 +44,7 @@ class ContentStateReducerTest { initialState = BrowserState(tabs = listOf(mock(), currentTab)), ) - browserStore.dispatch(ContentAction.EnteredPdfViewer(currentTabId)).join() + browserStore.dispatch(ContentAction.EnteredPdfViewer(currentTabId)) assertTrue(browserStore.state.findTabOrCustomTabOrSelectedTab(currentTabId)!!.content.isPdf) } @@ -63,7 +63,7 @@ class ContentStateReducerTest { initialState = BrowserState(tabs = listOf(mock(), currentTab)), ) - browserStore.dispatch(ContentAction.ExitedPdfViewer(currentTabId)).join() + browserStore.dispatch(ContentAction.ExitedPdfViewer(currentTabId)) assertFalse(browserStore.state.findTabOrCustomTabOrSelectedTab(currentTabId)!!.content.isPdf) } diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/selector/SelectorsKtTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/selector/SelectorsKtTest.kt @@ -12,7 +12,6 @@ import mozilla.components.browser.state.state.createCustomTab import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull @@ -29,21 +28,21 @@ class SelectorsKtTest { store.dispatch( CustomTabListAction.AddCustomTabAction(createCustomTab("https://www.mozilla.org")), - ).joinBlocking() + ) assertNull(store.state.selectedTab) val tab = createTab("https://www.firefox.com") - store.dispatch(TabListAction.AddTabAction(tab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab, select = true)) assertEquals(tab, store.state.selectedTab) val otherTab = createTab("https://getpocket.com", lastAccess = tabLastAccessTimeStamp) - store.dispatch(TabListAction.AddTabAction(otherTab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(otherTab)) assertEquals(tab, store.state.selectedTab) - store.dispatch(TabListAction.SelectTabAction(otherTab.id)).joinBlocking() + store.dispatch(TabListAction.SelectTabAction(otherTab.id)) assertEquals(otherTab, store.state.selectedTab) } @@ -56,19 +55,19 @@ class SelectorsKtTest { store.dispatch( CustomTabListAction.AddCustomTabAction(createCustomTab("https://www.mozilla.org")), - ).joinBlocking() + ) assertNull(store.state.selectedNormalTab) val privateTab = createTab("https://www.firefox.com", private = true) - store.dispatch(TabListAction.AddTabAction(privateTab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(privateTab, select = true)) assertNull(store.state.selectedNormalTab) val normalTab = createTab("https://getpocket.com", lastAccess = tabLastAccessTimeStamp) - store.dispatch(TabListAction.AddTabAction(normalTab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(normalTab)) assertNull(store.state.selectedNormalTab) - store.dispatch(TabListAction.SelectTabAction(normalTab.id)).joinBlocking() + store.dispatch(TabListAction.SelectTabAction(normalTab.id)) assertEquals(normalTab, store.state.selectedNormalTab) } diff --git a/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/store/BrowserStoreExceptionTest.kt b/mobile/android/android-components/components/browser/state/src/test/java/mozilla/components/browser/state/store/BrowserStoreExceptionTest.kt @@ -12,7 +12,6 @@ import mozilla.components.browser.state.state.TabGroup import mozilla.components.browser.state.state.TabPartition import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.state.recover.toRecoverableTab -import mozilla.components.support.test.ext.joinBlocking import org.junit.Test import org.junit.runner.RunWith @@ -28,29 +27,28 @@ class BrowserStoreExceptionTest { val parent = createTab("https://www.mozilla.org") val child = createTab("https://www.firefox.com", parent = parent) - store.dispatch(TabListAction.AddTabAction(child)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(child)) } @Test(expected = IllegalArgumentException::class) fun `AddTabAction - Exception is thrown if tab already exists`() { val store = BrowserStore() val tab1 = createTab("https://www.mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab1)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab1)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab1)) + store.dispatch(TabListAction.AddTabAction(tab1)) } @Test(expected = IllegalArgumentException::class) fun `RestoreTabAction - Exception is thrown if tab already exists`() { val store = BrowserStore() val tab1 = createTab("https://www.mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab1)).joinBlocking() - + store.dispatch(TabListAction.AddTabAction(tab1)) store.dispatch( TabListAction.RestoreAction( listOf(tab1.toRecoverableTab()), restoreLocation = TabListAction.RestoreAction.RestoreLocation.BEGINNING, ), - ).joinBlocking() + ) } @Test(expected = IllegalArgumentException::class) @@ -69,7 +67,7 @@ class BrowserStoreExceptionTest { createTab(id = "a", url = "https://www.example.org"), ), ), - ).joinBlocking() + ) } @Test(expected = IllegalArgumentException::class) @@ -92,7 +90,7 @@ class BrowserStoreExceptionTest { TabListAction.AddMultipleTabsAction( tabs = listOf(tab1, tab2), ), - ).joinBlocking() + ) } @Test(expected = IllegalArgumentException::class) @@ -115,7 +113,7 @@ class BrowserStoreExceptionTest { partition = partitionId, group = testGroup, ), - ).joinBlocking() + ) } @Test(expected = IllegalArgumentException::class) @@ -129,7 +127,7 @@ class BrowserStoreExceptionTest { partition = partition, group = testGroup, ), - ).joinBlocking() + ) } @Test(expected = IllegalArgumentException::class) @@ -146,7 +144,6 @@ class BrowserStoreExceptionTest { val tab = createTab(id = "tab1", url = "https://firefox.com") store.dispatch(TabGroupAction.AddTabAction(tabPartition.id, tabGroup.id, tab.id)) - .joinBlocking() } @Test(expected = IllegalArgumentException::class) @@ -165,6 +162,6 @@ class BrowserStoreExceptionTest { store.dispatch( TabGroupAction.AddTabsAction(tabPartition.id, tabGroup.id, listOf(tab1.id, tab2.id)), - ).joinBlocking() + ) } } diff --git a/mobile/android/android-components/components/browser/thumbnails/src/test/java/mozilla/components/browser/thumbnails/BrowserThumbnailsTest.kt b/mobile/android/android-components/components/browser/thumbnails/src/test/java/mozilla/components/browser/thumbnails/BrowserThumbnailsTest.kt @@ -12,7 +12,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineView import mozilla.components.support.test.any -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule @@ -60,7 +59,7 @@ class BrowserThumbnailsTest { thumbnails.start() thumbnails.stop() - store.dispatch(ContentAction.UpdateThumbnailAction(tabId, mock())).joinBlocking() + store.dispatch(ContentAction.UpdateThumbnailAction(tabId, mock())) verifyNoMoreInteractions(engineView) } @@ -70,7 +69,7 @@ class BrowserThumbnailsTest { fun `feature must capture thumbnail when a site finishes loading and first paint`() { val bitmap: Bitmap? = mock() - store.dispatch(ContentAction.UpdateLoadingStateAction(tabId, true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction(tabId, true)) thumbnails.start() @@ -82,8 +81,8 @@ class BrowserThumbnailsTest { verify(store, never()).dispatch(ContentAction.UpdateThumbnailAction(tabId, bitmap!!)) - store.dispatch(ContentAction.UpdateLoadingStateAction(tabId, false)).joinBlocking() - store.dispatch(ContentAction.UpdateFirstContentfulPaintStateAction(tabId, true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction(tabId, false)) + store.dispatch(ContentAction.UpdateFirstContentfulPaintStateAction(tabId, true)) verify(store).dispatch(ContentAction.UpdateThumbnailAction(tabId, bitmap)) } @@ -132,7 +131,7 @@ class BrowserThumbnailsTest { @Test fun `when a page is loaded and the os is in low memory condition thumbnail should not be captured`() { - store.dispatch(ContentAction.UpdateThumbnailAction(tabId, mock())).joinBlocking() + store.dispatch(ContentAction.UpdateThumbnailAction(tabId, mock())) thumbnails.testLowMemory = true diff --git a/mobile/android/android-components/components/browser/thumbnails/src/test/java/mozilla/components/browser/thumbnails/HomepageThumbnailsTest.kt b/mobile/android/android-components/components/browser/thumbnails/src/test/java/mozilla/components/browser/thumbnails/HomepageThumbnailsTest.kt @@ -13,8 +13,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.lib.state.Middleware -import mozilla.components.support.test.ext.joinBlocking -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 @@ -62,8 +60,6 @@ class HomepageThumbnailsTest { fun `capture thumbnail when homepage is opened`() { thumbnails.start() - store.waitUntilIdle() - captureActionsMiddleware.assertLastAction(ContentAction.UpdateThumbnailAction::class) { assertEquals(tabId, this.tabId) assertEquals(bitmap, this.bitmap) @@ -78,8 +74,6 @@ class HomepageThumbnailsTest { } feature.start() - store.waitUntilIdle() - captureActionsMiddleware.assertNotDispatched(ContentAction.UpdateThumbnailAction::class) } @@ -92,21 +86,17 @@ class HomepageThumbnailsTest { } feature.start() - store.waitUntilIdle() - store.dispatch( TabListAction.AddTabAction( createTab(homepageUrl, id = "1"), ), - ).joinBlocking() + ) store.dispatch( TabListAction.SelectTabAction( tabId = "1", ), - ).joinBlocking() - - store.waitUntilIdle() + ) captureActionsMiddleware.assertLastAction(ContentAction.UpdateThumbnailAction::class) { assertEquals("1", it.sessionId) @@ -116,15 +106,13 @@ class HomepageThumbnailsTest { TabListAction.AddTabAction( createTab(homepageUrl, id = "2"), ), - ).joinBlocking() + ) store.dispatch( TabListAction.SelectTabAction( "2", ), - ).joinBlocking() - - store.waitUntilIdle() + ) captureActionsMiddleware.assertLastAction(ContentAction.UpdateThumbnailAction::class) { assertEquals("2", it.sessionId) @@ -134,15 +122,13 @@ class HomepageThumbnailsTest { TabListAction.AddTabAction( createTab("www.google.com", id = "3"), ), - ).joinBlocking() + ) store.dispatch( TabListAction.SelectTabAction( tabId = "3", ), - ).joinBlocking() - - store.waitUntilIdle() + ) captureActionsMiddleware.assertLastAction(ContentAction.UpdateThumbnailAction::class) { assertEquals("2", it.sessionId) @@ -152,15 +138,13 @@ class HomepageThumbnailsTest { TabListAction.AddTabAction( createTab(homepageUrl, id = "4"), ), - ).joinBlocking() + ) store.dispatch( TabListAction.SelectTabAction( tabId = "4", ), - ).joinBlocking() - - store.waitUntilIdle() + ) captureActionsMiddleware.assertLastAction(ContentAction.UpdateThumbnailAction::class) { assertEquals("4", it.sessionId) @@ -180,9 +164,7 @@ class HomepageThumbnailsTest { TabListAction.AddTabAction( createTab(homepageUrl, id = "1"), ), - ).joinBlocking() - - store.waitUntilIdle() + ) captureActionsMiddleware.assertNotDispatched(ContentAction.UpdateThumbnailAction::class) } @@ -192,8 +174,6 @@ class HomepageThumbnailsTest { thumbnails = HomepageThumbnails(testContext, store, homepageUrl) thumbnails.start() - store.waitUntilIdle() - captureActionsMiddleware.assertNotDispatched(ContentAction.UpdateThumbnailAction::class) } @@ -215,8 +195,6 @@ class HomepageThumbnailsTest { feature.start() - store.waitUntilIdle() - captureActionsMiddleware.assertNotDispatched(ContentAction.UpdateThumbnailAction::class) } @@ -226,8 +204,6 @@ class HomepageThumbnailsTest { thumbnails.start() - store.waitUntilIdle() - captureActionsMiddleware.assertNotDispatched(ContentAction.UpdateThumbnailAction::class) } } diff --git a/mobile/android/android-components/components/browser/thumbnails/src/test/java/mozilla/components/browser/thumbnails/ThumbnailsMiddlewareTest.kt b/mobile/android/android-components/components/browser/thumbnails/src/test/java/mozilla/components/browser/thumbnails/ThumbnailsMiddlewareTest.kt @@ -14,7 +14,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.browser.thumbnails.storage.ThumbnailStorage import mozilla.components.concept.base.images.ImageSaveRequest -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.mock import org.junit.Test @@ -34,7 +33,7 @@ class ThumbnailsMiddlewareTest { ) val bitmap: Bitmap = mock() - store.dispatch(ContentAction.UpdateThumbnailAction(request.id, bitmap)).joinBlocking() + store.dispatch(ContentAction.UpdateThumbnailAction(request.id, bitmap)) verify(thumbnailStorage).saveThumbnail(request, bitmap) } @@ -49,7 +48,7 @@ class ThumbnailsMiddlewareTest { ) val bitmap: Bitmap = mock() - store.dispatch(ContentAction.UpdateThumbnailAction(request.id, bitmap)).joinBlocking() + store.dispatch(ContentAction.UpdateThumbnailAction(request.id, bitmap)) verify(thumbnailStorage).saveThumbnail(request, bitmap) } @@ -68,7 +67,7 @@ class ThumbnailsMiddlewareTest { middleware = listOf(ThumbnailsMiddleware(thumbnailStorage)), ) - store.dispatch(TabListAction.RemoveAllNormalTabsAction).joinBlocking() + store.dispatch(TabListAction.RemoveAllNormalTabsAction) verify(thumbnailStorage).deleteThumbnail("test-tab1", false) verify(thumbnailStorage).deleteThumbnail("test-tab2", false) verify(thumbnailStorage).deleteThumbnail("test-tab3", false) @@ -90,7 +89,7 @@ class ThumbnailsMiddlewareTest { middleware = listOf(ThumbnailsMiddleware(thumbnailStorage)), ) - store.dispatch(TabListAction.RemoveAllPrivateTabsAction).joinBlocking() + store.dispatch(TabListAction.RemoveAllPrivateTabsAction) verify(thumbnailStorage, never()).deleteThumbnail("test-tab1", false) verify(thumbnailStorage).deleteThumbnail("test-tab2", true) verify(thumbnailStorage).deleteThumbnail("test-tab3", true) @@ -110,7 +109,7 @@ class ThumbnailsMiddlewareTest { middleware = listOf(ThumbnailsMiddleware(thumbnailStorage)), ) - store.dispatch(TabListAction.RemoveAllTabsAction()).joinBlocking() + store.dispatch(TabListAction.RemoveAllTabsAction()) verify(thumbnailStorage).clearThumbnails() } @@ -128,7 +127,7 @@ class ThumbnailsMiddlewareTest { middleware = listOf(ThumbnailsMiddleware(thumbnailStorage)), ) - store.dispatch(TabListAction.RemoveTabAction(sessionIdOrUrl)).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction(sessionIdOrUrl)) verify(thumbnailStorage).deleteThumbnail(sessionIdOrUrl, false) } @@ -146,7 +145,7 @@ class ThumbnailsMiddlewareTest { middleware = listOf(ThumbnailsMiddleware(thumbnailStorage)), ) - store.dispatch(TabListAction.RemoveTabAction(sessionIdOrUrl)).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction(sessionIdOrUrl)) verify(thumbnailStorage).deleteThumbnail(sessionIdOrUrl, true) } @@ -164,7 +163,7 @@ class ThumbnailsMiddlewareTest { middleware = listOf(ThumbnailsMiddleware(thumbnailStorage)), ) - store.dispatch(TabListAction.RemoveTabsAction(listOf(sessionIdOrUrl))).joinBlocking() + store.dispatch(TabListAction.RemoveTabsAction(listOf(sessionIdOrUrl))) verify(thumbnailStorage).deleteThumbnail(sessionIdOrUrl, false) } @@ -184,8 +183,8 @@ class ThumbnailsMiddlewareTest { ), ) - store.dispatch(ContentAction.UpdateThumbnailAction("test-tab1", mock())).joinBlocking() - store.dispatch(TabListAction.RemoveTabAction("test-tab1")).joinBlocking() + store.dispatch(ContentAction.UpdateThumbnailAction("test-tab1", mock())) + store.dispatch(TabListAction.RemoveTabAction("test-tab1")) // We shouldn't allow thumbnail actions to continue being processed. capture.assertNotDispatched(ContentAction.UpdateThumbnailAction::class) @@ -193,7 +192,7 @@ class ThumbnailsMiddlewareTest { capture.assertLastAction(TabListAction.RemoveTabAction::class) {} // All other actions should also continue being processed. - store.dispatch(EngineAction.KillEngineSessionAction("test-tab1")).joinBlocking() + store.dispatch(EngineAction.KillEngineSessionAction("test-tab1")) capture.assertLastAction(EngineAction.KillEngineSessionAction::class) {} } } diff --git a/mobile/android/android-components/components/feature/app-links/src/test/java/mozilla/components/feature/app/links/AppLinksFeatureTest.kt b/mobile/android/android-components/components/feature/app-links/src/test/java/mozilla/components/feature/app/links/AppLinksFeatureTest.kt @@ -24,8 +24,6 @@ import mozilla.components.concept.engine.EngineSession import mozilla.components.feature.session.SessionUseCases import mozilla.components.support.test.any import mozilla.components.support.test.eq -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.After @@ -114,14 +112,13 @@ class AppLinksFeatureTest { @Test fun `WHEN feature started THEN feature observes app intents`() { val tab = createTab(webUrl) - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) verify(feature, never()).handleAppIntent(any(), any(), any(), any(), any()) val intent: Intent = mock() val appIntent = AppIntentState(intentUrl, intent, null, null) - store.dispatch(ContentAction.UpdateAppIntentAction(tab.id, appIntent)).joinBlocking() + store.dispatch(ContentAction.UpdateAppIntentAction(tab.id, appIntent)) - store.waitUntilIdle() verify(feature).handleAppIntent(any(), any(), any(), any(), any()) val tabWithConsumedAppIntent = store.state.findTab(tab.id)!! @@ -131,14 +128,14 @@ class AppLinksFeatureTest { @Test fun `WHEN feature is stopped THEN feature doesn't observes app intents`() { val tab = createTab(webUrl) - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) verify(feature, never()).handleAppIntent(any(), any(), any(), any(), any()) feature.stop() val intent: Intent = mock() val appIntent = AppIntentState(intentUrl, intent, null, null) - store.dispatch(ContentAction.UpdateAppIntentAction(tab.id, appIntent)).joinBlocking() + store.dispatch(ContentAction.UpdateAppIntentAction(tab.id, appIntent)) verify(feature, never()).handleAppIntent(any(), any(), any(), any(), any()) } diff --git a/mobile/android/android-components/components/feature/awesomebar/src/test/java/mozilla/components/feature/awesomebar/provider/SessionSuggestionProviderTest.kt b/mobile/android/android-components/components/feature/awesomebar/src/test/java/mozilla/components/feature/awesomebar/provider/SessionSuggestionProviderTest.kt @@ -47,9 +47,9 @@ class SessionSuggestionProviderTest { assertTrue(suggestions.isEmpty()) } - store.dispatch(TabListAction.AddTabAction(tab1)).join() - store.dispatch(TabListAction.AddTabAction(tab2)).join() - store.dispatch(TabListAction.AddTabAction(tab3)).join() + store.dispatch(TabListAction.AddTabAction(tab1)) + store.dispatch(TabListAction.AddTabAction(tab2)) + store.dispatch(TabListAction.AddTabAction(tab3)) run { val suggestions = provider.onInputChanged("Example") @@ -59,7 +59,7 @@ class SessionSuggestionProviderTest { assertEquals("Switch to tab", suggestions[0].description) } - store.dispatch(TabListAction.AddTabAction(tab4)).join() + store.dispatch(TabListAction.AddTabAction(tab4)) run { val suggestions = provider.onInputChanged("Example") @@ -81,8 +81,8 @@ class SessionSuggestionProviderTest { val tab2 = createTab("https://www.mozilla.org/example/of/content") val provider = SessionSuggestionProvider(store, mock(), switchToTabDescription = "Switch to tab") - store.dispatch(TabListAction.AddTabAction(tab1)).join() - store.dispatch(TabListAction.AddTabAction(tab2)).join() + store.dispatch(TabListAction.AddTabAction(tab1)) + store.dispatch(TabListAction.AddTabAction(tab2)) run { val suggestions = provider.onInputChanged("mozilla ") @@ -105,8 +105,8 @@ class SessionSuggestionProviderTest { val tab2 = createTab("https://www.mozilla.org/example/of/content") val provider = SessionSuggestionProvider(store, mock(), switchToTabDescription = "Switch to tab") - store.dispatch(TabListAction.AddTabAction(tab1)).join() - store.dispatch(TabListAction.AddTabAction(tab2)).join() + store.dispatch(TabListAction.AddTabAction(tab1)) + store.dispatch(TabListAction.AddTabAction(tab2)) run { val suggestions = provider.onInputChanged(" mozilla") @@ -128,7 +128,7 @@ class SessionSuggestionProviderTest { val tab1 = createTab("https://www.mozilla.org/example/of/content") val provider = SessionSuggestionProvider(store, mock(), switchToTabDescription = "Switch to tab") - store.dispatch(TabListAction.AddTabAction(tab1)).join() + store.dispatch(TabListAction.AddTabAction(tab1)) run { val suggestions = provider.onInputChanged("mozilla example content") @@ -147,7 +147,7 @@ class SessionSuggestionProviderTest { val tab1 = createTab("https://www.mozilla.org/example/of/content") val provider = SessionSuggestionProvider(store, mock(), switchToTabDescription = "Switch to tab") - store.dispatch(TabListAction.AddTabAction(tab1)).join() + store.dispatch(TabListAction.AddTabAction(tab1)) run { val suggestions = provider.onInputChanged("mozilla example test") @@ -403,9 +403,9 @@ class SessionSuggestionProviderTest { assertTrue(suggestions.isEmpty()) } - store.dispatch(TabListAction.AddTabAction(tab1)).join() - store.dispatch(TabListAction.AddTabAction(tab2)).join() - store.dispatch(TabListAction.AddTabAction(tab3)).join() + store.dispatch(TabListAction.AddTabAction(tab1)) + store.dispatch(TabListAction.AddTabAction(tab2)) + store.dispatch(TabListAction.AddTabAction(tab3)) run { val suggestions = provider.onInputChanged("Mozilla") diff --git a/mobile/android/android-components/components/feature/containers/src/test/java/mozilla/components/feature/containers/ContainerMiddlewareTest.kt b/mobile/android/android-components/components/feature/containers/src/test/java/mozilla/components/feature/containers/ContainerMiddlewareTest.kt @@ -10,8 +10,6 @@ import mozilla.components.browser.state.action.ContainerAction import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.state.ContainerState import mozilla.components.browser.state.store.BrowserStore -import mozilla.components.support.test.ext.joinBlocking -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 @@ -46,10 +44,7 @@ class ContainerMiddlewareTest { middleware = listOf(middleware), ) - store.waitUntilIdle() // wait to consume InitAction - store.waitUntilIdle() // wait to consume AddContainersAction - - store.dispatch(ContainerAction.AddContainerAction(container)).joinBlocking() + store.dispatch(ContainerAction.AddContainerAction(container)) verify(storage).addContainer( container.contextId, @@ -69,9 +64,6 @@ class ContainerMiddlewareTest { middleware = listOf(middleware), ) - store.waitUntilIdle() // wait to consume InitAction - store.waitUntilIdle() // wait to consume AddContainersAction - verify(storage).getContainers() assertEquals(container, store.state.containers["contextId"]) } @@ -90,11 +82,7 @@ class ContainerMiddlewareTest { middleware = listOf(middleware), ) - store.waitUntilIdle() // wait to consume InitAction - store.waitUntilIdle() // wait to consume AddContainersAction - store.dispatch(ContainerAction.RemoveContainerAction(container.contextId)) - .joinBlocking() verify(storage).removeContainer(container) } diff --git a/mobile/android/android-components/components/feature/contextmenu/src/test/java/mozilla/components/feature/contextmenu/ContextMenuFeatureTest.kt b/mobile/android/android-components/components/feature/contextmenu/src/test/java/mozilla/components/feature/contextmenu/ContextMenuFeatureTest.kt @@ -21,8 +21,6 @@ import mozilla.components.support.base.Component import mozilla.components.support.base.facts.Action import mozilla.components.support.base.facts.processor.CollectionProcessor import mozilla.components.support.test.any -import mozilla.components.support.test.ext.joinBlocking -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 @@ -81,7 +79,7 @@ class ContextMenuFeatureTest { "test-tab", HitResult.UNKNOWN("https://www.mozilla.org"), ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() @@ -111,7 +109,7 @@ class ContextMenuFeatureTest { "test-tab", HitResult.UNKNOWN("https://www.mozilla.org"), ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() @@ -134,7 +132,7 @@ class ContextMenuFeatureTest { "test-tab", HitResult.UNKNOWN("https://www.mozilla.org"), ), - ).joinBlocking() + ) val feature = ContextMenuFeature( fragmentManager, @@ -206,7 +204,6 @@ class ContextMenuFeatureTest { ) store.dispatch(TabListAction.RemoveTabAction("test-tab")) - .joinBlocking() feature.start() @@ -263,7 +260,7 @@ class ContextMenuFeatureTest { "test-tab", HitResult.UNKNOWN("https://www.mozilla.org"), ), - ).joinBlocking() + ) val (engineView, _) = mockEngineView() @@ -279,7 +276,6 @@ class ContextMenuFeatureTest { feature.onMenuCancelled("test-tab") - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() assertNull(store.state.findTab("test-tab")!!.content.hitResult) @@ -300,7 +296,7 @@ class ContextMenuFeatureTest { "test-tab", HitResult.UNKNOWN("https://www.mozilla.org"), ), - ).joinBlocking() + ) val (engineView, view) = mockEngineView() var actionInvoked = false @@ -320,7 +316,6 @@ class ContextMenuFeatureTest { ContextMenuUseCases(store), ) - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() assertNotNull(store.state.findTab("test-tab")!!.content.hitResult) @@ -328,7 +323,6 @@ class ContextMenuFeatureTest { feature.onMenuItemSelected("test-tab", "test-id") - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() assertNull(store.state.findTab("test-tab")!!.content.hitResult) @@ -351,7 +345,7 @@ class ContextMenuFeatureTest { "test-tab", HitResult.UNKNOWN("https://www.mozilla.org"), ), - ).joinBlocking() + ) val (engineView, _) = mockEngineView() val candidate = ContextMenuCandidate( diff --git a/mobile/android/android-components/components/feature/customtabs/src/test/java/mozilla/components/feature/customtabs/CustomTabWindowFeatureTest.kt b/mobile/android/android-components/components/feature/customtabs/src/test/java/mozilla/components/feature/customtabs/CustomTabWindowFeatureTest.kt @@ -20,7 +20,6 @@ import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.window.WindowRequest import mozilla.components.support.test.any -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.whenever @@ -74,7 +73,7 @@ class CustomTabWindowFeatureTest { feature.start() whenever(windowRequest.type).thenReturn(WindowRequest.Type.OPEN) whenever(windowRequest.url).thenReturn("https://www.firefox.com") - store.dispatch(ContentAction.UpdateWindowRequestAction(sessionId, windowRequest)).joinBlocking() + store.dispatch(ContentAction.UpdateWindowRequestAction(sessionId, windowRequest)) verify(activity).startActivity(any(), any()) verify(store).dispatch(ContentAction.ConsumeWindowRequestAction(sessionId)) @@ -90,7 +89,7 @@ class CustomTabWindowFeatureTest { whenever(windowRequest.type).thenReturn(WindowRequest.Type.OPEN) whenever(windowRequest.url).thenReturn("blob:https://www.firefox.com") whenever(activity.startActivity(any(), any())).thenThrow(exception) - store.dispatch(ContentAction.UpdateWindowRequestAction(sessionId, windowRequest)).joinBlocking() + store.dispatch(ContentAction.UpdateWindowRequestAction(sessionId, windowRequest)) verify(engineSession).loadUrl("blob:https://www.firefox.com") } @@ -157,7 +156,7 @@ class CustomTabWindowFeatureTest { val windowRequest: WindowRequest = mock() whenever(windowRequest.type).thenReturn(WindowRequest.Type.OPEN) whenever(windowRequest.url).thenReturn("https://www.firefox.com") - store.dispatch(ContentAction.UpdateWindowRequestAction(sessionId, windowRequest)).joinBlocking() + store.dispatch(ContentAction.UpdateWindowRequestAction(sessionId, windowRequest)) verify(activity, never()).startActivity(any(), any()) verify(store, never()).dispatch(ContentAction.ConsumeWindowRequestAction(sessionId)) } diff --git a/mobile/android/android-components/components/feature/customtabs/src/test/java/mozilla/components/feature/customtabs/CustomTabsToolbarFeatureTest.kt b/mobile/android/android-components/components/feature/customtabs/src/test/java/mozilla/components/feature/customtabs/CustomTabsToolbarFeatureTest.kt @@ -41,7 +41,6 @@ import mozilla.components.support.ktx.android.content.res.resolveAttribute import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor import mozilla.components.support.test.eq -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext @@ -1145,7 +1144,7 @@ class CustomTabsToolbarFeatureTest { "mozilla", "https://github.com/mozilla-mobile/android-components", ), - ).joinBlocking() + ) verify(feature).addActionButton(anyInt(), any()) verify(toolbar).addBrowserAction(captor.capture()) @@ -1457,7 +1456,7 @@ class CustomTabsToolbarFeatureTest { "mozilla", "https://github.com/mozilla-mobile/android-components", ), - ).joinBlocking() + ) val menuBuilder = toolbar.display.menuBuilder!! @@ -1858,7 +1857,7 @@ class CustomTabsToolbarFeatureTest { "mozilla", "Internet for people, not profit - Mozilla", ), - ).joinBlocking() + ) assertEquals("Internet for people, not profit - Mozilla", toolbar.title) } @@ -1900,7 +1899,7 @@ class CustomTabsToolbarFeatureTest { store.dispatch( ContentAction.UpdateUrlAction("mozilla", "https://www.mozilla.org/en-US/firefox/"), - ).joinBlocking() + ) assertEquals("", toolbar.title) @@ -1909,31 +1908,31 @@ class CustomTabsToolbarFeatureTest { "mozilla", "Firefox - Protect your life online with privacy-first products", ), - ).joinBlocking() + ) assertEquals("Firefox - Protect your life online with privacy-first products", toolbar.title) store.dispatch( ContentAction.UpdateUrlAction("mozilla", "https://github.com/mozilla-mobile/android-components"), - ).joinBlocking() + ) assertEquals("https://github.com/mozilla-mobile/android-components", toolbar.title) store.dispatch( ContentAction.UpdateTitleAction("mozilla", "Le GitHub"), - ).joinBlocking() + ) assertEquals("Le GitHub", toolbar.title) store.dispatch( ContentAction.UpdateUrlAction("mozilla", "https://github.com/mozilla-mobile/fenix"), - ).joinBlocking() + ) assertEquals("https://github.com/mozilla-mobile/fenix", toolbar.title) store.dispatch( ContentAction.UpdateTitleAction("mozilla", ""), - ).joinBlocking() + ) assertEquals("https://github.com/mozilla-mobile/fenix", toolbar.title) @@ -1942,13 +1941,13 @@ class CustomTabsToolbarFeatureTest { "mozilla", "A collection of Android libraries to build browsers or browser-like applications.", ), - ).joinBlocking() + ) assertEquals("A collection of Android libraries to build browsers or browser-like applications.", toolbar.title) store.dispatch( ContentAction.UpdateTitleAction("mozilla", ""), - ).joinBlocking() + ) assertEquals("https://github.com/mozilla-mobile/fenix", toolbar.title) } diff --git a/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/AbstractFetchDownloadServiceTest.kt b/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/AbstractFetchDownloadServiceTest.kt @@ -59,8 +59,6 @@ import mozilla.components.support.base.facts.processor.CollectionProcessor import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor import mozilla.components.support.test.eq -import mozilla.components.support.test.ext.joinBlocking -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 @@ -181,7 +179,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -206,7 +204,7 @@ class AbstractFetchDownloadServiceTest { downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) @@ -224,7 +222,7 @@ class AbstractFetchDownloadServiceTest { downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) @@ -243,7 +241,7 @@ class AbstractFetchDownloadServiceTest { downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) val newDownloadState = download.copy(status = DOWNLOADING) - browserStore.dispatch(DownloadAction.AddDownloadAction(newDownloadState)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(newDownloadState)) service.onStartCommand(downloadIntent, 0, 0) @@ -262,7 +260,7 @@ class AbstractFetchDownloadServiceTest { downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) @@ -475,10 +473,9 @@ class AbstractFetchDownloadServiceTest { downloadDeleted = false, ) - browserStore.dispatch(DownloadAction.AddDownloadAction(downloadState)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(downloadState)) service.downloadJobs[downloadJobState.state.id] = downloadJobState service.verifyDownload(downloadJobState) - browserStore.waitUntilIdle() assertEquals(downloadJobState.state.contentLength, service.downloadJobs[downloadJobState.state.id]!!.state.contentLength) assertEquals(downloadJobState.state.contentLength, browserStore.state.downloads.values.first().contentLength) @@ -498,7 +495,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -537,7 +534,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -590,7 +587,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -668,7 +665,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -716,7 +713,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -767,7 +764,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -821,7 +818,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -866,9 +863,9 @@ class AbstractFetchDownloadServiceTest { doNothing().`when`(service).performDownload(any(), anyBoolean()) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) - service.downloadJobs.values.first().job!!.joinBlocking() + service.downloadJobs.values.first().job!! verify(service).startDownloadJob(any()) assertEquals(DOWNLOADING, service.downloadJobs.values.first().status) @@ -881,7 +878,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) verify(service, never()).startDownloadJob(any()) @@ -897,7 +894,7 @@ class AbstractFetchDownloadServiceTest { doNothing().`when`(service).performDownload(any(), anyBoolean()) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) verify(service).setForegroundNotification() @@ -1085,7 +1082,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -1133,7 +1130,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -1164,7 +1161,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -1197,7 +1194,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -1224,7 +1221,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -1342,7 +1339,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.registerNotificationActionsReceiver() service.onStartCommand(downloadIntent, 0, 0) @@ -1403,7 +1400,7 @@ class AbstractFetchDownloadServiceTest { val downloadIntent = Intent("ACTION_DOWNLOAD") downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.registerNotificationActionsReceiver() service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -1915,7 +1912,7 @@ class AbstractFetchDownloadServiceTest { val cancelledDownloadIntent = Intent("ACTION_DOWNLOAD") cancelledDownloadIntent.putExtra(EXTRA_DOWNLOAD_ID, cancelledDownload.id) - browserStore.dispatch(DownloadAction.AddDownloadAction(cancelledDownload)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(cancelledDownload)) service.onStartCommand(cancelledDownloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } @@ -1938,7 +1935,7 @@ class AbstractFetchDownloadServiceTest { downloadIntent.putExtra(EXTRA_DOWNLOAD_ID, download.id) // Start another download to ensure its notifications are presented - browserStore.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + browserStore.dispatch(DownloadAction.AddDownloadAction(download)) service.onStartCommand(downloadIntent, 0, 0) service.downloadJobs.values.forEach { it.job?.join() } verify(service, times(2)).performDownload(providedDownload.capture(), anyBoolean()) diff --git a/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/DownloadMiddlewareTest.kt b/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/DownloadMiddlewareTest.kt @@ -27,8 +27,6 @@ import mozilla.components.concept.fetch.Response import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor import mozilla.components.support.test.eq -import mozilla.components.support.test.ext.joinBlocking -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 @@ -71,7 +69,7 @@ class DownloadMiddlewareTest { ) val download = DownloadState("https://mozilla.org/download", destinationDirectory = "") - store.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + store.dispatch(DownloadAction.AddDownloadAction(download)) val intentCaptor = argumentCaptor<Intent>() verify(downloadMiddleware).startForegroundService(intentCaptor.capture()) @@ -82,7 +80,7 @@ class DownloadMiddlewareTest { // We don't store private downloads in the storage. val privateDownload = download.copy(id = "newId", private = true) - store.dispatch(DownloadAction.AddDownloadAction(privateDownload)).joinBlocking() + store.dispatch(DownloadAction.AddDownloadAction(privateDownload)) verify(downloadMiddleware, never()).saveDownload(any(), any()) verify(downloadMiddleware.downloadStorage, never()).add(privateDownload) @@ -109,7 +107,7 @@ class DownloadMiddlewareTest { val privateDownload = DownloadState("https://mozilla.org/download", private = true) - store.dispatch(DownloadAction.AddDownloadAction(privateDownload)).joinBlocking() + store.dispatch(DownloadAction.AddDownloadAction(privateDownload)) verify(downloadMiddleware.downloadStorage, never()).add(privateDownload) } @@ -131,12 +129,12 @@ class DownloadMiddlewareTest { ) var download = DownloadState("https://mozilla.org/download", destinationDirectory = "") - store.dispatch(DownloadAction.RestoreDownloadStateAction(download)).joinBlocking() + store.dispatch(DownloadAction.RestoreDownloadStateAction(download)) verify(downloadStorage, never()).add(download) download = DownloadState("https://mozilla.org/download", destinationDirectory = "") - store.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + store.dispatch(DownloadAction.AddDownloadAction(download)) verify(downloadStorage).add(download) } @@ -160,7 +158,7 @@ class DownloadMiddlewareTest { middleware = listOf(downloadMiddleware), ) - store.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + store.dispatch(DownloadAction.AddDownloadAction(download)) verify(downloadStorage, never()).add(download) } @@ -198,9 +196,9 @@ class DownloadMiddlewareTest { fileName = tempFile.name, ) - store.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + store.dispatch(DownloadAction.AddDownloadAction(download)) - store.dispatch(DownloadAction.RemoveDownloadAction(download.id)).joinBlocking() + store.dispatch(DownloadAction.RemoveDownloadAction(download.id)) verify(downloadStorage).remove(download) @@ -235,9 +233,9 @@ class DownloadMiddlewareTest { fileName = tempFile.name, ) - store.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + store.dispatch(DownloadAction.AddDownloadAction(download)) - store.dispatch(DownloadAction.RemoveDownloadAction(download.id)).joinBlocking() + store.dispatch(DownloadAction.RemoveDownloadAction(download.id)) verify(downloadStorage).remove(download) @@ -261,9 +259,9 @@ class DownloadMiddlewareTest { ) val download = DownloadState("https://mozilla.org/download", destinationDirectory = "") - store.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + store.dispatch(DownloadAction.AddDownloadAction(download)) - store.dispatch(DownloadAction.RemoveAllDownloadsAction).joinBlocking() + store.dispatch(DownloadAction.RemoveAllDownloadsAction) verify(downloadStorage).removeAllDownloads() } @@ -285,28 +283,28 @@ class DownloadMiddlewareTest { ) val download = DownloadState("https://mozilla.org/download", status = INITIATED) - store.dispatch(DownloadAction.AddDownloadAction(download)).joinBlocking() + store.dispatch(DownloadAction.AddDownloadAction(download)) val downloadInTheStore = store.state.downloads.getValue(download.id) assertEquals(download, downloadInTheStore) var updatedDownload = download.copy(status = COMPLETED, skipConfirmation = true) - store.dispatch(DownloadAction.UpdateDownloadAction(updatedDownload)).joinBlocking() + store.dispatch(DownloadAction.UpdateDownloadAction(updatedDownload)) verify(downloadStorage).update(updatedDownload) // skipConfirmation is value that we are not storing in the storage, // changes on it shouldn't trigger an update on the storage. updatedDownload = updatedDownload.copy(skipConfirmation = false) - store.dispatch(DownloadAction.UpdateDownloadAction(updatedDownload)).joinBlocking() + store.dispatch(DownloadAction.UpdateDownloadAction(updatedDownload)) verify(downloadStorage, times(1)).update(any()) // Private downloads are not updated in the storage. updatedDownload = updatedDownload.copy(private = true) - store.dispatch(DownloadAction.UpdateDownloadAction(updatedDownload)).joinBlocking() + store.dispatch(DownloadAction.UpdateDownloadAction(updatedDownload)) verify(downloadStorage, times(1)).update(any()) } @@ -343,10 +341,9 @@ class DownloadMiddlewareTest { assertTrue(store.state.downloads.isEmpty()) - store.dispatch(DownloadAction.RestoreDownloadsStateAction).joinBlocking() + store.dispatch(DownloadAction.RestoreDownloadsStateAction) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() assertEquals(download, store.state.downloads.values.first()) verify(downloadStorage, never()).remove(download) @@ -374,10 +371,9 @@ class DownloadMiddlewareTest { assertTrue(store.state.downloads.isEmpty()) - store.dispatch(DownloadAction.RestoreDownloadsStateAction).joinBlocking() + store.dispatch(DownloadAction.RestoreDownloadsStateAction) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() assertTrue(store.state.downloads.isEmpty()) } @@ -431,10 +427,9 @@ class DownloadMiddlewareTest { val actions = listOf(TabListAction.RemoveAllTabsAction(), TabListAction.RemoveAllPrivateTabsAction) actions.forEach { - store.dispatch(it).joinBlocking() + store.dispatch(it) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(downloadMiddleware, times(1)).removePrivateNotifications(any()) reset(downloadMiddleware) @@ -464,10 +459,9 @@ class DownloadMiddlewareTest { middleware = listOf(downloadMiddleware), ) - store.dispatch(TabListAction.RemoveTabsAction(listOf("test-tab1", "test-tab3"))).joinBlocking() + store.dispatch(TabListAction.RemoveTabsAction(listOf("test-tab1", "test-tab3"))) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(downloadMiddleware, times(1)).removePrivateNotifications(any()) reset(downloadMiddleware) @@ -496,10 +490,9 @@ class DownloadMiddlewareTest { middleware = listOf(downloadMiddleware), ) - store.dispatch(TabListAction.RemoveTabsAction(listOf("test-tab1", "test-tab2"))).joinBlocking() + store.dispatch(TabListAction.RemoveTabsAction(listOf("test-tab1", "test-tab2"))) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(downloadMiddleware, times(0)).removePrivateNotifications(any()) reset(downloadMiddleware) @@ -528,10 +521,9 @@ class DownloadMiddlewareTest { middleware = listOf(downloadMiddleware), ) - store.dispatch(TabListAction.RemoveTabAction("test-tab3")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("test-tab3")) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(downloadMiddleware, times(1)).removePrivateNotifications(any()) } @@ -559,10 +551,9 @@ class DownloadMiddlewareTest { middleware = listOf(downloadMiddleware), ) - store.dispatch(TabListAction.RemoveTabAction("test-tab3")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("test-tab3")) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(downloadMiddleware, times(0)).removePrivateNotifications(any()) } @@ -660,12 +651,11 @@ class DownloadMiddlewareTest { val tab = createTab("https://www.mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab, select = true)).joinBlocking() - store.dispatch(ContentAction.UpdateDownloadAction(tab.id, download = download)).joinBlocking() - store.dispatch(ContentAction.CancelDownloadAction(tab.id, download.id)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab, select = true)) + store.dispatch(ContentAction.UpdateDownloadAction(tab.id, download = download)) + store.dispatch(ContentAction.CancelDownloadAction(tab.id, download.id)) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(downloadMiddleware, times(1)).closeDownloadResponse(any(), any()) verify(response).close() @@ -692,8 +682,8 @@ class DownloadMiddlewareTest { val response = mock<Response>() val download = DownloadState(url = "https://www.mozilla.org/file.txt", sessionId = tab.id, response = response) - store.dispatch(TabListAction.AddTabAction(tab, select = true)).joinBlocking() - store.dispatch(ContentAction.UpdateDownloadAction(tab.id, download = download)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab, select = true)) + store.dispatch(ContentAction.UpdateDownloadAction(tab.id, download = download)) downloadMiddleware.closeDownloadResponse(store, tab.id) verify(response).close() @@ -732,10 +722,9 @@ class DownloadMiddlewareTest { assertTrue(store.state.downloads.isEmpty()) tempFile.delete() - store.dispatch(DownloadAction.RestoreDownloadsStateAction).joinBlocking() + store.dispatch(DownloadAction.RestoreDownloadsStateAction) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(downloadStorage).remove(download) } @@ -768,10 +757,9 @@ class DownloadMiddlewareTest { assertTrue(store.state.downloads.isNotEmpty()) - store.dispatch(DownloadAction.RemoveDeletedDownloads).joinBlocking() + store.dispatch(DownloadAction.RemoveDeletedDownloads) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() val expected = BrowserState(downloads = mapOf()) assertEquals(expected, store.state) @@ -811,10 +799,9 @@ class DownloadMiddlewareTest { assertTrue(store.state.downloads.isNotEmpty()) - store.dispatch(DownloadAction.RemoveDeletedDownloads).joinBlocking() + store.dispatch(DownloadAction.RemoveDeletedDownloads) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() val expected = BrowserState(downloads = mapOf(download.id to download)) assertEquals(expected, store.state) @@ -850,10 +837,9 @@ class DownloadMiddlewareTest { assertTrue(store.state.downloads.isNotEmpty()) - store.dispatch(DownloadAction.RemoveDeletedDownloads).joinBlocking() + store.dispatch(DownloadAction.RemoveDeletedDownloads) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() val expected = BrowserState(downloads = mapOf(download.id to download)) assertEquals(expected, store.state) @@ -887,10 +873,9 @@ class DownloadMiddlewareTest { assertTrue(store.state.downloads.isNotEmpty()) - store.dispatch(DownloadAction.RemoveDeletedDownloads).joinBlocking() + store.dispatch(DownloadAction.RemoveDeletedDownloads) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() val expected = BrowserState(downloads = mapOf(download.id to download)) assertEquals(expected, store.state) @@ -924,10 +909,9 @@ class DownloadMiddlewareTest { assertTrue(store.state.downloads.isNotEmpty()) - store.dispatch(DownloadAction.RemoveDeletedDownloads).joinBlocking() + store.dispatch(DownloadAction.RemoveDeletedDownloads) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() val expected = BrowserState(downloads = mapOf(download.id to download)) assertEquals(expected, store.state) @@ -961,10 +945,9 @@ class DownloadMiddlewareTest { assertTrue(store.state.downloads.isNotEmpty()) - store.dispatch(DownloadAction.RemoveDeletedDownloads).joinBlocking() + store.dispatch(DownloadAction.RemoveDeletedDownloads) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() val expected = BrowserState(downloads = mapOf(download.id to download)) assertEquals(expected, store.state) @@ -998,10 +981,9 @@ class DownloadMiddlewareTest { assertTrue(store.state.downloads.isNotEmpty()) - store.dispatch(DownloadAction.RemoveDeletedDownloads).joinBlocking() + store.dispatch(DownloadAction.RemoveDeletedDownloads) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() val expected = BrowserState(downloads = mapOf()) assertEquals(expected, store.state) diff --git a/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/DownloadsFeatureTest.kt b/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/DownloadsFeatureTest.kt @@ -31,8 +31,6 @@ import mozilla.components.feature.downloads.ui.DownloaderApp import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor import mozilla.components.support.test.eq -import mozilla.components.support.test.ext.joinBlocking -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 @@ -100,7 +98,6 @@ class DownloadsFeatureTest { assertFalse(requestedPermissions) store.dispatch(ContentAction.UpdateDownloadAction("test-tab", download)) - .joinBlocking() dispatcher.scheduler.advanceUntilIdle() @@ -127,7 +124,6 @@ class DownloadsFeatureTest { val download = DownloadState(url = "https://www.mozilla.org", sessionId = "test-tab") store.dispatch(ContentAction.UpdateDownloadAction("test-tab", download)) - .joinBlocking() dispatcher.scheduler.advanceUntilIdle() @@ -183,7 +179,6 @@ class DownloadsFeatureTest { doReturn(false).`when`(feature).isDownloadBiggerThanAvailableSpace(download) store.dispatch(ContentAction.UpdateDownloadAction("test-tab", download)) - .joinBlocking() dispatcher.scheduler.advanceUntilIdle() @@ -225,10 +220,8 @@ class DownloadsFeatureTest { doReturn(false).`when`(feature).isDownloadBiggerThanAvailableSpace(download) store.dispatch(ContentAction.UpdateDownloadAction("test-tab", download)) - .joinBlocking() dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(fragmentManager, never()).beginTransaction() verify(downloadManager).download(eq(download), anyString()) @@ -242,7 +235,6 @@ class DownloadsFeatureTest { val download = DownloadState(url = "https://www.mozilla.org", sessionId = "test-tab") store.dispatch(ContentAction.UpdateDownloadAction("test-tab", download)) - .joinBlocking() val dialogFragment: DownloadDialogFragment = mock() val fragmentManager: FragmentManager = mock() @@ -280,7 +272,6 @@ class DownloadsFeatureTest { doReturn(dialogFragment).`when`(fragmentManager).findFragmentByTag(DownloadDialogFragment.FRAGMENT_TAG) store.dispatch(ContentAction.UpdateDownloadAction("test-tab", download)) - .joinBlocking() doReturn(closeDownloadResponseUseCase).`when`(downloadsUseCases).cancelDownloadRequest val feature = spy( @@ -311,7 +302,6 @@ class DownloadsFeatureTest { val grantedPermissionsArray = arrayOf(PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_GRANTED).toIntArray() store.dispatch(ContentAction.UpdateDownloadAction("test-tab", download = download)) - .joinBlocking() doReturn(permissionsArray).`when`(downloadManager).permissions doReturn(consumeDownloadUseCase).`when`(downloadsUseCases).consumeDownload @@ -347,7 +337,6 @@ class DownloadsFeatureTest { val grantedPermissionsArray = arrayOf(PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_GRANTED).toIntArray() store.dispatch(ContentAction.UpdateDownloadAction("test-tab", download = download)) - .joinBlocking() val feature = spy( DownloadsFeature( @@ -391,7 +380,7 @@ class DownloadsFeatureTest { "test-tab", DownloadState("https://www.mozilla.org"), ), - ).joinBlocking() + ) val downloadManager: DownloadManager = mock() doReturn( @@ -414,8 +403,6 @@ class DownloadsFeatureTest { arrayOf(PackageManager.PERMISSION_GRANTED, PackageManager.PERMISSION_DENIED).toIntArray(), ) - store.waitUntilIdle() - verify(downloadManager, never()).download(any(), anyString()) verify(closeDownloadResponseUseCase).invoke(anyString(), anyString()) verify(feature).showPermissionDeniedDialog() @@ -473,7 +460,6 @@ class DownloadsFeatureTest { doReturn(false).`when`(feature).isDownloadBiggerThanAvailableSpace(download) store.dispatch(ContentAction.UpdateDownloadAction("test-tab", download)) - .joinBlocking() dispatcher.scheduler.advanceUntilIdle() @@ -1372,7 +1358,6 @@ class DownloadsFeatureTest { val cancelDownloadRequestUseCase = mock<CancelDownloadRequestUseCase>() val download = DownloadState(url = "https://www.mozilla.org", sessionId = "test-tab") store.dispatch(ContentAction.UpdateDownloadAction("test-tab", download = download)) - .joinBlocking() doReturn(cancelDownloadRequestUseCase).`when`(downloadsUseCases).cancelDownloadRequest @@ -1391,12 +1376,11 @@ class DownloadsFeatureTest { feature.start() store.dispatch(ContentAction.UpdateDownloadAction("test-tab", download = download)) - .joinBlocking() grantPermissions() val tab = createTab("https://www.firefox.com") - store.dispatch(TabListAction.AddTabAction(tab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab, select = true)) verify(feature).dismissAllDownloadDialogs() verify(downloadsUseCases).cancelDownloadRequest @@ -1409,7 +1393,6 @@ class DownloadsFeatureTest { val cancelDownloadRequestUseCase = mock<CancelDownloadRequestUseCase>() val download = DownloadState(url = "https://www.mozilla.org", sessionId = "test-tab") store.dispatch(ContentAction.UpdateDownloadAction("test-tab", download = download)) - .joinBlocking() doReturn(cancelDownloadRequestUseCase).`when`(downloadsUseCases).cancelDownloadRequest @@ -1428,12 +1411,11 @@ class DownloadsFeatureTest { feature.start() store.dispatch(ContentAction.UpdateDownloadAction("test-tab", download = download)) - .joinBlocking() grantPermissions() val tab = createTab("https://www.mozilla.org/example") - store.dispatch(TabListAction.AddTabAction(tab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab, select = true)) verify(feature, never()).dismissAllDownloadDialogs() verify(downloadsUseCases, never()).cancelDownloadRequest diff --git a/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/temporary/CopyDownloadFeatureTest.kt b/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/temporary/CopyDownloadFeatureTest.kt @@ -20,7 +20,6 @@ import mozilla.components.concept.fetch.Request import mozilla.components.concept.fetch.Response import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule @@ -106,7 +105,7 @@ class CopyDownloadFeatureTest { val action = CopyInternetResourceAction.AddCopyAction("123", download) copyFeature.start() - store.dispatch(action).joinBlocking() + store.dispatch(action) dispatcher.scheduler.advanceUntilIdle() verify(copyFeature).startCopy(download) diff --git a/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/temporary/ShareResourceFeatureTest.kt b/mobile/android/android-components/components/feature/downloads/src/test/java/mozilla/components/feature/downloads/temporary/ShareResourceFeatureTest.kt @@ -20,7 +20,6 @@ import mozilla.components.concept.fetch.Request import mozilla.components.concept.fetch.Response import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule @@ -104,7 +103,7 @@ class ShareResourceFeatureTest { val action = ShareResourceAction.AddShareAction("123", download) shareFeature.start() - store.dispatch(action).joinBlocking() + store.dispatch(action) dispatcher.scheduler.advanceUntilIdle() verify(shareFeature).startSharing(download) diff --git a/mobile/android/android-components/components/feature/findinpage/src/test/java/mozilla/components/feature/findinpage/internal/FindInPagePresenterTest.kt b/mobile/android/android-components/components/feature/findinpage/src/test/java/mozilla/components/feature/findinpage/internal/FindInPagePresenterTest.kt @@ -13,7 +13,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.feature.findinpage.view.FindInPageView import mozilla.components.support.test.any -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertEquals @@ -54,17 +53,17 @@ class FindInPagePresenterTest { presenter.start() val result = FindResultState(0, 2, false) - store.dispatch(ContentAction.AddFindResultAction("test-tab", result)).joinBlocking() + store.dispatch(ContentAction.AddFindResultAction("test-tab", result)) dispatcher.scheduler.advanceUntilIdle() verify(view, never()).displayResult(result) presenter.bind(store.state.selectedTab!!) - store.dispatch(ContentAction.AddFindResultAction("test-tab", result)).joinBlocking() + store.dispatch(ContentAction.AddFindResultAction("test-tab", result)) dispatcher.scheduler.advanceUntilIdle() verify(view).displayResult(result) val result2 = FindResultState(1, 2, true) - store.dispatch(ContentAction.AddFindResultAction("test-tab", result2)).joinBlocking() + store.dispatch(ContentAction.AddFindResultAction("test-tab", result2)) dispatcher.scheduler.advanceUntilIdle() verify(view).displayResult(result2) } @@ -76,12 +75,12 @@ class FindInPagePresenterTest { presenter.start() presenter.bind(store.state.selectedTab!!) - store.dispatch(ContentAction.AddFindResultAction("test-tab", mock())).joinBlocking() + store.dispatch(ContentAction.AddFindResultAction("test-tab", mock())) dispatcher.scheduler.advanceUntilIdle() verify(view, times(1)).displayResult(any()) presenter.stop() - store.dispatch(ContentAction.AddFindResultAction("test-tab", mock())).joinBlocking() + store.dispatch(ContentAction.AddFindResultAction("test-tab", mock())) dispatcher.scheduler.advanceUntilIdle() verify(view, times(1)).displayResult(any()) } diff --git a/mobile/android/android-components/components/feature/fxsuggest/src/test/java/mozilla/components/feature/fxsuggest/FxSuggestFactsMiddlewareTest.kt b/mobile/android/android-components/components/feature/fxsuggest/src/test/java/mozilla/components/feature/fxsuggest/FxSuggestFactsMiddlewareTest.kt @@ -17,7 +17,6 @@ import mozilla.components.support.base.Component import mozilla.components.support.base.facts.Action import mozilla.components.support.base.facts.Facts import mozilla.components.support.base.facts.processor.CollectionProcessor -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import org.junit.After import org.junit.Assert.assertEquals @@ -46,7 +45,7 @@ class FxSuggestFactsMiddlewareTest { middleware = listOf(FxSuggestFactsMiddleware()), ) - store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)).joinBlocking() + store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)) assertTrue(processor.facts.isEmpty()) } @@ -72,7 +71,7 @@ class FxSuggestFactsMiddlewareTest { middleware = listOf(FxSuggestFactsMiddleware()), ) - store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)).joinBlocking() + store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)) assertTrue(processor.facts.isEmpty()) } @@ -115,7 +114,7 @@ class FxSuggestFactsMiddlewareTest { middleware = listOf(FxSuggestFactsMiddleware()), ) - store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = true)).joinBlocking() + store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = true)) assertEquals(1, processor.facts.size) processor.facts[0].apply { @@ -193,7 +192,7 @@ class FxSuggestFactsMiddlewareTest { middleware = listOf(FxSuggestFactsMiddleware()), ) - store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)).joinBlocking() + store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)) assertEquals(1, processor.facts.size) processor.facts[0].apply { @@ -272,7 +271,7 @@ class FxSuggestFactsMiddlewareTest { middleware = listOf(FxSuggestFactsMiddleware()), ) - store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)).joinBlocking() + store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)) assertEquals(1, processor.facts.size) processor.facts[0].apply { @@ -351,7 +350,7 @@ class FxSuggestFactsMiddlewareTest { middleware = listOf(FxSuggestFactsMiddleware()), ) - store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)).joinBlocking() + store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)) assertEquals(2, processor.facts.size) processor.facts[0].apply { @@ -476,7 +475,7 @@ class FxSuggestFactsMiddlewareTest { middleware = listOf(FxSuggestFactsMiddleware()), ) - store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)).joinBlocking() + store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)) assertEquals(2, processor.facts.size) processor.facts[0].apply { @@ -610,7 +609,7 @@ class FxSuggestFactsMiddlewareTest { middleware = listOf(FxSuggestFactsMiddleware()), ) - store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)).joinBlocking() + store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)) assertEquals(2, processor.facts.size) processor.facts[0].apply { @@ -744,7 +743,7 @@ class FxSuggestFactsMiddlewareTest { middleware = listOf(FxSuggestFactsMiddleware()), ) - store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)).joinBlocking() + store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)) assertEquals(3, processor.facts.size) processor.facts[0].apply { @@ -876,7 +875,7 @@ class FxSuggestFactsMiddlewareTest { middleware = listOf(FxSuggestFactsMiddleware()), ) - store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)).joinBlocking() + store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)) assertEquals(1, processor.facts.size) processor.facts[0].apply { @@ -943,7 +942,7 @@ class FxSuggestFactsMiddlewareTest { middleware = listOf(FxSuggestFactsMiddleware()), ) - store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)).joinBlocking() + store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false)) assertEquals(2, processor.facts.size) processor.facts[0].apply { diff --git a/mobile/android/android-components/components/feature/intent/src/test/java/mozilla/components/feature/intent/processing/TabIntentProcessorTest.kt b/mobile/android/android-components/components/feature/intent/src/test/java/mozilla/components/feature/intent/processing/TabIntentProcessorTest.kt @@ -28,8 +28,6 @@ import mozilla.components.feature.search.SearchUseCases import mozilla.components.feature.search.ext.createSearchEngine import mozilla.components.feature.session.SessionUseCases import mozilla.components.feature.tabs.TabsUseCases -import mozilla.components.support.test.ext.joinBlocking -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 @@ -104,7 +102,6 @@ class TabIntentProcessorTest { assertEquals(0, store.state.tabs.size) handler.process(intent) - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) assertTrue(store.state.tabs[0].source is SessionState.Source.External.ActionView) @@ -112,7 +109,7 @@ class TabIntentProcessorTest { assertNotNull(tab) val otherTab = createTab("https://firefox.com") - store.dispatch(TabListAction.AddTabAction(otherTab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(otherTab, select = true)) assertEquals(2, store.state.tabs.size) assertEquals(otherTab, store.state.selectedTab) assertTrue(store.state.tabs[1].source is SessionState.Source.Internal.None) @@ -123,7 +120,6 @@ class TabIntentProcessorTest { whenever(intent.dataString).thenReturn("mozilla.org") handler.process(intent) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertEquals(tab, store.state.selectedTab) // sources of existing tabs weren't affected @@ -133,7 +129,6 @@ class TabIntentProcessorTest { // Intent with a url that's missing a scheme whenever(intent.dataString).thenReturn("example.com") handler.process(intent) - store.waitUntilIdle() assertEquals(3, store.state.tabs.size) assertTrue(store.state.tabs[0].source is SessionState.Source.External.ActionView) assertNotNull(store.state.findNormalOrPrivateTabByUrl("http://example.com", private = false)) @@ -148,7 +143,6 @@ class TabIntentProcessorTest { assertEquals(0, store.state.tabs.size) handler.process(intent) - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) assertTrue(store.state.tabs[0].source is SessionState.Source.External.ActionView) @@ -156,19 +150,17 @@ class TabIntentProcessorTest { assertNotNull(tab) val otherTab = createTab("https://firefox.com") - store.dispatch(TabListAction.AddTabAction(otherTab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(otherTab, select = true)) assertEquals(2, store.state.tabs.size) assertEquals(otherTab, store.state.selectedTab) handler.process(intent) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertEquals(tab, store.state.selectedTab) // Intent with a url that's missing a scheme whenever(intent.dataString).thenReturn("example.com") handler.process(intent) - store.waitUntilIdle() assertEquals(3, store.state.tabs.size) assertTrue(store.state.tabs[0].source is SessionState.Source.External.ActionView) assertNotNull(store.state.findNormalOrPrivateTabByUrl("http://example.com", private = false)) @@ -183,26 +175,23 @@ class TabIntentProcessorTest { assertEquals(0, store.state.tabs.size) handler.process(intent) - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) val tab = store.state.findNormalOrPrivateTabByUrl("https://mozilla.org", false) assertNotNull(tab) val otherTab = createTab("https://firefox.com") - store.dispatch(TabListAction.AddTabAction(otherTab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(otherTab, select = true)) assertEquals(2, store.state.tabs.size) assertEquals(otherTab, store.state.selectedTab) handler.process(intent) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertEquals(tab, store.state.selectedTab) // Intent with a url that's missing a scheme whenever(intent.dataString).thenReturn("example.com") handler.process(intent) - store.waitUntilIdle() assertEquals(3, store.state.tabs.size) assertTrue(store.state.tabs[0].source is SessionState.Source.External.ActionView) assertNotNull(store.state.findNormalOrPrivateTabByUrl("http://example.com", private = false)) @@ -218,35 +207,30 @@ class TabIntentProcessorTest { assertEquals(0, store.state.tabs.size) handler.process(intent) - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) assertEquals("https://mozilla.org", store.state.tabs[0].content.url) assertTrue(store.state.tabs[0].source is SessionState.Source.External.ActionSend) whenever(intent.getStringExtra(Intent.EXTRA_TEXT)).thenReturn("see https://getpocket.com") handler.process(intent) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertEquals("https://getpocket.com", store.state.tabs[1].content.url) assertTrue(store.state.tabs[1].source is SessionState.Source.External.ActionSend) whenever(intent.getStringExtra(Intent.EXTRA_TEXT)).thenReturn("see https://firefox.com and https://mozilla.org") handler.process(intent) - store.waitUntilIdle() assertEquals(3, store.state.tabs.size) assertEquals("https://firefox.com", store.state.tabs[2].content.url) assertTrue(store.state.tabs[2].source is SessionState.Source.External.ActionSend) whenever(intent.getStringExtra(Intent.EXTRA_TEXT)).thenReturn("checkout the Tweet: https://tweets.mozilla.com") handler.process(intent) - store.waitUntilIdle() assertEquals(4, store.state.tabs.size) assertEquals("https://tweets.mozilla.com", store.state.tabs[3].content.url) assertTrue(store.state.tabs[3].source is SessionState.Source.External.ActionSend) whenever(intent.getStringExtra(Intent.EXTRA_TEXT)).thenReturn("checkout the Tweet: HTTPS://tweets.mozilla.org") handler.process(intent) - store.waitUntilIdle() assertEquals(5, store.state.tabs.size) assertEquals("https://tweets.mozilla.org", store.state.tabs[4].content.url) assertTrue(store.state.tabs[4].source is SessionState.Source.External.ActionSend) @@ -254,7 +238,6 @@ class TabIntentProcessorTest { // Intent with a url that's missing a scheme whenever(intent.getStringExtra(Intent.EXTRA_TEXT)).thenReturn("example.com") handler.process(intent) - store.waitUntilIdle() assertEquals(6, store.state.tabs.size) assertTrue(store.state.tabs[5].source is SessionState.Source.External.ActionSend) assertNotNull(store.state.findNormalOrPrivateTabByUrl("http://example.com", private = false)) @@ -274,7 +257,6 @@ class TabIntentProcessorTest { assertEquals(0, store.state.tabs.size) handler.process(intent) - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) assertEquals(searchUrl, store.state.tabs[0].content.url) assertEquals(searchTerms, store.state.tabs[0].content.searchTerms) @@ -316,7 +298,6 @@ class TabIntentProcessorTest { assertEquals(0, store.state.tabs.size) handler.process(intent) - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) assertEquals("http://mozilla.org", store.state.tabs[0].content.url) assertEquals("", store.state.tabs[0].content.searchTerms) @@ -325,7 +306,6 @@ class TabIntentProcessorTest { // Intent with a url that's missing a scheme whenever(intent.getStringExtra(SearchManager.QUERY)).thenReturn("example.com") handler.process(intent) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertTrue(store.state.tabs[1].source is SessionState.Source.External.ActionSearch) assertNotNull(store.state.findNormalOrPrivateTabByUrl("http://example.com", private = false)) @@ -345,7 +325,6 @@ class TabIntentProcessorTest { assertEquals(0, store.state.tabs.size) handler.process(intent) - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) assertEquals(searchUrl, store.state.tabs[0].content.url) assertEquals(searchTerms, store.state.tabs[0].content.searchTerms) @@ -374,7 +353,6 @@ class TabIntentProcessorTest { assertEquals(0, store.state.tabs.size) handler.process(intent) - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) assertEquals("http://mozilla.org", store.state.tabs[0].content.url) assertEquals("", store.state.tabs[0].content.searchTerms) @@ -383,7 +361,6 @@ class TabIntentProcessorTest { // Intent with a url that's missing a scheme whenever(intent.getStringExtra(SearchManager.QUERY)).thenReturn("example.com") handler.process(intent) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertTrue(store.state.tabs[1].source is SessionState.Source.External.ActionSearch) assertNotNull(store.state.findNormalOrPrivateTabByUrl("http://example.com", private = false)) @@ -402,7 +379,6 @@ class TabIntentProcessorTest { assertEquals(0, store.state.tabs.size) handler.process(intent) - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) assertEquals(searchUrl, store.state.tabs[0].content.url) assertEquals(searchTerms, store.state.tabs[0].content.searchTerms) @@ -478,7 +454,6 @@ class TabIntentProcessorTest { whenever(intent.getIntExtra(EXTRA_APP_LINK_LAUNCH_TYPE, APP_LINK_LAUNCH_TYPE_UNKNOWN)).thenReturn(APP_LINK_LAUNCH_TYPE_COLD) handler.process(intent) - store.waitUntilIdle() val expected = EngineSession.LoadUrlFlags.select(EngineSession.LoadUrlFlags.external().value, APP_LINK_LAUNCH_TYPE_COLD) @@ -495,7 +470,6 @@ class TabIntentProcessorTest { whenever(intent.hasExtra(EXTRA_APP_LINK_LAUNCH_TYPE)).thenReturn(false) handler.process(intent) - store.waitUntilIdle() val expected = EngineSession.LoadUrlFlags.select(EngineSession.LoadUrlFlags.external().value) @@ -512,7 +486,6 @@ class TabIntentProcessorTest { whenever(intent.hasExtra(EXTRA_APP_LINK_LAUNCH_TYPE)).thenReturn(true) handler.process(intent) - store.waitUntilIdle() val expected = EngineSession.LoadUrlFlags.select(EngineSession.LoadUrlFlags.external().value) diff --git a/mobile/android/android-components/components/feature/media/src/test/java/mozilla/components/feature/media/fullscreen/MediaSessionFullscreenFeatureTest.kt b/mobile/android/android-components/components/feature/media/src/test/java/mozilla/components/feature/media/fullscreen/MediaSessionFullscreenFeatureTest.kt @@ -21,8 +21,6 @@ import mozilla.components.browser.state.state.createCustomTab import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.mediasession.MediaSession -import mozilla.components.support.test.ext.joinBlocking -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 @@ -207,11 +205,9 @@ class MediaSessionFullscreenFeatureTest { feature.start() activity.enterPictureInPictureMode() - store.waitUntilIdle() assertTrue(activity.isInPictureInPictureMode) store.dispatch(ContentAction.PictureInPictureChangedAction("tab1", true)) - store.waitUntilIdle() assertEquals(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, activity.requestedOrientation) } @@ -246,9 +242,7 @@ class MediaSessionFullscreenFeatureTest { feature.start() activity.enterPictureInPictureMode() - store.waitUntilIdle() store.dispatch(ContentAction.PictureInPictureChangedAction("tab1", true)) - store.waitUntilIdle() assertEquals(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, activity.requestedOrientation) val tab2 = createTab( @@ -263,7 +257,6 @@ class MediaSessionFullscreenFeatureTest { MediaSession.ElementMetadata(), ), ) - store.waitUntilIdle() assertEquals(ActivityInfo.SCREEN_ORIENTATION_USER, activity.requestedOrientation) assertEquals(tab2.id, store.state.selectedTabId) } @@ -298,11 +291,9 @@ class MediaSessionFullscreenFeatureTest { feature.start() activity.enterPictureInPictureMode() - store.waitUntilIdle() assertTrue(activity.isInPictureInPictureMode) store.dispatch(ContentAction.PictureInPictureChangedAction("tab1", true)) - store.waitUntilIdle() assertEquals(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, activity.requestedOrientation) @@ -313,7 +304,6 @@ class MediaSessionFullscreenFeatureTest { MediaSession.ElementMetadata(), ), ) - store.waitUntilIdle() assertEquals(ActivityInfo.SCREEN_ORIENTATION_USER, activity.requestedOrientation) } @@ -349,10 +339,8 @@ class MediaSessionFullscreenFeatureTest { feature.start() activity.enterPictureInPictureMode() - store.waitUntilIdle() store.dispatch(ContentAction.PictureInPictureChangedAction("tab1", true)) - store.waitUntilIdle() assertEquals(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, activity.requestedOrientation) val customTab = createCustomTab( @@ -360,10 +348,9 @@ class MediaSessionFullscreenFeatureTest { source = SessionState.Source.Internal.CustomTab, id = "tab2", ) - store.dispatch(CustomTabListAction.AddCustomTabAction(customTab)).joinBlocking() + store.dispatch(CustomTabListAction.AddCustomTabAction(customTab)) val externalActivity = Robolectric.buildActivity(Activity::class.java).setup().get() assertEquals(1, store.state.customTabs.size) - store.waitUntilIdle() val featureForExternalAppBrowser = MediaSessionFullscreenFeature( externalActivity, store, @@ -408,17 +395,14 @@ class MediaSessionFullscreenFeatureTest { verify(activity.window).addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) store.dispatch(MediaSessionAction.UpdateMediaPlaybackStateAction("tab1", MediaSession.PlaybackState.PAUSED)) - store.waitUntilIdle() verify(activity.window).clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) clearInvocations(activity.window) store.dispatch(MediaSessionAction.UpdateMediaPlaybackStateAction("tab1", MediaSession.PlaybackState.PLAYING)) - store.waitUntilIdle() verify(activity.window).addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) store.dispatch(MediaSessionAction.DeactivatedMediaSessionAction("tab1")) - store.waitUntilIdle() verify(activity.window).clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } @@ -456,13 +440,11 @@ class MediaSessionFullscreenFeatureTest { verify(activity.window, never()).addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) store.dispatch(MediaSessionAction.UpdateMediaFullscreenAction("tab1", true, elementMetadata)) - store.waitUntilIdle() verify(activity.window).addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) clearInvocations(activity.window) store.dispatch(MediaSessionAction.UpdateMediaFullscreenAction("tab1", false, elementMetadata)) - store.waitUntilIdle() verify(activity.window).clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } @@ -506,7 +488,6 @@ class MediaSessionFullscreenFeatureTest { clearInvocations(activity.window) store.dispatch(TabListAction.AddTabAction(tab2, select = true)) store.dispatch(MediaSessionAction.UpdateMediaFullscreenAction(store.state.tabs[0].id, false, elementMetadata)) - store.waitUntilIdle() verify(activity.window).clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) assertEquals(tab2.id, store.state.selectedTabId) } diff --git a/mobile/android/android-components/components/feature/media/src/test/java/mozilla/components/feature/media/middleware/LastMediaAccessMiddlewareTest.kt b/mobile/android/android-components/components/feature/media/src/test/java/mozilla/components/feature/media/middleware/LastMediaAccessMiddlewareTest.kt @@ -11,7 +11,6 @@ import mozilla.components.browser.state.state.LastMediaAccessState import mozilla.components.browser.state.state.TabSessionState import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.mediasession.MediaSession -import mozilla.components.support.test.ext.joinBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -40,7 +39,6 @@ class LastMediaAccessMiddlewareTest { store .dispatch(MediaSessionAction.UpdateMediaPlaybackStateAction(mediaTabId, MediaSession.PlaybackState.PLAYING)) - .joinBlocking() val updatedMediaState = store.state.tabs[1].lastMediaAccessState assertTrue( @@ -71,7 +69,6 @@ class LastMediaAccessMiddlewareTest { store .dispatch(MediaSessionAction.UpdateMediaPlaybackStateAction(mediaTabId, MediaSession.PlaybackState.PLAYING)) - .joinBlocking() val updatedMediaState = store.state.tabs[1].lastMediaAccessState assertTrue( @@ -101,7 +98,6 @@ class LastMediaAccessMiddlewareTest { store .dispatch(MediaSessionAction.UpdateMediaPlaybackStateAction(mediaTabId, MediaSession.PlaybackState.PAUSED)) - .joinBlocking() assertEquals(222, store.state.tabs[0].lastMediaAccessState.lastMediaAccess) } @@ -126,7 +122,6 @@ class LastMediaAccessMiddlewareTest { store .dispatch(MediaSessionAction.UpdateMediaPlaybackStateAction(mediaTabId, MediaSession.PlaybackState.PAUSED)) - .joinBlocking() assertEquals(333, store.state.tabs[0].lastMediaAccessState.lastMediaAccess) } @@ -151,7 +146,6 @@ class LastMediaAccessMiddlewareTest { store .dispatch(MediaSessionAction.UpdateMediaPlaybackStateAction(mediaTabId, MediaSession.PlaybackState.STOPPED)) - .joinBlocking() assertEquals(222, store.state.tabs[0].lastMediaAccessState.lastMediaAccess) } @@ -176,7 +170,6 @@ class LastMediaAccessMiddlewareTest { store .dispatch(MediaSessionAction.UpdateMediaPlaybackStateAction(mediaTabId, MediaSession.PlaybackState.STOPPED)) - .joinBlocking() assertEquals(333, store.state.tabs[0].lastMediaAccessState.lastMediaAccess) } @@ -201,7 +194,6 @@ class LastMediaAccessMiddlewareTest { store .dispatch(MediaSessionAction.UpdateMediaPlaybackStateAction(mediaTabId, MediaSession.PlaybackState.UNKNOWN)) - .joinBlocking() assertEquals(222, store.state.tabs[0].lastMediaAccessState.lastMediaAccess) } @@ -226,7 +218,6 @@ class LastMediaAccessMiddlewareTest { store .dispatch(MediaSessionAction.UpdateMediaPlaybackStateAction(mediaTabId, MediaSession.PlaybackState.UNKNOWN)) - .joinBlocking() assertEquals(333, store.state.tabs[0].lastMediaAccessState.lastMediaAccess) } @@ -251,7 +242,6 @@ class LastMediaAccessMiddlewareTest { store .dispatch(MediaSessionAction.DeactivatedMediaSessionAction(mediaTabId)) - .joinBlocking() assertEquals(mediaTabUrl, store.state.tabs[0].lastMediaAccessState.lastMediaUrl) assertEquals(222, store.state.tabs[0].lastMediaAccessState.lastMediaAccess) @@ -278,7 +268,6 @@ class LastMediaAccessMiddlewareTest { store .dispatch(MediaSessionAction.DeactivatedMediaSessionAction(mediaTabId)) - .joinBlocking() assertEquals(mediaTabUrl, store.state.tabs[0].lastMediaAccessState.lastMediaUrl) assertEquals(333, store.state.tabs[0].lastMediaAccessState.lastMediaAccess) diff --git a/mobile/android/android-components/components/feature/media/src/test/java/mozilla/components/feature/media/middleware/RecordingDevicesMiddlewareTest.kt b/mobile/android/android-components/components/feature/media/src/test/java/mozilla/components/feature/media/middleware/RecordingDevicesMiddlewareTest.kt @@ -17,8 +17,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.media.RecordingDevice import mozilla.components.support.base.android.NotificationsDelegate -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.whenever import org.junit.Assert.assertEquals @@ -111,8 +109,6 @@ class RecordingDevicesMiddlewareTest { middleware = listOf(middleware), ) - store.waitUntilIdle() - assertEquals(0, notificationManager.size()) store.dispatch( @@ -122,7 +118,7 @@ class RecordingDevicesMiddlewareTest { RecordingDevice(RecordingDevice.Type.CAMERA, RecordingDevice.Status.RECORDING), ), ), - ).joinBlocking() + ) assertEquals(1, notificationManager.size()) @@ -131,7 +127,7 @@ class RecordingDevicesMiddlewareTest { sessionId = "mozilla", devices = emptyList(), ), - ).joinBlocking() + ) assertEquals(0, notificationManager.size()) } diff --git a/mobile/android/android-components/components/feature/privatemode/src/test/java/mozilla/components/feature/privatemode/notification/AbstractPrivateNotificationServiceTest.kt b/mobile/android/android-components/components/feature/privatemode/src/test/java/mozilla/components/feature/privatemode/notification/AbstractPrivateNotificationServiceTest.kt @@ -23,7 +23,6 @@ import mozilla.components.feature.privatemode.notification.AbstractPrivateNotifi import mozilla.components.feature.privatemode.notification.AbstractPrivateNotificationService.Companion.defaultIgnoreTaskActions import mozilla.components.support.base.android.NotificationsDelegate import mozilla.components.support.test.argumentCaptor -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule @@ -144,7 +143,7 @@ class AbstractPrivateNotificationServiceTest { service.onCreate() val mockLocale = Locale.forLanguageTag("English") - service.store.dispatch(LocaleAction.UpdateLocaleAction(mockLocale)).joinBlocking() + service.store.dispatch(LocaleAction.UpdateLocaleAction(mockLocale)) dispatcher.scheduler.advanceUntilIdle() verify(service).notifyLocaleChanged() diff --git a/mobile/android/android-components/components/feature/privatemode/src/test/java/mozilla/components/feature/privatemode/notification/PrivateNotificationFeatureTest.kt b/mobile/android/android-components/components/feature/privatemode/src/test/java/mozilla/components/feature/privatemode/notification/PrivateNotificationFeatureTest.kt @@ -58,7 +58,7 @@ class PrivateNotificationFeatureTest { val privateSession = createTab("https://firefox.com", private = true) val intent = argumentCaptor<Intent>() - store.dispatch(TabListAction.AddTabAction(privateSession)).join() + store.dispatch(TabListAction.AddTabAction(privateSession)) feature.start() dispatcher.scheduler.runCurrent() @@ -76,7 +76,7 @@ class PrivateNotificationFeatureTest { feature.start() verify(context, never()).startService(any()) - store.dispatch(TabListAction.AddTabAction(privateSession)).join() + store.dispatch(TabListAction.AddTabAction(privateSession)) verify(context, times(1)).startService(any()) Unit } @@ -88,8 +88,8 @@ class PrivateNotificationFeatureTest { feature.start() - store.dispatch(TabListAction.AddTabAction(privateSession1)).join() - store.dispatch(TabListAction.AddTabAction(privateSession2)).join() + store.dispatch(TabListAction.AddTabAction(privateSession1)) + store.dispatch(TabListAction.AddTabAction(privateSession2)) verify(context, times(1)).startService(any()) Unit @@ -103,10 +103,10 @@ class PrivateNotificationFeatureTest { feature.start() verify(context, never()).startService(any()) - store.dispatch(TabListAction.AddTabAction(normalSession)).join() + store.dispatch(TabListAction.AddTabAction(normalSession)) verify(context, never()).startService(any()) - store.dispatch(CustomTabListAction.AddCustomTabAction(customSession)).join() + store.dispatch(CustomTabListAction.AddCustomTabAction(customSession)) verify(context, never()).startService(any()) Unit } @@ -121,10 +121,10 @@ class PrivateNotificationFeatureTest { feature.start() verify(context, never()).startService(any()) - store.dispatch(CustomTabListAction.AddCustomTabAction(privateCustomSession)).join() + store.dispatch(CustomTabListAction.AddCustomTabAction(privateCustomSession)) verify(context, never()).startService(any()) - store.dispatch(CustomTabListAction.AddCustomTabAction(customSession)).join() + store.dispatch(CustomTabListAction.AddCustomTabAction(customSession)) verify(context, never()).startService(any()) Unit } diff --git a/mobile/android/android-components/components/feature/prompts/src/test/java/mozilla/components/feature/prompts/PromptFeatureTest.kt b/mobile/android/android-components/components/feature/prompts/src/test/java/mozilla/components/feature/prompts/PromptFeatureTest.kt @@ -69,8 +69,6 @@ import mozilla.components.support.base.facts.Action import mozilla.components.support.base.facts.processor.CollectionProcessor import mozilla.components.support.test.any import mozilla.components.support.test.eq -import mozilla.components.support.test.ext.joinBlocking -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 @@ -147,7 +145,7 @@ class PromptFeatureTest { feature.start() val promptRequest = SingleChoice(arrayOf(), {}, {}) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) verify(feature).onPromptRequested(store.state.tabs.first()) } @@ -167,7 +165,6 @@ class PromptFeatureTest { val promptRequest = SingleChoice(arrayOf(), {}, {}) store.dispatch(ContentAction.UpdatePromptRequestAction("custom-tab", promptRequest)) - .joinBlocking() verify(feature).onPromptRequested(store.state.customTabs.first()) } @@ -186,8 +183,8 @@ class PromptFeatureTest { feature.start() val promptRequest = SingleChoice(arrayOf(), {}, {}) - store.dispatch(ContentAction.UpdatePermissionsRequest(tabId, mock())).joinBlocking() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePermissionsRequest(tabId, mock())) + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) verify(feature).onCancel(tabId, promptRequest.uid) } @@ -207,7 +204,7 @@ class PromptFeatureTest { feature.start() val promptRequest = SingleChoice(arrayOf(), {}, {}) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) verify(feature).onPromptRequested(store.state.tabs.first()) } @@ -226,7 +223,6 @@ class PromptFeatureTest { val singleChoiceRequest = SingleChoice(arrayOf(), {}, {}) store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, singleChoiceRequest)) - .joinBlocking() verify(fragmentManager).beginTransaction() } @@ -245,7 +241,6 @@ class PromptFeatureTest { val singleChoiceRequest = SingleChoice(arrayOf(), {}, {}) store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, singleChoiceRequest)) - .joinBlocking() verify(fragmentManager, never()).beginTransaction() } @@ -259,7 +254,6 @@ class PromptFeatureTest { whenever(singleChoiceRequest.shouldDismissOnLoad).thenReturn(false) store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, singleChoiceRequest)) - .joinBlocking() val feature = PromptFeature( activity = mock(), @@ -308,7 +302,6 @@ class PromptFeatureTest { val singleChoiceRequest = SingleChoice(arrayOf(), {}, {}) store.dispatch(ContentAction.UpdatePromptRequestAction("invalid-tab", singleChoiceRequest)) - .joinBlocking() val transaction: FragmentTransaction = mock() doReturn(transaction).`when`(fragmentManager).beginTransaction() @@ -430,8 +423,6 @@ class PromptFeatureTest { val saveLoginPrompt: SaveLoginDialogFragment = mock() store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) - .joinBlocking() - store.waitUntilIdle() val feature = spy( PromptFeature( @@ -454,7 +445,6 @@ class PromptFeatureTest { // when store.dispatch(ContentAction.ConsumePromptRequestAction(tabId, promptRequest)) - .joinBlocking() // then verify(saveLoginPrompt).dismissAllowingStateLoss() @@ -485,8 +475,6 @@ class PromptFeatureTest { feature.handleDialogsRequest(promptRequest, session) - store.waitUntilIdle() - verify(feature).dismissDialogRequest(promptRequest, session) } @@ -518,8 +506,6 @@ class PromptFeatureTest { feature.handleDialogsRequest(promptRequest, session) - store.waitUntilIdle() - assertTrue(onRemoveLastSavedPasswordCalled) verify(feature).dismissDialogRequest(promptRequest, session) } @@ -550,8 +536,6 @@ class PromptFeatureTest { feature.handleDialogsRequest(promptRequest, session) - store.waitUntilIdle() - verify(feature).dismissDialogRequest(promptRequest, session) } @@ -588,8 +572,6 @@ class PromptFeatureTest { feature.dismissDialogRequest(promptRequest, tab) - store.waitUntilIdle() - verify(store).dispatch(ContentAction.ConsumePromptRequestAction(tab.id, promptRequest)) assertTrue(onDismissWasCalled) } @@ -852,7 +834,6 @@ class PromptFeatureTest { verify(feature.addressPicker!!).dismissSelectAddressRequest(selectAddressPromptRequest) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) } @@ -900,13 +881,11 @@ class PromptFeatureTest { val singleChoiceRequest = SingleChoice(arrayOf(), {}, {}) store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, singleChoiceRequest)) - .joinBlocking() assertEquals(1, tab()!!.content.promptRequests.size) assertEquals(singleChoiceRequest, tab()!!.content.promptRequests[0]) feature.onCancel(tabId, singleChoiceRequest.uid) - store.waitUntilIdle() assertTrue(tab()?.content?.promptRequests?.isEmpty() ?: false) } @@ -927,13 +906,11 @@ class PromptFeatureTest { val singleChoiceRequest = SingleChoice(arrayOf(), {}, {}) store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, singleChoiceRequest)) - .joinBlocking() assertEquals(1, tab()!!.content.promptRequests.size) assertEquals(singleChoiceRequest, tab()!!.content.promptRequests[0]) feature.onConfirm(tabId, singleChoiceRequest.uid, mock<Choice>()) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) } @@ -954,13 +931,11 @@ class PromptFeatureTest { val menuChoiceRequest = MenuChoice(arrayOf(), {}, {}) store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, menuChoiceRequest)) - .joinBlocking() assertEquals(1, tab()!!.content.promptRequests.size) assertEquals(menuChoiceRequest, tab()!!.content.promptRequests[0]) feature.onConfirm(tabId, menuChoiceRequest.uid, mock<Choice>()) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) } @@ -981,13 +956,11 @@ class PromptFeatureTest { val multipleChoiceRequest = MultipleChoice(arrayOf(), {}, {}) store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, multipleChoiceRequest)) - .joinBlocking() assertEquals(1, tab()!!.content.promptRequests.size) assertEquals(multipleChoiceRequest, tab()!!.content.promptRequests[0]) feature.onConfirm(tabId, multipleChoiceRequest.uid, arrayOf<Choice>()) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) } @@ -1018,15 +991,13 @@ class PromptFeatureTest { feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onConfirm(tabId, promptRequest.uid, false) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onShowNoMoreAlertsWasCalled) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onCancel(tabId, promptRequest.uid) - store.waitUntilIdle() assertTrue(onDismissWasCalled) } @@ -1048,9 +1019,8 @@ class PromptFeatureTest { feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onCancel(tabId, promptRequest.uid) - store.waitUntilIdle() assertTrue(onDismissWasCalled) assertTrue(tab()!!.content.promptRequests.isEmpty()) } @@ -1082,15 +1052,13 @@ class PromptFeatureTest { feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onConfirm(tabId, promptRequest.uid, false to "") - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onConfirmWasCalled) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onCancel(tabId, promptRequest.uid) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onDismissWasCalled) } @@ -1121,10 +1089,9 @@ class PromptFeatureTest { feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onCancel(tabId, promptRequest.uid) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onDismissWasCalled) } @@ -1165,16 +1132,13 @@ class PromptFeatureTest { feature.start() store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) - .joinBlocking() val now = Date() feature.onConfirm(tabId, promptRequest.uid, now) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertEquals(now, selectedDate) store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) - .joinBlocking() feature.onClear(tabId, promptRequest.uid) assertTrue(onClearWasCalled) @@ -1224,10 +1188,8 @@ class PromptFeatureTest { intent.data = mock() store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, filePickerRequest)) - .joinBlocking() feature.onActivityResult(FILE_PICKER_ACTIVITY_REQUEST_CODE, intent, RESULT_OK) - store.waitUntilIdle() assertTrue(onSingleFileSelectionWasCalled) assertTrue(tab()!!.content.promptRequests.isEmpty()) } @@ -1268,10 +1230,8 @@ class PromptFeatureTest { } store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, filePickerRequest)) - .joinBlocking() feature.onActivityResult(FILE_PICKER_ACTIVITY_REQUEST_CODE, intent, RESULT_OK) - store.waitUntilIdle() assertTrue(onMultipleFileSelectionWasCalled) assertTrue(tab()!!.content.promptRequests.isEmpty()) } @@ -1298,10 +1258,8 @@ class PromptFeatureTest { val intent = Intent() store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, filePickerRequest)) - .joinBlocking() feature.onActivityResult(FILE_PICKER_ACTIVITY_REQUEST_CODE, intent, RESULT_CANCELED) - store.waitUntilIdle() assertTrue(onDismissWasCalled) assertTrue(tab()!!.content.promptRequests.isEmpty()) } @@ -1430,20 +1388,14 @@ class PromptFeatureTest { ) store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, loginPickerRequest)) - .joinBlocking() loginPickerRequest.onConfirm(login) - store.waitUntilIdle() - assertEquals(confirmedLogin, login) store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, loginPickerRequest)) - .joinBlocking() loginPickerRequest.onDismiss() - store.waitUntilIdle() - assertTrue(onDismissWasCalled) } @@ -1473,21 +1425,15 @@ class PromptFeatureTest { ) store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, selectCreditCardRequest)) - .joinBlocking() selectCreditCardRequest.onConfirm(creditCard) - store.waitUntilIdle() - assertEquals(creditCard, confirmedCreditCard) assertTrue(onConfirmCalled) store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, selectCreditCardRequest)) - .joinBlocking() selectCreditCardRequest.onDismiss() - store.waitUntilIdle() - assertTrue(onDismissCalled) } @@ -1525,17 +1471,15 @@ class PromptFeatureTest { feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onConfirm(tabId, promptRequest.uid, "" to "") - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onConfirmWasCalled) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onCancel(tabId, promptRequest.uid) - store.waitUntilIdle() assertTrue(onDismissWasCalled) } @@ -1574,10 +1518,9 @@ class PromptFeatureTest { feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onConfirm(tabId, promptRequest.uid, "" to "") - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onLeaveWasCalled) } @@ -1614,10 +1557,9 @@ class PromptFeatureTest { feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onCancel(tabId, promptRequest.uid) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onDismissWasCalled) } @@ -1649,17 +1591,15 @@ class PromptFeatureTest { feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onConfirm(tabId, promptRequest.uid, "#f6b73c") - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onConfirmWasCalled) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onCancel(tabId, promptRequest.uid) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onDismissWasCalled) } @@ -1690,10 +1630,9 @@ class PromptFeatureTest { feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onConfirm(tabId, promptRequest.uid, true) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onConfirmWasCalled) } @@ -1726,10 +1665,9 @@ class PromptFeatureTest { feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onCancel(tabId, promptRequest.uid, true) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onCancelWasCalled) } @@ -1768,10 +1706,9 @@ class PromptFeatureTest { feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onCancel(tabId, promptRequest.uid) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onCancelWasCalled) } @@ -1818,23 +1755,20 @@ class PromptFeatureTest { feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onConfirm(tabId, promptRequest.uid, true to MultiButtonDialogFragment.ButtonType.POSITIVE) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onPositiveButtonWasCalled) feature.promptAbuserDetector.resetJSAlertAbuseState() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onConfirm(tabId, promptRequest.uid, true to MultiButtonDialogFragment.ButtonType.NEGATIVE) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onNegativeButtonWasCalled) feature.promptAbuserDetector.resetJSAlertAbuseState() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onConfirm(tabId, promptRequest.uid, true to MultiButtonDialogFragment.ButtonType.NEUTRAL) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onNeutralButtonWasCalled) } @@ -1874,10 +1808,9 @@ class PromptFeatureTest { feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.onCancel(tabId, promptRequest.uid) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onCancelWasCalled) } @@ -1908,7 +1841,7 @@ class PromptFeatureTest { promptRequests.forEach { request -> onDismissWasCalled = false - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, request)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, request)) verify(fragmentManager, never()).beginTransaction() assertTrue(onDismissWasCalled) } @@ -1933,15 +1866,15 @@ class PromptFeatureTest { feature.start() feature.promptAbuserDetector.userWantsMoreDialogs(false) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, alertRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, alertRequest)) verify(fragmentManager, never()).beginTransaction() assertTrue(onDismissWasCalled) // Simulate reloading page - store.dispatch(ContentAction.UpdateLoadingStateAction(tabId, true)).joinBlocking() - store.dispatch(ContentAction.UpdateLoadingStateAction(tabId, false)).joinBlocking() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, alertRequest)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction(tabId, true)) + store.dispatch(ContentAction.UpdateLoadingStateAction(tabId, false)) + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, alertRequest)) assertTrue(feature.promptAbuserDetector.shouldShowMoreDialogs) verify(fragmentManager).beginTransaction() @@ -1966,14 +1899,14 @@ class PromptFeatureTest { feature.start() assertTrue(feature.promptAbuserDetector.shouldShowMoreDialogs) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, popupPrompt)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, popupPrompt)) verify(fragmentManager, times(1)).beginTransaction() feature.onCancel(tabId, popupPrompt.uid, true) assertFalse(feature.promptAbuserDetector.shouldShowMoreDialogs) assertTrue(onDenyCalled) onDenyCalled = false - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, popupPrompt)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, popupPrompt)) verify(fragmentManager, times(1)).beginTransaction() assertFalse(feature.promptAbuserDetector.shouldShowMoreDialogs) assertTrue(onDenyCalled) @@ -2010,7 +1943,6 @@ class PromptFeatureTest { feature.start() store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, selectLoginRequest)) - .joinBlocking() verify(loginPicker).handleSelectLoginRequest(selectLoginRequest) } @@ -2045,7 +1977,6 @@ class PromptFeatureTest { feature.start() store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, selectLoginRequest)) - .joinBlocking() verify(loginPicker, never()).handleSelectLoginRequest(selectLoginRequest) } @@ -2087,7 +2018,6 @@ class PromptFeatureTest { feature.start() store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, selectLoginRequest)) - .joinBlocking() verify(loginPicker, never()).handleSelectLoginRequest(selectLoginRequest) } @@ -2121,12 +2051,11 @@ class PromptFeatureTest { feature.start() store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, selectLoginRequest)) - .joinBlocking() verify(loginPicker).handleSelectLoginRequest(selectLoginRequest) // Simulate reloading page - store.dispatch(ContentAction.UpdateLoadingStateAction(tabId, true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction(tabId, true)) verify(loginPicker).dismissCurrentLoginSelect(selectLoginRequest) } @@ -2168,12 +2097,11 @@ class PromptFeatureTest { feature.start() store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, selectCreditCardRequest)) - .joinBlocking() verify(creditCardPicker).handleSelectCreditCardRequest(selectCreditCardRequest) // Simulate reloading page - store.dispatch(ContentAction.UpdateLoadingStateAction(tabId, true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction(tabId, true)) verify(creditCardPicker).dismissSelectCreditCardRequest(selectCreditCardRequest) } @@ -2198,7 +2126,6 @@ class PromptFeatureTest { val promptRequest = PromptRequest.Share(ShareData("Title", "Text", null), {}, {}, {}) store.dispatch(ContentAction.UpdatePromptRequestAction("custom-tab", promptRequest)) - .joinBlocking() verify(feature).onPromptRequested(store.state.customTabs.first()) verify(delegate).showShareSheet( @@ -2228,7 +2155,6 @@ class PromptFeatureTest { val selectCreditCardRequest = PromptRequest.SelectCreditCard(listOf(mock()), {}, {}) store.dispatch(ContentAction.UpdatePromptRequestAction("custom-tab", selectCreditCardRequest)) - .joinBlocking() verify(feature).onPromptRequested(store.state.customTabs.first()) verify(creditCardPicker).handleSelectCreditCardRequest(selectCreditCardRequest) @@ -2253,7 +2179,6 @@ class PromptFeatureTest { val selectCreditCardRequest = PromptRequest.SelectCreditCard(emptyList(), {}, {}) store.dispatch(ContentAction.UpdatePromptRequestAction("custom-tab", selectCreditCardRequest)) - .joinBlocking() verify(feature).onPromptRequested(store.state.customTabs.first()) verify(creditCardPicker, never()).handleSelectCreditCardRequest(selectCreditCardRequest) @@ -2278,7 +2203,6 @@ class PromptFeatureTest { val selectCreditCardRequest = PromptRequest.SelectCreditCard(listOf(mock()), {}, {}) store.dispatch(ContentAction.UpdatePromptRequestAction("custom-tab", selectCreditCardRequest)) - .joinBlocking() verify(feature).onPromptRequested(store.state.customTabs.first()) verify(creditCardPicker, never()).handleSelectCreditCardRequest(selectCreditCardRequest) @@ -2298,7 +2222,7 @@ class PromptFeatureTest { ) { } val promptRequest: Alert = mock() - store.dispatch(ContentAction.UpdatePromptRequestAction("custom-tab", promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction("custom-tab", promptRequest)) feature.start() verify(exitFullScreenUseCase).invoke("custom-tab") @@ -2317,7 +2241,7 @@ class PromptFeatureTest { ) { } val promptRequest: Alert = mock() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.start() verify(exitFullScreenUseCase).invoke(tabId) @@ -2346,7 +2270,7 @@ class PromptFeatureTest { ) { } val promptRequest: Alert = mock() - store.dispatch(ContentAction.UpdatePromptRequestAction(privateTabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(privateTabId, promptRequest)) feature.start() verify(exitFullScreenUseCase).invoke(privateTabId) @@ -2385,8 +2309,6 @@ class PromptFeatureTest { feature.handleDialogsRequest(promptRequest, session) - store.waitUntilIdle() - verify(feature).dismissDialogRequest(promptRequest, session) } @@ -2423,8 +2345,6 @@ class PromptFeatureTest { feature.handleDialogsRequest(promptRequest, session) - store.waitUntilIdle() - verify(feature).dismissDialogRequest(promptRequest, session) } @@ -2463,8 +2383,6 @@ class PromptFeatureTest { feature.handleDialogsRequest(promptRequest, session) - store.waitUntilIdle() - verify(feature).dismissDialogRequest(promptRequest, session) } @@ -2491,13 +2409,12 @@ class PromptFeatureTest { onFailure = {}, onDismiss = {}, ) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, shareRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, shareRequest)) assertEquals(1, tab()!!.content.promptRequests.size) assertEquals(shareRequest, tab()!!.content.promptRequests[0]) feature.onConfirm(tabId, shareRequest.uid, null) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onSuccessCalled) } @@ -2525,13 +2442,12 @@ class PromptFeatureTest { onFailure = {}, onDismiss = { onDismissCalled = true }, ) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, shareRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, shareRequest)) assertEquals(1, tab()!!.content.promptRequests.size) assertEquals(shareRequest, tab()!!.content.promptRequests[0]) feature.onCancel(tabId, shareRequest.uid) - store.waitUntilIdle() assertTrue(tab()!!.content.promptRequests.isEmpty()) assertTrue(onDismissCalled) } @@ -2558,7 +2474,7 @@ class PromptFeatureTest { onFailure = {}, onDismiss = {}, ) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, shareRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, shareRequest)) val fragment = mock<PromptDialogFragment>() whenever(fragment.shouldDismissOnLoad).thenReturn(true) @@ -2575,7 +2491,7 @@ class PromptFeatureTest { ), select = true, ), - ).joinBlocking() + ) verify(fragment, times(1)).dismiss() } @@ -2602,7 +2518,7 @@ class PromptFeatureTest { onFailure = {}, onDismiss = {}, ) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, shareRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, shareRequest)) val fragment = mock<PromptDialogFragment>() whenever(fragment.shouldDismissOnLoad).thenReturn(true) @@ -2612,7 +2528,7 @@ class PromptFeatureTest { val newTabId = "test-tab-2" - store.dispatch(TabListAction.SelectTabAction(newTabId)).joinBlocking() + store.dispatch(TabListAction.SelectTabAction(newTabId)) verify(fragment, times(1)).dismiss() } @@ -2639,14 +2555,14 @@ class PromptFeatureTest { onFailure = {}, onDismiss = {}, ) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, shareRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, shareRequest)) val fragment = mock<PromptDialogFragment>() whenever(fragment.shouldDismissOnLoad).thenReturn(true) whenever(fragment.isStateSaved).thenReturn(true) feature.activePrompt = WeakReference(fragment) - store.dispatch(ContentAction.UpdateUrlAction(tabId, "mozilla.org")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tabId, "mozilla.org")) verify(fragment, times(1)).dismiss() } @@ -2672,14 +2588,14 @@ class PromptFeatureTest { onFailure = {}, onDismiss = {}, ) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, shareRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, shareRequest)) val fragment = mock<PromptDialogFragment>() whenever(fragment.shouldDismissOnLoad).thenReturn(true) whenever(fragment.isStateSaved).thenReturn(false) feature.activePrompt = WeakReference(fragment) - store.dispatch(ContentAction.UpdateUrlAction(tabId, "mozilla.org")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tabId, "mozilla.org")) verify(fragment, never()).dismiss() } @@ -2709,10 +2625,10 @@ class PromptFeatureTest { ) feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.activePrompt = WeakReference(saveLoginPrompt) - store.dispatch(ContentAction.UpdateUrlAction(tabId, newUrlSameDomain)).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tabId, newUrlSameDomain)) verify(saveLoginPrompt, never()).dismiss() } @@ -2743,10 +2659,10 @@ class PromptFeatureTest { ) feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) feature.activePrompt = WeakReference(saveLoginPrompt) - store.dispatch(ContentAction.UpdateUrlAction(tabId, newUrlDifferentDomain)).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tabId, newUrlDifferentDomain)) verify(saveLoginPrompt, times(1)).dismiss() } @@ -2813,7 +2729,7 @@ class PromptFeatureTest { onFailure = {}, onDismiss = {}, ) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, shareRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, shareRequest)) val fragment = spy( SaveLoginDialogFragment.newInstance( @@ -2830,9 +2746,9 @@ class PromptFeatureTest { ) feature.activePrompt = WeakReference(fragment) - store.dispatch(ContentAction.UpdateProgressAction(tabId, 0)).joinBlocking() - store.dispatch(ContentAction.UpdateProgressAction(tabId, 10)).joinBlocking() - store.dispatch(ContentAction.UpdateProgressAction(tabId, 100)).joinBlocking() + store.dispatch(ContentAction.UpdateProgressAction(tabId, 0)) + store.dispatch(ContentAction.UpdateProgressAction(tabId, 10)) + store.dispatch(ContentAction.UpdateProgressAction(tabId, 100)) verify(fragment, times(0)).dismiss() } @@ -2864,7 +2780,7 @@ class PromptFeatureTest { { }, { }, ) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) val prompt = feature.activePrompt?.get() assertNotNull(prompt) @@ -2923,13 +2839,11 @@ class PromptFeatureTest { ) store .dispatch(ContentAction.UpdatePromptRequestAction(tabId, repostRequest)) - .joinBlocking() assertEquals(1, tab()!!.content.promptRequests.size) assertEquals(repostRequest, tab()!!.content.promptRequests[0]) feature.onConfirm(tabId, repostRequest.uid, null) - store.waitUntilIdle() assertTrue(acceptCalled) assertTrue(tab()!!.content.promptRequests.isEmpty()) } @@ -2954,13 +2868,11 @@ class PromptFeatureTest { ) store .dispatch(ContentAction.UpdatePromptRequestAction(tabId, repostRequest)) - .joinBlocking() assertEquals(1, tab()!!.content.promptRequests.size) assertEquals(repostRequest, tab()!!.content.promptRequests[0]) feature.onCancel(tabId, repostRequest.uid) - store.waitUntilIdle() assertTrue(dismissCalled) assertTrue(tab()!!.content.promptRequests.isEmpty()) } @@ -2995,7 +2907,7 @@ class PromptFeatureTest { feature.start() - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, request)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, request)) assertEquals(1, tab()!!.content.promptRequests.size) @@ -3005,8 +2917,6 @@ class PromptFeatureTest { value = creditCardEntry, ) - store.waitUntilIdle() - assertTrue(tab()!!.content.promptRequests.isEmpty()) } @@ -3035,21 +2945,17 @@ class PromptFeatureTest { }, ) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, request)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, request)) request.onConfirm(creditCardEntry) - store.waitUntilIdle() - assertEquals(creditCardEntry, confirmedCreditCard) assertTrue(onConfirmCalled) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, request)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, request)) request.onDismiss() - store.waitUntilIdle() - assertTrue(onDismissCalled) } @@ -3117,8 +3023,6 @@ class PromptFeatureTest { val dialogFragment: CreditCardSaveDialogFragment = mock() store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, promptRequest)) - .joinBlocking() - store.waitUntilIdle() val feature = PromptFeature( activity = mock(), @@ -3137,7 +3041,6 @@ class PromptFeatureTest { feature.activePromptRequest = promptRequest store.dispatch(ContentAction.ConsumePromptRequestAction(tabId, promptRequest)) - .joinBlocking() verify(dialogFragment).dismissAllowingStateLoss() } @@ -3209,12 +3112,10 @@ class PromptFeatureTest { onDismiss = {}, ) store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, singleChoicePrompt)) - .joinBlocking() val fragment = mock<ChoiceDialogFragment>() whenever(fragment.isStateSaved).thenReturn(false) store.dispatch(ContentAction.ConsumePromptRequestAction(tabId, singleChoicePrompt)) - .joinBlocking() assertEquals(null, feature.activePrompt?.get()) assertTrue(feature.activePromptsToDismiss.isEmpty()) } @@ -3245,14 +3146,14 @@ class PromptFeatureTest { onConfirm = {}, onDismiss = {}, ) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, previousPrompt)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, previousPrompt)) val fragment = mock<ChoiceDialogFragment>() whenever(fragment.shouldDismissOnLoad).thenReturn(true) whenever(fragment.isStateSaved).thenReturn(true) feature.activePrompt = WeakReference(fragment) - store.dispatch(ContentAction.ReplacePromptRequestAction(tabId, previousPrompt.uid, updatedPrompt)).joinBlocking() + store.dispatch(ContentAction.ReplacePromptRequestAction(tabId, previousPrompt.uid, updatedPrompt)) verify(fragment).dismiss() } @@ -3275,10 +3176,8 @@ class PromptFeatureTest { ) store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, filePickerRequest)) - .joinBlocking() feature.start() - store.waitUntilIdle() assertFalse(onDismissWasCalled) assertTrue(tab()!!.content.promptRequests.isNotEmpty()) @@ -3356,7 +3255,6 @@ class PromptFeatureTest { val certificateRequest = PromptRequest.CertificateRequest("exmaple.com", null, { }) store.dispatch(ContentAction.UpdatePromptRequestAction("custom-tab", certificateRequest)) - .joinBlocking() verify(feature).onPromptRequested(store.state.customTabs.first()) verify(certificatePicker).handleCertificateRequest(certificateRequest) diff --git a/mobile/android/android-components/components/feature/prompts/src/test/java/mozilla/components/feature/prompts/PromptMiddlewareTest.kt b/mobile/android/android-components/components/feature/prompts/src/test/java/mozilla/components/feature/prompts/PromptMiddlewareTest.kt @@ -10,7 +10,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.prompt.PromptRequest -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse @@ -49,13 +48,13 @@ class PromptMiddlewareTest { var onDenyCalled = false val onDeny = { onDenyCalled = true } val popupPrompt1 = PromptRequest.Popup("https://firefox.com", onAllow = { }, onDeny = onDeny) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, popupPrompt1)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, popupPrompt1)) assertEquals(1, tab()!!.content.promptRequests.size) assertEquals(popupPrompt1, tab()!!.content.promptRequests[0]) assertFalse(onDenyCalled) val popupPrompt2 = PromptRequest.Popup("https://firefox.com", onAllow = { }, onDeny = onDeny) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, popupPrompt2)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, popupPrompt2)) assertEquals(1, tab()!!.content.promptRequests.size) assertEquals(popupPrompt1, tab()!!.content.promptRequests[0]) assertTrue(onDenyCalled) @@ -66,13 +65,13 @@ class PromptMiddlewareTest { var onDenyCalled = false val onDeny = { onDenyCalled = true } val popupPrompt = PromptRequest.Popup("https://firefox.com", onAllow = { }, onDeny = onDeny) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, popupPrompt)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, popupPrompt)) assertEquals(1, tab()!!.content.promptRequests.size) assertEquals(popupPrompt, tab()!!.content.promptRequests[0]) assertFalse(onDenyCalled) val alert = PromptRequest.Alert("title", "message", false, { }, { }) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, alert)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, alert)) assertEquals(2, tab()!!.content.promptRequests.size) assertEquals(popupPrompt, tab()!!.content.promptRequests[0]) assertEquals(alert, tab()!!.content.promptRequests[1]) @@ -81,14 +80,14 @@ class PromptMiddlewareTest { @Test fun `Process popup after other prompt request`() { val alert = PromptRequest.Alert("title", "message", false, { }, { }) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, alert)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, alert)) assertEquals(1, tab()!!.content.promptRequests.size) assertEquals(alert, tab()!!.content.promptRequests[0]) var onDenyCalled = false val onDeny = { onDenyCalled = true } val popupPrompt = PromptRequest.Popup("https://firefox.com", onAllow = { }, onDeny = onDeny) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, popupPrompt)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, popupPrompt)) assertEquals(2, tab()!!.content.promptRequests.size) assertEquals(alert, tab()!!.content.promptRequests[0]) assertEquals(popupPrompt, tab()!!.content.promptRequests[1]) @@ -98,12 +97,12 @@ class PromptMiddlewareTest { @Test fun `Process other prompt requests`() { val alert = PromptRequest.Alert("title", "message", false, { }, { }) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, alert)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, alert)) assertEquals(1, tab()!!.content.promptRequests.size) assertEquals(alert, tab()!!.content.promptRequests[0]) val beforeUnloadPrompt = PromptRequest.BeforeUnload("title", onLeave = { }, onStay = { }, onDismiss = { }) - store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, beforeUnloadPrompt)).joinBlocking() + store.dispatch(ContentAction.UpdatePromptRequestAction(tabId, beforeUnloadPrompt)) assertEquals(2, tab()!!.content.promptRequests.size) assertEquals(alert, tab()!!.content.promptRequests[0]) assertEquals(beforeUnloadPrompt, tab()!!.content.promptRequests[1]) diff --git a/mobile/android/android-components/components/feature/prompts/src/test/java/mozilla/components/feature/prompts/file/FileUploadsDirCleanerMiddlewareTest.kt b/mobile/android/android-components/components/feature/prompts/src/test/java/mozilla/components/feature/prompts/file/FileUploadsDirCleanerMiddlewareTest.kt @@ -9,8 +9,6 @@ import mozilla.components.browser.state.action.ContentAction import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Rule @@ -40,22 +38,19 @@ class FileUploadsDirCleanerMiddlewareTest { ), ) - store.dispatch(ContentAction.UpdateUrlAction("test-tab", "https://www.wikipedia.org")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction("test-tab", "https://www.wikipedia.org")) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(fileUploadsDirCleaner).cleanRecentUploads() - store.dispatch(ContentAction.UpdateUrlAction("test-tab", "https://www.wikipedia.org/cats")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction("test-tab", "https://www.wikipedia.org/cats")) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() // Same site, no cleanups expected verify(fileUploadsDirCleaner, times(1)).cleanRecentUploads() - store.dispatch(ContentAction.UpdateUrlAction("test-tab", "https://www.example.com")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction("test-tab", "https://www.example.com")) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() // Navigating to another site clean up expected verify(fileUploadsDirCleaner, times(2)).cleanRecentUploads() @@ -76,9 +71,8 @@ class FileUploadsDirCleanerMiddlewareTest { ), ) - store.dispatch(ContentAction.UpdateUrlAction("test-tab", "https://www.mozilla.org")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction("test-tab", "https://www.mozilla.org")) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(fileUploadsDirCleaner).cleanRecentUploads() } @@ -98,9 +92,8 @@ class FileUploadsDirCleanerMiddlewareTest { ), ) - store.dispatch(ContentAction.UpdateUrlAction("test-tab", "https://www.wikipedia.org")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction("test-tab", "https://www.wikipedia.org")) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(fileUploadsDirCleaner, times(0)).performCleanRecentUploads() } diff --git a/mobile/android/android-components/components/feature/pwa/src/test/java/mozilla/components/feature/pwa/feature/ManifestUpdateFeatureTest.kt b/mobile/android/android-components/components/feature/pwa/src/test/java/mozilla/components/feature/pwa/feature/ManifestUpdateFeatureTest.kt @@ -14,7 +14,6 @@ import mozilla.components.feature.pwa.ManifestStorage import mozilla.components.feature.pwa.WebAppShortcutManager import mozilla.components.support.test.any import mozilla.components.support.test.ext.joinBlocking -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 @@ -70,8 +69,6 @@ class ManifestUpdateFeatureTest { feature.start() - store.waitUntilIdle() - feature.stop() verify(storage).updateManifestUsedAt(baseManifest) @@ -95,7 +92,7 @@ class ManifestUpdateFeatureTest { sessionId, baseManifest, ), - ).joinBlocking() + ) feature.start() @@ -121,7 +118,7 @@ class ManifestUpdateFeatureTest { sessionId, baseManifest, ), - ).joinBlocking() + ) feature.start() @@ -133,7 +130,7 @@ class ManifestUpdateFeatureTest { sessionId, newManifest, ), - ).joinBlocking() + ) feature.updateJob!!.joinBlocking() @@ -159,7 +156,7 @@ class ManifestUpdateFeatureTest { sessionId, baseManifest, ), - ).joinBlocking() + ) feature.updateJob?.joinBlocking() @@ -183,7 +180,7 @@ class ManifestUpdateFeatureTest { sessionId, baseManifest, ), - ).joinBlocking() + ) feature.start() @@ -192,7 +189,7 @@ class ManifestUpdateFeatureTest { ContentAction.RemoveWebAppManifestAction( sessionId, ), - ).joinBlocking() + ) feature.updateJob?.joinBlocking() @@ -216,7 +213,7 @@ class ManifestUpdateFeatureTest { sessionId, baseManifest, ), - ).joinBlocking() + ) feature.start() @@ -226,7 +223,7 @@ class ManifestUpdateFeatureTest { sessionId, WebAppManifest(name = "Mozilla", startUrl = "https://netscape.com"), ), - ).joinBlocking() + ) feature.updateJob?.joinBlocking() diff --git a/mobile/android/android-components/components/feature/pwa/src/test/java/mozilla/components/feature/pwa/feature/WebAppHideToolbarFeatureTest.kt b/mobile/android/android-components/components/feature/pwa/src/test/java/mozilla/components/feature/pwa/feature/WebAppHideToolbarFeatureTest.kt @@ -24,7 +24,6 @@ import mozilla.components.feature.customtabs.store.CustomTabsServiceStore import mozilla.components.feature.customtabs.store.OriginRelationPair import mozilla.components.feature.customtabs.store.ValidateRelationshipAction import mozilla.components.feature.customtabs.store.VerificationStatus -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertFalse @@ -203,22 +202,22 @@ class WebAppHideToolbarFeatureTest { store.dispatch( ContentAction.UpdateUrlAction(customTabId, "https://mozilla.com/example-page"), - ).joinBlocking() + ) assertFalse(toolbarVisible) store.dispatch( ContentAction.UpdateUrlAction(customTabId, "https://firefox.com/out-of-scope"), - ).joinBlocking() + ) assertTrue(toolbarVisible) store.dispatch( ContentAction.UpdateUrlAction(customTabId, "https://mozilla.com/back-in-scope"), - ).joinBlocking() + ) assertFalse(toolbarVisible) store.dispatch( ContentAction.UpdateUrlAction(customTabId, "https://m.mozilla.com/second-origin"), - ).joinBlocking() + ) assertFalse(toolbarVisible) } @@ -238,22 +237,22 @@ class WebAppHideToolbarFeatureTest { store.dispatch( ContentAction.UpdateUrlAction(customTabId, "https://mozilla.github.io/my-app/"), - ).joinBlocking() + ) assertFalse(toolbarVisible) store.dispatch( ContentAction.UpdateUrlAction(customTabId, "https://firefox.com/out-of-scope"), - ).joinBlocking() + ) assertTrue(toolbarVisible) store.dispatch( ContentAction.UpdateUrlAction(customTabId, "https://mozilla.github.io/my-app-almost-in-scope"), - ).joinBlocking() + ) assertTrue(toolbarVisible) store.dispatch( ContentAction.UpdateUrlAction(customTabId, "https://mozilla.github.io/my-app/sub-page"), - ).joinBlocking() + ) assertFalse(toolbarVisible) } @@ -273,12 +272,12 @@ class WebAppHideToolbarFeatureTest { store.dispatch( ContentAction.UpdateUrlAction(customTabId, "https://mozilla.github.io/prefix/"), - ).joinBlocking() + ) assertFalse(toolbarVisible) store.dispatch( ContentAction.UpdateUrlAction(customTabId, "https://mozilla.github.io/prefix-of/resource.html"), - ).joinBlocking() + ) assertFalse(toolbarVisible) } @@ -312,7 +311,7 @@ class WebAppHideToolbarFeatureTest { "https://m.mozilla.com".toUri(), VerificationStatus.PENDING, ), - ).joinBlocking() + ) assertTrue(toolbarVisible) customTabsStore.dispatch( @@ -322,7 +321,7 @@ class WebAppHideToolbarFeatureTest { "https://mozilla.com".toUri(), VerificationStatus.PENDING, ), - ).joinBlocking() + ) assertFalse(toolbarVisible) } diff --git a/mobile/android/android-components/components/feature/readerview/src/test/java/mozilla/components/feature/readerview/ReaderViewFeatureTest.kt b/mobile/android/android-components/components/feature/readerview/src/test/java/mozilla/components/feature/readerview/ReaderViewFeatureTest.kt @@ -32,7 +32,6 @@ import mozilla.components.feature.readerview.view.ReaderViewControlsView import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor import mozilla.components.support.test.eq -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule @@ -192,7 +191,7 @@ class ReaderViewFeatureTest { val readerViewFeature = spy(ReaderViewFeature(testContext, engine, store, mock())) readerViewFeature.start() - store.dispatch(ReaderAction.UpdateReaderableCheckRequiredAction(tab.id, true)).joinBlocking() + store.dispatch(ReaderAction.UpdateReaderableCheckRequiredAction(tab.id, true)) val tabCaptor = argumentCaptor<TabSessionState>() verify(readerViewFeature).checkReaderState(tabCaptor.capture()) @@ -207,7 +206,7 @@ class ReaderViewFeatureTest { val readerViewFeature = spy(ReaderViewFeature(testContext, engine, store, mock())) readerViewFeature.start() - store.dispatch(ReaderAction.UpdateReaderConnectRequiredAction(tab.id, true)).joinBlocking() + store.dispatch(ReaderAction.UpdateReaderConnectRequiredAction(tab.id, true)) val tabCaptor = argumentCaptor<TabSessionState>() verify(readerViewFeature).connectReaderViewContentScript(tabCaptor.capture()) assertEquals(tab.id, tabCaptor.value.id) @@ -227,24 +226,24 @@ class ReaderViewFeatureTest { readerViewFeature.start() assertTrue(readerViewStatusChanges.isEmpty()) - store.dispatch(TabListAction.SelectTabAction(tab.id)).joinBlocking() - store.dispatch(ReaderAction.UpdateReaderableAction(tab.id, true)).joinBlocking() + store.dispatch(TabListAction.SelectTabAction(tab.id)) + store.dispatch(ReaderAction.UpdateReaderableAction(tab.id, true)) assertEquals(1, readerViewStatusChanges.size) assertEquals(Pair(true, false), readerViewStatusChanges[0]) - store.dispatch(ReaderAction.UpdateReaderActiveAction(tab.id, true)).joinBlocking() + store.dispatch(ReaderAction.UpdateReaderActiveAction(tab.id, true)) assertEquals(2, readerViewStatusChanges.size) assertEquals(Pair(true, true), readerViewStatusChanges[1]) - store.dispatch(ReaderAction.UpdateReaderableAction(tab.id, true)).joinBlocking() + store.dispatch(ReaderAction.UpdateReaderableAction(tab.id, true)) // No change -> No notification should have been sent assertEquals(2, readerViewStatusChanges.size) - store.dispatch(ReaderAction.UpdateReaderActiveAction(tab.id, false)).joinBlocking() + store.dispatch(ReaderAction.UpdateReaderActiveAction(tab.id, false)) assertEquals(3, readerViewStatusChanges.size) assertEquals(Pair(true, false), readerViewStatusChanges[2]) - store.dispatch(ReaderAction.UpdateReaderableAction(tab.id, false)).joinBlocking() + store.dispatch(ReaderAction.UpdateReaderableAction(tab.id, false)) assertEquals(4, readerViewStatusChanges.size) assertEquals(Pair(false, false), readerViewStatusChanges[3]) } @@ -321,9 +320,9 @@ class ReaderViewFeatureTest { val tab = createTab("https://www.mozilla.org", id = "test-tab", readerState = ReaderState(active = true)) val store = BrowserStore(initialState = BrowserState(tabs = listOf(tab))) val readerViewFeature = ReaderViewFeature(testContext, engine, store, mock()) - store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)).joinBlocking() - store.dispatch(TabListAction.SelectTabAction(tab.id)).joinBlocking() - store.dispatch(ContentAction.UpdateBackNavigationStateAction(tab.id, true)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)) + store.dispatch(TabListAction.SelectTabAction(tab.id)) + store.dispatch(ContentAction.UpdateBackNavigationStateAction(tab.id, true)) readerViewFeature.hideReaderView() verify(engineSession).goBack(false) @@ -445,8 +444,8 @@ class ReaderViewFeatureTest { val tab = createTab("https://www.mozilla.org", id = "test-tab") val store = BrowserStore(BrowserState(tabs = listOf(tab))) - store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)).joinBlocking() - store.dispatch(TabListAction.SelectTabAction(tab.id)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)) + store.dispatch(TabListAction.SelectTabAction(tab.id)) val controlsView: ReaderViewControlsView = mock() val view: View = mock() @@ -455,7 +454,7 @@ class ReaderViewFeatureTest { val readerViewFeature = spy(ReaderViewFeature(testContext, engine, store, controlsView)) assertFalse(readerViewFeature.onBackPressed()) - store.dispatch(ReaderAction.UpdateReaderActiveAction(tab.id, true)).joinBlocking() + store.dispatch(ReaderAction.UpdateReaderActiveAction(tab.id, true)) whenever(view.visibility).thenReturn(View.VISIBLE) assertTrue(readerViewFeature.onBackPressed()) verify(readerViewFeature, never()).hideReaderView(any()) @@ -501,7 +500,7 @@ class ReaderViewFeatureTest { val messageHandler = argumentCaptor<MessageHandler>() val message = argumentCaptor<JSONObject>() readerViewFeature.start() - store.dispatch(ReaderAction.UpdateReaderConnectRequiredAction(tab.id, true)).joinBlocking() + store.dispatch(ReaderAction.UpdateReaderConnectRequiredAction(tab.id, true)) verify(controller).registerContentMessageHandler( eq(engineSession), messageHandler.capture(), @@ -557,7 +556,7 @@ class ReaderViewFeatureTest { val message = argumentCaptor<JSONObject>() readerViewFeature.start() - store.dispatch(ReaderAction.UpdateReaderConnectRequiredAction(tab.id, true)).joinBlocking() + store.dispatch(ReaderAction.UpdateReaderConnectRequiredAction(tab.id, true)) verify(controller).registerContentMessageHandler( eq(engineSession), messageHandler.capture(), @@ -586,8 +585,8 @@ class ReaderViewFeatureTest { val engine: Engine = mock() val store = BrowserStore(BrowserState(tabs = listOf(tab))) - store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)).joinBlocking() - store.dispatch(TabListAction.SelectTabAction(tab.id)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)) + store.dispatch(TabListAction.SelectTabAction(tab.id)) val ext: WebExtension = mock() contentPort?.let { diff --git a/mobile/android/android-components/components/feature/readerview/src/test/java/mozilla/components/feature/readerview/ReaderViewMiddlewareTest.kt b/mobile/android/android-components/components/feature/readerview/src/test/java/mozilla/components/feature/readerview/ReaderViewMiddlewareTest.kt @@ -16,7 +16,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession import mozilla.components.feature.readerview.ReaderViewFeature.Companion.READER_VIEW_EXTENSION_ID -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.webextensions.BuiltInWebExtensionController import org.junit.Assert.assertEquals @@ -40,8 +39,8 @@ class ReaderViewMiddlewareTest { ) val tab = createTab("https://www.mozilla.org", id = "test-tab") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() - store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, mock())).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) + store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, mock())) val readerState = store.state.findTab(tab.id)!!.readerState assertTrue(readerState.connectRequired) @@ -60,11 +59,11 @@ class ReaderViewMiddlewareTest { middleware = listOf(middleware), ) - store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession)) assertSame(engineSession, store.state.findTab(tab.id)?.engineState?.engineSession) verify(controller, never()).disconnectPort(engineSession, READER_VIEW_EXTENSION_ID) - store.dispatch(EngineAction.UnlinkEngineSessionAction(tab.id)).joinBlocking() + store.dispatch(EngineAction.UnlinkEngineSessionAction(tab.id)) assertNull(store.state.findTab(tab.id)?.engineState?.engineSession) verify(controller).disconnectPort(engineSession, READER_VIEW_EXTENSION_ID) } @@ -88,7 +87,7 @@ class ReaderViewMiddlewareTest { assertFalse(store.state.findTab(tab2.id)!!.readerState.checkRequired) assertTrue(store.state.findTab(tab2.id)!!.readerState.readerable) - store.dispatch(TabListAction.SelectTabAction(tab2.id)).joinBlocking() + store.dispatch(TabListAction.SelectTabAction(tab2.id)) assertFalse(store.state.findTab(tab1.id)!!.readerState.readerable) assertFalse(store.state.findTab(tab1.id)!!.readerState.checkRequired) assertFalse(store.state.findTab(tab1.id)!!.readerState.connectRequired) @@ -106,7 +105,7 @@ class ReaderViewMiddlewareTest { ) assertFalse(store.state.findTab(tab.id)!!.readerState.checkRequired) - store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://www.firefox.com")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://www.firefox.com")) assertTrue(store.state.findTab(tab.id)!!.readerState.checkRequired) } @@ -123,10 +122,10 @@ class ReaderViewMiddlewareTest { ) assertFalse(store.state.findTab(tab.id)!!.readerState.active) - store.dispatch(ContentAction.UpdateUrlAction(tab.id, "moz-extension://123?url=articleLink")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tab.id, "moz-extension://123?url=articleLink")) assertTrue(store.state.findTab(tab.id)!!.readerState.active) - store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://www.firefox.com")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://www.firefox.com")) assertFalse(store.state.findTab(tab.id)!!.readerState.active) assertFalse(store.state.findTab(tab.id)!!.readerState.readerable) assertTrue(store.state.findTab(tab.id)!!.readerState.checkRequired) @@ -154,7 +153,7 @@ class ReaderViewMiddlewareTest { tab.id, "moz-extension://123?url=https%3A%2F%2Fmozilla.org%2Farticle1", ), - ).joinBlocking() + ) assertTrue(store.state.findTab(tab.id)!!.readerState.active) assertEquals("https://mozilla.org/article1", store.state.findTab(tab.id)!!.content.url) @@ -180,7 +179,7 @@ class ReaderViewMiddlewareTest { tab.id, activeUrl = "https://mozilla.org/article1", ), - ).joinBlocking() + ) assertEquals("https://mozilla.org/article1", store.state.findTab(tab.id)!!.content.url) } @@ -206,7 +205,7 @@ class ReaderViewMiddlewareTest { tab.id, "https://mozilla.org/article1", ), - ).joinBlocking() + ) assertFalse(store.state.findTab(tab.id)!!.readerState.active) } diff --git a/mobile/android/android-components/components/feature/recentlyclosed/src/test/java/mozilla/components/feature/recentlyclosed/RecentlyClosedMiddlewareTest.kt b/mobile/android/android-components/components/feature/recentlyclosed/src/test/java/mozilla/components/feature/recentlyclosed/RecentlyClosedMiddlewareTest.kt @@ -17,8 +17,6 @@ import mozilla.components.concept.engine.Engine import mozilla.components.feature.session.middleware.undo.UndoMiddleware import mozilla.components.support.test.argumentCaptor import mozilla.components.support.test.eq -import mozilla.components.support.test.ext.joinBlocking -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 @@ -67,9 +65,8 @@ class RecentlyClosedMiddlewareTest { middleware = listOf(middleware), ) - store.dispatch(RecentlyClosedAction.AddClosedTabsAction(listOf(closedTab))).joinBlocking() + store.dispatch(RecentlyClosedAction.AddClosedTabsAction(listOf(closedTab))) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(storage).addTabsToCollectionWithMax( listOf(closedTab), @@ -92,11 +89,10 @@ class RecentlyClosedMiddlewareTest { middleware = listOf(UndoMiddleware(mainScope = scope), middleware), ) - store.dispatch(TabListAction.RemoveTabsAction(listOf("1234", "5678"))).joinBlocking() - store.dispatch(UndoAction.ClearRecoverableTabs(store.state.undoHistory.tag)).joinBlocking() + store.dispatch(TabListAction.RemoveTabsAction(listOf("1234", "5678"))) + store.dispatch(UndoAction.ClearRecoverableTabs(store.state.undoHistory.tag)) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() val closedTabCaptor = argumentCaptor<List<RecoverableTab>>() verify(storage).addTabsToCollectionWithMax( @@ -132,11 +128,10 @@ class RecentlyClosedMiddlewareTest { middleware = listOf(UndoMiddleware(mainScope = scope), middleware), ) - store.dispatch(TabListAction.RemoveTabAction("1234")).joinBlocking() - store.dispatch(UndoAction.ClearRecoverableTabs(store.state.undoHistory.tag)).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("1234")) + store.dispatch(UndoAction.ClearRecoverableTabs(store.state.undoHistory.tag)) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() val closedTabCaptor = argumentCaptor<List<RecoverableTab>>() verify(storage).addTabsToCollectionWithMax( @@ -166,9 +161,8 @@ class RecentlyClosedMiddlewareTest { middleware = listOf(middleware), ) - store.dispatch(TabListAction.RemoveTabAction("1234")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("1234")) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(storage).getTabs() verifyNoMoreInteractions(storage) @@ -189,11 +183,10 @@ class RecentlyClosedMiddlewareTest { middleware = listOf(UndoMiddleware(mainScope = scope), middleware), ) - store.dispatch(TabListAction.RemoveAllNormalTabsAction).joinBlocking() - store.dispatch(UndoAction.ClearRecoverableTabs(store.state.undoHistory.tag)).joinBlocking() + store.dispatch(TabListAction.RemoveAllNormalTabsAction) + store.dispatch(UndoAction.ClearRecoverableTabs(store.state.undoHistory.tag)) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() val closedTabCaptor = argumentCaptor<List<RecoverableTab>>() verify(storage).addTabsToCollectionWithMax( @@ -224,11 +217,10 @@ class RecentlyClosedMiddlewareTest { middleware = listOf(UndoMiddleware(mainScope = scope), middleware), ) - store.dispatch(TabListAction.RemoveAllTabsAction()).joinBlocking() - store.dispatch(UndoAction.ClearRecoverableTabs(store.state.undoHistory.tag)).joinBlocking() + store.dispatch(TabListAction.RemoveAllTabsAction()) + store.dispatch(UndoAction.ClearRecoverableTabs(store.state.undoHistory.tag)) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() val closedTabCaptor = argumentCaptor<List<RecoverableTab>>() verify(storage).addTabsToCollectionWithMax( @@ -253,25 +245,24 @@ class RecentlyClosedMiddlewareTest { middleware = listOf(UndoMiddleware(mainScope = scope), middleware), ) - store.dispatch(TabListAction.AddTabAction(createTab("https://www.mozilla.org", id = "tab1"))).joinBlocking() - store.dispatch(TabListAction.AddTabAction(createTab("https://www.firefox.com", id = "tab2"))).joinBlocking() - store.dispatch(TabListAction.AddTabAction(createTab("https://getpocket.com", id = "tab3"))).joinBlocking() - store.dispatch(TabListAction.AddTabAction(createTab("https://theverge.com", id = "tab4"))).joinBlocking() - store.dispatch(TabListAction.AddTabAction(createTab("https://www.google.com", id = "tab5"))).joinBlocking() + store.dispatch(TabListAction.AddTabAction(createTab("https://www.mozilla.org", id = "tab1"))) + store.dispatch(TabListAction.AddTabAction(createTab("https://www.firefox.com", id = "tab2"))) + store.dispatch(TabListAction.AddTabAction(createTab("https://getpocket.com", id = "tab3"))) + store.dispatch(TabListAction.AddTabAction(createTab("https://theverge.com", id = "tab4"))) + store.dispatch(TabListAction.AddTabAction(createTab("https://www.google.com", id = "tab5"))) assertEquals(5, store.state.tabs.size) - store.dispatch(TabListAction.RemoveTabAction("tab2")).joinBlocking() - store.dispatch(TabListAction.RemoveTabAction("tab3")).joinBlocking() - store.dispatch(TabListAction.RemoveTabAction("tab1")).joinBlocking() - store.dispatch(TabListAction.RemoveTabAction("tab5")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("tab2")) + store.dispatch(TabListAction.RemoveTabAction("tab3")) + store.dispatch(TabListAction.RemoveTabAction("tab1")) + store.dispatch(TabListAction.RemoveTabAction("tab5")) - store.dispatch(UndoAction.ClearRecoverableTabs(store.state.undoHistory.tag)).joinBlocking() + store.dispatch(UndoAction.ClearRecoverableTabs(store.state.undoHistory.tag)) assertEquals(1, store.state.tabs.size) assertEquals("tab4", store.state.selectedTabId) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() val closedTabCaptor = argumentCaptor<List<RecoverableTab>>() @@ -309,12 +300,8 @@ class RecentlyClosedMiddlewareTest { val middleware = RecentlyClosedMiddleware(lazy { storage }, 5, scope) val store = BrowserStore(initialState = BrowserState(), middleware = listOf(middleware)) - // Wait for Init action of store to be processed - store.waitUntilIdle() - // Now wait for Middleware to process Init action and store to process action from middleware dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(storage).getTabs() assertEquals(closedTab.state, store.state.closedTabs[0]) @@ -334,12 +321,8 @@ class RecentlyClosedMiddlewareTest { middleware = listOf(middleware), ) - store.dispatch(RecentlyClosedAction.RemoveClosedTabAction(closedTab.state)).joinBlocking() - dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() - + store.dispatch(RecentlyClosedAction.RemoveClosedTabAction(closedTab.state)) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(storage).removeTab(closedTab.state) } @@ -356,12 +339,9 @@ class RecentlyClosedMiddlewareTest { middleware = listOf(middleware), ) - store.dispatch(RecentlyClosedAction.RemoveAllClosedTabAction).joinBlocking() + store.dispatch(RecentlyClosedAction.RemoveAllClosedTabAction) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() - dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() verify(storage).removeAllTabs() } } diff --git a/mobile/android/android-components/components/feature/search/src/test/java/mozilla/components/feature/search/SearchFeatureTest.kt b/mobile/android/android-components/components/feature/search/src/test/java/mozilla/components/feature/search/SearchFeatureTest.kt @@ -13,8 +13,6 @@ import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.search.SearchRequest import mozilla.components.support.test.any import mozilla.components.support.test.eq -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.After @@ -68,13 +66,13 @@ class SearchFeatureTest { verify(performSearch, times(0)).invoke(any(), eq(SELECTED_TAB_ID)) val normalSearchRequest = SearchRequest(isPrivate = false, query = "query") - store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, normalSearchRequest)).joinBlocking() + store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, normalSearchRequest)) verify(performSearch, times(1)).invoke(any(), eq(SELECTED_TAB_ID)) verify(performSearch, times(1)).invoke(normalSearchRequest, SELECTED_TAB_ID) val privateSearchRequest = SearchRequest(isPrivate = true, query = "query") - store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, privateSearchRequest)).joinBlocking() + store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, privateSearchRequest)) verify(performSearch, times(2)).invoke(any(), eq(SELECTED_TAB_ID)) verify(performSearch, times(1)).invoke(privateSearchRequest, SELECTED_TAB_ID) @@ -87,13 +85,13 @@ class SearchFeatureTest { verify(performSearch, times(0)).invoke(any(), eq(SELECTED_TAB_ID)) val normalSearchRequest = SearchRequest(isPrivate = false, query = "query") - store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, normalSearchRequest)).joinBlocking() + store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, normalSearchRequest)) verify(performSearch, times(0)).invoke(any(), eq(SELECTED_TAB_ID)) verify(performSearch, times(0)).invoke(normalSearchRequest, SELECTED_TAB_ID) val privateSearchRequest = SearchRequest(isPrivate = true, query = "query") - store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, privateSearchRequest)).joinBlocking() + store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, privateSearchRequest)) verify(performSearch, times(0)).invoke(any(), eq(SELECTED_TAB_ID)) verify(performSearch, times(0)).invoke(privateSearchRequest, SELECTED_TAB_ID) @@ -102,14 +100,12 @@ class SearchFeatureTest { @Test fun `WHEN a search request has been handled THEN that request should have been consumed`() { val normalSearchRequest = SearchRequest(isPrivate = false, query = "query") - store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, normalSearchRequest)).joinBlocking() - store.waitUntilIdle() + store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, normalSearchRequest)) assertNull(store.state.selectedTab!!.content.searchRequest) val privateSearchRequest = SearchRequest(isPrivate = true, query = "query") - store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, privateSearchRequest)).joinBlocking() - store.waitUntilIdle() + store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, privateSearchRequest)) assertNull(store.state.selectedTab!!.content.searchRequest) } @@ -119,14 +115,12 @@ class SearchFeatureTest { val searchRequest = SearchRequest(isPrivate = false, query = "query") verify(performSearch, times(0)).invoke(searchRequest, SELECTED_TAB_ID) - store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, searchRequest)).joinBlocking() - store.waitUntilIdle() + store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, searchRequest)) verify(performSearch, times(1)).invoke(searchRequest, SELECTED_TAB_ID) assertNull(store.state.selectedTab!!.content.searchRequest) - store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, searchRequest)).joinBlocking() - store.waitUntilIdle() + store.dispatch(ContentAction.UpdateSearchRequestAction(SELECTED_TAB_ID, searchRequest)) verify(performSearch, times(2)).invoke(searchRequest, SELECTED_TAB_ID) assertNull(store.state.selectedTab!!.content.searchRequest) diff --git a/mobile/android/android-components/components/feature/search/src/test/java/mozilla/components/feature/search/SearchUseCasesTest.kt b/mobile/android/android-components/components/feature/search/src/test/java/mozilla/components/feature/search/SearchUseCasesTest.kt @@ -23,8 +23,6 @@ import mozilla.components.concept.engine.EngineSession.LoadUrlFlags import mozilla.components.feature.search.ext.createSearchEngine import mozilla.components.feature.session.SessionUseCases import mozilla.components.feature.tabs.TabsUseCases -import mozilla.components.support.test.ext.joinBlocking -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.whenever @@ -97,13 +95,12 @@ class SearchUseCasesTest { tab = createTab(url = "https://www.mozilla.org", id = id), select = true, ), - ).joinBlocking() + ) useCases.defaultSearch( searchTerms = searchTerms, searchEngine = searchEngine, ) - store.waitUntilIdle() val isSearchAction = middleware.findFirstAction(ContentAction.UpdateIsSearchAction::class) assertEquals(id, isSearchAction.sessionId) @@ -134,7 +131,6 @@ class SearchUseCasesTest { sessionId = "mozilla", searchEngine = searchEngine, ) - store.waitUntilIdle() verify(newTabUseCase).invoke( url = searchUrl, @@ -157,7 +153,6 @@ class SearchUseCasesTest { whenever(newTabUseCase(searchUrl, isSearch = true)).thenReturn("2342") useCases.newTabSearch(searchTerms, SessionState.Source.Internal.NewTab) - store.waitUntilIdle() verify(newTabUseCase).invoke( searchUrl, @@ -197,7 +192,6 @@ class SearchUseCasesTest { flags = flags, additionalHeaders = additionalHeaders, ) - store.waitUntilIdle() verify(newTabUseCase).invoke( url = searchUrl, @@ -220,7 +214,6 @@ class SearchUseCasesTest { whenever(newTabUseCase(searchUrl, isSearch = true)).thenReturn("2342") useCases.defaultSearch(searchTerms) - store.waitUntilIdle() verify(newTabUseCase).invoke( searchUrl, @@ -259,7 +252,6 @@ class SearchUseCasesTest { flags = flags, additionalHeaders = additionalHeaders, ) - store.waitUntilIdle() verify(newTabUseCase).invoke( url = searchUrl, @@ -288,7 +280,6 @@ class SearchUseCasesTest { ).thenReturn("1177") useCases.newPrivateTabSearch.invoke(searchTerms) - store.waitUntilIdle() verify(newTabUseCase).invoke( searchUrl, @@ -320,8 +311,6 @@ class SearchUseCasesTest { useCases.newPrivateTabSearch.invoke(searchTerms, parentSessionId = "test-parent") - store.waitUntilIdle() - verify(newTabUseCase).invoke( searchUrl, parentId = "test-parent", @@ -346,8 +335,6 @@ class SearchUseCasesTest { store.findSearchEngineById("engine-d"), ) - store.waitUntilIdle() - assertEquals("engine-d", store.state.search.userSelectedSearchEngineId) assertNull(store.state.search.userSelectedSearchEngineName) @@ -355,8 +342,6 @@ class SearchUseCasesTest { store.findSearchEngineById("engine-b"), ) - store.waitUntilIdle() - assertEquals("engine-b", store.state.search.userSelectedSearchEngineId) assertEquals("Engine B", store.state.search.userSelectedSearchEngineName) @@ -364,8 +349,6 @@ class SearchUseCasesTest { store.findSearchEngineById("engine-f"), ) - store.waitUntilIdle() - assertEquals("engine-f", store.state.search.userSelectedSearchEngineId) assertNull(store.state.search.userSelectedSearchEngineName) } @@ -383,8 +366,6 @@ class SearchUseCasesTest { store.findSearchEngineById("engine-i"), ) - store.waitUntilIdle() - assertEquals(8, store.state.search.searchEngines.size) assertEquals(2, store.state.search.availableSearchEngines.size) @@ -408,8 +389,6 @@ class SearchUseCasesTest { store.findSearchEngineById("engine-h"), ) - store.waitUntilIdle() - assertEquals(8, store.state.search.searchEngines.size) assertEquals(2, store.state.search.availableSearchEngines.size) @@ -437,8 +416,6 @@ class SearchUseCasesTest { ), ) - store.waitUntilIdle() - assertEquals(8, store.state.search.searchEngines.size) assertEquals(3, store.state.search.availableSearchEngines.size) @@ -463,8 +440,6 @@ class SearchUseCasesTest { store.findSearchEngineById("engine-b"), ) - store.waitUntilIdle() - assertEquals(6, store.state.search.searchEngines.size) assertEquals(4, store.state.search.availableSearchEngines.size) @@ -488,8 +463,6 @@ class SearchUseCasesTest { store.findSearchEngineById("engine-f"), ) - store.waitUntilIdle() - assertEquals(6, store.state.search.searchEngines.size) assertEquals(4, store.state.search.availableSearchEngines.size) @@ -513,8 +486,6 @@ class SearchUseCasesTest { store.findSearchEngineById("engine-d"), ) - store.waitUntilIdle() - assertEquals(6, store.state.search.searchEngines.size) assertEquals(3, store.state.search.availableSearchEngines.size) @@ -532,7 +503,6 @@ class SearchUseCasesTest { searchEngineId = "engine-d", isEnabled = false, ) - store.waitUntilIdle() assertEquals(1, store.state.search.disabledSearchEngineIds.size) } @@ -548,7 +518,6 @@ class SearchUseCasesTest { searchEngineId = "engine-d", isEnabled = true, ) - store.waitUntilIdle() assertEquals(0, store.state.search.disabledSearchEngineIds.size) } @@ -578,7 +547,6 @@ class SearchUseCasesTest { assertEquals("bundled-engine-c", store.state.search.hiddenSearchEngines[0].id) useCases.restoreHiddenSearchEngines.invoke() - store.waitUntilIdle() assertEquals(3, store.state.search.regionSearchEngines.size) assertEquals(0, store.state.search.hiddenSearchEngines.size) @@ -606,7 +574,6 @@ class SearchUseCasesTest { assertEquals("bundled-engine-c", store.state.search.regionSearchEngines[2].id) useCases.restoreHiddenSearchEngines.invoke() - store.waitUntilIdle() assertEquals(0, store.state.search.hiddenSearchEngines.size) assertEquals(3, store.state.search.regionSearchEngines.size) diff --git a/mobile/android/android-components/components/feature/search/src/test/java/mozilla/components/feature/search/middleware/AdsTelemetryMiddlewareTest.kt b/mobile/android/android-components/components/feature/search/src/test/java/mozilla/components/feature/search/middleware/AdsTelemetryMiddlewareTest.kt @@ -54,7 +54,7 @@ class AdsTelemetryMiddlewareTest { triggeredByUser = false, ), ), - ).joinBlocking() + ) assertEquals(1, adsMiddleware.redirectChain.size) assertEquals("https://mozilla.org", adsMiddleware.redirectChain[sessionId]!!.root) @@ -77,7 +77,7 @@ class AdsTelemetryMiddlewareTest { triggeredByUser = false, ), ), - ).joinBlocking() + ) assertEquals(1, adsMiddleware.redirectChain.size) assertEquals("https://mozilla.org", adsMiddleware.redirectChain[sessionId]!!.root) @@ -98,7 +98,6 @@ class AdsTelemetryMiddlewareTest { store .dispatch(ContentAction.UpdateUrlAction(sessionId, "https://mozilla.org/firefox")) - .joinBlocking() verify(adsTelemetry).checkIfAddWasClicked( "https://mozilla.org", @@ -113,17 +112,17 @@ class AdsTelemetryMiddlewareTest { initialState = browserState, middleware = listOf(adsMiddleware), ) - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) store.dispatch( ContentAction.UpdateLoadRequestAction( tab.id, LoadRequestState("https://mozilla.org", true, true), ), - ).joinBlocking() + ) assertNotNull(adsMiddleware.redirectChain[tab.id]) - store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://mozilla.org")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://mozilla.org")) assertNull(adsMiddleware.redirectChain[tab.id]) } } diff --git a/mobile/android/android-components/components/feature/search/src/test/java/mozilla/components/feature/search/middleware/SearchMiddlewareTest.kt b/mobile/android/android-components/components/feature/search/src/test/java/mozilla/components/feature/search/middleware/SearchMiddlewareTest.kt @@ -16,9 +16,7 @@ import mozilla.components.browser.state.store.BrowserStore import mozilla.components.feature.search.ext.createSearchEngine import mozilla.components.feature.search.storage.CustomSearchEngineStorage import mozilla.components.feature.search.storage.SearchMetadataStorage -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.fakes.android.FakeSharedPreferences -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 @@ -77,9 +75,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("US", "US"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -108,9 +106,9 @@ class SearchMiddlewareTest { RegionState("US", "US"), "test", ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -138,9 +136,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("AN", "AN"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -176,9 +174,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("CA", "CA"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -214,9 +212,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("CY", "CY"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -252,9 +250,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("FY", "NL"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -290,9 +288,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("EN", "AU"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -328,9 +326,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("EN", "GB"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -367,9 +365,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("EN", "IE"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -406,9 +404,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("FR", "BE"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -445,9 +443,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("FR", "CA"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -483,9 +481,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("FR", "FR"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -522,9 +520,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("DE", "AT"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -562,9 +560,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("DE", "DE"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -602,9 +600,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("DSB", "DE"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -640,9 +638,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("HSB", "DE"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -678,9 +676,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("ES", "ES"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -716,9 +714,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("it", "IT"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -754,9 +752,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("lij", "ZE"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -792,9 +790,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("sv", "SE"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -831,9 +829,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("pl", "PL"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -868,9 +866,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("RU", "RU"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -900,9 +898,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("US", "US"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isNotEmpty()) @@ -948,9 +946,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("US", "US"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isNotEmpty()) @@ -1000,9 +998,9 @@ class SearchMiddlewareTest { store.dispatch( SearchAction.SetRegionAction(RegionState.Default), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.customSearchEngines.isNotEmpty()) assertNull(store.state.search.userSelectedSearchEngineId) @@ -1026,9 +1024,9 @@ class SearchMiddlewareTest { store.dispatch( SearchAction.SetRegionAction(RegionState.Default), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertEquals("test-id", store.state.search.userSelectedSearchEngineId) } @@ -1052,15 +1050,15 @@ class SearchMiddlewareTest { store.dispatch( SearchAction.SetRegionAction(RegionState.Default), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertNull(store.state.search.userSelectedSearchEngineId) - store.dispatch(SearchAction.SelectSearchEngineAction(id, null)).joinBlocking() + store.dispatch(SearchAction.SelectSearchEngineAction(id, null)) - wait(store, dispatcher) + wait(dispatcher) assertEquals(id, store.state.search.userSelectedSearchEngineId) } @@ -1079,9 +1077,9 @@ class SearchMiddlewareTest { store.dispatch( SearchAction.SetRegionAction(RegionState.Default), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertEquals(id, store.state.search.userSelectedSearchEngineId) } @@ -1107,9 +1105,9 @@ class SearchMiddlewareTest { store.dispatch( SearchAction.SetRegionAction(RegionState.Default), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isNotEmpty()) @@ -1133,9 +1131,9 @@ class SearchMiddlewareTest { store.dispatch( SearchAction.AddAdditionalSearchEngineAction("youtube"), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isNotEmpty()) @@ -1162,9 +1160,9 @@ class SearchMiddlewareTest { store.dispatch( SearchAction.SetRegionAction(RegionState.Default), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isNotEmpty()) @@ -1188,9 +1186,9 @@ class SearchMiddlewareTest { SearchAction.RemoveAdditionalSearchEngineAction( "youtube", ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isNotEmpty()) @@ -1219,9 +1217,9 @@ class SearchMiddlewareTest { store.dispatch( SearchAction.SetRegionAction(RegionState.Default), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isNotEmpty()) @@ -1263,9 +1261,9 @@ class SearchMiddlewareTest { store.dispatch( SearchAction.SetRegionAction(RegionState.Default), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.customSearchEngines.isEmpty()) verify(storage).loadSearchEngineList() @@ -1274,9 +1272,9 @@ class SearchMiddlewareTest { // Add a custom search engine val engine1 = SearchEngine("test-id-1", "test engine one", mock(), type = SearchEngine.Type.CUSTOM) - store.dispatch(SearchAction.UpdateCustomSearchEngineAction(engine1)).joinBlocking() + store.dispatch(SearchAction.UpdateCustomSearchEngineAction(engine1)) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.customSearchEngines.isNotEmpty()) assertEquals(1, store.state.search.customSearchEngines.size) @@ -1286,9 +1284,9 @@ class SearchMiddlewareTest { // Add another custom search engine val engine2 = SearchEngine("test-id-2", "test engine two", mock(), type = SearchEngine.Type.CUSTOM) - store.dispatch(SearchAction.UpdateCustomSearchEngineAction(engine2)).joinBlocking() + store.dispatch(SearchAction.UpdateCustomSearchEngineAction(engine2)) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.customSearchEngines.isNotEmpty()) assertEquals(2, store.state.search.customSearchEngines.size) @@ -1303,9 +1301,9 @@ class SearchMiddlewareTest { val updated = engine1.copy( name = "updated engine", ) - store.dispatch(SearchAction.UpdateCustomSearchEngineAction(updated)).joinBlocking() + store.dispatch(SearchAction.UpdateCustomSearchEngineAction(updated)) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.customSearchEngines.isNotEmpty()) assertEquals(2, store.state.search.customSearchEngines.size) @@ -1317,9 +1315,9 @@ class SearchMiddlewareTest { // Remove second engine - store.dispatch(SearchAction.RemoveCustomSearchEngineAction(engine2.id)).joinBlocking() + store.dispatch(SearchAction.RemoveCustomSearchEngineAction(engine2.id)) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.customSearchEngines.isNotEmpty()) assertEquals(1, store.state.search.customSearchEngines.size) @@ -1368,9 +1366,9 @@ class SearchMiddlewareTest { "bing", false, ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(metadataStorage.getDisabledSearchEngineIds().contains("bing")) assertTrue(store.state.search.disabledSearchEngineIds.contains("bing")) @@ -1380,9 +1378,9 @@ class SearchMiddlewareTest { "bing", true, ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertFalse(metadataStorage.getDisabledSearchEngineIds().contains("bing")) assertFalse(store.state.search.disabledSearchEngineIds.contains("bing")) @@ -1403,16 +1401,16 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("US", "US"), ), - ).joinBlocking() - wait(store, dispatcher) + ) + wait(dispatcher) val google = store.state.search.regionSearchEngines.find { searchEngine -> searchEngine.name == "Google" } assertNotNull(google!!) assertEquals(0, store.state.search.hiddenSearchEngines.size) assertEquals(0, metadataStorage.getHiddenSearchEngines().size) - store.dispatch(SearchAction.HideSearchEngineAction(google.id)).joinBlocking() - wait(store, dispatcher) + store.dispatch(SearchAction.HideSearchEngineAction(google.id)) + wait(dispatcher) assertNull(store.state.search.regionSearchEngines.find { it.id == google.id }) @@ -1421,8 +1419,8 @@ class SearchMiddlewareTest { assertNotNull(store.state.search.hiddenSearchEngines.find { it.id == google.id }) assertNotNull(metadataStorage.getHiddenSearchEngines().find { it == google.id }) - store.dispatch(SearchAction.RestoreHiddenSearchEnginesAction).joinBlocking() - wait(store, dispatcher) + store.dispatch(SearchAction.RestoreHiddenSearchEnginesAction) + wait(dispatcher) assertNotNull(store.state.search.regionSearchEngines.find { it.id == google.id }) @@ -1446,9 +1444,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("US", "US"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) store.state.search.regionSearchEngines.find { searchEngine -> searchEngine.name == "Google" } } @@ -1461,18 +1459,18 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("US", "US"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertNotNull(store.state.search.regionSearchEngines.find { it.id == google.id }) assertEquals(0, store.state.search.hiddenSearchEngines.size) store.dispatch( SearchAction.HideSearchEngineAction(google.id), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertNull(store.state.search.regionSearchEngines.find { it.id == google.id }) assertEquals(1, store.state.search.hiddenSearchEngines.size) @@ -1486,9 +1484,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("US", "US"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertNull(store.state.search.regionSearchEngines.find { it.id == google.id }) assertEquals(1, store.state.search.hiddenSearchEngines.size) @@ -1496,7 +1494,7 @@ class SearchMiddlewareTest { store.dispatch( SearchAction.ShowSearchEngineAction(google.id), - ).joinBlocking() + ) assertNotNull(store.state.search.regionSearchEngines.find { it.id == google.id }) assertEquals(0, store.state.search.hiddenSearchEngines.size) @@ -1509,9 +1507,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("US", "US"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertNotNull(store.state.search.regionSearchEngines.find { it.id == google.id }) assertEquals(0, store.state.search.hiddenSearchEngines.size) @@ -1534,9 +1532,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("US", "US"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) val google = store.state.search.searchEngines.find { it.name == "Google" } assertNotNull(google!!) @@ -1547,9 +1545,9 @@ class SearchMiddlewareTest { searchEngineId = "google-b-1-m", searchEngineName = "Google", ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertEquals("google-b-1-m", store.state.search.userSelectedSearchEngineId) assertEquals("Google", store.state.search.userSelectedSearchEngineName) @@ -1567,9 +1565,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("DE", "DE"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertEquals("google-b-1-m", store.state.search.userSelectedSearchEngineId) assertEquals("Google", store.state.search.userSelectedSearchEngineName) @@ -1597,9 +1595,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("US", "US"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertEquals(0, store.state.search.customSearchEngines.size) @@ -1615,9 +1613,9 @@ class SearchMiddlewareTest { ), ), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertEquals(1, store.state.search.customSearchEngines.size) } @@ -1629,9 +1627,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("US", "US"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertEquals(1, store.state.search.customSearchEngines.size) } @@ -1668,9 +1666,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("US", "US"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertEquals(1, store.state.search.customSearchEngines.size) @@ -1695,9 +1693,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("US", "US"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertEquals(1, store.state.search.customSearchEngines.size) @@ -1727,9 +1725,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("US", "US"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) // /////////////////////////////////////////////////////////////////////////////////////////// // Verify initial state @@ -1749,13 +1747,13 @@ class SearchMiddlewareTest { SearchAction.HideSearchEngineAction( "google-b-1-m", ), - ).joinBlocking() + ) store.dispatch( SearchAction.HideSearchEngineAction( "ddg", ), - ).joinBlocking() + ) // /////////////////////////////////////////////////////////////////////////////////////////// // Verify after hiding search engines @@ -1773,11 +1771,11 @@ class SearchMiddlewareTest { store.dispatch( SearchAction.ShowSearchEngineAction("google-b-1-m"), - ).joinBlocking() + ) store.dispatch( SearchAction.ShowSearchEngineAction("ddg"), - ).joinBlocking() + ) // /////////////////////////////////////////////////////////////////////////////////////////// // Verify state after adding search engines back @@ -1813,9 +1811,9 @@ class SearchMiddlewareTest { SearchAction.SetRegionAction( RegionState("JA", "JA"), ), - ).joinBlocking() + ) - wait(store, dispatcher) + wait(dispatcher) assertTrue(store.state.search.regionSearchEngines.isNotEmpty()) assertTrue(store.state.search.additionalAvailableSearchEngines.isEmpty()) @@ -1836,13 +1834,7 @@ class SearchMiddlewareTest { } } -private fun wait(store: BrowserStore, dispatcher: TestDispatcher) { - // First we wait for the InitAction that may still need to be processed. - store.waitUntilIdle() - +private fun wait(dispatcher: TestDispatcher) { // Now we wait for the Middleware that may need to asynchronously process an action the test dispatched dispatcher.scheduler.advanceUntilIdle() - - // Since the Middleware may have dispatched an action, we now wait for the store again. - store.waitUntilIdle() } diff --git a/mobile/android/android-components/components/feature/search/src/test/java/mozilla/components/feature/search/region/RegionMiddlewareTest.kt b/mobile/android/android-components/components/feature/search/src/test/java/mozilla/components/feature/search/region/RegionMiddlewareTest.kt @@ -18,7 +18,6 @@ import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.fakes.FakeClock import mozilla.components.support.test.fakes.android.FakeContext import mozilla.components.support.test.fakes.android.FakeSharedPreferences -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 @@ -63,9 +62,7 @@ class RegionMiddlewareTest { middleware = listOf(middleware), ) - store.waitUntilIdle() middleware.updateJob?.joinBlocking() - store.waitUntilIdle() assertNotEquals(RegionState.Default, store.state.search.region) assertEquals("FR", store.state.search.region!!.home) @@ -81,10 +78,9 @@ class RegionMiddlewareTest { middleware = listOf(middleware), ) - store.dispatch(InitAction).joinBlocking() + store.dispatch(InitAction) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() assertEquals(RegionState.Default, store.state.search.region) assertEquals("XX", store.state.search.region!!.home) @@ -103,9 +99,8 @@ class RegionMiddlewareTest { middleware = listOf(middleware), ) - store.dispatch(InitAction).joinBlocking() + store.dispatch(InitAction) middleware.updateJob?.joinBlocking() - store.waitUntilIdle() assertEquals("FR", store.state.search.region!!.home) assertEquals("FR", store.state.search.region!!.current) @@ -113,18 +108,16 @@ class RegionMiddlewareTest { locationService.region = LocationService.Region("DE", "Germany") regionManager.update() - store.dispatch(InitAction).joinBlocking() + store.dispatch(InitAction) middleware.updateJob?.joinBlocking() - store.waitUntilIdle() assertEquals("FR", store.state.search.region!!.home) assertEquals("DE", store.state.search.region!!.current) clock.advanceBy(1000L * 60L * 60L * 24L * 21L) - store.dispatch(InitAction).joinBlocking() + store.dispatch(InitAction) middleware.updateJob?.joinBlocking() - store.waitUntilIdle() assertEquals("DE", store.state.search.region!!.home) assertEquals("DE", store.state.search.region!!.current) @@ -142,9 +135,8 @@ class RegionMiddlewareTest { middleware = listOf(middleware), ) - store.dispatch(InitAction).joinBlocking() + store.dispatch(InitAction) middleware.updateJob?.joinBlocking() - store.waitUntilIdle() assertEquals("FR", store.state.search.region!!.home) assertEquals("FR", store.state.search.region!!.current) @@ -152,9 +144,8 @@ class RegionMiddlewareTest { locationService.region = LocationService.Region("DE", "Germany") regionManager.update() - store.dispatch(RefreshSearchEnginesAction).joinBlocking() + store.dispatch(RefreshSearchEnginesAction) middleware.updateJob?.joinBlocking() - store.waitUntilIdle() assertEquals("FR", store.state.search.region!!.home) assertEquals("DE", store.state.search.region!!.current) diff --git a/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/CoordinateScrollingFeatureTest.kt b/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/CoordinateScrollingFeatureTest.kt @@ -14,7 +14,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineView import mozilla.components.feature.session.CoordinateScrollingFeature.Companion.DEFAULT_SCROLL_FLAGS -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.whenever import org.junit.Before @@ -55,7 +54,7 @@ class CoordinateScrollingFeatureTest { scrollFeature.start() shadowOf(getMainLooper()).idle() - store.dispatch(ContentAction.UpdateLoadingStateAction("mozilla", true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction("mozilla", true)) verify((mockView.layoutParams as AppBarLayout.LayoutParams)).scrollFlags = 0 verify(mockView).layoutParams = any() @@ -68,7 +67,7 @@ class CoordinateScrollingFeatureTest { scrollFeature.start() shadowOf(getMainLooper()).idle() - store.dispatch(ContentAction.UpdateLoadingStateAction("mozilla", true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction("mozilla", true)) verify((mockView.layoutParams as AppBarLayout.LayoutParams)).scrollFlags = DEFAULT_SCROLL_FLAGS verify(mockView).layoutParams = any() @@ -81,7 +80,7 @@ class CoordinateScrollingFeatureTest { scrollFeature.start() shadowOf(getMainLooper()).idle() - store.dispatch(ContentAction.UpdateLoadingStateAction("mozilla", true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction("mozilla", true)) verify((mockView.layoutParams as AppBarLayout.LayoutParams)).scrollFlags = 12 verify(mockView).layoutParams = any() diff --git a/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/FullScreenFeatureTest.kt b/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/FullScreenFeatureTest.kt @@ -10,8 +10,6 @@ import mozilla.components.browser.state.action.TabListAction import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore -import mozilla.components.support.test.ext.joinBlocking -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 @@ -46,7 +44,6 @@ class FullScreenFeatureTest { ) feature.start() - store.waitUntilIdle() assertNull(viewPort) assertNull(fullscreen) @@ -73,7 +70,6 @@ class FullScreenFeatureTest { ) feature.start() - store.waitUntilIdle() assertNull(viewPort) assertNull(fullscreen) @@ -96,14 +92,14 @@ class FullScreenFeatureTest { "A", true, ), - ).joinBlocking() + ) store.dispatch( ContentAction.ViewportFitChangedAction( "A", 42, ), - ).joinBlocking() + ) val feature = FullScreenFeature( store = store, @@ -114,7 +110,6 @@ class FullScreenFeatureTest { ) feature.start() - store.waitUntilIdle() assertEquals(42, viewPort) assertTrue(fullscreen!!) @@ -147,7 +142,7 @@ class FullScreenFeatureTest { "A", true, ), - ).joinBlocking() + ) assertNull(viewPort) assertTrue(fullscreen!!) @@ -180,14 +175,14 @@ class FullScreenFeatureTest { "A", true, ), - ).joinBlocking() + ) store.dispatch( ContentAction.ViewportFitChangedAction( "A", WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES, ), - ).joinBlocking() + ) assertNotEquals(0, viewPort) assertEquals(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES, viewPort) @@ -225,14 +220,14 @@ class FullScreenFeatureTest { "B", true, ), - ).joinBlocking() + ) store.dispatch( ContentAction.ViewportFitChangedAction( "B", WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES, ), - ).joinBlocking() + ) assertEquals(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES, viewPort) assertTrue(fullscreen!!) @@ -242,14 +237,14 @@ class FullScreenFeatureTest { "B", false, ), - ).joinBlocking() + ) store.dispatch( ContentAction.ViewportFitChangedAction( "B", 0, ), - ).joinBlocking() + ) assertEquals(0, viewPort) assertFalse(fullscreen) @@ -284,14 +279,14 @@ class FullScreenFeatureTest { "B", true, ), - ).joinBlocking() + ) store.dispatch( ContentAction.ViewportFitChangedAction( "B", WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER, ), - ).joinBlocking() + ) feature.start() @@ -305,14 +300,14 @@ class FullScreenFeatureTest { "B", false, ), - ).joinBlocking() + ) store.dispatch( ContentAction.ViewportFitChangedAction( "B", WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES, ), - ).joinBlocking() + ) assertEquals(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER, viewPort) assertTrue(fullscreen) @@ -354,14 +349,14 @@ class FullScreenFeatureTest { "B", true, ), - ).joinBlocking() + ) store.dispatch( ContentAction.ViewportFitChangedAction( "B", WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES, ), - ).joinBlocking() + ) assertTrue(feature.onBackPressed()) @@ -395,21 +390,21 @@ class FullScreenFeatureTest { "A", true, ), - ).joinBlocking() + ) store.dispatch( ContentAction.ViewportFitChangedAction( "A", WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES, ), - ).joinBlocking() + ) assertEquals(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES, viewPort) assertTrue(fullscreen!!) store.dispatch( TabListAction.RemoveTabAction(tabId = "A"), - ).joinBlocking() + ) assertEquals(0, viewPort) assertFalse(fullscreen) @@ -488,9 +483,8 @@ class FullScreenFeatureTest { "A", true, ), - ).joinBlocking() + ) feature.start() - store.waitUntilIdle() } } diff --git a/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/SessionFeatureTest.kt b/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/SessionFeatureTest.kt @@ -20,8 +20,6 @@ import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.EngineView import mozilla.components.support.test.any -import mozilla.components.support.test.ext.joinBlocking -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 @@ -52,14 +50,13 @@ class SessionFeatureTest { doReturn(actualView).`when`(view).asView() val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("B", engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("B", engineSession)) val feature = SessionFeature(store, mock(), mock(), view) verify(view, never()).render(any()) feature.start() - store.waitUntilIdle() verify(view).render(engineSession) } @@ -72,15 +69,13 @@ class SessionFeatureTest { doReturn(actualView).`when`(view).asView() val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("C", engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("C", engineSession)) val feature = SessionFeature(store, mock(), mock(), view, tabId = "C") verify(view, never()).render(any()) feature.start() - store.waitUntilIdle() - verify(view).render(engineSession) } @@ -93,14 +88,12 @@ class SessionFeatureTest { doReturn(actualView).`when`(view).asView() val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("D", engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("D", engineSession)) val feature = SessionFeature(store, mock(), mock(), view, tabId = "D") verify(view, never()).render(any()) feature.start() - store.waitUntilIdle() - verify(view).render(engineSession) } @@ -114,18 +107,16 @@ class SessionFeatureTest { val engineSessionA: EngineSession = mock() val engineSessionB: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("A", engineSessionA)).joinBlocking() - store.dispatch(EngineAction.LinkEngineSessionAction("B", engineSessionB)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("A", engineSessionA)) + store.dispatch(EngineAction.LinkEngineSessionAction("B", engineSessionB)) val feature = SessionFeature(store, mock(), mock(), view) verify(view, never()).render(any()) feature.start() - store.waitUntilIdle() verify(view).render(engineSessionB) - store.dispatch(TabListAction.SelectTabAction("A")).joinBlocking() - store.waitUntilIdle() + store.dispatch(TabListAction.SelectTabAction("A")) verify(view).render(engineSessionA) } @@ -140,7 +131,6 @@ class SessionFeatureTest { verify(view, never()).render(any()) feature.start() - store.waitUntilIdle() verify(store).dispatch(EngineAction.CreateEngineSessionAction("B")) } @@ -154,20 +144,18 @@ class SessionFeatureTest { val engineSessionA: EngineSession = mock() val engineSessionB: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("A", engineSessionA)).joinBlocking() - store.dispatch(EngineAction.LinkEngineSessionAction("B", engineSessionB)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("A", engineSessionA)) + store.dispatch(EngineAction.LinkEngineSessionAction("B", engineSessionB)) val feature = SessionFeature(store, mock(), mock(), view) verify(view, never()).render(any()) feature.start() - store.waitUntilIdle() verify(view).render(engineSessionB) feature.stop() - store.dispatch(TabListAction.SelectTabAction("A")).joinBlocking() - store.waitUntilIdle() + store.dispatch(TabListAction.SelectTabAction("A")) verify(view, never()).render(engineSessionA) } @@ -180,17 +168,15 @@ class SessionFeatureTest { doReturn(actualView).`when`(view).asView() val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("B", engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("B", engineSession)) val feature = SessionFeature(store, mock(), mock(), view) feature.start() - store.waitUntilIdle() - verify(view).render(engineSession) verify(view, never()).release() - store.dispatch(TabListAction.RemoveAllTabsAction()).joinBlocking() + store.dispatch(TabListAction.RemoveAllTabsAction()) verify(view).release() } @@ -203,22 +189,20 @@ class SessionFeatureTest { doReturn(actualView).`when`(view).asView() val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("B", engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("B", engineSession)) val feature = SessionFeature(store, mock(), mock(), view) verify(view, never()).render(any()) feature.start() - store.waitUntilIdle() - verify(view).render(engineSession) val newEngineSession: EngineSession = mock() feature.release() verify(view).release() - store.dispatch(TabListAction.SelectTabAction("A")).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("A")) verify(view, never()).render(newEngineSession) } @@ -231,19 +215,17 @@ class SessionFeatureTest { doReturn(actualView).`when`(view).asView() val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("D", engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("D", engineSession)) val feature = SessionFeature(store, mock(), mock(), view, tabId = "D") verify(view, never()).render(any()) feature.start() - store.waitUntilIdle() - verify(view).render(engineSession) verify(view, never()).release() - store.dispatch(CustomTabListAction.RemoveCustomTabAction("D")).joinBlocking() + store.dispatch(CustomTabListAction.RemoveCustomTabAction("D")) verify(view).release() } @@ -301,7 +283,7 @@ class SessionFeatureTest { "A", canGoBack = true, ), - ).joinBlocking() + ) val useCase: SessionUseCases.GoBackUseCase = mock() @@ -343,7 +325,7 @@ class SessionFeatureTest { "A", canGoForward = true, ), - ).joinBlocking() + ) val forwardUseCase: SessionUseCases.GoForwardUseCase = mock() @@ -363,14 +345,12 @@ class SessionFeatureTest { doReturn(actualView).`when`(view).asView() val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("D", engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("D", engineSession)) val feature = SessionFeature(store, mock(), mock(), view, tabId = "D") verify(view, never()).render(any()) feature.start() - store.waitUntilIdle() - verify(view).render(engineSession) feature.stop() @@ -387,14 +367,13 @@ class SessionFeatureTest { doReturn(actualView).`when`(view).asView() val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("A", engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("A", engineSession)) val feature = SessionFeature(store, mock(), mock(), view, tabId = "A") verify(view, never()).render(any()) feature.start() - store.dispatch(CrashAction.SessionCrashedAction("A")).joinBlocking() - store.waitUntilIdle() + store.dispatch(CrashAction.SessionCrashedAction("A")) verify(view, atLeastOnce()).release() middleware.assertNotDispatched(EngineAction.CreateEngineSessionAction::class) } @@ -408,14 +387,13 @@ class SessionFeatureTest { doReturn(actualView).`when`(view).asView() val engineSession: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction("B", engineSession)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction("B", engineSession)) val feature = SessionFeature(store, mock(), mock(), view) verify(view, never()).render(any()) assertEquals(0L, store.state.findTab("B")?.lastAccess) feature.start() - store.waitUntilIdle() assertNotEquals(0L, store.state.findTab("B")?.lastAccess) verify(view).render(engineSession) diff --git a/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/SessionUseCasesTest.kt b/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/SessionUseCasesTest.kt @@ -18,8 +18,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.EngineSession.LoadUrlFlags -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.mock import org.junit.Assert.assertEquals @@ -73,7 +71,6 @@ class SessionUseCasesTest { @Test fun loadUrlWithEngineSession() { useCases.loadUrl("https://getpocket.com") - store.waitUntilIdle() middleware.assertNotDispatched(EngineAction.LoadUrlAction::class) verify(engineSession).loadUrl(url = "https://getpocket.com") middleware.assertLastAction(EngineAction.OptimizedLoadUrlTriggeredAction::class) { action -> @@ -82,7 +79,6 @@ class SessionUseCasesTest { } useCases.loadUrl("https://www.mozilla.org", LoadUrlFlags.select(LoadUrlFlags.EXTERNAL)) - store.waitUntilIdle() middleware.assertNotDispatched(EngineAction.LoadUrlAction::class) verify(engineSession).loadUrl( url = "https://www.mozilla.org", @@ -95,7 +91,6 @@ class SessionUseCasesTest { } useCases.loadUrl("https://firefox.com", store.state.selectedTabId) - store.waitUntilIdle() middleware.assertNotDispatched(EngineAction.LoadUrlAction::class) verify(engineSession).loadUrl(url = "https://firefox.com") middleware.assertLastAction(EngineAction.OptimizedLoadUrlTriggeredAction::class) { action -> @@ -108,7 +103,6 @@ class SessionUseCasesTest { store.state.selectedTabId, LoadUrlFlags.select(LoadUrlFlags.BYPASS_PROXY), ) - store.waitUntilIdle() middleware.assertNotDispatched(EngineAction.LoadUrlAction::class) verify(engineSession).loadUrl( url = "https://developer.mozilla.org", @@ -124,7 +118,6 @@ class SessionUseCasesTest { "https://www.mozilla.org/en-CA/firefox/browsers/mobile/", "bugzilla", ) - store.waitUntilIdle() middleware.assertNotDispatched(EngineAction.LoadUrlAction::class) verify(childEngineSession).loadUrl( url = "https://www.mozilla.org/en-CA/firefox/browsers/mobile/", @@ -137,10 +130,9 @@ class SessionUseCasesTest { @Test fun loadUrlWithoutEngineSession() { - store.dispatch(EngineAction.UnlinkEngineSessionAction("mozilla")).joinBlocking() + store.dispatch(EngineAction.UnlinkEngineSessionAction("mozilla")) useCases.loadUrl("https://getpocket.com") - store.waitUntilIdle() middleware.assertLastAction(EngineAction.LoadUrlAction::class) { action -> assertEquals("mozilla", action.tabId) @@ -148,7 +140,6 @@ class SessionUseCasesTest { } useCases.loadUrl("https://www.mozilla.org", LoadUrlFlags.select(LoadUrlFlags.EXTERNAL)) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.LoadUrlAction::class) { action -> assertEquals("mozilla", action.tabId) @@ -157,7 +148,6 @@ class SessionUseCasesTest { } useCases.loadUrl("https://firefox.com", store.state.selectedTabId) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.LoadUrlAction::class) { action -> assertEquals("mozilla", action.tabId) @@ -169,7 +159,6 @@ class SessionUseCasesTest { store.state.selectedTabId, LoadUrlFlags.select(LoadUrlFlags.BYPASS_PROXY), ) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.LoadUrlAction::class) { action -> assertEquals("mozilla", action.tabId) @@ -181,7 +170,6 @@ class SessionUseCasesTest { @Test fun loadData() { useCases.loadData("<html><body></body></html>", "text/html") - store.waitUntilIdle() middleware.assertLastAction(EngineAction.LoadDataAction::class) { action -> assertEquals("mozilla", action.tabId) assertEquals("<html><body></body></html>", action.data) @@ -194,7 +182,6 @@ class SessionUseCasesTest { "text/plain", tabId = store.state.selectedTabId, ) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.LoadDataAction::class) { action -> assertEquals("mozilla", action.tabId) assertEquals("Should load in WebView", action.data) @@ -208,7 +195,6 @@ class SessionUseCasesTest { "base64", store.state.selectedTabId, ) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.LoadDataAction::class) { action -> assertEquals("mozilla", action.tabId) assertEquals("Should also load in WebView", action.data) @@ -220,14 +206,12 @@ class SessionUseCasesTest { @Test fun reload() { useCases.reload() - store.waitUntilIdle() middleware.assertLastAction(EngineAction.ReloadAction::class) { action -> assertEquals("mozilla", action.tabId) } useCases.reload(store.state.selectedTabId, LoadUrlFlags.select(LoadUrlFlags.EXTERNAL)) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.ReloadAction::class) { action -> assertEquals("mozilla", action.tabId) @@ -239,7 +223,6 @@ class SessionUseCasesTest { fun reloadBypassCache() { val flags = LoadUrlFlags.select(LoadUrlFlags.BYPASS_CACHE) useCases.reload(store.state.selectedTabId, flags = flags) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.ReloadAction::class) { action -> assertEquals("mozilla", action.tabId) @@ -250,22 +233,18 @@ class SessionUseCasesTest { @Test fun stopLoading() = runTest { useCases.stopLoading() - store.waitUntilIdle() verify(engineSession).stopLoading() useCases.stopLoading(store.state.selectedTabId) - store.waitUntilIdle() verify(engineSession, times(2)).stopLoading() } @Test fun goBack() { useCases.goBack(null) - store.waitUntilIdle() middleware.assertNotDispatched(EngineAction.GoBackAction::class) useCases.goBack(store.state.selectedTabId) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.GoBackAction::class) { action -> assertEquals("mozilla", action.tabId) assertTrue(action.userInteraction) @@ -273,7 +252,6 @@ class SessionUseCasesTest { middleware.reset() useCases.goBack(userInteraction = false) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.GoBackAction::class) { action -> assertEquals("mozilla", action.tabId) assertFalse(action.userInteraction) @@ -283,11 +261,9 @@ class SessionUseCasesTest { @Test fun goForward() { useCases.goForward(null) - store.waitUntilIdle() middleware.assertNotDispatched(EngineAction.GoForwardAction::class) useCases.goForward(store.state.selectedTabId) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.GoForwardAction::class) { action -> assertEquals("mozilla", action.tabId) assertTrue(action.userInteraction) @@ -295,7 +271,6 @@ class SessionUseCasesTest { middleware.reset() useCases.goForward(userInteraction = false) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.GoForwardAction::class) { action -> assertEquals("mozilla", action.tabId) assertFalse(action.userInteraction) @@ -305,18 +280,15 @@ class SessionUseCasesTest { @Test fun goToHistoryIndex() { useCases.goToHistoryIndex(tabId = null, index = 0) - store.waitUntilIdle() middleware.assertNotDispatched(EngineAction.GoToHistoryIndexAction::class) useCases.goToHistoryIndex(tabId = "test", index = 5) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.GoToHistoryIndexAction::class) { action -> assertEquals("test", action.tabId) assertEquals(5, action.index) } useCases.goToHistoryIndex(index = 10) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.GoToHistoryIndexAction::class) { action -> assertEquals("mozilla", action.tabId) assertEquals(10, action.index) @@ -326,26 +298,22 @@ class SessionUseCasesTest { @Test fun requestDesktopSite() { useCases.requestDesktopSite(true, store.state.selectedTabId) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.ToggleDesktopModeAction::class) { action -> assertEquals("mozilla", action.tabId) assertTrue(action.enable) } useCases.requestDesktopSite(false) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.ToggleDesktopModeAction::class) { action -> assertEquals("mozilla", action.tabId) assertFalse(action.enable) } useCases.requestDesktopSite(true, store.state.selectedTabId) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.ToggleDesktopModeAction::class) { action -> assertEquals("mozilla", action.tabId) assertTrue(action.enable) } useCases.requestDesktopSite(false, store.state.selectedTabId) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.ToggleDesktopModeAction::class) { action -> assertEquals("mozilla", action.tabId) assertFalse(action.enable) @@ -355,14 +323,12 @@ class SessionUseCasesTest { @Test fun exitFullscreen() { useCases.exitFullscreen(store.state.selectedTabId) - store.waitUntilIdle() middleware.assertLastAction(EngineAction.ExitFullScreenModeAction::class) { action -> assertEquals("mozilla", action.tabId) } middleware.reset() useCases.exitFullscreen() - store.waitUntilIdle() middleware.assertLastAction(EngineAction.ExitFullScreenModeAction::class) { action -> assertEquals("mozilla", action.tabId) } @@ -373,7 +339,7 @@ class SessionUseCasesTest { var createdTab: TabSessionState? = null var tabCreatedForUrl: String? = null - store.dispatch(TabListAction.RemoveAllTabsAction()).joinBlocking() + store.dispatch(TabListAction.RemoveAllTabsAction()) val loadUseCase = SessionUseCases.DefaultLoadUrlUseCase(store) { url -> tabCreatedForUrl = url @@ -381,7 +347,6 @@ class SessionUseCasesTest { } loadUseCase("https://www.example.com") - store.waitUntilIdle() assertEquals("https://www.example.com", tabCreatedForUrl) assertNotNull(createdTab) @@ -397,8 +362,7 @@ class SessionUseCasesTest { var createdTab: TabSessionState? = null var tabCreatedForUrl: String? = null - store.dispatch(TabListAction.RemoveAllTabsAction()).joinBlocking() - store.waitUntilIdle() + store.dispatch(TabListAction.RemoveAllTabsAction()) val loadUseCase = SessionUseCases.LoadDataUseCase(store) { url -> tabCreatedForUrl = url @@ -406,7 +370,6 @@ class SessionUseCasesTest { } loadUseCase("Hello", mimeType = "text/plain", encoding = "UTF-8") - store.waitUntilIdle() assertEquals("about:blank", tabCreatedForUrl) assertNotNull(createdTab) @@ -422,7 +385,6 @@ class SessionUseCasesTest { @Test fun `CrashRecoveryUseCase will restore specified session`() { useCases.crashRecovery.invoke(listOf("mozilla")) - store.waitUntilIdle() middleware.assertLastAction(CrashAction.RestoreCrashedSessionAction::class) { action -> assertEquals("mozilla", action.tabId) @@ -451,7 +413,6 @@ class SessionUseCasesTest { val useCases = SessionUseCases(store) useCases.crashRecovery.invoke() - store.waitUntilIdle() middleware.assertFirstAction(CrashAction.RestoreCrashedSessionAction::class) { action -> assertEquals("tab1", action.tabId) @@ -465,7 +426,6 @@ class SessionUseCasesTest { @Test fun `PurgeHistoryUseCase dispatches PurgeHistory action`() { useCases.purgeHistory() - store.waitUntilIdle() middleware.findFirstAction(EngineAction.PurgeHistoryAction::class) } @@ -485,30 +445,25 @@ class SessionUseCasesTest { // Make sure use case doesn't crash for custom tab and non-existent tab useCases.updateLastAccess(customTab.id) - store.waitUntilIdle() assertEquals(0L, store.state.findTab(tab.id)?.lastAccess) // Update last access for a specific tab with default value useCases.updateLastAccess(tab.id) - store.waitUntilIdle() assertNotEquals(0L, store.state.findTab(tab.id)?.lastAccess) // Update last access for a specific tab with specific value useCases.updateLastAccess(tab.id, 123L) - store.waitUntilIdle() assertEquals(123L, store.state.findTab(tab.id)?.lastAccess) // Update last access for currently selected tab - store.dispatch(TabListAction.SelectTabAction(otherTab.id)).joinBlocking() + store.dispatch(TabListAction.SelectTabAction(otherTab.id)) assertEquals(0L, store.state.findTab(otherTab.id)?.lastAccess) useCases.updateLastAccess() - store.waitUntilIdle() assertNotEquals(0L, store.state.findTab(otherTab.id)?.lastAccess) // Update last access for currently selected tab with specific value - store.dispatch(TabListAction.SelectTabAction(otherTab.id)).joinBlocking() + store.dispatch(TabListAction.SelectTabAction(otherTab.id)) useCases.updateLastAccess(lastAccess = 345L) - store.waitUntilIdle() assertEquals(345L, store.state.findTab(otherTab.id)?.lastAccess) } } diff --git a/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/SettingsUseCasesTest.kt b/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/SettingsUseCasesTest.kt @@ -12,7 +12,6 @@ import mozilla.components.concept.engine.Engine import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.EngineSession.TrackingProtectionPolicy import mozilla.components.concept.engine.Settings -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import org.junit.Test import org.mockito.Mockito.doReturn @@ -40,14 +39,14 @@ class SettingsUseCasesTest { tabId = "A", engineSession = engineSessionA, ), - ).joinBlocking() + ) store.dispatch( EngineAction.LinkEngineSessionAction( tabId = "B", engineSession = engineSessionB, ), - ).joinBlocking() + ) val engine: Engine = mock() val settings: Settings = mock() diff --git a/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/SwipeRefreshFeatureTest.kt b/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/SwipeRefreshFeatureTest.kt @@ -18,8 +18,6 @@ import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.EngineView import mozilla.components.concept.engine.InputResultDetail import mozilla.components.concept.engine.selection.SelectionActionDelegate -import mozilla.components.support.test.ext.joinBlocking -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.assertFalse @@ -89,8 +87,7 @@ class SwipeRefreshFeatureTest { val selectedTab = store.state.findCustomTabOrSelectedTab()!! - store.dispatch(ContentAction.UpdateRefreshCanceledStateAction(selectedTab.id, true)).joinBlocking() - store.waitUntilIdle() + store.dispatch(ContentAction.UpdateRefreshCanceledStateAction(selectedTab.id, true)) assertFalse(selectedTab.content.refreshCanceled) } @@ -98,22 +95,20 @@ class SwipeRefreshFeatureTest { @Test fun `feature clears the swipeRefreshLayout#isRefreshing when tab fishes loading or a refreshCanceled`() { refreshFeature.start() - store.waitUntilIdle() val selectedTab = store.state.findCustomTabOrSelectedTab()!! // Ignoring the first event from the initial state. reset(mockLayout) - store.dispatch(ContentAction.UpdateRefreshCanceledStateAction(selectedTab.id, true)).joinBlocking() - store.waitUntilIdle() + store.dispatch(ContentAction.UpdateRefreshCanceledStateAction(selectedTab.id, true)) verify(mockLayout, times(2)).isRefreshing = false // To trigger to an event we have to change loading from its previous value (false to true). // As if we dispatch with loading = false, none event will be trigger. - store.dispatch(ContentAction.UpdateLoadingStateAction(selectedTab.id, true)).joinBlocking() - store.dispatch(ContentAction.UpdateLoadingStateAction(selectedTab.id, false)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction(selectedTab.id, true)) + store.dispatch(ContentAction.UpdateLoadingStateAction(selectedTab.id, false)) verify(mockLayout, times(3)).isRefreshing = false } diff --git a/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/TrackingProtectionUseCasesTest.kt b/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/TrackingProtectionUseCasesTest.kt @@ -25,8 +25,6 @@ import mozilla.components.concept.engine.content.blocking.TrackingProtectionExce import mozilla.components.concept.engine.content.blocking.TrackingProtectionExceptionStorage import mozilla.components.support.test.any import mozilla.components.support.test.eq -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.mock import mozilla.components.support.test.whenever import org.junit.Assert.assertFalse @@ -116,7 +114,7 @@ class TrackingProtectionUseCasesTest { store.dispatch( EngineAction.UnlinkEngineSessionAction("A"), - ).joinBlocking() + ) whenever(engine.getTrackersLog(any(), any(), any())).then { onSuccess(emptyList()) @@ -149,7 +147,7 @@ class TrackingProtectionUseCasesTest { fun `add exception with a null engine session will not call the store`() { store.dispatch( EngineAction.UnlinkEngineSessionAction("A"), - ).joinBlocking() + ) useCases.addException("A") @@ -189,11 +187,10 @@ class TrackingProtectionUseCasesTest { override val url: String = tab1.content.url } - store.dispatch(TabListAction.AddTabAction(tab1)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab2)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab3)).joinBlocking() - store.dispatch(CustomTabListAction.AddCustomTabAction(customTab)).joinBlocking() - store.waitUntilIdle() + store.dispatch(TabListAction.AddTabAction(tab1)) + store.dispatch(TabListAction.AddTabAction(tab2)) + store.dispatch(TabListAction.AddTabAction(tab3)) + store.dispatch(CustomTabListAction.AddCustomTabAction(customTab)) assertTrue(store.state.findTab(tab1.id)!!.trackingProtection.ignoredOnTrackingProtection) assertTrue(store.state.findTab(tab2.id)!!.trackingProtection.ignoredOnTrackingProtection) @@ -204,8 +201,6 @@ class TrackingProtectionUseCasesTest { verify(exceptionStore).remove(exception) - store.waitUntilIdle() - assertFalse(store.state.findTab(tab1.id)!!.trackingProtection.ignoredOnTrackingProtection) // Different domain from tab1 MUST not be affected @@ -220,7 +215,7 @@ class TrackingProtectionUseCasesTest { fun `remove exception with a null engine session will not call the store`() { store.dispatch( EngineAction.UnlinkEngineSessionAction("A"), - ).joinBlocking() + ) useCases.removeException("A") @@ -248,7 +243,7 @@ class TrackingProtectionUseCasesTest { store.dispatch( EngineAction.UnlinkEngineSessionAction("A"), - ).joinBlocking() + ) useCases.containsException("A") { contains = it diff --git a/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/middleware/LastAccessMiddlewareTest.kt b/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/middleware/LastAccessMiddlewareTest.kt @@ -16,7 +16,6 @@ import mozilla.components.browser.state.state.recover.RecoverableTab import mozilla.components.browser.state.state.recover.TabState import mozilla.components.browser.state.store.BrowserStore import mozilla.components.lib.state.MiddlewareContext -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.whenever import org.junit.Assert.assertEquals @@ -58,7 +57,7 @@ class LastAccessMiddlewareTest { assertEquals(0L, store.state.tabs[0].lastAccess) assertEquals(0L, store.state.tabs[1].lastAccess) - store.dispatch(TabListAction.SelectTabAction("456")).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("456")) assertEquals(0L, store.state.tabs[0].lastAccess) assertNotEquals(0L, store.state.tabs[1].lastAccess) @@ -79,7 +78,7 @@ class LastAccessMiddlewareTest { assertEquals(0L, store.state.selectedTab?.lastAccess) val newTab = createTab("https://firefox.com", id = "456") - store.dispatch(TabListAction.AddTabAction(newTab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(newTab, select = true)) assertEquals("456", store.state.selectedTabId) assertNotEquals(0L, store.state.selectedTab?.lastAccess) @@ -100,7 +99,7 @@ class LastAccessMiddlewareTest { assertEquals(0L, store.state.selectedTab?.lastAccess) val newTab = createTab("https://firefox.com", id = "456") - store.dispatch(TabListAction.AddTabAction(newTab, select = false)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(newTab, select = false)) assertEquals("123", store.state.selectedTabId) assertEquals(0L, store.state.selectedTab?.lastAccess) @@ -119,7 +118,7 @@ class LastAccessMiddlewareTest { ) assertEquals(0L, store.state.selectedTab?.lastAccess) - store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://mozilla.org")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://mozilla.org")) assertNotEquals(0L, store.state.selectedTab?.lastAccess) } @@ -136,8 +135,8 @@ class LastAccessMiddlewareTest { assertEquals(0L, store.state.selectedTab?.lastAccess) val newTab = createTab("https://mozilla.org", id = "456") - store.dispatch(TabListAction.AddTabAction(newTab)).joinBlocking() - store.dispatch(ContentAction.UpdateUrlAction(newTab.id, "https://mozilla.org")).joinBlocking() + store.dispatch(TabListAction.AddTabAction(newTab)) + store.dispatch(ContentAction.UpdateUrlAction(newTab.id, "https://mozilla.org")) assertEquals(0L, store.state.selectedTab?.lastAccess) assertEquals(0L, store.state.findTab(newTab.id)?.lastAccess) } @@ -158,7 +157,7 @@ class LastAccessMiddlewareTest { assertEquals(0L, store.state.tabs[0].lastAccess) assertEquals(0L, store.state.tabs[1].lastAccess) - store.dispatch(TabListAction.RemoveTabAction("123")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("123")) val selectedTab = store.state.findTab("456") assertNotNull(selectedTab) @@ -182,7 +181,7 @@ class LastAccessMiddlewareTest { assertEquals(0L, store.state.tabs[0].lastAccess) assertEquals(0L, store.state.tabs[1].lastAccess) - store.dispatch(TabListAction.RemoveTabAction("456")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("456")) val selectedTab = store.state.findTab("123") assertNotNull(selectedTab) assertEquals(selectedTab!!.id, store.state.selectedTabId) @@ -207,7 +206,7 @@ class LastAccessMiddlewareTest { assertEquals(0L, store.state.tabs[1].lastAccess) assertEquals(0L, store.state.tabs[2].lastAccess) - store.dispatch(TabListAction.RemoveTabsAction(listOf("123", "456"))).joinBlocking() + store.dispatch(TabListAction.RemoveTabsAction(listOf("123", "456"))) val selectedTab = store.state.findTab("789") assertNotNull(selectedTab) @@ -233,7 +232,7 @@ class LastAccessMiddlewareTest { assertEquals(0L, store.state.tabs[1].lastAccess) assertEquals(0L, store.state.tabs[2].lastAccess) - store.dispatch(TabListAction.RemoveTabsAction(listOf("456", "789"))).joinBlocking() + store.dispatch(TabListAction.RemoveTabsAction(listOf("456", "789"))) val selectedTab = store.state.findTab("123") assertEquals(selectedTab!!.id, store.state.selectedTabId) assertEquals(0L, selectedTab.lastAccess) @@ -257,7 +256,7 @@ class LastAccessMiddlewareTest { assertEquals(0L, store.state.tabs[1].lastAccess) assertEquals(0L, store.state.tabs[2].lastAccess) - store.dispatch(TabListAction.RemoveAllPrivateTabsAction).joinBlocking() + store.dispatch(TabListAction.RemoveAllPrivateTabsAction) val selectedTab = store.state.findTab("123") assertNotNull(selectedTab) @@ -289,7 +288,7 @@ class LastAccessMiddlewareTest { "2", TabListAction.RestoreAction.RestoreLocation.BEGINNING, ), - ).joinBlocking() + ) assertTrue(store.state.tabs.size == 2) diff --git a/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/middleware/undo/UndoMiddlewareTest.kt b/mobile/android/android-components/components/feature/session/src/test/java/mozilla/components/feature/session/middleware/undo/UndoMiddlewareTest.kt @@ -12,8 +12,6 @@ import mozilla.components.browser.state.selector.selectedTab import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore -import mozilla.components.support.test.ext.joinBlocking -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 @@ -48,7 +46,7 @@ class UndoMiddlewareTest { store.dispatch( TabListAction.RemoveTabAction(tabId = "mozilla"), - ).joinBlocking() + ) assertEquals(1, store.state.tabs.size) assertEquals("https://getpocket.com", store.state.selectedTab!!.content.url) @@ -80,7 +78,7 @@ class UndoMiddlewareTest { store.dispatch( TabListAction.RemoveTabsAction(listOf("mozilla", "pocket")), - ).joinBlocking() + ) assertEquals(1, store.state.tabs.size) assertEquals("https://firefox.com", store.state.selectedTab!!.content.url) @@ -112,7 +110,7 @@ class UndoMiddlewareTest { store.dispatch( TabListAction.RemoveAllNormalTabsAction, - ).joinBlocking() + ) assertEquals(1, store.state.tabs.size) assertNull(store.state.selectedTab) @@ -144,7 +142,7 @@ class UndoMiddlewareTest { store.dispatch( TabListAction.RemoveAllTabsAction(), - ).joinBlocking() + ) assertEquals(0, store.state.tabs.size) assertNull(store.state.selectedTab) @@ -176,15 +174,13 @@ class UndoMiddlewareTest { store.dispatch( TabListAction.RemoveAllTabsAction(false), - ).joinBlocking() + ) assertEquals(0, store.state.tabs.size) assertNull(store.state.selectedTab) restoreRecoverableTabs(dispatcher, store) - store.waitUntilIdle() - assertEquals(0, store.state.tabs.size) } @@ -210,7 +206,7 @@ class UndoMiddlewareTest { store.dispatch( TabListAction.RemoveAllPrivateTabsAction, - ).joinBlocking() + ) assertNull(store.state.undoHistory.selectedTabId) assertEquals(1, store.state.undoHistory.tabs.size) @@ -219,7 +215,7 @@ class UndoMiddlewareTest { store.dispatch( TabListAction.RemoveAllNormalTabsAction, - ).joinBlocking() + ) assertEquals("pocket", store.state.undoHistory.selectedTabId) assertEquals(2, store.state.undoHistory.tabs.size) @@ -257,7 +253,7 @@ class UndoMiddlewareTest { store.dispatch( TabListAction.RemoveAllNormalTabsAction, - ).joinBlocking() + ) assertEquals(1, store.state.tabs.size) assertEquals("https://reddit.com/r/firefox", store.state.tabs[0].content.url) @@ -267,7 +263,6 @@ class UndoMiddlewareTest { assertEquals("https://getpocket.com", store.state.undoHistory.tabs[1].state.url) dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() assertNull(store.state.undoHistory.selectedTabId) assertTrue(store.state.undoHistory.tabs.isEmpty()) @@ -287,8 +282,7 @@ private suspend fun restoreRecoverableTabs(dispatcher: TestDispatcher, store: Br // Otherwise we deadlock the test here when we wait for the store to complete and // at the same time the middleware dispatches a coroutine on the dispatcher which will // also block on the store in SessionManager.restore(). - store.dispatch(UndoAction.RestoreRecoverableTabs).joinBlocking() + store.dispatch(UndoAction.RestoreRecoverableTabs) } dispatcher.scheduler.advanceUntilIdle() - store.waitUntilIdle() } diff --git a/mobile/android/android-components/components/feature/sitepermissions/src/test/java/mozilla/components/feature/sitepermissions/SitePermissionsFeatureTest.kt b/mobile/android/android-components/components/feature/sitepermissions/src/test/java/mozilla/components/feature/sitepermissions/SitePermissionsFeatureTest.kt @@ -63,7 +63,6 @@ import mozilla.components.support.base.facts.processor.CollectionProcessor import mozilla.components.support.base.feature.OnNeedToRequestPermissions import mozilla.components.support.test.any import mozilla.components.support.test.eq -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule @@ -187,7 +186,7 @@ class SitePermissionsFeatureTest { verify(sitePermissionFeature).setupLoadingCollector() // when - mockStore.dispatch(ContentAction.UpdateLoadingStateAction(SESSION_ID, true)).joinBlocking() + mockStore.dispatch(ContentAction.UpdateLoadingStateAction(SESSION_ID, true)) // then verify(mockStore).dispatch( @@ -205,7 +204,7 @@ class SitePermissionsFeatureTest { sitePermissionFeature.stop() // when - mockStore.dispatch(ContentAction.UpdateLoadingStateAction(SESSION_ID, true)).joinBlocking() + mockStore.dispatch(ContentAction.UpdateLoadingStateAction(SESSION_ID, true)) verify(mockStorage).clearTemporaryPermissions() diff --git a/mobile/android/android-components/components/feature/syncedtabs/src/test/java/mozilla/components/feature/syncedtabs/storage/SyncedTabsStorageTest.kt b/mobile/android/android-components/components/feature/syncedtabs/src/test/java/mozilla/components/feature/syncedtabs/storage/SyncedTabsStorageTest.kt @@ -24,7 +24,6 @@ import mozilla.components.service.fxa.SyncEngine import mozilla.components.service.fxa.manager.FxaAccountManager import mozilla.components.service.fxa.sync.SyncReason import mozilla.components.support.test.any -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain @@ -78,7 +77,7 @@ class SyncedTabsStorageTest { feature.start() // This action will change the state due to lastUsed timestamp, but will run the flow. - store.dispatch(TabListAction.RemoveAllPrivateTabsAction).joinBlocking() + store.dispatch(TabListAction.RemoveAllPrivateTabsAction) verify(tabsStorage, times(2)).store( listOf( @@ -105,7 +104,7 @@ class SyncedTabsStorageTest { ) feature.start() // Run the flow. - store.dispatch(TabListAction.RemoveAllPrivateTabsAction).joinBlocking() + store.dispatch(TabListAction.RemoveAllPrivateTabsAction) verify(tabsStorage, times(2)).store( listOf( @@ -116,7 +115,7 @@ class SyncedTabsStorageTest { feature.stop() // Run the flow. - store.dispatch(TabListAction.RemoveAllPrivateTabsAction).joinBlocking() + store.dispatch(TabListAction.RemoveAllPrivateTabsAction) verify(tabsStorage, never()).store(listOf()) // any() is not working so we send garbage } @@ -278,7 +277,7 @@ class SyncedTabsStorageTest { ) // Change a tab besides loading it - store.dispatch(ContentAction.UpdateProgressAction("tab1", 50)).joinBlocking() + store.dispatch(ContentAction.UpdateProgressAction("tab1", 50)) reset(tabsStorage) @@ -307,7 +306,7 @@ class SyncedTabsStorageTest { ) feature.start() - store.dispatch(ContentAction.UpdateLoadingStateAction("tab1", false)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction("tab1", false)) verify(tabsStorage).store( listOf( @@ -338,7 +337,7 @@ class SyncedTabsStorageTest { ) feature.start() - store.dispatch(TabListAction.SelectTabAction("tab2")).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("tab2")) verify(tabsStorage, times(2)).store( listOf( @@ -370,7 +369,7 @@ class SyncedTabsStorageTest { ) feature.start() - store.dispatch(LastAccessAction.UpdateLastAccessAction("tab1", 300L)).joinBlocking() + store.dispatch(LastAccessAction.UpdateLastAccessAction("tab1", 300L)) verify(tabsStorage, times(1)).store( listOf( diff --git a/mobile/android/android-components/components/feature/tabs/src/test/java/mozilla/components/feature/tabs/CustomTabsUseCasesTest.kt b/mobile/android/android-components/components/feature/tabs/src/test/java/mozilla/components/feature/tabs/CustomTabsUseCasesTest.kt @@ -13,8 +13,6 @@ import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.Engine import mozilla.components.concept.engine.EngineSession import mozilla.components.support.test.any -import mozilla.components.support.test.ext.joinBlocking -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 @@ -57,24 +55,22 @@ class CustomTabsUseCasesTest { @Test fun `MigrateCustomTabUseCase - turns custom tab into regular tab and selects it`() { val customTab = createCustomTab("https://mozilla.org") - store.dispatch(CustomTabListAction.AddCustomTabAction(customTab)).joinBlocking() + store.dispatch(CustomTabListAction.AddCustomTabAction(customTab)) assertEquals(0, store.state.tabs.size) assertEquals(1, store.state.customTabs.size) tabsUseCases.migrate(customTab.id, select = false) - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) assertEquals(0, store.state.customTabs.size) assertNull(store.state.selectedTabId) val otherCustomTab = createCustomTab("https://firefox.com") - store.dispatch(CustomTabListAction.AddCustomTabAction(otherCustomTab)).joinBlocking() + store.dispatch(CustomTabListAction.AddCustomTabAction(otherCustomTab)) assertEquals(1, store.state.tabs.size) assertEquals(1, store.state.customTabs.size) tabsUseCases.migrate(otherCustomTab.id, select = true) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertEquals(0, store.state.customTabs.size) diff --git a/mobile/android/android-components/components/feature/tabs/src/test/java/mozilla/components/feature/tabs/TabsUseCasesTest.kt b/mobile/android/android-components/components/feature/tabs/src/test/java/mozilla/components/feature/tabs/TabsUseCasesTest.kt @@ -26,8 +26,6 @@ import mozilla.components.concept.engine.EngineSessionState import mozilla.components.concept.storage.HistoryMetadataKey import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor -import mozilla.components.support.test.ext.joinBlocking -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 @@ -79,14 +77,13 @@ class TabsUseCasesTest { fun `SelectTabUseCase - tab is marked as selected in store`() { val tab = createTab("https://mozilla.org") val otherTab = createTab("https://firefox.com") - store.dispatch(TabListAction.AddTabAction(otherTab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(otherTab)) + store.dispatch(TabListAction.AddTabAction(tab)) assertEquals(otherTab.id, store.state.selectedTabId) assertEquals(otherTab, store.state.selectedTab) tabsUseCases.selectTab(tab.id) - store.waitUntilIdle() assertEquals(tab.id, store.state.selectedTabId) assertEquals(tab, store.state.selectedTab) } @@ -94,26 +91,24 @@ class TabsUseCasesTest { @Test fun `RemoveTabUseCase - session will be removed from store`() { val tab = createTab("https://mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) assertEquals(1, store.state.tabs.size) tabsUseCases.removeTab(tab.id) - store.waitUntilIdle() assertEquals(0, store.state.tabs.size) } @Test fun `RemoveTabUseCase - remove by ID and select parent if it exists`() { val parentTab = createTab("https://firefox.com") - store.dispatch(TabListAction.AddTabAction(parentTab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(parentTab)) val tab = createTab("https://mozilla.org", parent = parentTab) - store.dispatch(TabListAction.AddTabAction(tab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab, select = true)) assertEquals(2, store.state.tabs.size) assertEquals(tab.id, store.state.selectedTabId) tabsUseCases.removeTab(tab.id, selectParentIfExists = true) - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) assertEquals(parentTab.id, store.state.selectedTabId) } @@ -122,14 +117,13 @@ class TabsUseCasesTest { fun `RemoveTabsUseCase - list of sessions can be removed`() { val tab = createTab("https://mozilla.org") val otherTab = createTab("https://firefox.com") - store.dispatch(TabListAction.AddTabAction(otherTab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(otherTab)) + store.dispatch(TabListAction.AddTabAction(tab)) assertEquals(otherTab.id, store.state.selectedTabId) assertEquals(otherTab, store.state.selectedTab) tabsUseCases.removeTabs(listOf(tab.id, otherTab.id)) - store.waitUntilIdle() assertEquals(0, store.state.tabs.size) } @@ -137,7 +131,6 @@ class TabsUseCasesTest { fun `AddNewTabUseCase - session will be added to store`() { tabsUseCases.addTab("https://www.mozilla.org") - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) assertEquals("https://www.mozilla.org", store.state.tabs[0].content.url) assertFalse(store.state.tabs[0].content.private) @@ -147,7 +140,6 @@ class TabsUseCasesTest { fun `AddNewTabUseCase - private session will be added to store`() { tabsUseCases.addTab("https://www.mozilla.org", private = true) - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) assertEquals("https://www.mozilla.org", store.state.tabs[0].content.url) assertTrue(store.state.tabs[0].content.private) @@ -157,7 +149,6 @@ class TabsUseCasesTest { fun `AddNewTabUseCase will not load URL if flag is set to false`() { tabsUseCases.addTab("https://www.mozilla.org", startLoading = false) - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) assertEquals("https://www.mozilla.org", store.state.tabs[0].content.url) verify(engineSession, never()).loadUrl(anyString(), any(), any(), any(), any(), anyBoolean()) @@ -168,11 +159,9 @@ class TabsUseCasesTest { tabsUseCases.addTab("https://www.mozilla.org", startLoading = true) // Wait for CreateEngineSessionAction and middleware - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() // Wait for LinkEngineSessionAction and middleware - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() assertEquals(1, store.state.tabs.size) @@ -190,11 +179,9 @@ class TabsUseCasesTest { ) // Wait for CreateEngineSessionAction and middleware - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() // Wait for LinkEngineSessionAction and middleware - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() assertEquals(1, store.state.tabs.size) @@ -212,8 +199,6 @@ class TabsUseCasesTest { engineSession = session, ) - store.waitUntilIdle() - assertEquals(1, store.state.tabs.size) assertEquals("https://www.mozilla.org", store.state.tabs[0].content.url) assertSame(session, store.state.tabs[0].engineState.engineSession) @@ -229,8 +214,6 @@ class TabsUseCasesTest { contextId = contextId, ) - store.waitUntilIdle() - assertEquals(1, store.state.tabs.size) assertEquals("https://www.mozilla.org", store.state.tabs[0].content.url) assertEquals(contextId, store.state.tabs[0].contextId) @@ -246,8 +229,6 @@ class TabsUseCasesTest { title = title, ) - store.waitUntilIdle() - assertEquals(1, store.state.tabs.size) assertEquals("https://www.mozilla.org", store.state.tabs[0].content.url) assertEquals(title, store.state.tabs[0].content.title) @@ -268,8 +249,6 @@ class TabsUseCasesTest { historyMetadata = historyMetadata, ) - store.waitUntilIdle() - assertEquals(1, store.state.tabs.size) assertEquals("https://www.mozilla.org", store.state.tabs[0].content.url) assertEquals(historyMetadata, store.state.tabs[0].historyMetadata) @@ -283,8 +262,6 @@ class TabsUseCasesTest { isSearch = true, ) - store.waitUntilIdle() - assertEquals(1, store.state.tabs.size) assertEquals(true, store.state.tabs.single().content.isSearch) } @@ -302,8 +279,6 @@ class TabsUseCasesTest { additionalHeaders = additionalHeaders, ) - store.waitUntilIdle() - assertEquals(1, store.state.tabs.size) assertTrue(store.state.tabs.single().content.isSearch) assertEquals(flags, store.state.tabs.single().engineState.initialLoadFlags) @@ -322,7 +297,6 @@ class TabsUseCasesTest { @Test fun `GIVEN a tab is added with a parent loadURL will include the parent`() { val parentTabId = tabsUseCases.addTab(url = "https://www.firefox.com", selectTab = true) - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() verify(engineSession, times(1)).loadUrl( @@ -336,7 +310,6 @@ class TabsUseCasesTest { tabsUseCases.addTab(url = "https://www.mozilla.org", parentId = parentTabId) - store.waitUntilIdle() dispatcher.scheduler.advanceUntilIdle() assertEquals(2, store.state.tabs.size) @@ -351,34 +324,31 @@ class TabsUseCasesTest { @Test fun `RemoveAllTabsUseCase will remove all sessions`() { val tab = createTab("https://mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) assertEquals(1, store.state.tabs.size) val tab2 = createTab("https://firefox.com", private = true) - store.dispatch(TabListAction.AddTabAction(tab2)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab2)) assertEquals(2, store.state.tabs.size) tabsUseCases.removeAllTabs() - store.waitUntilIdle() assertEquals(0, store.state.tabs.size) } @Test fun `RemoveNormalTabsUseCase and RemovePrivateTabsUseCase will remove sessions for particular type of tabs private or normal`() { val tab = createTab("https://mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) assertEquals(1, store.state.tabs.size) val privateTab = createTab("https://firefox.com", private = true) - store.dispatch(TabListAction.AddTabAction(privateTab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(privateTab)) assertEquals(2, store.state.tabs.size) tabsUseCases.removeNormalTabs() - store.waitUntilIdle() assertEquals(1, store.state.tabs.size) tabsUseCases.removePrivateTabs() - store.waitUntilIdle() assertEquals(0, store.state.tabs.size) } @@ -424,15 +394,13 @@ class TabsUseCasesTest { val sessionStorage: SessionStorage = mock() whenever(sessionStorage.restore(any())).thenReturn(recoverableBrowserState) - store.dispatch(TabListAction.AddTabAction(tab = newTab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab = newTab)) tabsUseCases.restore.invoke( storage = sessionStorage, tabTimeoutInMs = DAY_IN_MS, ) - store.waitUntilIdle() - assertEquals(restoredTabs.first().id, store.state.tabs.first().id) assertEquals(newTab.id, store.state.tabs.last().id) } @@ -442,15 +410,14 @@ class TabsUseCasesTest { val tab = createTab("https://mozilla.org") val otherTab = createTab("https://firefox.com") - store.dispatch(TabListAction.AddTabAction(otherTab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(otherTab)) + store.dispatch(TabListAction.AddTabAction(tab)) assertEquals(otherTab.id, store.state.selectedTabId) assertEquals(otherTab, store.state.selectedTab) assertEquals(2, store.state.tabs.size) val tabID = tabsUseCases.selectOrAddTab(tab.content.url) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertEquals(tab.id, store.state.selectedTabId) @@ -468,16 +435,14 @@ class TabsUseCasesTest { val tab = createTab("https://mozilla.org", historyMetadata = historyMetadata) val otherTab = createTab("https://firefox.com") - store.dispatch(TabListAction.AddTabAction(otherTab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(otherTab)) + store.dispatch(TabListAction.AddTabAction(tab)) assertEquals(otherTab.id, store.state.selectedTabId) assertEquals(otherTab, store.state.selectedTab) assertEquals(2, store.state.tabs.size) val tabID = tabsUseCases.selectOrAddTab(tab.content.url, historyMetadata = historyMetadata) - store.waitUntilIdle() - assertEquals(2, store.state.tabs.size) assertEquals(tab.id, store.state.selectedTabId) assertEquals(tab, store.state.selectedTab) @@ -488,14 +453,13 @@ class TabsUseCasesTest { fun `selectOrAddTab adds new tab if no matching existing tab could be found`() { val tab = createTab("https://mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) assertEquals(tab.id, store.state.selectedTabId) assertEquals(tab, store.state.selectedTab) assertEquals(1, store.state.tabs.size) val tabID = tabsUseCases.selectOrAddTab("https://firefox.com") - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertNotNull(store.state.findNormalOrPrivateTabByUrl("https://firefox.com", false)) @@ -510,7 +474,7 @@ class TabsUseCasesTest { referrerUrl = "https://firefox.com", ) - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) assertEquals(tab.id, store.state.selectedTabId) assertEquals(tab, store.state.selectedTab) @@ -518,7 +482,6 @@ class TabsUseCasesTest { val tabID = tabsUseCases.selectOrAddTab("https://firefox.com", historyMetadata = historyMetadata) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertNotNull(store.state.findNormalOrPrivateTabByUrl("https://firefox.com", false)) @@ -530,14 +493,13 @@ class TabsUseCasesTest { val tab = createTab("https://mozilla.org") val otherTab = createTab("https://firefox.com") - store.dispatch(TabListAction.AddTabAction(otherTab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(otherTab)) + store.dispatch(TabListAction.AddTabAction(tab)) assertEquals(otherTab, store.state.selectedTab) assertEquals(2, store.state.tabs.size) val actualTabId = tabsUseCases.selectOrAddTab(url = "https://mozilla.org/#welcome", ignoreFragment = true) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertEquals(tab, store.state.selectedTab) @@ -548,14 +510,13 @@ class TabsUseCasesTest { fun `selectOrAddTab adds new tab if no matching existing tab could be found with ignoreFragment set to true`() { val tab = createTab("https://mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) assertEquals(tab.id, store.state.selectedTabId) assertEquals(tab, store.state.selectedTab) assertEquals(1, store.state.tabs.size) val tabID = tabsUseCases.selectOrAddTab(url = "https://firefox.com", ignoreFragment = true) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertEquals(store.state.selectedTabId, tabID) @@ -566,7 +527,6 @@ class TabsUseCasesTest { assertEquals(false, store.state.desktopMode) val tabID = tabsUseCases.selectOrAddTab(url = "https://firefox.com") - store.waitUntilIdle() assertEquals(store.state.selectedTabId, tabID) assertEquals(false, store.state.selectedTab?.content?.desktopMode) @@ -574,11 +534,10 @@ class TabsUseCasesTest { @Test fun `selectOrAddTab adds new tab when store desktop mode is true and tab's desktop mode matches`() { - store.dispatch(DefaultDesktopModeAction.ToggleDesktopMode).joinBlocking() + store.dispatch(DefaultDesktopModeAction.ToggleDesktopMode) assertEquals(true, store.state.desktopMode) val tabID = tabsUseCases.selectOrAddTab(url = "https://firefox.com") - store.waitUntilIdle() assertEquals(store.state.selectedTabId, tabID) assertEquals(true, store.state.selectedTab?.content?.desktopMode) @@ -599,17 +558,16 @@ class TabsUseCasesTest { TabListAction.AddTabAction( createTab(id = "mozilla", url = "https://www.mozilla.org"), ), - ).joinBlocking() + ) assertEquals(1, store.state.tabs.size) val engineSessionState: EngineSessionState = mock() store.dispatch( EngineAction.UpdateEngineSessionStateAction("mozilla", engineSessionState), - ).joinBlocking() + ) val tab = store.state.findTab("mozilla")!! val dupId = tabsUseCases.duplicateTab.invoke(tab) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertEquals(dupId, store.state.tabs[1].id) @@ -624,9 +582,8 @@ class TabsUseCasesTest { @Test fun `duplicateTab creates duplicates of private tabs`() { val tab = createTab(id = "mozilla", url = "https://www.mozilla.org", private = true) - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) tabsUseCases.duplicateTab.invoke(tab) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertTrue(store.state.tabs[0].content.private) @@ -636,9 +593,8 @@ class TabsUseCasesTest { @Test fun `duplicateTab keeps contextId`() { val tab = createTab(id = "mozilla", url = "https://www.mozilla.org", contextId = "work") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) tabsUseCases.duplicateTab.invoke(tab) - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertEquals("work", store.state.tabs[0].contextId) @@ -648,9 +604,8 @@ class TabsUseCasesTest { @Test fun `duplicateTab without tab argument uses the selected tab`() { var tab = createTab(url = "https://www.mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) var dupId = tabsUseCases.duplicateTab.invoke(selectNewTab = true)!! - store.waitUntilIdle() assertEquals(2, store.state.tabs.size) assertNotNull(dupId) @@ -660,7 +615,6 @@ class TabsUseCasesTest { tab = dup dupId = tabsUseCases.duplicateTab.invoke(selectNewTab = false)!! - store.waitUntilIdle() assertEquals(3, store.state.tabs.size) assertNotNull(dupId) @@ -672,9 +626,9 @@ class TabsUseCasesTest { @Test fun `MoveTabsUseCase will move a tab`() { val tab = createTab("https://mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) val tab2 = createTab("https://firefox.com", private = true) - store.dispatch(TabListAction.AddTabAction(tab2)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab2)) assertEquals(2, store.state.tabs.size) assertEquals("https://mozilla.org", store.state.tabs[0].content.url) assertEquals("https://firefox.com", store.state.tabs[1].content.url) @@ -682,7 +636,6 @@ class TabsUseCasesTest { val tab1Id = store.state.tabs[0].id val tab2Id = store.state.tabs[1].id tabsUseCases.moveTabs(listOf(tab1Id), tab2Id, true) - store.waitUntilIdle() assertEquals("https://firefox.com", store.state.tabs[0].content.url) assertEquals("https://mozilla.org", store.state.tabs[1].content.url) } @@ -690,12 +643,11 @@ class TabsUseCasesTest { @Test fun `MigratePrivateTabUseCase will migrate a private tab`() { val tab = createTab("https://mozilla.org", private = true) - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) assertEquals(1, store.state.tabs.size) assertEquals(true, store.state.tabs[0].content.private) tabsUseCases.migratePrivateTabUseCase(tab.id) - store.waitUntilIdle() // Still only 1 tab and that tab still has the same URL... assertEquals(1, store.state.tabs.size) assertEquals("https://mozilla.org", store.state.tabs[0].content.url) @@ -708,10 +660,9 @@ class TabsUseCasesTest { fun `MigratePrivateTabUseCase will respect alternativeUrl`() { // This (obviously!) isn't a real reader-mode URL, but is fine for the purposes of this test. val tab = createTab("https://mozilla.org/reader-mode", private = true) - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) tabsUseCases.migratePrivateTabUseCase(store.state.tabs[0].id, "https://mozilla.org/not-reader-mode") - store.waitUntilIdle() // Still only 1 tab with our alternative URL assertEquals(1, store.state.tabs.size) assertEquals("https://mozilla.org/not-reader-mode", store.state.tabs[0].content.url) @@ -721,7 +672,7 @@ class TabsUseCasesTest { @Test fun `MigratePrivateTabUseCase will fail on a regular tab`() { val tab = createTab("https://mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) assertEquals(1, store.state.tabs.size) assertThrows(IllegalArgumentException::class.java) { tabsUseCases.migratePrivateTabUseCase(tab.id) diff --git a/mobile/android/android-components/components/feature/tabs/src/test/java/mozilla/components/feature/tabs/WindowFeatureTest.kt b/mobile/android/android-components/components/feature/tabs/src/test/java/mozilla/components/feature/tabs/WindowFeatureTest.kt @@ -11,7 +11,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.window.WindowRequest -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.whenever @@ -65,7 +64,7 @@ class WindowFeatureTest { whenever(windowRequest.type).thenReturn(WindowRequest.Type.OPEN) whenever(windowRequest.url).thenReturn("https://www.firefox.com") - store.dispatch(ContentAction.UpdateWindowRequestAction(tabId, windowRequest)).joinBlocking() + store.dispatch(ContentAction.UpdateWindowRequestAction(tabId, windowRequest)) verify(addTabUseCase).invoke(url = "about:blank", selectTab = true, parentId = tabId) verify(store).dispatch(ContentAction.ConsumeWindowRequestAction(tabId)) @@ -80,8 +79,8 @@ class WindowFeatureTest { whenever(windowRequest.type).thenReturn(WindowRequest.Type.OPEN) whenever(windowRequest.url).thenReturn("https://www.firefox.com") - store.dispatch(TabListAction.SelectTabAction(privateTabId)).joinBlocking() - store.dispatch(ContentAction.UpdateWindowRequestAction(privateTabId, windowRequest)).joinBlocking() + store.dispatch(TabListAction.SelectTabAction(privateTabId)) + store.dispatch(ContentAction.UpdateWindowRequestAction(privateTabId, windowRequest)) verify(addTabUseCase).invoke(url = "about:blank", selectTab = true, parentId = privateTabId, private = true) verify(store).dispatch(ContentAction.ConsumeWindowRequestAction(privateTabId)) @@ -96,7 +95,7 @@ class WindowFeatureTest { whenever(windowRequest.type).thenReturn(WindowRequest.Type.CLOSE) whenever(windowRequest.prepare()).thenReturn(engineSession) - store.dispatch(ContentAction.UpdateWindowRequestAction(tabId, windowRequest)).joinBlocking() + store.dispatch(ContentAction.UpdateWindowRequestAction(tabId, windowRequest)) verify(removeTabUseCase).invoke(tabId) verify(store).dispatch(ContentAction.ConsumeWindowRequestAction(tabId)) @@ -111,7 +110,7 @@ class WindowFeatureTest { val windowRequest: WindowRequest = mock() whenever(windowRequest.type).thenReturn(WindowRequest.Type.CLOSE) - store.dispatch(ContentAction.UpdateWindowRequestAction(tabId, windowRequest)).joinBlocking() + store.dispatch(ContentAction.UpdateWindowRequestAction(tabId, windowRequest)) verify(removeTabUseCase, never()).invoke(tabId) verify(store, never()).dispatch(ContentAction.ConsumeWindowRequestAction(tabId)) diff --git a/mobile/android/android-components/components/feature/tabs/src/test/java/mozilla/components/feature/tabs/tabstray/TabsTrayPresenterTest.kt b/mobile/android/android-components/components/feature/tabs/src/test/java/mozilla/components/feature/tabs/tabstray/TabsTrayPresenterTest.kt @@ -11,7 +11,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.browser.tabstray.TabsTray -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert import org.junit.Assert.assertEquals @@ -96,7 +95,7 @@ class TabsTrayPresenterTest { TabListAction.AddTabAction( createTab("https://developer.mozilla.org/"), ), - ).joinBlocking() + ) assertEquals(3, tabsTray.updateTabs!!.size) @@ -130,12 +129,12 @@ class TabsTrayPresenterTest { assertEquals(2, tabsTray.updateTabs!!.size) - store.dispatch(TabListAction.RemoveTabAction("a")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("a")) dispatcher.scheduler.advanceUntilIdle() assertEquals(1, tabsTray.updateTabs!!.size) - store.dispatch(TabListAction.RemoveTabAction("b")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("b")) dispatcher.scheduler.advanceUntilIdle() assertEquals(0, tabsTray.updateTabs!!.size) @@ -170,7 +169,7 @@ class TabsTrayPresenterTest { assertEquals(2, tabsTray.updateTabs!!.size) - store.dispatch(TabListAction.RemoveAllTabsAction()).joinBlocking() + store.dispatch(TabListAction.RemoveAllTabsAction()) dispatcher.scheduler.advanceUntilIdle() assertEquals(0, tabsTray.updateTabs!!.size) @@ -208,7 +207,7 @@ class TabsTrayPresenterTest { assertEquals(5, tabsTray.updateTabs!!.size) assertEquals("a", tabsTray.selectedTabId) - store.dispatch(TabListAction.SelectTabAction("d")).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("d")) dispatcher.scheduler.advanceUntilIdle() println("Selection: " + store.state.selectedTabId) @@ -273,7 +272,7 @@ class TabsTrayPresenterTest { Assert.assertFalse(closed) - store.dispatch(TabListAction.RemoveAllTabsAction()).joinBlocking() + store.dispatch(TabListAction.RemoveAllTabsAction()) dispatcher.scheduler.advanceUntilIdle() assertTrue(closed) @@ -309,12 +308,12 @@ class TabsTrayPresenterTest { Assert.assertFalse(closed) - store.dispatch(TabListAction.RemoveTabAction("a")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("a")) dispatcher.scheduler.advanceUntilIdle() Assert.assertFalse(closed) - store.dispatch(TabListAction.RemoveTabAction("b")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("b")) dispatcher.scheduler.advanceUntilIdle() assertTrue(closed) diff --git a/mobile/android/android-components/components/feature/tabs/src/test/java/mozilla/components/feature/tabs/toolbar/TabCounterToolbarButtonTest.kt b/mobile/android/android-components/components/feature/tabs/src/test/java/mozilla/components/feature/tabs/toolbar/TabCounterToolbarButtonTest.kt @@ -20,7 +20,6 @@ import mozilla.components.browser.state.state.recover.RecoverableTab import mozilla.components.browser.state.state.recover.TabState import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.menu.MenuController -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule @@ -137,7 +136,7 @@ class TabCounterToolbarButtonTest { store.dispatch( TabListAction.AddTabAction(createTab("https://www.mozilla.org")), - ).joinBlocking() + ) verify(button).updateCount(eq(1)) } @@ -168,7 +167,7 @@ class TabCounterToolbarButtonTest { ), restoreLocation = TabListAction.RestoreAction.RestoreLocation.BEGINNING, ), - ).joinBlocking() + ) verify(button).updateCount(eq(1)) } @@ -190,7 +189,7 @@ class TabCounterToolbarButtonTest { whenever(button.updateCount(anyInt())).then { } button.createView(LinearLayout(testContext) as ViewGroup) as TabCounterView - store.dispatch(TabListAction.RemoveTabAction(tab.id)).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction(tab.id)) verify(button).updateCount(eq(0)) } @@ -214,7 +213,7 @@ class TabCounterToolbarButtonTest { store.dispatch( TabListAction.AddTabAction(createTab("https://www.mozilla.org", private = true)), - ).joinBlocking() + ) verify(button).updateCount(eq(1)) } @@ -238,7 +237,7 @@ class TabCounterToolbarButtonTest { button.createView(LinearLayout(testContext) as ViewGroup) as TabCounterView - store.dispatch(TabListAction.RemoveTabAction(tab.id)).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction(tab.id)) verify(button).updateCount(eq(0)) } diff --git a/mobile/android/android-components/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ContainerToolbarFeatureTest.kt b/mobile/android/android-components/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ContainerToolbarFeatureTest.kt @@ -12,7 +12,6 @@ import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.toolbar.Toolbar import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertEquals @@ -78,7 +77,7 @@ class ContainerToolbarFeatureTest { ), ) val containerToolbarFeature = getContainerToolbarFeature(toolbar, store) - store.dispatch(TabListAction.SelectTabAction("tab2")).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("tab2")) coroutinesTestRule.testDispatcher.scheduler.advanceUntilIdle() verify(store).observeManually(any()) diff --git a/mobile/android/android-components/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarPresenterTest.kt b/mobile/android/android-components/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarPresenterTest.kt @@ -126,7 +126,7 @@ class ToolbarPresenterTest { issuer = "Mozilla", ), ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() @@ -172,7 +172,7 @@ class ToolbarPresenterTest { verifyNoMoreInteractions(toolbarPresenter.renderer) verifyNoMoreInteractions(toolbar) - store.dispatch(TabListAction.RemoveTabAction("tab1")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("tab1")) dispatcher.scheduler.advanceUntilIdle() @@ -209,7 +209,7 @@ class ToolbarPresenterTest { sessionId = "tab1", searchTerms = "Hello World", ), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() @@ -240,7 +240,7 @@ class ToolbarPresenterTest { store.dispatch( ContentAction.UpdateProgressAction("tab1", 75), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() @@ -250,7 +250,7 @@ class ToolbarPresenterTest { store.dispatch( ContentAction.UpdateProgressAction("tab1", 90), - ).joinBlocking() + ) dispatcher.scheduler.advanceUntilIdle() @@ -287,7 +287,7 @@ class ToolbarPresenterTest { dispatcher.scheduler.advanceUntilIdle() - store.dispatch(TabListAction.RemoveTabAction("tab2")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("tab2")) verify(toolbarPresenter.renderer).start() verify(toolbarPresenter.renderer).post("https://www.mozilla.org") @@ -350,7 +350,7 @@ class ToolbarPresenterTest { verifyNoMoreInteractions(toolbarPresenter.renderer) verifyNoMoreInteractions(toolbar) - store.dispatch(TabListAction.SelectTabAction("tab2")).joinBlocking() + store.dispatch(TabListAction.SelectTabAction("tab2")) dispatcher.scheduler.advanceUntilIdle() @@ -396,21 +396,18 @@ class ToolbarPresenterTest { verify(toolbar).siteTrackingProtection = Toolbar.SiteTrackingProtection.OFF_GLOBALLY store.dispatch(TrackingProtectionAction.ToggleAction("tab", true)) - .joinBlocking() dispatcher.scheduler.advanceUntilIdle() verify(toolbar).siteTrackingProtection = Toolbar.SiteTrackingProtection.ON_NO_TRACKERS_BLOCKED store.dispatch(TrackingProtectionAction.TrackerBlockedAction("tab", mock())) - .joinBlocking() dispatcher.scheduler.advanceUntilIdle() verify(toolbar).siteTrackingProtection = Toolbar.SiteTrackingProtection.ON_TRACKERS_BLOCKED store.dispatch(TrackingProtectionAction.ToggleExclusionListAction("tab", true)) - .joinBlocking() dispatcher.scheduler.advanceUntilIdle() @@ -448,20 +445,19 @@ class ToolbarPresenterTest { verify(toolbar).highlight = Toolbar.Highlight.NONE - store.dispatch(NotificationChangedAction("tab", true)).joinBlocking() + store.dispatch(NotificationChangedAction("tab", true)) dispatcher.scheduler.advanceUntilIdle() verify(toolbar).highlight = Toolbar.Highlight.PERMISSIONS_CHANGED store.dispatch(TrackingProtectionAction.ToggleExclusionListAction("tab", true)) - .joinBlocking() dispatcher.scheduler.advanceUntilIdle() verify(toolbar, times(2)).highlight = Toolbar.Highlight.PERMISSIONS_CHANGED - store.dispatch(UpdatePermissionHighlightsStateAction.Reset("tab")).joinBlocking() + store.dispatch(UpdatePermissionHighlightsStateAction.Reset("tab")) dispatcher.scheduler.advanceUntilIdle() diff --git a/mobile/android/android-components/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/WebExtensionToolbarFeatureTest.kt b/mobile/android/android-components/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/WebExtensionToolbarFeatureTest.kt @@ -21,7 +21,6 @@ import mozilla.components.concept.engine.webextension.WebExtensionPageAction import mozilla.components.concept.toolbar.Toolbar import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.whenever @@ -276,8 +275,8 @@ class WebExtensionToolbarFeatureTest { assertEquals(2, webExtToolbarFeature.webExtensionBrowserActions.size) assertEquals(2, webExtToolbarFeature.webExtensionPageActions.size) - store.dispatch(WebExtensionAction.UninstallWebExtensionAction("1")).joinBlocking() - store.dispatch(WebExtensionAction.UpdateWebExtensionEnabledAction("2", false)).joinBlocking() + store.dispatch(WebExtensionAction.UninstallWebExtensionAction("1")) + store.dispatch(WebExtensionAction.UpdateWebExtensionEnabledAction("2", false)) webExtToolbarFeature.start() assertEquals(0, webExtToolbarFeature.webExtensionBrowserActions.size) diff --git a/mobile/android/android-components/components/lib/state/src/androidTest/java/mozilla/components/lib/state/ext/ComposeExtensionsKtTest.kt b/mobile/android/android-components/components/lib/state/src/androidTest/java/mozilla/components/lib/state/ext/ComposeExtensionsKtTest.kt @@ -5,7 +5,6 @@ package mozilla.components.lib.state.ext import androidx.compose.ui.test.junit4.createComposeRule -import kotlinx.coroutines.runBlocking import mozilla.components.lib.state.Action import mozilla.components.lib.state.State import mozilla.components.lib.state.Store @@ -48,7 +47,7 @@ class ComposeExtensionsKtTest { value = composeState.value } - store.dispatchBlockingOnIdle(TestAction.IncrementAction) + store.dispatch(TestAction.IncrementAction) rule.runOnIdle { assertEquals(86, value) @@ -79,10 +78,10 @@ class ComposeExtensionsKtTest { assertEquals(listOf("Loading"), value) } - store.dispatchBlockingOnIdle(TestAction.IncrementAction) - store.dispatchBlockingOnIdle(TestAction.IncrementAction) - store.dispatchBlockingOnIdle(TestAction.IncrementAction) - store.dispatchBlockingOnIdle(TestAction.IncrementAction) + store.dispatch(TestAction.IncrementAction) + store.dispatch(TestAction.IncrementAction) + store.dispatch(TestAction.IncrementAction) + store.dispatch(TestAction.IncrementAction) rule.runOnIdle { // Value after 4 increments, aka counter is 4. Note that it doesn't recompose here @@ -91,7 +90,7 @@ class ComposeExtensionsKtTest { } // 5th increment - store.dispatchBlockingOnIdle(TestAction.IncrementAction) + store.dispatch(TestAction.IncrementAction) rule.runOnIdle { assertEquals(listOf(loading, content), value) @@ -118,48 +117,41 @@ class ComposeExtensionsKtTest { assertEquals(84, value) - store.dispatchBlockingOnIdle(TestAction.IncrementAction) + store.dispatch(TestAction.IncrementAction) rule.runOnIdle { // State value didn't change because value returned by `observer` function did not change assertEquals(84, value) } - store.dispatchBlockingOnIdle(TestAction.SetTextAction("Hello World")) + store.dispatch(TestAction.SetTextAction("Hello World")) rule.runOnIdle { // Now, after the value from the observer function changed, we are seeing the new value assertEquals(86, value) } - store.dispatchBlockingOnIdle(TestAction.SetValueAction(23)) + store.dispatch(TestAction.SetValueAction(23)) rule.runOnIdle { // Observer function result is the same, no state update assertEquals(86, value) } - store.dispatchBlockingOnIdle(TestAction.SetTextAction("Hello World")) + store.dispatch(TestAction.SetTextAction("Hello World")) rule.runOnIdle { // Text was updated to the same value, observer function result is the same, no state update assertEquals(86, value) } - store.dispatchBlockingOnIdle(TestAction.SetTextAction("Hello World Again")) + store.dispatch(TestAction.SetTextAction("Hello World Again")) rule.runOnIdle { // Now, after the value from the observer function changed, we are seeing the new value assertEquals(46, value) } } - - private fun Store<TestState, TestAction>.dispatchBlockingOnIdle(action: TestAction) { - rule.runOnIdle { - val job = dispatch(action) - runBlocking { job.join() } - } - } } fun reducer(state: TestState, action: TestAction): TestState = when (action) { diff --git a/mobile/android/android-components/components/lib/state/src/main/java/mozilla/components/lib/state/Store.kt b/mobile/android/android-components/components/lib/state/src/main/java/mozilla/components/lib/state/Store.kt @@ -6,7 +6,6 @@ package mozilla.components.lib.state import androidx.annotation.CheckResult import androidx.annotation.VisibleForTesting -import kotlinx.coroutines.Job import mozilla.components.lib.state.internal.ReducerChainBuilder import java.lang.ref.WeakReference import java.util.Collections @@ -68,20 +67,13 @@ open class Store<S : State, A : Action>( * Invocations are serialized by synchronizing on `this@Store`, * preventing concurrent modification of the underlying store. * Long running reducers and/or middlewares can and will impact all consumers. + * + * @return Unit. Previously this returned a new Job that was launched here, but this no longer happens. */ - fun dispatch(action: A): Job { + fun dispatch(action: A) = synchronized(this@Store) { reducerChainBuilder.get(this@Store).invoke(action) } - // see https://bugzilla.mozilla.org/show_bug.cgi?id=1980348 - // previously, we launched a new coroutine here. - // this `Job()` is a dummy implementation for now to avoiding having to change the api. - // the aspiration is to remove this, simplify the api and delete a load of joining code. - val job = Job().also { - it.complete() - } - return job - } /** * Transitions from the current [State] to the passed in [state] and notifies all observers. diff --git a/mobile/android/android-components/components/lib/state/src/test/java/mozilla/components/lib/state/ext/FragmentKtTest.kt b/mobile/android/android-components/components/lib/state/src/test/java/mozilla/components/lib/state/ext/FragmentKtTest.kt @@ -16,7 +16,6 @@ import mozilla.components.lib.state.TestState import mozilla.components.lib.state.reducer import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert @@ -73,7 +72,7 @@ class FragmentKtTest { assertEquals(0, receivedValue) // Updating state: Nothing received yet. - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(0, receivedValue) @@ -83,12 +82,12 @@ class FragmentKtTest { assertEquals(24, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(25, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) latch = CountDownLatch(1) @@ -96,7 +95,7 @@ class FragmentKtTest { // View gets detached onAttachListener.value.onViewDetachedFromWindow(view) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) } @@ -129,31 +128,31 @@ class FragmentKtTest { assertEquals(23, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(24, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(25, receivedValue) doReturn(null).`when`(fragment).activity latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(25, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(25, receivedValue) doReturn(mock<FragmentActivity>()).`when`(fragment).activity latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(28, receivedValue) } @@ -194,7 +193,7 @@ class FragmentKtTest { assertEquals(0, receivedValue) // Updating state: Nothing received yet. - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(0, receivedValue) @@ -204,12 +203,12 @@ class FragmentKtTest { assertEquals(24, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(25, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) latch = CountDownLatch(1) @@ -217,7 +216,7 @@ class FragmentKtTest { // View gets detached onAttachListener.value.onViewDetachedFromWindow(view) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) } @@ -257,7 +256,7 @@ class FragmentKtTest { assertEquals(0, receivedValue) // Updating state: Nothing received yet. - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(0, receivedValue) @@ -267,7 +266,7 @@ class FragmentKtTest { assertEquals(24, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(25, receivedValue) latch = CountDownLatch(1) diff --git a/mobile/android/android-components/components/lib/state/src/test/java/mozilla/components/lib/state/ext/StoreExtensionsKtTest.kt b/mobile/android/android-components/components/lib/state/src/test/java/mozilla/components/lib/state/ext/StoreExtensionsKtTest.kt @@ -23,7 +23,6 @@ import mozilla.components.lib.state.Store import mozilla.components.lib.state.TestAction import mozilla.components.lib.state.TestState import mozilla.components.lib.state.reducer -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain @@ -61,7 +60,7 @@ class StoreExtensionsKtTest { var stateObserved = false store.observe(owner) { stateObserved = true } - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(stateObserved) } @@ -80,12 +79,12 @@ class StoreExtensionsKtTest { assertTrue(stateObserved) stateObserved = false - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(stateObserved) stateObserved = false owner.lifecycleRegistry.currentState = Lifecycle.State.DESTROYED - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(stateObserved) } @@ -106,7 +105,7 @@ class StoreExtensionsKtTest { // CREATED: Observer does still not get invoked stateObserved = false owner.lifecycleRegistry.currentState = Lifecycle.State.CREATED - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(stateObserved) // STARTED: Observer gets initial state and observers updates @@ -115,25 +114,25 @@ class StoreExtensionsKtTest { assertTrue(stateObserved) stateObserved = false - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(stateObserved) // RESUMED: Observer continues to get updates stateObserved = false owner.lifecycleRegistry.currentState = Lifecycle.State.RESUMED - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(stateObserved) // CREATED: Not observing anymore stateObserved = false owner.lifecycleRegistry.currentState = Lifecycle.State.CREATED - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(stateObserved) // DESTROYED: Not observing stateObserved = false owner.lifecycleRegistry.currentState = Lifecycle.State.DESTROYED - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(stateObserved) } @@ -164,7 +163,7 @@ class StoreExtensionsKtTest { assertEquals(0, receivedValue) // Updating state: Nothing received yet. - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(0, receivedValue) @@ -174,12 +173,12 @@ class StoreExtensionsKtTest { assertEquals(24, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(25, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) latch = CountDownLatch(1) @@ -187,7 +186,7 @@ class StoreExtensionsKtTest { job.cancelAndJoin() assertTrue(channel.isClosedForReceive) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) } @@ -236,7 +235,7 @@ class StoreExtensionsKtTest { // Updating state: Nothing received yet. latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(0, receivedValue) @@ -246,12 +245,12 @@ class StoreExtensionsKtTest { assertEquals(24, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(25, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) latch = CountDownLatch(1) @@ -259,7 +258,7 @@ class StoreExtensionsKtTest { job.cancelAndJoin() // Receiving nothing anymore since coroutine is cancelled - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) } @@ -282,7 +281,7 @@ class StoreExtensionsKtTest { } } - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertTrue(store.subscriptions.isEmpty()) } @@ -305,7 +304,7 @@ class StoreExtensionsKtTest { } } - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertTrue(store.subscriptions.isEmpty()) } @@ -335,17 +334,17 @@ class StoreExtensionsKtTest { assertEquals(23, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(24, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(25, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) @@ -354,7 +353,7 @@ class StoreExtensionsKtTest { job.cancelAndJoin() // Receiving nothing anymore since coroutine is cancelled - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) } @@ -383,24 +382,24 @@ class StoreExtensionsKtTest { // Updating state: Nothing received yet. latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(24, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(25, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) scope.cancel() latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) } @@ -431,7 +430,7 @@ class StoreExtensionsKtTest { // Updating state: Nothing received yet. latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(0, receivedValue) @@ -442,19 +441,19 @@ class StoreExtensionsKtTest { assertEquals(24, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(25, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) scope.cancel() latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) } @@ -471,10 +470,10 @@ class StoreExtensionsKtTest { store.observeForever { state -> observedValue = state.counter } assertEquals(23, observedValue) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertEquals(24, observedValue) - store.dispatch(TestAction.DecrementAction).joinBlocking() + store.dispatch(TestAction.DecrementAction) assertEquals(23, observedValue) } @@ -497,7 +496,7 @@ class StoreExtensionsKtTest { assertTrue(stateObserved) stateObserved = false - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(stateObserved) activity.windowManager.removeView(view) @@ -505,7 +504,7 @@ class StoreExtensionsKtTest { assertFalse(view.isAttachedToWindow) stateObserved = false - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(stateObserved) } @@ -526,7 +525,7 @@ class StoreExtensionsKtTest { assertFalse(stateObserved) stateObserved = false - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(stateObserved) activity.windowManager.addView(view, WindowManager.LayoutParams(100, 100)) @@ -548,7 +547,7 @@ class StoreExtensionsKtTest { assertFalse(view.isAttachedToWindow) stateObserved = false - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(stateObserved) } } diff --git a/mobile/android/android-components/components/lib/state/src/test/java/mozilla/components/lib/state/ext/ViewKtTest.kt b/mobile/android/android-components/components/lib/state/src/test/java/mozilla/components/lib/state/ext/ViewKtTest.kt @@ -12,7 +12,6 @@ import mozilla.components.lib.state.TestAction import mozilla.components.lib.state.TestState import mozilla.components.lib.state.reducer import mozilla.components.support.test.argumentCaptor -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertEquals @@ -57,7 +56,7 @@ class ViewKtTest { assertEquals(0, receivedValue) // Updating state: Nothing received yet. - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(0, receivedValue) @@ -67,12 +66,12 @@ class ViewKtTest { assertEquals(24, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(25, receivedValue) latch = CountDownLatch(1) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) latch = CountDownLatch(1) @@ -80,7 +79,7 @@ class ViewKtTest { // View gets detached onAttachListener.value.onViewDetachedFromWindow(view) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertFalse(latch.await(1, TimeUnit.SECONDS)) assertEquals(26, receivedValue) } diff --git a/mobile/android/android-components/components/lib/state/src/test/java/mozilla/components/lib/state/helpers/AbstractBindingTest.kt b/mobile/android/android-components/components/lib/state/src/test/java/mozilla/components/lib/state/helpers/AbstractBindingTest.kt @@ -9,7 +9,6 @@ import mozilla.components.lib.state.Store import mozilla.components.lib.state.TestAction import mozilla.components.lib.state.TestState import mozilla.components.lib.state.reducer -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -71,15 +70,15 @@ class AbstractBindingTest { } } - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) binding.start() - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) binding.stop() - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) } } diff --git a/mobile/android/android-components/components/support/locale/src/test/java/mozilla/components/support/locale/LocaleMiddlewareTest.kt b/mobile/android/android-components/components/support/locale/src/test/java/mozilla/components/support/locale/LocaleMiddlewareTest.kt @@ -9,8 +9,6 @@ import kotlinx.coroutines.test.runTest import mozilla.components.browser.state.action.LocaleAction import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.store.BrowserStore -import mozilla.components.support.test.ext.joinBlocking -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 @@ -59,8 +57,7 @@ class LocaleMiddlewareTest { assertEquals(store.state.locale, null) - store.dispatch(LocaleAction.RestoreLocaleStateAction).joinBlocking() - store.waitUntilIdle() + store.dispatch(LocaleAction.RestoreLocaleStateAction) dispatcher.scheduler.advanceUntilIdle() assertEquals(store.state.locale, currentLocale) @@ -89,7 +86,7 @@ class LocaleMiddlewareTest { assertEquals(store.state.locale, null) val newLocale = "es".toLocale() - store.dispatch(LocaleAction.UpdateLocaleAction(newLocale)).joinBlocking() + store.dispatch(LocaleAction.UpdateLocaleAction(newLocale)) dispatcher.scheduler.advanceUntilIdle() verify(localeManager).setNewLocale(testContext, locale = newLocale) diff --git a/mobile/android/android-components/components/support/webextensions/src/test/java/mozilla/components/support/webextensions/WebExtensionPopupObserverTest.kt b/mobile/android/android-components/components/support/webextensions/src/test/java/mozilla/components/support/webextensions/WebExtensionPopupObserverTest.kt @@ -9,7 +9,6 @@ import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.state.WebExtensionState import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertEquals @@ -41,7 +40,7 @@ class WebExtensionPopupObserverTest { observer.start() assertNull(extensionOpeningPopup) - store.dispatch(WebExtensionAction.UpdatePopupSessionAction(extensionId, popupSession = engineSession)).joinBlocking() + store.dispatch(WebExtensionAction.UpdatePopupSessionAction(extensionId, popupSession = engineSession)) assertNotNull(extensionOpeningPopup) assertEquals(extensionId, extensionOpeningPopup!!.id) assertEquals(engineSession, extensionOpeningPopup.popupSession) @@ -49,7 +48,7 @@ class WebExtensionPopupObserverTest { // Verify that stopped feature does not observe and forward requests to open popup extensionOpeningPopup = null observer.stop() - store.dispatch(WebExtensionAction.UpdatePopupSessionAction(extensionId, popupSession = mock())).joinBlocking() + store.dispatch(WebExtensionAction.UpdatePopupSessionAction(extensionId, popupSession = mock())) assertNull(extensionOpeningPopup) } } diff --git a/mobile/android/android-components/components/support/webextensions/src/test/java/mozilla/components/support/webextensions/WebExtensionSupportTest.kt b/mobile/android/android-components/components/support/webextensions/src/test/java/mozilla/components/support/webextensions/WebExtensionSupportTest.kt @@ -34,8 +34,6 @@ import mozilla.components.support.base.facts.processor.CollectionProcessor import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor import mozilla.components.support.test.eq -import mozilla.components.support.test.ext.joinBlocking -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 @@ -205,7 +203,6 @@ class WebExtensionSupportTest { val tabHandlerCaptor = argumentCaptor<TabHandler>() WebExtensionSupport.initialize(engine, store) - store.waitUntilIdle() verify(ext).registerTabHandler(eq(engineSession), tabHandlerCaptor.capture()) tabHandlerCaptor.value.onCloseTab(ext, engineSession) verify(store).dispatch(TabListAction.RemoveTabAction(tabId)) @@ -238,7 +235,6 @@ class WebExtensionSupportTest { val tabHandlerCaptor = argumentCaptor<TabHandler>() WebExtensionSupport.initialize(engine, store) - store.waitUntilIdle() verify(ext).registerTabHandler(eq(engineSession), tabHandlerCaptor.capture()) tabHandlerCaptor.value.onCloseTab(ext, engineSession) verify(store).dispatch(CustomTabListAction.RemoveCustomTabAction(tabId)) @@ -278,7 +274,6 @@ class WebExtensionSupportTest { onCloseTabOverride = { _, _ -> onCloseTabCalled = true }, ) - store.waitUntilIdle() verify(ext).registerTabHandler(eq(engineSession), tabHandlerCaptor.capture()) tabHandlerCaptor.value.onCloseTab(ext, engineSession) assertTrue(onCloseTabCalled) @@ -314,7 +309,6 @@ class WebExtensionSupportTest { verify(ext).registerTabHandler(eq(engineSession), tabHandlerCaptor.capture()) assertNull(store.state.selectedTabId) assertTrue(tabHandlerCaptor.value.onUpdateTab(ext, engineSession, true, null)) - store.waitUntilIdle() assertEquals("testTabId", store.state.selectedTabId) // Update URL of tab @@ -322,7 +316,7 @@ class WebExtensionSupportTest { verify(engineSession).loadUrl("url") // Update non-existing tab - store.dispatch(TabListAction.RemoveTabAction(tabId)).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction(tabId)) assertFalse(tabHandlerCaptor.value.onUpdateTab(ext, engineSession, true, "url")) } @@ -356,14 +350,13 @@ class WebExtensionSupportTest { verify(ext).registerTabHandler(eq(engineSession), tabHandlerCaptor.capture()) assertNull(store.state.selectedTabId) assertTrue(tabHandlerCaptor.value.onUpdateTab(ext, engineSession, true, null)) - store.waitUntilIdle() // Update URL of tab assertTrue(tabHandlerCaptor.value.onUpdateTab(ext, engineSession, false, "url")) verify(engineSession).loadUrl("url") // Update non-existing tab - store.dispatch(CustomTabListAction.RemoveCustomTabAction(tabId)).joinBlocking() + store.dispatch(CustomTabListAction.RemoveCustomTabAction(tabId)) assertFalse(tabHandlerCaptor.value.onUpdateTab(ext, engineSession, true, "url")) } @@ -429,7 +422,7 @@ class WebExtensionSupportTest { verify(store, times(3)).dispatch(webExtensionActionCaptor.capture()) assertEquals(ext.id, (webExtensionActionCaptor.allValues.last() as WebExtensionAction.UpdateTabBrowserAction).extensionId) - store.dispatch(ContentAction.UpdateUrlAction(sessionId = "1", url = "https://www.firefox.com")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(sessionId = "1", url = "https://www.firefox.com")) verify(ext, times(1)).registerActionHandler(eq(engineSession), actionHandlerCaptor.capture()) verify(ext, times(1)).registerTabHandler(eq(engineSession), tabHandlerCaptor.capture()) @@ -670,12 +663,12 @@ class WebExtensionSupportTest { ) val engineSession1: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession1)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(tab.id, engineSession1)) verify(ext).registerActionHandler(eq(engineSession1), actionHandlerCaptor.capture()) verify(ext).registerTabHandler(eq(engineSession1), tabHandlerCaptor.capture()) val engineSession2: EngineSession = mock() - store.dispatch(EngineAction.LinkEngineSessionAction(customTab.id, engineSession2)).joinBlocking() + store.dispatch(EngineAction.LinkEngineSessionAction(customTab.id, engineSession2)) verify(ext).registerActionHandler(eq(engineSession2), actionHandlerCaptor.capture()) verify(ext).registerTabHandler(eq(engineSession2), tabHandlerCaptor.capture()) } @@ -777,7 +770,6 @@ class WebExtensionSupportTest { val actionCaptor = argumentCaptor<mozilla.components.browser.state.action.BrowserAction>() delegateCaptor.value.onToggleActionPopup(ext, engineSession, browserAction) - store.waitUntilIdle() verify(store, times(1)).dispatch(actionCaptor.capture()) assertEquals("popupTab", (actionCaptor.value as TabListAction.SelectTabAction).tabId) } @@ -808,7 +800,6 @@ class WebExtensionSupportTest { // Toggling again should close tab val actionCaptor = argumentCaptor<mozilla.components.browser.state.action.BrowserAction>() delegateCaptor.value.onToggleActionPopup(ext, engineSession, browserAction) - store.waitUntilIdle() verify(store).dispatch(actionCaptor.capture()) assertEquals("popupTab", (actionCaptor.value as TabListAction.RemoveTabAction).tabId) @@ -923,7 +914,6 @@ class WebExtensionSupportTest { verify(engine).registerWebExtensionDelegate(delegateCaptor.capture()) delegateCaptor.value.onExtensionListUpdated() - store.waitUntilIdle() val actionCaptor = argumentCaptor<WebExtensionAction>() verify(store, times(3)).dispatch(actionCaptor.capture()) @@ -943,7 +933,6 @@ class WebExtensionSupportTest { // Verify installed extensions are cleared installedList.clear() delegateCaptor.value.onExtensionListUpdated() - store.waitUntilIdle() assertTrue(WebExtensionSupport.installedExtensions.isEmpty()) } @@ -988,8 +977,6 @@ class WebExtensionSupportTest { assertEquals(1, WebExtensionSupport.installedExtensions.size) assertEquals(extOnceReady, WebExtensionSupport.installedExtensions[ext.id]) assertEquals(extOnceReadyMeta, WebExtensionSupport.installedExtensions[ext.id]?.getMetadata()) - - store.waitUntilIdle() } @Test @@ -1004,7 +991,6 @@ class WebExtensionSupportTest { verify(engine).registerWebExtensionDelegate(delegateCaptor.capture()) delegateCaptor.value.onDisabledExtensionProcessSpawning() - store.waitUntilIdle() assertTrue(store.state.showExtensionsProcessDisabledPrompt) } @@ -1044,16 +1030,13 @@ class WebExtensionSupportTest { WebExtensionSupport.initialize(engine, store) - store.waitUntilIdle() assertNotNull(store.state.findTab("1")) assertNotNull(store.state.findTab("2")) assertNull(store.state.findTab("3")) // Make sure we're running a single cleanup and stop the scope after store.dispatch(TabListAction.AddTabAction(createTab(id = "4", url = "moz-extension://1234-5678-90/"))) - .joinBlocking() - store.waitUntilIdle() assertNotNull(store.state.findTab("4")) } diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt @@ -761,7 +761,7 @@ class HistoryFragment : LibraryPageFragment<History>(), UserInteractionHandler, ) } browserStore.dispatch(RecentlyClosedAction.RemoveAllClosedTabAction) - browserStore.dispatch(EngineAction.PurgeHistoryAction).join() + browserStore.dispatch(EngineAction.PurgeHistoryAction) historyStore.dispatch(HistoryFragmentAction.ExitDeletionMode) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/TestUtils.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/TestUtils.kt @@ -4,13 +4,7 @@ package org.mozilla.fenix -import kotlinx.coroutines.Job -import mozilla.components.lib.state.Action -import mozilla.components.lib.state.State -import mozilla.components.lib.state.Store import mozilla.components.service.pocket.PocketStory.ContentRecommendation -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle /** * Utility file for providing shared functions that are used across multiple test files. @@ -48,11 +42,3 @@ object TestUtils { } } } - -/** - * Blocking [Store.dispatch] call of the given [action] ensures completion of the [Job]. - */ -fun <S : State, A : Action> Store<S, A>.testDispatch(action: A) { - dispatch(action).joinBlocking() - waitUntilIdle() -} diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/bindings/InactiveTabsBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/bindings/InactiveTabsBindingTest.kt @@ -5,7 +5,6 @@ package org.mozilla.fenix.bindings import mozilla.components.browser.state.state.createTab -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain import org.junit.Rule @@ -52,7 +51,7 @@ class InactiveTabsBindingTest { tabsTrayStore = tabsTrayStore, ) binding.start() - appStore.dispatch(AppAction.UpdateInactiveExpanded(true)).joinBlocking() + appStore.dispatch(AppAction.UpdateInactiveExpanded(true)) verify(tabsTrayStore).dispatch(TabsTrayAction.UpdateInactiveExpanded(true)) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/bookmarks/PrivateBrowsingLockMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/bookmarks/PrivateBrowsingLockMiddlewareTest.kt @@ -7,8 +7,6 @@ package org.mozilla.fenix.bookmarks import androidx.test.ext.junit.runners.AndroidJUnit4 import mozilla.components.lib.state.Middleware import mozilla.components.lib.state.MiddlewareContext -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertFalse import org.junit.Assert.assertNotNull @@ -50,8 +48,7 @@ class PrivateBrowsingLockMiddlewareTest { assertFalse(testMiddlewareInvoked) assertNull(middleware.pendingAction) - store.dispatch(action).joinBlocking() - store.waitUntilIdle() + store.dispatch(action) assertTrue(verificationRequested) assertFalse(testMiddlewareInvoked) @@ -80,8 +77,7 @@ class PrivateBrowsingLockMiddlewareTest { assertFalse(testMiddlewareInvoked) assertNull(middleware.pendingAction) - store.dispatch(action).joinBlocking() - store.waitUntilIdle() + store.dispatch(action) assertTrue(verificationRequested) assertFalse(testMiddlewareInvoked) @@ -110,8 +106,7 @@ class PrivateBrowsingLockMiddlewareTest { assertFalse(testMiddlewareInvoked) assertNull(middleware.pendingAction) - store.dispatch(action).joinBlocking() - store.waitUntilIdle() + store.dispatch(action) assertTrue(verificationRequested) assertFalse(testMiddlewareInvoked) @@ -142,8 +137,7 @@ class PrivateBrowsingLockMiddlewareTest { assertFalse(testMiddlewareInvoked) assertNull(middleware.pendingAction) - store.dispatch(action).joinBlocking() - store.waitUntilIdle() + store.dispatch(action) assertFalse(verificationRequested) assertTrue(testMiddlewareInvoked) @@ -172,8 +166,7 @@ class PrivateBrowsingLockMiddlewareTest { assertFalse(testMiddlewareInvoked) assertNull(middleware.pendingAction) - store.dispatch(action).joinBlocking() - store.waitUntilIdle() + store.dispatch(action) assertFalse(verificationRequested) assertTrue(testMiddlewareInvoked) @@ -202,8 +195,7 @@ class PrivateBrowsingLockMiddlewareTest { assertFalse(testMiddlewareInvoked) assertNull(middleware.pendingAction) - store.dispatch(action).joinBlocking() - store.waitUntilIdle() + store.dispatch(action) assertFalse(verificationRequested) assertTrue(testMiddlewareInvoked) @@ -230,8 +222,7 @@ class PrivateBrowsingLockMiddlewareTest { assertFalse(testMiddlewareInvoked) assertNotNull(middleware.pendingAction) - store.dispatch(action).joinBlocking() - store.waitUntilIdle() + store.dispatch(action) assertTrue(testMiddlewareInvoked) assertNull(middleware.pendingAction) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/browser/BrowserFragmentTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/browser/BrowserFragmentTest.kt @@ -30,7 +30,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.browser.toolbar.BrowserToolbar -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.After import org.junit.Assert.assertTrue @@ -176,7 +175,7 @@ class BrowserFragmentTest { @Test fun `GIVEN tabs are restored WHEN there are no tabs THEN navigate to home`() { browserFragment.observeRestoreComplete(store, navController) - store.dispatch(RestoreCompleteAction).joinBlocking() + store.dispatch(RestoreCompleteAction) verify(exactly = 1) { navController.popBackStack(R.id.homeFragment, false) } } @@ -185,7 +184,7 @@ class BrowserFragmentTest { fun `GIVEN tabs are restored WHEN there are tabs THEN do not navigate`() { addAndSelectTab(testTab) browserFragment.observeRestoreComplete(store, navController) - store.dispatch(RestoreCompleteAction).joinBlocking() + store.dispatch(RestoreCompleteAction) verify(exactly = 0) { navController.popBackStack(R.id.homeFragment, false) } } @@ -194,7 +193,7 @@ class BrowserFragmentTest { fun `GIVEN tabs are restored WHEN there is no selected tab THEN navigate to home`() { val store = BrowserStore(initialState = BrowserState(tabs = listOf(testTab))) browserFragment.observeRestoreComplete(store, navController) - store.dispatch(RestoreCompleteAction).joinBlocking() + store.dispatch(RestoreCompleteAction) verify(exactly = 1) { navController.popBackStack(R.id.homeFragment, false) } } @@ -467,8 +466,8 @@ class BrowserFragmentTest { } private fun addAndSelectTab(tab: TabSessionState) { - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() - store.dispatch(TabListAction.SelectTabAction(tab.id)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) + store.dispatch(TabListAction.SelectTabAction(tab.id)) } internal class MockedLifecycleOwner(initialState: Lifecycle.State) : LifecycleOwner { diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/browser/OpenInAppOnboardingObserverTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/browser/OpenInAppOnboardingObserverTest.kt @@ -20,7 +20,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.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.After @@ -92,10 +91,10 @@ class OpenInAppOnboardingObserverTest { every { settings.shouldOpenLinksInApp() } returns true every { settings.shouldShowOpenInAppCfr } returns true every { appLinksUseCases.appLinkRedirect.invoke(any()).hasExternalApp() } returns true - store.dispatch(ContentAction.UpdateLoadingStateAction("1", true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction("1", true)) openInAppOnboardingObserver.start() - store.dispatch(ContentAction.UpdateLoadingStateAction("1", false)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction("1", false)) verify(exactly = 0) { infoBanner.showBanner() } } @@ -104,11 +103,11 @@ class OpenInAppOnboardingObserverTest { every { settings.shouldOpenLinksInApp() } returns false every { settings.shouldShowOpenInAppCfr } returns true every { appLinksUseCases.appLinkRedirect.invoke(any()).hasExternalApp() } returns true - store.dispatch(ContentAction.UpdateLoadingStateAction("1", true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction("1", true)) openInAppOnboardingObserver.start() - store.dispatch(ContentAction.UpdateLoadingStateAction("1", false)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction("1", false)) verify(exactly = 1) { infoBanner.showBanner() } } @@ -117,10 +116,10 @@ class OpenInAppOnboardingObserverTest { every { settings.openLinksInExternalApp } returns "never" every { settings.shouldShowOpenInAppCfr } returns false every { appLinksUseCases.appLinkRedirect.invoke(any()).hasExternalApp() } returns true - store.dispatch(ContentAction.UpdateLoadingStateAction("1", true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction("1", true)) openInAppOnboardingObserver.start() - store.dispatch(ContentAction.UpdateLoadingStateAction("1", false)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction("1", false)) verify(exactly = 0) { infoBanner.showBanner() } } @@ -129,11 +128,11 @@ class OpenInAppOnboardingObserverTest { every { settings.openLinksInExternalApp } returns "never" every { settings.shouldShowOpenInAppCfr } returns true every { appLinksUseCases.appLinkRedirect.invoke(any()).hasExternalApp() } returns false - store.dispatch(ContentAction.UpdateLoadingStateAction("1", true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction("1", true)) openInAppOnboardingObserver.start() - store.dispatch(ContentAction.UpdateLoadingStateAction("1", false)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction("1", false)) verify(exactly = 0) { infoBanner.showBanner() } } @@ -143,18 +142,18 @@ class OpenInAppOnboardingObserverTest { every { settings.shouldShowOpenInAppCfr } returns true every { appLinksUseCases.appLinkRedirect.invoke(any()).hasExternalApp() } returns true - store.dispatch(ContentAction.UpdateLoadingStateAction("1", true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction("1", true)) openInAppOnboardingObserver.start() - store.dispatch(ContentAction.UpdateLoadingStateAction("1", false)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction("1", false)) verify(exactly = 1) { infoBanner.showBanner() } verify(exactly = 0) { infoBanner.dismiss() } - store.dispatch(ContentAction.UpdateUrlAction("1", "https://www.mozilla.org/en-US/")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction("1", "https://www.mozilla.org/en-US/")) verify(exactly = 0) { infoBanner.dismiss() } - store.dispatch(ContentAction.UpdateUrlAction("1", "https://www.firefox.com")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction("1", "https://www.firefox.com")) verify(exactly = 1) { infoBanner.dismiss() } } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/browser/TranslationsBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/browser/TranslationsBindingTest.kt @@ -20,7 +20,6 @@ import mozilla.components.concept.engine.translate.TranslationError import mozilla.components.concept.engine.translate.TranslationOperation import mozilla.components.concept.engine.translate.TranslationPair import mozilla.components.concept.engine.translate.TranslationSupport -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Rule @@ -110,14 +109,14 @@ class TranslationsBindingTest { TranslationsAction.SetSupportedLanguagesAction( supportedLanguages = supportLanguages, ), - ).joinBlocking() + ) browserStore.dispatch( TranslationsAction.TranslateStateChangeAction( tabId = tabId, translationEngineState = translationEngineState, ), - ).joinBlocking() + ) browserStore.dispatch( TranslationsAction.TranslateAction( @@ -126,7 +125,7 @@ class TranslationsBindingTest { toLanguage = spanishLanguage.code, options = null, ), - ).joinBlocking() + ) verify(onTranslationsActionUpdated).invoke(expectedTranslationStatus) verify(browserScreenStore).dispatch( @@ -165,7 +164,7 @@ class TranslationsBindingTest { TranslationsAction.TranslateExpectedAction( tabId = tabId, ), - ).joinBlocking() + ) verify(onTranslationsActionUpdated).invoke(expectedTranslationStatus) verify(browserScreenStore).dispatch( @@ -229,7 +228,7 @@ class TranslationsBindingTest { tabId = tab.id, isOfferTranslate = true, ), - ).joinBlocking() + ) verify(onShowTranslationsDialog).invoke() } @@ -268,7 +267,7 @@ class TranslationsBindingTest { tabId = tab.id, isOfferTranslate = true, ), - ).joinBlocking() + ) verify(onShowTranslationsDialog, never()).invoke() verify(binding).recordTranslationStartTelemetry() @@ -331,7 +330,7 @@ class TranslationsBindingTest { tabId = tab.id, isOfferTranslate = false, ), - ).joinBlocking() + ) verify(onShowTranslationsDialog, never()).invoke() verify(binding, never()).recordTranslationStartTelemetry() @@ -363,14 +362,14 @@ class TranslationsBindingTest { TranslationsAction.TranslateExpectedAction( tabId = tabId, ), - ).joinBlocking() + ) browserStore.dispatch( TranslationsAction.TranslateOfferAction( tabId = tab.id, isOfferTranslate = false, ), - ).joinBlocking() + ) browserStore.dispatch( TranslationsAction.TranslateExceptionAction( @@ -378,7 +377,7 @@ class TranslationsBindingTest { TranslationOperation.TRANSLATE, TranslationError.CouldNotTranslateError(null), ), - ).joinBlocking() + ) verify(onShowTranslationsDialog).invoke() verify(binding, never()).recordTranslationStartTelemetry() diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/browser/settings/DesktopModeMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/browser/settings/DesktopModeMiddlewareTest.kt @@ -12,8 +12,6 @@ import kotlinx.coroutines.test.advanceUntilIdle import mozilla.components.browser.state.action.DefaultDesktopModeAction import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.store.BrowserStore -import mozilla.components.support.test.ext.joinBlocking -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 @@ -51,7 +49,6 @@ class DesktopModeMiddlewareTest { ) advanceUntilIdle() - store.waitUntilIdle() launch { assertEquals(expected, store.state.desktopMode) @@ -71,7 +68,6 @@ class DesktopModeMiddlewareTest { ) advanceUntilIdle() - store.waitUntilIdle() launch { assertEquals(expected, store.state.desktopMode) @@ -95,10 +91,8 @@ class DesktopModeMiddlewareTest { ) advanceUntilIdle() - store.waitUntilIdle() - store.dispatch(DefaultDesktopModeAction.ToggleDesktopMode).joinBlocking() + store.dispatch(DefaultDesktopModeAction.ToggleDesktopMode) advanceUntilIdle() - store.waitUntilIdle() } @Test @@ -118,9 +112,8 @@ class DesktopModeMiddlewareTest { ) advanceUntilIdle() - store.waitUntilIdle() - store.dispatch(DefaultDesktopModeAction.ToggleDesktopMode).joinBlocking() + store.dispatch(DefaultDesktopModeAction.ToggleDesktopMode) } @Test @@ -141,10 +134,8 @@ class DesktopModeMiddlewareTest { ) advanceUntilIdle() - store.waitUntilIdle() - store.dispatch(DefaultDesktopModeAction.ToggleDesktopMode).joinBlocking() + store.dispatch(DefaultDesktopModeAction.ToggleDesktopMode) advanceUntilIdle() - store.waitUntilIdle() launch { assertEquals(expected, store.state.desktopMode) @@ -169,10 +160,8 @@ class DesktopModeMiddlewareTest { ) advanceUntilIdle() - store.waitUntilIdle() - store.dispatch(DefaultDesktopModeAction.ToggleDesktopMode).joinBlocking() + store.dispatch(DefaultDesktopModeAction.ToggleDesktopMode) advanceUntilIdle() - store.waitUntilIdle() launch { assertEquals(expected, store.state.desktopMode) @@ -193,10 +182,8 @@ class DesktopModeMiddlewareTest { assertNull(DesktopMode.settingsAlwaysRequestDesktopSite.testGetValue()) advanceUntilIdle() - store.waitUntilIdle() - store.dispatch(DefaultDesktopModeAction.ToggleDesktopMode).joinBlocking() + store.dispatch(DefaultDesktopModeAction.ToggleDesktopMode) advanceUntilIdle() - store.waitUntilIdle() assertNotNull(DesktopMode.settingsAlwaysRequestDesktopSite.testGetValue()) val snapshot = DesktopMode.settingsAlwaysRequestDesktopSite.testGetValue()!! diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/collections/CollectionCreationStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/collections/CollectionCreationStoreTest.kt @@ -61,10 +61,10 @@ class CollectionCreationStoreTest { ), ) - store.dispatch(CollectionCreationAction.AddAllTabs).joinBlocking() + store.dispatch(CollectionCreationAction.AddAllTabs) assertEquals(tabs.toSet(), store.state.selectedTabs) - store.dispatch(CollectionCreationAction.RemoveAllTabs).joinBlocking() + store.dispatch(CollectionCreationAction.RemoveAllTabs) assertEquals(emptySet<Tab>(), store.state.selectedTabs) } @@ -80,16 +80,16 @@ class CollectionCreationStoreTest { ), ) - store.dispatch(CollectionCreationAction.TabAdded(tab2)).joinBlocking() + store.dispatch(CollectionCreationAction.TabAdded(tab2)) assertEquals(setOf(tab2), store.state.selectedTabs) - store.dispatch(CollectionCreationAction.TabAdded(tab1)).joinBlocking() + store.dispatch(CollectionCreationAction.TabAdded(tab1)) assertEquals(setOf(tab1, tab2), store.state.selectedTabs) - store.dispatch(CollectionCreationAction.TabAdded(tab3)).joinBlocking() + store.dispatch(CollectionCreationAction.TabAdded(tab3)) assertEquals(setOf(tab1, tab2, tab3), store.state.selectedTabs) - store.dispatch(CollectionCreationAction.TabRemoved(tab2)).joinBlocking() + store.dispatch(CollectionCreationAction.TabRemoved(tab2)) assertEquals(setOf(tab1, tab3), store.state.selectedTabs) } @@ -107,7 +107,7 @@ class CollectionCreationStoreTest { saveCollectionStep = SaveCollectionStep.RenameCollection, defaultCollectionNumber = 3, ), - ).joinBlocking() + ) assertEquals(SaveCollectionStep.RenameCollection, store.state.saveCollectionStep) assertEquals(3, store.state.defaultCollectionNumber) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/collections/DefaultCollectionCreationControllerTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/collections/DefaultCollectionCreationControllerTest.kt @@ -17,7 +17,6 @@ import mozilla.components.browser.state.action.TabListAction import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.feature.tab.collections.TabCollection -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain @@ -86,7 +85,7 @@ class DefaultCollectionCreationControllerTest { browserStore.dispatch( TabListAction.AddMultipleTabsAction(listOf(tab1, tab2)), - ).joinBlocking() + ) coEvery { tabCollectionStorage.addTabsToCollection(any(), any()) } returns 1L coEvery { tabCollectionStorage.createCollection(any(), any()) } returns 1L @@ -194,7 +193,7 @@ class DefaultCollectionCreationControllerTest { val tab2 = createTab("https://www.mozilla.org", id = "session-2") browserStore.dispatch( TabListAction.AddMultipleTabsAction(listOf(tab1, tab2)), - ).joinBlocking() + ) val tabs = listOf( Tab("session-1", "", "", ""), diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/AboutHomeMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/AboutHomeMiddlewareTest.kt @@ -12,7 +12,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.history.HistoryItem import mozilla.components.concept.engine.utils.ABOUT_HOME_URL -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.middleware.CaptureActionsMiddleware import org.junit.Assert.assertEquals import org.junit.Before @@ -43,7 +42,7 @@ class AboutHomeMiddlewareTest { store.dispatch( ContentAction.UpdateTitleAction(sessionId = tab.id, title = ""), - ).joinBlocking() + ) assertEquals( homepageTitle, @@ -61,7 +60,7 @@ class AboutHomeMiddlewareTest { store.dispatch( ContentAction.UpdateTitleAction(sessionId = tab.id, title = title), - ).joinBlocking() + ) assertEquals( title, @@ -90,7 +89,7 @@ class AboutHomeMiddlewareTest { historyList = originalHistoryList, currentIndex = 1, ), - ).joinBlocking() + ) assertEquals( expectedHistoryList, diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/AppStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/AppStoreTest.kt @@ -53,7 +53,6 @@ import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryGrou import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryHighlight import org.mozilla.fenix.messaging.FenixMessageSurfaceId import org.mozilla.fenix.onboarding.FenixOnboarding -import org.mozilla.fenix.testDispatch class AppStoreTest { private lateinit var context: Context @@ -103,11 +102,11 @@ class AppStoreTest { assertEquals(BrowsingMode.Normal, appStore.state.mode) // Change the AppStore to Private mode. - appStore.dispatch(AppAction.BrowsingModeManagerModeChanged(BrowsingMode.Private)).join() + appStore.dispatch(AppAction.BrowsingModeManagerModeChanged(BrowsingMode.Private)) assertEquals(BrowsingMode.Private, appStore.state.mode) // Change the AppStore back to Normal mode. - appStore.dispatch(AppAction.BrowsingModeManagerModeChanged(BrowsingMode.Normal)).join() + appStore.dispatch(AppAction.BrowsingModeManagerModeChanged(BrowsingMode.Normal)) assertEquals(BrowsingMode.Normal, appStore.state.mode) } @@ -125,7 +124,7 @@ class AppStoreTest { emptyList(), mockk(), ) - appStore.dispatch(UpdateMessageToShow(message)).join() + appStore.dispatch(UpdateMessageToShow(message)) assertFalse(appStore.state.messaging.messageToShow.isEmpty()) } @@ -136,7 +135,7 @@ class AppStoreTest { // Add 2 TabCollections to the AppStore. val tabCollections: List<TabCollection> = listOf(mockk(), mockk()) - appStore.dispatch(AppAction.CollectionsChange(tabCollections)).join() + appStore.dispatch(AppAction.CollectionsChange(tabCollections)) assertEquals(tabCollections, appStore.state.collections) } @@ -147,7 +146,7 @@ class AppStoreTest { // Add 2 TopSites to the AppStore. val topSites: List<TopSite> = listOf(mockk(), mockk()) - appStore.dispatch(AppAction.TopSitesChange(topSites)).join() + appStore.dispatch(AppAction.TopSitesChange(topSites)) assertEquals(topSites, appStore.state.topSites) } @@ -168,7 +167,7 @@ class AppStoreTest { // Add 2 RecentTabs to the AppStore val recentTab1: RecentTab.Tab = mockk() val recentTabs: List<RecentTab> = listOf(recentTab1) - appStore.dispatch(AppAction.RecentTabsChange(recentTabs)).join() + appStore.dispatch(AppAction.RecentTabsChange(recentTabs)) assertEquals(recentTabs, appStore.state.recentTabs) assertEquals(listOf(group1, group2, group3, highlight), appStore.state.recentHistory) @@ -183,12 +182,12 @@ class AppStoreTest { ) val loading = RecentSyncedTabState.Loading - appStore.dispatch(AppAction.RecentSyncedTabStateChange(loading)).join() + appStore.dispatch(AppAction.RecentSyncedTabStateChange(loading)) assertEquals(loading, appStore.state.recentSyncedTabState) val recentSyncedTabs = listOf(RecentSyncedTab("device name", DeviceType.DESKTOP, "title", "url", null)) val success = RecentSyncedTabState.Success(recentSyncedTabs) - appStore.dispatch(AppAction.RecentSyncedTabStateChange(success)).join() + appStore.dispatch(AppAction.RecentSyncedTabStateChange(success)) assertEquals(success, appStore.state.recentSyncedTabState) assertEquals(recentSyncedTabs, (appStore.state.recentSyncedTabState as RecentSyncedTabState.Success).tabs) } @@ -198,7 +197,7 @@ class AppStoreTest { assertEquals(0, appStore.state.recentHistory.size) val historyMetadata: List<RecentHistoryGroup> = listOf(mockk(), mockk()) - appStore.dispatch(AppAction.RecentHistoryChange(historyMetadata)).join() + appStore.dispatch(AppAction.RecentHistoryChange(historyMetadata)) assertEquals(historyMetadata, appStore.state.recentHistory) } @@ -214,13 +213,13 @@ class AppStoreTest { ) appStore = AppStore(recentHistoryState) - appStore.dispatch(AppAction.RemoveRecentHistoryHighlight("invalid")).join() + appStore.dispatch(AppAction.RemoveRecentHistoryHighlight("invalid")) assertEquals(recentHistoryState, appStore.state) - appStore.dispatch(AppAction.RemoveRecentHistoryHighlight(h1.title)).join() + appStore.dispatch(AppAction.RemoveRecentHistoryHighlight(h1.title)) assertEquals(recentHistoryState, appStore.state) - appStore.dispatch(AppAction.RemoveRecentHistoryHighlight(h1.url)).join() + appStore.dispatch(AppAction.RemoveRecentHistoryHighlight(h1.url)) assertEquals( recentHistoryState.copy(recentHistory = listOf(g1, g2, h2)), appStore.state, @@ -234,10 +233,10 @@ class AppStoreTest { val h1 = RecentHistoryHighlight(title = "highlight One", url = "url1") val h2 = RecentHistoryHighlight(title = "highlight two", url = "url2") val recentHistory: List<RecentlyVisitedItem> = listOf(g1, g2, h1, h2) - appStore.dispatch(AppAction.RecentHistoryChange(recentHistory)).join() + appStore.dispatch(AppAction.RecentHistoryChange(recentHistory)) assertEquals(recentHistory, appStore.state.recentHistory) - appStore.dispatch(AppAction.DisbandSearchGroupAction("Test one")).join() + appStore.dispatch(AppAction.DisbandSearchGroupAction("Test one")) assertEquals(listOf(g2, h1, h2), appStore.state.recentHistory) } @@ -245,7 +244,7 @@ class AppStoreTest { fun `Test changing hiding collections placeholder`() = runTest { assertTrue(appStore.state.showCollectionPlaceholder) - appStore.dispatch(AppAction.RemoveCollectionsPlaceholder).join() + appStore.dispatch(AppAction.RemoveCollectionsPlaceholder) assertFalse(appStore.state.showCollectionPlaceholder) } @@ -257,8 +256,8 @@ class AppStoreTest { } // Expand the given collection. - appStore.dispatch(AppAction.CollectionsChange(listOf(collection))).join() - appStore.dispatch(AppAction.CollectionExpanded(collection, true)).join() + appStore.dispatch(AppAction.CollectionsChange(listOf(collection))) + appStore.dispatch(AppAction.CollectionExpanded(collection, true)) assertTrue(appStore.state.expandedCollections.contains(collection.id)) assertEquals(1, appStore.state.expandedCollections.size) @@ -309,7 +308,7 @@ class AppStoreTest { recentHistory = recentHistory, recentSyncedTabState = recentSyncedTabState, ), - ).join() + ) assertEquals(collections, appStore.state.collections) assertEquals(topSites, appStore.state.topSites) @@ -357,7 +356,7 @@ class AppStoreTest { ), ) - appStore.dispatch(ContentRecommendationsAction.SelectPocketStoriesCategory(anotherCategoryName)).join() + appStore.dispatch(ContentRecommendationsAction.SelectPocketStoriesCategory(anotherCategoryName)) val selectedCategoriesState = appStore.state.recommendationState.pocketStoriesCategoriesSelections assertEquals("Two categories should now be selected", 2, selectedCategoriesState.size) @@ -411,7 +410,7 @@ class AppStoreTest { ), ) - appStore.dispatch(ContentRecommendationsAction.DeselectPocketStoriesCategory(otherCategoryName)).join() + appStore.dispatch(ContentRecommendationsAction.DeselectPocketStoriesCategory(otherCategoryName)) val selectedCategoriesState = appStore.state.recommendationState.pocketStoriesCategoriesSelections assertEquals("Only one category should remain selected", 1, selectedCategoriesState.size) @@ -440,7 +439,6 @@ class AppStoreTest { ) appStore.dispatch(ContentRecommendationsAction.PocketStoriesClean) - .join() assertTrue(appStore.state.recommendationState.pocketStoriesCategories.isEmpty()) assertTrue(appStore.state.recommendationState.pocketStoriesCategoriesSelections.isEmpty()) @@ -500,7 +498,7 @@ class AppStoreTest { ContentRecommendationsAction.PocketSponsoredStoriesChange( sponsoredStories = listOf(sponsoredStory1, sponsoredStory2), ), - ).join() + ) assertTrue( appStore.state.recommendationState.pocketSponsoredStories.containsAll( @@ -518,7 +516,7 @@ class AppStoreTest { ContentRecommendationsAction.PocketSponsoredStoriesChange( sponsoredStories = updatedSponsoredStories, ), - ).join() + ) assertTrue( appStore.state.recommendationState.pocketSponsoredStories.containsAll(updatedSponsoredStories), @@ -590,7 +588,7 @@ class AppStoreTest { ContentRecommendationsAction.SponsoredContentsChange( sponsoredContents = currentSponsoredContentsToShow, ), - ).join() + ) assertEquals(currentSponsoredContentsToShow, appStore.state.recommendationState.sponsoredContents) assertEquals( @@ -605,7 +603,7 @@ class AppStoreTest { ContentRecommendationsAction.SponsoredContentsChange( sponsoredContents = currentSponsoredContentsToShow, ), - ).join() + ) assertEquals(currentSponsoredContentsToShow, appStore.state.recommendationState.sponsoredContents) assertEquals( @@ -650,7 +648,7 @@ class AppStoreTest { PocketImpression(story = story3, position = 2), ), ), - ).join() + ) assertEquals(4, appStore.state.recommendationState.pocketSponsoredStories.size) assertEquals(3, appStore.state.recommendationState.pocketSponsoredStories[0].caps.currentImpressions.size) @@ -703,7 +701,7 @@ class AppStoreTest { PocketImpression(story = sponsoredContent3, position = 2), ), ), - ).join() + ) assertEquals(4, appStore.state.recommendationState.sponsoredContents.size) assertEquals(3, appStore.state.recommendationState.sponsoredContents[0].caps.currentImpressions.size) @@ -753,7 +751,7 @@ class AppStoreTest { PocketImpression(story = recommendation3, position = 2), ), ), - ).join() + ) assertEquals(4, appStore.state.recommendationState.contentRecommendations.size) assertEquals(1, appStore.state.recommendationState.contentRecommendations[0].impressions) @@ -795,7 +793,7 @@ class AppStoreTest { val categoriesForFirstDispatch = listOf(defaultPocketCategoryWithStory, anotherPocketCategory) appStore.dispatch( ContentRecommendationsAction.PocketStoriesCategoriesChange(categoriesForFirstDispatch), - ).join() + ) assertTrue( "Available categories should contain the dispatched categories", @@ -816,7 +814,7 @@ class AppStoreTest { val categoriesForSecondDispatch = listOf(yetAnotherPocketCategory) appStore.dispatch( ContentRecommendationsAction.PocketStoriesCategoriesChange(categoriesForSecondDispatch), - ).join() + ) assertTrue( "Available categories should contain the newly dispatched categories", @@ -847,7 +845,7 @@ class AppStoreTest { storiesCategories = listOf(otherStoriesCategory, anotherStoriesCategory), categoriesSelected = listOf(selectedCategory), ), - ).join() + ) assertTrue( appStore.state.recommendationState.pocketStoriesCategories.containsAll( @@ -894,7 +892,7 @@ class AppStoreTest { ContentRecommendationsAction.ContentRecommendationsFetched( recommendations = recommendations, ), - ).join() + ) assertEquals(recommendations, appStore.state.recommendationState.contentRecommendations) assertEquals(recommendations, appStore.state.recommendationState.pocketStories) @@ -904,7 +902,7 @@ class AppStoreTest { fun `WHEN init action is dispatched THEN the setup checklist state remains the same`() { val appState = AppState(setupChecklistState = SetupChecklistState()) - appStore.testDispatch(AppAction.SetupChecklistAction.Init) + appStore.dispatch(AppAction.SetupChecklistAction.Init) assertEquals(SetupChecklistState(), appState.setupChecklistState) } @@ -913,7 +911,7 @@ class AppStoreTest { fun `WHEN closed action is dispatched THEN the setup checklist state visible value is updated`() { val appState = AppState(setupChecklistState = SetupChecklistState()) - appStore.testDispatch(AppAction.SetupChecklistAction.Closed) + appStore.dispatch(AppAction.SetupChecklistAction.Closed) assertEquals(SetupChecklistState(isVisible = true), appState.setupChecklistState) } @@ -959,7 +957,7 @@ class AppStoreTest { assertTrue((store.state.setupChecklistState!!.checklistItems[0] as ChecklistItem.Group).isExpanded) assertFalse((store.state.setupChecklistState!!.checklistItems[1] as ChecklistItem.Group).isExpanded) - store.testDispatch(AppAction.SetupChecklistAction.ChecklistItemClicked(collapsedGroup)) + store.dispatch(AppAction.SetupChecklistAction.ChecklistItemClicked(collapsedGroup)) // Verify that the expanded group was collapsed, and the other one got expanded assertFalse((store.state.setupChecklistState!!.checklistItems[0] as ChecklistItem.Group).isExpanded) @@ -978,7 +976,7 @@ class AppStoreTest { val appState = AppState(setupChecklistState = SetupChecklistState(checklistItems = listOf(task))) val store = AppStore(appState) - store.testDispatch(AppAction.SetupChecklistAction.ChecklistItemClicked(task)) + store.dispatch(AppAction.SetupChecklistAction.ChecklistItemClicked(task)) assertFalse((store.state.setupChecklistState!!.checklistItems[0] as ChecklistItem.Task).isCompleted) } @@ -995,11 +993,11 @@ class AppStoreTest { val appState = AppState(setupChecklistState = SetupChecklistState(checklistItems = listOf(task))) val store = AppStore(appState) - store.testDispatch(AppAction.SetupChecklistAction.TaskPreferenceUpdated(task.type, true)) + store.dispatch(AppAction.SetupChecklistAction.TaskPreferenceUpdated(task.type, true)) assertTrue((store.state.setupChecklistState!!.checklistItems[0] as ChecklistItem.Task).isCompleted) - store.testDispatch(AppAction.SetupChecklistAction.TaskPreferenceUpdated(task.type, false)) + store.dispatch(AppAction.SetupChecklistAction.TaskPreferenceUpdated(task.type, false)) assertFalse((store.state.setupChecklistState!!.checklistItems[0] as ChecklistItem.Task).isCompleted) } @@ -1027,12 +1025,17 @@ class AppStoreTest { val appState = AppState(setupChecklistState = SetupChecklistState(checklistItems = listOf(group))) val store = AppStore(appState) - store.testDispatch(AppAction.SetupChecklistAction.TaskPreferenceUpdated(updatedTask.type, true)) + store.dispatch(AppAction.SetupChecklistAction.TaskPreferenceUpdated(updatedTask.type, true)) assertTrue((store.state.setupChecklistState!!.checklistItems[0] as ChecklistItem.Group).tasks[0].isCompleted) assertFalse((store.state.setupChecklistState!!.checklistItems[0] as ChecklistItem.Group).tasks[1].isCompleted) - store.testDispatch(AppAction.SetupChecklistAction.TaskPreferenceUpdated(updatedTask.type, false)) + store.dispatch( + AppAction.SetupChecklistAction.TaskPreferenceUpdated( + updatedTask.type, + false, + ), + ) assertFalse((store.state.setupChecklistState!!.checklistItems[0] as ChecklistItem.Group).tasks[0].isCompleted) assertFalse((store.state.setupChecklistState!!.checklistItems[0] as ChecklistItem.Group).tasks[1].isCompleted) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/ChangeDetectionMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/ChangeDetectionMiddlewareTest.kt @@ -9,7 +9,6 @@ import mozilla.components.lib.state.Middleware import mozilla.components.lib.state.Reducer import mozilla.components.lib.state.State import mozilla.components.lib.state.Store -import mozilla.components.support.test.ext.joinBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Test @@ -35,12 +34,12 @@ class ChangeDetectionMiddlewareTest { listOf(middleware), ) - store.dispatch(TestAction.IncrementAction).joinBlocking() + store.dispatch(TestAction.IncrementAction) assertTrue(capturedAction is TestAction.IncrementAction) assertEquals(0, preCount) assertEquals(1, postCount) - store.dispatch(TestAction.DecrementAction).joinBlocking() + store.dispatch(TestAction.DecrementAction) assertTrue(capturedAction is TestAction.DecrementAction) assertEquals(1, preCount) assertEquals(0, postCount) @@ -66,12 +65,12 @@ class ChangeDetectionMiddlewareTest { listOf(middleware), ) - store.dispatch(TestAction.SetEnabled(true)).joinBlocking() + store.dispatch(TestAction.SetEnabled(true)) assertTrue(capturedAction is TestAction.SetEnabled) assertEquals(false, preState[1]) assertEquals(true, postState[1]) - store.dispatch(TestAction.SetEnabled(false)).joinBlocking() + store.dispatch(TestAction.SetEnabled(false)) assertTrue(capturedAction is TestAction.SetEnabled) assertEquals(true, preState[1]) assertEquals(false, postState[1]) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/LogMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/LogMiddlewareTest.kt @@ -31,7 +31,7 @@ class LogMiddlewareTest { val actionMessages = listOf("one!", "two!", "buckle my shoe!") actionMessages.forEach { message -> val action = AAction(message) - store.dispatch(action).join() + store.dispatch(action) verify(logger).info(action.toString()) } } @@ -47,7 +47,7 @@ class LogMiddlewareTest { val actionMessages = listOf("one!", "two!", "buckle my shoe!") actionMessages.forEach { message -> - store.dispatch(AAction(message)).join() + store.dispatch(AAction(message)) } verify(logger, times(3)).info(AAction::class.java.name) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/ProfileMarkerMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/ProfileMarkerMiddlewareTest.kt @@ -41,7 +41,7 @@ class ProfileMarkerMiddlewareTest { val actionMessages = listOf("one!", "two!", "buckle my shoe!") actionMessages.forEach { message -> - store.dispatch(AAction(message)).join() + store.dispatch(AAction(message)) this.advanceUntilIdle() assertTrue(captured.any { it.first == markerName && it.second!!.contains("AAction") }) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/StartupMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/StartupMiddlewareTest.kt @@ -13,7 +13,6 @@ import mozilla.components.browser.state.action.RestoreCompleteAction import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.robolectric.testContext import org.junit.Before @@ -48,7 +47,7 @@ class StartupMiddlewareTest { settings.enableHomepageAsNewTab = true val store = createStore() - store.dispatch(RestoreCompleteAction).joinBlocking() + store.dispatch(RestoreCompleteAction) captureActionsMiddleware.assertLastAction(RestoreCompleteAction::class) {} @@ -62,7 +61,7 @@ class StartupMiddlewareTest { settings.enableHomepageAsNewTab = false val store = createStore() - store.dispatch(RestoreCompleteAction).joinBlocking() + store.dispatch(RestoreCompleteAction) captureActionsMiddleware.assertLastAction(RestoreCompleteAction::class) {} @@ -79,7 +78,7 @@ class StartupMiddlewareTest { initialState = BrowserState(tabs = listOf(tab)), ) - store.dispatch(RestoreCompleteAction).joinBlocking() + store.dispatch(RestoreCompleteAction) captureActionsMiddleware.assertLastAction(RestoreCompleteAction::class) {} diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/menu/MenuNavigationMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/menu/MenuNavigationMiddlewareTest.kt @@ -91,7 +91,7 @@ class MenuNavigationMiddlewareTest { accountState = accountState, accesspoint = accessPoint, ), - ).join() + ) verify { navController.navigate( @@ -113,7 +113,7 @@ class MenuNavigationMiddlewareTest { accountState = accountState, accesspoint = accesspoint, ), - ).join() + ) verify { navController.navigate( @@ -143,7 +143,7 @@ class MenuNavigationMiddlewareTest { accountState = accountState, accesspoint = accesspoint, ), - ).join() + ) verify { navController.navigate( @@ -158,7 +158,7 @@ class MenuNavigationMiddlewareTest { @Test fun `WHEN navigate to settings action is dispatched THEN navigate to settings`() = runTest { val store = createStore() - store.dispatch(MenuAction.Navigate.Settings).join() + store.dispatch(MenuAction.Navigate.Settings) verify { navController.navigate( @@ -171,7 +171,7 @@ class MenuNavigationMiddlewareTest { @Test fun `WHEN navigate to bookmarks action is dispatched THEN navigate to bookmarks`() = runTest { val store = createStore() - store.dispatch(MenuAction.Navigate.Bookmarks).join() + store.dispatch(MenuAction.Navigate.Bookmarks) verify { navController.navigate( @@ -190,7 +190,7 @@ class MenuNavigationMiddlewareTest { MenuAction.Navigate.InstalledAddonDetails( addon = addon, ), - ).join() + ) verify { navController.navigate( @@ -203,7 +203,7 @@ class MenuNavigationMiddlewareTest { @Test fun `WHEN navigate to history action is dispatched THEN navigate to history`() = runTest { val store = createStore() - store.dispatch(MenuAction.Navigate.History).join() + store.dispatch(MenuAction.Navigate.History) verify { navController.navigate( @@ -216,7 +216,7 @@ class MenuNavigationMiddlewareTest { @Test fun `WHEN navigate to downloads action is dispatched THEN navigate to downloads`() = runTest { val store = createStore() - store.dispatch(MenuAction.Navigate.Downloads).join() + store.dispatch(MenuAction.Navigate.Downloads) verify { navController.navigate( @@ -229,7 +229,7 @@ class MenuNavigationMiddlewareTest { @Test fun `WHEN navigate to passwords action is dispatched THEN navigate to passwords`() = runTest { val store = createStore() - store.dispatch(MenuAction.Navigate.Passwords).join() + store.dispatch(MenuAction.Navigate.Passwords) verify { navController.navigate( @@ -248,7 +248,7 @@ class MenuNavigationMiddlewareTest { }, ) - store.dispatch(MenuAction.Navigate.ReleaseNotes).join() + store.dispatch(MenuAction.Navigate.ReleaseNotes) assertEquals(SupportUtils.WHATS_NEW_URL, params?.url) } @@ -268,7 +268,7 @@ class MenuNavigationMiddlewareTest { every { webAppUseCases.isInstallable() } returns true - store.dispatch(MenuAction.Navigate.AddToHomeScreen).join() + store.dispatch(MenuAction.Navigate.AddToHomeScreen) coVerify(exactly = 1) { webAppUseCases.addToHomescreen() } assertTrue(dismissWasCalled) @@ -287,7 +287,7 @@ class MenuNavigationMiddlewareTest { every { webAppUseCases.isInstallable() } returns false - store.dispatch(MenuAction.Navigate.AddToHomeScreen).join() + store.dispatch(MenuAction.Navigate.AddToHomeScreen) verify { navController.navigate( @@ -312,7 +312,7 @@ class MenuNavigationMiddlewareTest { val directionsSlot = slot<NavDirections>() val optionsSlot = slot<NavOptions>() - store.dispatch(MenuAction.Navigate.SaveToCollection(hasCollection = true)).join() + store.dispatch(MenuAction.Navigate.SaveToCollection(hasCollection = true)) verify { navController.navigate( @@ -351,7 +351,7 @@ class MenuNavigationMiddlewareTest { val directionsSlot = slot<NavDirections>() val optionsSlot = slot<NavOptions>() - store.dispatch(MenuAction.Navigate.SaveToCollection(hasCollection = false)).join() + store.dispatch(MenuAction.Navigate.SaveToCollection(hasCollection = false)) verify { navController.navigate( @@ -402,7 +402,7 @@ class MenuNavigationMiddlewareTest { ), ) - store.dispatch(MenuAction.Navigate.EditBookmark).join() + store.dispatch(MenuAction.Navigate.EditBookmark) verify { navController.navigate( @@ -426,7 +426,7 @@ class MenuNavigationMiddlewareTest { ), ) - store.dispatch(MenuAction.Navigate.Translate).join() + store.dispatch(MenuAction.Navigate.Translate) verify { navController.navigate( @@ -458,7 +458,7 @@ class MenuNavigationMiddlewareTest { val directionsSlot = slot<NavDirections>() val optionsSlot = slot<NavOptions>() - store.dispatch(MenuAction.Navigate.Share).join() + store.dispatch(MenuAction.Navigate.Share) verify { navController.navigate( @@ -502,7 +502,7 @@ class MenuNavigationMiddlewareTest { val directionsSlot = slot<NavDirections>() val optionsSlot = slot<NavOptions>() - store.dispatch(MenuAction.Navigate.Share).join() + store.dispatch(MenuAction.Navigate.Share) verify { navController.navigate( @@ -546,7 +546,7 @@ class MenuNavigationMiddlewareTest { ), ) - store.dispatch(MenuAction.Navigate.Share).join() + store.dispatch(MenuAction.Navigate.Share) verify { browserStore.dispatch( @@ -576,7 +576,7 @@ class MenuNavigationMiddlewareTest { val directionsSlot = slot<NavDirections>() val optionsSlot = slot<NavOptions>() - store.dispatch(MenuAction.Navigate.Share).join() + store.dispatch(MenuAction.Navigate.Share) verify { navController.navigate( @@ -604,7 +604,7 @@ class MenuNavigationMiddlewareTest { @Test fun `WHEN navigate to manage extensions action is dispatched THEN navigate to the extensions management`() = runTest { val store = createStore() - store.dispatch(MenuAction.Navigate.ManageExtensions).join() + store.dispatch(MenuAction.Navigate.ManageExtensions) verify { navController.navigate( @@ -623,7 +623,7 @@ class MenuNavigationMiddlewareTest { }, ) - store.dispatch(MenuAction.Navigate.DiscoverMoreExtensions).join() + store.dispatch(MenuAction.Navigate.DiscoverMoreExtensions) assertEquals(AMO_HOMEPAGE_FOR_ANDROID, params?.url) } @@ -637,7 +637,7 @@ class MenuNavigationMiddlewareTest { }, ) - store.dispatch(MenuAction.Navigate.ExtensionsLearnMore).join() + store.dispatch(MenuAction.Navigate.ExtensionsLearnMore) assertEquals(SumoTopic.FIND_INSTALL_ADDONS, params?.sumoTopic) } @@ -646,7 +646,7 @@ class MenuNavigationMiddlewareTest { fun `WHEN navigate to addon details is dispatched THEN navigate to the addon details`() = runTest { val addon = Addon(id = "ext1") val store = createStore() - store.dispatch(MenuAction.Navigate.AddonDetails(addon = addon)).join() + store.dispatch(MenuAction.Navigate.AddonDetails(addon = addon)) verify { navController.navigate( @@ -668,7 +668,7 @@ class MenuNavigationMiddlewareTest { ), ), ), - ).dispatch(MenuAction.Navigate.WebCompatReporter).join() + ).dispatch(MenuAction.Navigate.WebCompatReporter) verify { navController.navigate( @@ -708,7 +708,7 @@ class MenuNavigationMiddlewareTest { }, ) - store.dispatch(MenuAction.Navigate.WebCompatReporter).join() + store.dispatch(MenuAction.Navigate.WebCompatReporter) assertTrue(sendMoreWebCompatInfoCalled) @@ -741,7 +741,7 @@ class MenuNavigationMiddlewareTest { ), ) - store.dispatch(MenuAction.Navigate.Back(viewHistory = true)).join() + store.dispatch(MenuAction.Navigate.Back(viewHistory = true)) verify { navController.navigate( @@ -769,7 +769,7 @@ class MenuNavigationMiddlewareTest { onDismiss = { dismissWasCalled = true }, ) - store.dispatch(MenuAction.Navigate.Back(viewHistory = false)).join() + store.dispatch(MenuAction.Navigate.Back(viewHistory = false)) verify { sessionUseCases.goBack.invoke(tab.id) @@ -786,7 +786,7 @@ class MenuNavigationMiddlewareTest { onDismiss = { dismissWasCalled = true }, ) - store.dispatch(MenuAction.Navigate.Back(viewHistory = false)).join() + store.dispatch(MenuAction.Navigate.Back(viewHistory = false)) verify { sessionUseCases.goBack.invoke(customTab.id) @@ -802,7 +802,7 @@ class MenuNavigationMiddlewareTest { ), ) - store.dispatch(MenuAction.Navigate.Forward(viewHistory = true)).join() + store.dispatch(MenuAction.Navigate.Forward(viewHistory = true)) verify { navController.navigate( @@ -830,7 +830,7 @@ class MenuNavigationMiddlewareTest { onDismiss = { dismissWasCalled = true }, ) - store.dispatch(MenuAction.Navigate.Forward(viewHistory = false)).join() + store.dispatch(MenuAction.Navigate.Forward(viewHistory = false)) verify { sessionUseCases.goForward.invoke(tab.id) @@ -847,7 +847,7 @@ class MenuNavigationMiddlewareTest { onDismiss = { dismissWasCalled = true }, ) - store.dispatch(MenuAction.Navigate.Forward(viewHistory = false)).join() + store.dispatch(MenuAction.Navigate.Forward(viewHistory = false)) verify { sessionUseCases.goForward.invoke(customTab.id) @@ -869,7 +869,7 @@ class MenuNavigationMiddlewareTest { onDismiss = { dismissWasCalled = true }, ) - store.dispatch(MenuAction.Navigate.Reload(bypassCache = true)).join() + store.dispatch(MenuAction.Navigate.Reload(bypassCache = true)) verify { sessionUseCases.reload.invoke( @@ -894,7 +894,7 @@ class MenuNavigationMiddlewareTest { onDismiss = { dismissWasCalled = true }, ) - store.dispatch(MenuAction.Navigate.Reload(bypassCache = false)).join() + store.dispatch(MenuAction.Navigate.Reload(bypassCache = false)) verify { sessionUseCases.reload.invoke( @@ -914,7 +914,7 @@ class MenuNavigationMiddlewareTest { onDismiss = { dismissWasCalled = true }, ) - store.dispatch(MenuAction.Navigate.Reload(bypassCache = false)).join() + store.dispatch(MenuAction.Navigate.Reload(bypassCache = false)) verify { sessionUseCases.reload.invoke( @@ -939,7 +939,7 @@ class MenuNavigationMiddlewareTest { onDismiss = { dismissWasCalled = true }, ) - store.dispatch(MenuAction.Navigate.Stop).join() + store.dispatch(MenuAction.Navigate.Stop) verify { sessionUseCases.stopLoading.invoke(tab.id) @@ -956,7 +956,7 @@ class MenuNavigationMiddlewareTest { onDismiss = { dismissWasCalled = true }, ) - store.dispatch(MenuAction.Navigate.Stop).join() + store.dispatch(MenuAction.Navigate.Stop) verify { sessionUseCases.stopLoading.invoke(customTab.id) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/menu/MenuStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/menu/MenuStoreTest.kt @@ -185,7 +185,7 @@ class MenuStoreTest { ) val store = MenuStore(initialState = initialState) - store.dispatch(MenuAction.AddBookmark).join() + store.dispatch(MenuAction.AddBookmark) assertEquals(initialState, store.state) } @@ -213,7 +213,7 @@ class MenuStoreTest { guid = "id1", isBookmarked = true, ) - store.dispatch(MenuAction.UpdateBookmarkState(bookmarkState = newBookmarkState)).join() + store.dispatch(MenuAction.UpdateBookmarkState(bookmarkState = newBookmarkState)) assertEquals(newBookmarkState, store.state.browserMenuState!!.bookmarkState) } @@ -233,7 +233,7 @@ class MenuStoreTest { ) val store = MenuStore(initialState = initialState) - store.dispatch(MenuAction.AddShortcut).join() + store.dispatch(MenuAction.AddShortcut) assertEquals(initialState, store.state) } @@ -253,7 +253,7 @@ class MenuStoreTest { ) val store = MenuStore(initialState = initialState) - store.dispatch(MenuAction.RemoveShortcut).join() + store.dispatch(MenuAction.RemoveShortcut) assertEquals(initialState, store.state) } @@ -276,7 +276,7 @@ class MenuStoreTest { assertNotNull(store.state.browserMenuState) assertFalse(store.state.browserMenuState!!.isPinned) - store.dispatch(MenuAction.UpdatePinnedState(isPinned = true)).join() + store.dispatch(MenuAction.UpdatePinnedState(isPinned = true)) assertTrue(store.state.browserMenuState!!.isPinned) } @@ -287,7 +287,7 @@ class MenuStoreTest { assertEquals(0, store.state.extensionMenuState.recommendedAddons.size) - store.dispatch(MenuAction.UpdateExtensionState(recommendedAddons = listOf(addon))).join() + store.dispatch(MenuAction.UpdateExtensionState(recommendedAddons = listOf(addon))) assertEquals(1, store.state.extensionMenuState.recommendedAddons.size) assertEquals(addon, store.state.extensionMenuState.recommendedAddons.first()) @@ -298,7 +298,7 @@ class MenuStoreTest { val initialState = MenuState() val store = MenuStore(initialState = initialState) - store.dispatch(MenuAction.FindInPage).join() + store.dispatch(MenuAction.FindInPage) assertEquals(initialState, store.state) } @@ -308,7 +308,7 @@ class MenuStoreTest { val initialState = MenuState() val store = MenuStore(initialState = initialState) - store.dispatch(MenuAction.RequestDesktopSite).join() + store.dispatch(MenuAction.RequestDesktopSite) assertTrue(store.state.isDesktopMode) } @@ -318,7 +318,7 @@ class MenuStoreTest { val initialState = MenuState(isDesktopMode = true) val store = MenuStore(initialState = initialState) - store.dispatch(MenuAction.RequestMobileSite).join() + store.dispatch(MenuAction.RequestMobileSite) assertFalse(store.state.isDesktopMode) } @@ -329,7 +329,7 @@ class MenuStoreTest { val addon = Addon(id = "ext1") val store = MenuStore(initialState = MenuState()) - store.dispatch(MenuAction.UpdateInstallAddonInProgress(addon)).join() + store.dispatch(MenuAction.UpdateInstallAddonInProgress(addon)) assertEquals(addon, store.state.extensionMenuState.addonInstallationInProgress) } @@ -350,7 +350,7 @@ class MenuStoreTest { ), ) - store.dispatch(MenuAction.InstallAddonSuccess(addon)).join() + store.dispatch(MenuAction.InstallAddonSuccess(addon)) assertEquals(null, store.state.extensionMenuState.addonInstallationInProgress) assertEquals(1, store.state.extensionMenuState.recommendedAddons.size) @@ -373,7 +373,7 @@ class MenuStoreTest { ), ) - store.dispatch(MenuAction.InstallAddonFailed(addon)).join() + store.dispatch(MenuAction.InstallAddonFailed(addon)) assertEquals(null, store.state.extensionMenuState.addonInstallationInProgress) assertEquals(2, store.state.extensionMenuState.recommendedAddons.size) @@ -397,7 +397,7 @@ class MenuStoreTest { }, ), ) - store.dispatch(MenuAction.UpdateWebExtensionBrowserMenuItems(webExtensionMenuItemList)).join() + store.dispatch(MenuAction.UpdateWebExtensionBrowserMenuItems(webExtensionMenuItemList)) assertEquals( store.state.extensionMenuState.browserWebExtensionMenuItem, @@ -411,7 +411,7 @@ class MenuStoreTest { val initialState = MenuState() val store = MenuStore(initialState = initialState) - store.dispatch(MenuAction.UpdateShowExtensionsOnboarding(true)).join() + store.dispatch(MenuAction.UpdateShowExtensionsOnboarding(true)) assertTrue(store.state.extensionMenuState.showExtensionsOnboarding) } @@ -432,7 +432,7 @@ class MenuStoreTest { ), ) - store.dispatch(MenuAction.UpdateManageExtensionsMenuItemVisibility(true)).join() + store.dispatch(MenuAction.UpdateManageExtensionsMenuItemVisibility(true)) assertTrue(store.state.extensionMenuState.shouldShowManageExtensionsMenuItem) } @@ -443,7 +443,7 @@ class MenuStoreTest { val initialState = MenuState() val store = MenuStore(initialState = initialState) - store.dispatch(MenuAction.UpdateShowDisabledExtensionsOnboarding(true)).join() + store.dispatch(MenuAction.UpdateShowDisabledExtensionsOnboarding(true)) assertTrue(store.state.extensionMenuState.showDisabledExtensionsOnboarding) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/menu/MenuTelemetryMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/menu/MenuTelemetryMiddlewareTest.kt @@ -43,7 +43,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.AddBookmark).joinBlocking() + store.dispatch(MenuAction.AddBookmark) assertTelemetryRecorded(Events.browserMenuAction, item = "add_bookmark") } @@ -53,7 +53,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.EditBookmark).joinBlocking() + store.dispatch(MenuAction.Navigate.EditBookmark) assertTelemetryRecorded(Events.browserMenuAction, item = "edit_bookmark") } @@ -63,7 +63,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Bookmarks).joinBlocking() + store.dispatch(MenuAction.Navigate.Bookmarks) assertTelemetryRecorded(Events.browserMenuAction, item = "bookmarks") } @@ -73,7 +73,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.AddShortcut).joinBlocking() + store.dispatch(MenuAction.AddShortcut) assertTelemetryRecorded(Events.browserMenuAction, item = "add_to_top_sites") } @@ -83,7 +83,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.OpenInRegularTab).joinBlocking() + store.dispatch(MenuAction.OpenInRegularTab) assertTelemetryRecorded(Events.browserMenuAction, item = "open_in_regular_tab") } @@ -93,7 +93,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.RemoveShortcut).joinBlocking() + store.dispatch(MenuAction.RemoveShortcut) assertTelemetryRecorded(Events.browserMenuAction, item = "remove_from_top_sites") } @@ -102,7 +102,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.AddToHomeScreen).joinBlocking() + store.dispatch(MenuAction.Navigate.AddToHomeScreen) assertTelemetryRecorded(Events.browserMenuAction, item = "add_to_homescreen") } @@ -112,7 +112,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Downloads).joinBlocking() + store.dispatch(MenuAction.Navigate.Downloads) assertTelemetryRecorded(Events.browserMenuAction, item = "downloads") } @@ -122,7 +122,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.History).joinBlocking() + store.dispatch(MenuAction.Navigate.History) assertTelemetryRecorded(Events.browserMenuAction, item = "history") } @@ -132,7 +132,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.ManageExtensions).joinBlocking() + store.dispatch(MenuAction.Navigate.ManageExtensions) assertTelemetryRecorded(Events.browserMenuAction, item = "addons_manager") } @@ -147,7 +147,7 @@ class MenuTelemetryMiddlewareTest { accountState = AccountState.NotAuthenticated, accesspoint = MenuAccessPoint.Browser, ), - ).joinBlocking() + ) assertTelemetryRecorded(Events.browserMenuAction, item = "sync_account") assertTelemetryRecorded(AppMenu.signIntoSync) @@ -158,7 +158,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.OpenInApp).joinBlocking() + store.dispatch(MenuAction.OpenInApp) assertTelemetryRecorded(Events.browserMenuAction, item = "open_in_app") } @@ -168,7 +168,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Passwords).joinBlocking() + store.dispatch(MenuAction.Navigate.Passwords) assertTelemetryRecorded(Events.browserMenuAction, item = "passwords") } @@ -178,7 +178,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.whatsNewTapped.testGetValue()) - store.dispatch(MenuAction.Navigate.ReleaseNotes).joinBlocking() + store.dispatch(MenuAction.Navigate.ReleaseNotes) assertNotNull(Events.whatsNewTapped.testGetValue()) val snapshot = Events.whatsNewTapped.testGetValue()!! @@ -192,7 +192,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.SaveToCollection(hasCollection = true)).joinBlocking() + store.dispatch(MenuAction.Navigate.SaveToCollection(hasCollection = true)) assertTelemetryRecorded(Events.browserMenuAction, item = "save_to_collection") } @@ -202,7 +202,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Back(viewHistory = false)).joinBlocking() + store.dispatch(MenuAction.Navigate.Back(viewHistory = false)) assertTelemetryRecorded(Events.browserMenuAction, item = "back") } @@ -212,7 +212,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Back(viewHistory = true)).joinBlocking() + store.dispatch(MenuAction.Navigate.Back(viewHistory = true)) assertTelemetryRecorded(Events.browserMenuAction, item = "back_long_press") } @@ -222,7 +222,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore(accessPoint = MenuAccessPoint.External) assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Back(viewHistory = false)).joinBlocking() + store.dispatch(MenuAction.Navigate.Back(viewHistory = false)) assertTelemetryRecorded(Events.browserMenuAction, item = "custom_back") } @@ -232,7 +232,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore(accessPoint = MenuAccessPoint.External) assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Back(viewHistory = true)).joinBlocking() + store.dispatch(MenuAction.Navigate.Back(viewHistory = true)) assertTelemetryRecorded(Events.browserMenuAction, item = "custom_back_long_press") } @@ -242,7 +242,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Forward(viewHistory = false)).joinBlocking() + store.dispatch(MenuAction.Navigate.Forward(viewHistory = false)) assertTelemetryRecorded(Events.browserMenuAction, item = "forward") } @@ -252,7 +252,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Forward(viewHistory = true)).joinBlocking() + store.dispatch(MenuAction.Navigate.Forward(viewHistory = true)) assertTelemetryRecorded(Events.browserMenuAction, item = "forward_long_press") } @@ -262,7 +262,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore(accessPoint = MenuAccessPoint.External) assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Forward(viewHistory = false)).joinBlocking() + store.dispatch(MenuAction.Navigate.Forward(viewHistory = false)) assertTelemetryRecorded(Events.browserMenuAction, item = "custom_forward") } @@ -272,7 +272,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore(accessPoint = MenuAccessPoint.External) assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Forward(viewHistory = true)).joinBlocking() + store.dispatch(MenuAction.Navigate.Forward(viewHistory = true)) assertTelemetryRecorded(Events.browserMenuAction, item = "custom_forward_long_press") } @@ -282,7 +282,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Reload(bypassCache = false)).joinBlocking() + store.dispatch(MenuAction.Navigate.Reload(bypassCache = false)) assertTelemetryRecorded(Events.browserMenuAction, item = "reload") } @@ -292,7 +292,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Stop).joinBlocking() + store.dispatch(MenuAction.Navigate.Stop) assertTelemetryRecorded(Events.browserMenuAction, item = "stop") } @@ -302,7 +302,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Share).joinBlocking() + store.dispatch(MenuAction.Navigate.Share) assertTelemetryRecorded(Events.browserMenuAction, item = "share") } @@ -312,7 +312,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore(accessPoint = MenuAccessPoint.External) assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.Share).joinBlocking() + store.dispatch(MenuAction.Navigate.Share) assertTelemetryRecorded(Events.browserMenuAction, item = "custom_share") } @@ -323,7 +323,7 @@ class MenuTelemetryMiddlewareTest { assertNull(Events.browserMenuAction.testGetValue()) assertNull(HomeMenu.settingsItemClicked.testGetValue()) - store.dispatch(MenuAction.Navigate.Settings).joinBlocking() + store.dispatch(MenuAction.Navigate.Settings) assertTelemetryRecorded(Events.browserMenuAction, item = "settings") assertNull(HomeMenu.settingsItemClicked.testGetValue()) @@ -335,7 +335,7 @@ class MenuTelemetryMiddlewareTest { assertNull(Events.browserMenuAction.testGetValue()) assertNull(HomeMenu.settingsItemClicked.testGetValue()) - store.dispatch(MenuAction.Navigate.Settings).joinBlocking() + store.dispatch(MenuAction.Navigate.Settings) assertTelemetryRecorded(HomeMenu.settingsItemClicked) assertNull(Events.browserMenuAction.testGetValue()) @@ -347,7 +347,7 @@ class MenuTelemetryMiddlewareTest { assertNull(Events.browserMenuAction.testGetValue()) assertNull(Translations.action.testGetValue()) - store.dispatch(MenuAction.Navigate.Translate).joinBlocking() + store.dispatch(MenuAction.Navigate.Translate) assertTelemetryRecorded(Events.browserMenuAction, item = "translate") @@ -361,7 +361,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.DeleteBrowsingDataAndQuit).joinBlocking() + store.dispatch(MenuAction.DeleteBrowsingDataAndQuit) assertTelemetryRecorded(Events.browserMenuAction, item = "quit") } @@ -371,7 +371,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.FindInPage).joinBlocking() + store.dispatch(MenuAction.FindInPage) assertTelemetryRecorded(Events.browserMenuAction, item = "find_in_page") } @@ -381,7 +381,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore(accessPoint = MenuAccessPoint.External) assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.FindInPage).joinBlocking() + store.dispatch(MenuAction.FindInPage) assertTelemetryRecorded(Events.browserMenuAction, item = "custom_find_in_page") } @@ -391,7 +391,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.MenuBanner).joinBlocking() + store.dispatch(MenuAction.MenuBanner) assertTelemetryRecorded(Events.browserMenuAction, item = "menu_banner") } @@ -401,7 +401,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.DismissMenuBanner).joinBlocking() + store.dispatch(MenuAction.DismissMenuBanner) assertTelemetryRecorded(Events.browserMenuAction, item = "dismiss_menu_banner") } @@ -411,7 +411,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(ReaderMode.appearance.testGetValue()) - store.dispatch(MenuAction.CustomizeReaderView).joinBlocking() + store.dispatch(MenuAction.CustomizeReaderView) assertTelemetryRecorded(ReaderMode.appearance) } @@ -439,7 +439,7 @@ class MenuTelemetryMiddlewareTest { assertNull(ReaderMode.opened.testGetValue()) - store.dispatch(MenuAction.ToggleReaderView).joinBlocking() + store.dispatch(MenuAction.ToggleReaderView) assertTelemetryRecorded(ReaderMode.opened) } @@ -467,7 +467,7 @@ class MenuTelemetryMiddlewareTest { assertNull(ReaderMode.closed.testGetValue()) - store.dispatch(MenuAction.ToggleReaderView).joinBlocking() + store.dispatch(MenuAction.ToggleReaderView) assertTelemetryRecorded(ReaderMode.closed) } @@ -477,7 +477,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.RequestDesktopSite).joinBlocking() + store.dispatch(MenuAction.RequestDesktopSite) assertTelemetryRecorded(Events.browserMenuAction, item = "desktop_view_on") } @@ -487,7 +487,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore(accessPoint = MenuAccessPoint.External) assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.RequestDesktopSite).joinBlocking() + store.dispatch(MenuAction.RequestDesktopSite) assertTelemetryRecorded(Events.browserMenuAction, item = "custom_desktop_view_on") } @@ -497,7 +497,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.RequestMobileSite).joinBlocking() + store.dispatch(MenuAction.RequestMobileSite) assertTelemetryRecorded(Events.browserMenuAction, item = "desktop_view_off") } @@ -507,7 +507,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore(accessPoint = MenuAccessPoint.External) assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.RequestMobileSite).joinBlocking() + store.dispatch(MenuAction.RequestMobileSite) assertTelemetryRecorded(Events.browserMenuAction, item = "custom_desktop_view_off") } @@ -516,7 +516,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.OpenInFirefox).joinBlocking() + store.dispatch(MenuAction.OpenInFirefox) assertTelemetryRecorded(Events.browserMenuAction, item = "open_in_fenix") } @@ -526,7 +526,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.DiscoverMoreExtensions).joinBlocking() + store.dispatch(MenuAction.Navigate.DiscoverMoreExtensions) assertTelemetryRecorded(Events.browserMenuAction, item = "discover_more_extensions") } @@ -536,7 +536,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.ExtensionsLearnMore).joinBlocking() + store.dispatch(MenuAction.Navigate.ExtensionsLearnMore) assertTelemetryRecorded(Events.browserMenuAction, item = "extensions_learn_more") } @@ -546,7 +546,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.AddonDetails(Addon(""))).joinBlocking() + store.dispatch(MenuAction.Navigate.AddonDetails(Addon(""))) assertTelemetryRecorded(Events.browserMenuAction, item = "addon_details") } @@ -556,7 +556,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.InstallAddon(Addon(""))).joinBlocking() + store.dispatch(MenuAction.InstallAddon(Addon(""))) assertTelemetryRecorded(Events.browserMenuAction, item = "install_addon") } @@ -566,7 +566,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.InstalledAddonDetails(Addon(""))).joinBlocking() + store.dispatch(MenuAction.Navigate.InstalledAddonDetails(Addon(""))) assertTelemetryRecorded(Events.browserMenuAction, item = "installed_addon_details") } @@ -576,7 +576,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Menu.showCfr.testGetValue()) - store.dispatch(MenuAction.OnCFRShown).joinBlocking() + store.dispatch(MenuAction.OnCFRShown) assertTelemetryRecorded(Menu.showCfr) } @@ -586,7 +586,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Menu.dismissCfr.testGetValue()) - store.dispatch(MenuAction.OnCFRDismiss).joinBlocking() + store.dispatch(MenuAction.OnCFRDismiss) assertTelemetryRecorded(Menu.dismissCfr) } @@ -596,7 +596,7 @@ class MenuTelemetryMiddlewareTest { val store = createStore() assertNull(Events.browserMenuAction.testGetValue()) - store.dispatch(MenuAction.Navigate.WebCompatReporter).joinBlocking() + store.dispatch(MenuAction.Navigate.WebCompatReporter) assertTelemetryRecorded(Events.browserMenuAction, item = "report_broken_site") } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/metrics/FxAccountsPingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/metrics/FxAccountsPingTest.kt @@ -9,7 +9,6 @@ import mozilla.components.service.fxa.store.Account import mozilla.components.service.fxa.store.SyncAction import mozilla.components.service.fxa.store.SyncStatus import mozilla.components.service.fxa.store.SyncStore -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import mozilla.telemetry.glean.private.JobTimeoutException import org.junit.Assert.assertEquals @@ -58,7 +57,7 @@ internal class FxAccountsPingTest { SyncAction.UpdateAccount( account = mockAccount, ), - ).joinBlocking() + ) job.join() assertEquals("123", syncStore.state.account?.uid) @@ -74,7 +73,7 @@ internal class FxAccountsPingTest { SyncAction.UpdateAccount( account = mockAccount, ), - ).joinBlocking() + ) assertEquals(syncStore.state.account?.uid, "123") val job = fxAccounts.testBeforeNextSubmit { validatorRun = true @@ -83,7 +82,7 @@ internal class FxAccountsPingTest { SyncAction.UpdateAccount( account = mockAccount.copy(uid = null), ), - ).joinBlocking() + ) try { job.join() @@ -103,7 +102,7 @@ internal class FxAccountsPingTest { SyncAction.UpdateAccount( account = mockAccount, ), - ).joinBlocking() + ) assertEquals("123", syncStore.state.account?.uid) val job = fxAccounts.testBeforeNextSubmit { validatorRun = true @@ -113,7 +112,7 @@ internal class FxAccountsPingTest { SyncAction.UpdateAccount( account = mockAccount.copy(email = "newEmail@email.com"), ), - ).joinBlocking() + ) try { job.join() diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserToolbarCFRPresenterTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserToolbarCFRPresenterTest.kt @@ -22,14 +22,12 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.browser.toolbar.BrowserToolbar import mozilla.components.concept.engine.EngineSession -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertNotNull import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith -import org.mozilla.fenix.R import org.mozilla.fenix.ext.isLargeWindow import org.mozilla.fenix.helpers.FenixGleanTestRule import org.mozilla.fenix.utils.Settings @@ -67,7 +65,7 @@ class BrowserToolbarCFRPresenterTest { privateTab.id, EngineSession.CookieBannerHandlingStatus.HANDLED, ), - ).joinBlocking() + ) verify { presenter.showCookieBannersCFR() } verify { settings.shouldShowCookieBannersCFR = false } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMiddlewareTest.kt @@ -90,7 +90,6 @@ import mozilla.components.feature.tabs.TabsUseCases import mozilla.components.lib.publicsuffixlist.PublicSuffixList import mozilla.components.lib.state.Middleware import mozilla.components.support.ktx.util.URLStringUtils -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext @@ -364,7 +363,6 @@ class BrowserToolbarMiddlewareTest { assertEqualsOrigin(pageOrigin, toolbarStore.state.displayState.pageOrigin) browserStore.dispatch(UpdateUrlAction(sessionId = tab.id, url = ABOUT_HOME_URL)) - .joinBlocking() mainLooperRule.idle() assertEqualsOrigin( @@ -393,7 +391,7 @@ class BrowserToolbarMiddlewareTest { screenWidthDp = 700 } - appStore.dispatch(AppAction.OrientationChange(Landscape)).joinBlocking() + appStore.dispatch(AppAction.OrientationChange(Landscape)) mainLooperRule.idle() toolbarBrowserActions = toolbarStore.state.displayState.browserActionsEnd @@ -431,7 +429,7 @@ class BrowserToolbarMiddlewareTest { screenWidthDp = 700 } - appStore.dispatch(AppAction.OrientationChange(Portrait)).joinBlocking() + appStore.dispatch(AppAction.OrientationChange(Portrait)) mainLooperRule.idle() toolbarBrowserActions = toolbarStore.state.displayState.browserActionsEnd @@ -456,9 +454,8 @@ class BrowserToolbarMiddlewareTest { val newNormalTab = createTab("test.com", private = false) val newPrivateTab = createTab("test.com", private = true) - browserStore.dispatch(AddTabAction(newNormalTab)).joinBlocking() - browserStore.dispatch(AddTabAction(newPrivateTab)).joinBlocking() - + browserStore.dispatch(AddTabAction(newNormalTab)) + browserStore.dispatch(AddTabAction(newPrivateTab)) mainLooperRule.idle() toolbarBrowserActions = toolbarStore.state.displayState.browserActionsEnd @@ -488,7 +485,7 @@ class BrowserToolbarMiddlewareTest { var tabCounterButton = toolbarBrowserActions[1] as TabCounterAction assertEqualsTabCounterButton(expectedTabCounterButton(1, true), tabCounterButton) - browserStore.dispatch(RemoveTabAction(initialPrivateTab.id)).joinBlocking() + browserStore.dispatch(RemoveTabAction(initialPrivateTab.id)) mainLooperRule.idle() toolbarBrowserActions = toolbarStore.state.displayState.browserActionsEnd @@ -886,7 +883,7 @@ class BrowserToolbarMiddlewareTest { every { appStore.state.searchState.selectedSearchEngine?.searchEngine } returns searchEngine - toolbarStore.dispatch(LoadFromClipboardClicked).joinBlocking() + toolbarStore.dispatch(LoadFromClipboardClicked) verify { browserUseCases.loadUrlOrSearch( @@ -1174,7 +1171,7 @@ class BrowserToolbarMiddlewareTest { it.dispatch(BrowserToolbarAction.Init()) } - browserStore.dispatch(UpdateProgressAction(currentTab.id, 50)).joinBlocking() + browserStore.dispatch(UpdateProgressAction(currentTab.id, 50)) mainLooperRule.idle() assertEquals( @@ -1204,7 +1201,7 @@ class BrowserToolbarMiddlewareTest { it.dispatch(BrowserToolbarAction.Init()) } - browserStore.dispatch(UpdateProgressAction(currentTab.id, 71)).joinBlocking() + browserStore.dispatch(UpdateProgressAction(currentTab.id, 71)) mainLooperRule.idle() assertEquals( @@ -1587,7 +1584,7 @@ class BrowserToolbarMiddlewareTest { screenWidthDp = 500 } every { mockContext.resources.configuration } returns configuration - appStore.dispatch(AppAction.OrientationChange(Portrait)).joinBlocking() + appStore.dispatch(AppAction.OrientationChange(Portrait)) mainLooperRule.idle() navigationActions = toolbarStore.state.displayState.navigationActions @@ -1964,7 +1961,7 @@ class BrowserToolbarMiddlewareTest { verify { reloadUseCases(currentTab.id, capture(loadUrlFlagsUsed)) } assertEquals(LoadUrlFlags.BYPASS_CACHE, loadUrlFlagsUsed.last().value) - browserStore.dispatch(UpdateLoadingStateAction(currentTab.id, true)).joinBlocking() + browserStore.dispatch(UpdateLoadingStateAction(currentTab.id, true)) mainLooperRule.idle() pageLoadButton = toolbarStore.state.displayState.browserActionsStart.last() as ActionButtonRes assertEquals(expectedStopButton, pageLoadButton) @@ -1972,7 +1969,7 @@ class BrowserToolbarMiddlewareTest { mainLooperRule.idle() verify { stopUseCases(currentTab.id) } - browserStore.dispatch(UpdateLoadingStateAction(currentTab.id, false)).joinBlocking() + browserStore.dispatch(UpdateLoadingStateAction(currentTab.id, false)) mainLooperRule.idle() pageLoadButton = toolbarStore.state.displayState.browserActionsStart.last() as ActionButtonRes assertEquals(expectedRefreshButton, pageLoadButton) @@ -2098,7 +2095,6 @@ class BrowserToolbarMiddlewareTest { assertEquals(expectedInsecureIndicator, securityIndicator) browserStore.dispatch(UpdateSecurityInfoAction(tab.id, SecurityInfoState(true))) - .joinBlocking() mainLooperRule.idle() toolbarPageActions = toolbarStore.state.displayState.pageActionsStart assertEquals(1, toolbarPageActions.size) @@ -2177,14 +2173,12 @@ class BrowserToolbarMiddlewareTest { it.dispatch(BrowserToolbarAction.Init()) } browserStore.dispatch(UpdateSecurityInfoAction(tab.id, SecurityInfoState(true))) - .joinBlocking() mainLooperRule.idle() val toolbarPageActions = toolbarStore.state.displayState.pageActionsStart assertEquals(1, toolbarPageActions.size) val securityIndicator = toolbarPageActions[0] as ActionButtonRes assertEquals(expectedSecureIndicator, securityIndicator) browserStore.dispatch(TrackingProtectionAction.ToggleAction(tabId = tabId, enabled = false)) - .joinBlocking() mainLooperRule.idle() val toolbarPageActions2 = toolbarStore.state.displayState.pageActionsStart assertEquals(1, toolbarPageActions2.size) @@ -2227,14 +2221,14 @@ class BrowserToolbarMiddlewareTest { it.dispatch(BrowserToolbarAction.Init()) } browserStore.dispatch(UpdateSecurityInfoAction(tab.id, SecurityInfoState(true))) - .joinBlocking() + mainLooperRule.idle() val toolbarPageActions = toolbarStore.state.displayState.pageActionsStart assertEquals(1, toolbarPageActions.size) val securityIndicator = toolbarPageActions[0] as ActionButtonRes assertEquals(expectedInsecureIndicator, securityIndicator) browserStore.dispatch(TrackingProtectionAction.ToggleAction(tabId = tabId, enabled = true)) - .joinBlocking() + mainLooperRule.idle() val toolbarPageActions2 = toolbarStore.state.displayState.pageActionsStart assertEquals(1, toolbarPageActions2.size) @@ -2551,7 +2545,7 @@ class BrowserToolbarMiddlewareTest { ) val middleware = buildMiddleware(browserStore = browserStore) - val store = buildStore(middleware) + buildStore(middleware) val action = middleware.buildAction( toolbarAction = ToolbarAction.TabCounter, @@ -2674,7 +2668,7 @@ class BrowserToolbarMiddlewareTest { } every { mockContext.resources.configuration } returns configuration - appStore.dispatch(AppAction.OrientationChange(Landscape)).joinBlocking() + appStore.dispatch(AppAction.OrientationChange(Landscape)) mainLooperRule.idle() navigationActions = toolbarStore.state.displayState.navigationActions @@ -2727,7 +2721,7 @@ class BrowserToolbarMiddlewareTest { AppAction.MenuNotification.AddMenuNotification( SupportedMenuNotifications.Downloads, ), - ).joinBlocking() + ) mainLooperRule.idle() val updatedMenuButton = toolbarStore.state.displayState.browserActionsEnd[2] as ActionButtonRes assertEquals(expectedMenuButton(true), updatedMenuButton) @@ -2750,7 +2744,7 @@ class BrowserToolbarMiddlewareTest { AppAction.MenuNotification.RemoveMenuNotification( SupportedMenuNotifications.Downloads, ), - ).joinBlocking() + ) mainLooperRule.idle() val updatedMenuButton = toolbarStore.state.displayState.browserActionsEnd[2] as ActionButtonRes assertEquals(expectedMenuButton(), updatedMenuButton) @@ -2776,7 +2770,7 @@ class BrowserToolbarMiddlewareTest { tabId = currentTab.id, value = true, ), - ).joinBlocking() + ) mainLooperRule.idle() siteInfo = toolbarStore.state.displayState.pageActionsStart.first() as ActionButtonRes @@ -2849,7 +2843,7 @@ class BrowserToolbarMiddlewareTest { tabId = currentTab.id, excluded = true, ), - ).joinBlocking() + ) mainLooperRule.idle() siteInfo = toolbarStore.state.displayState.pageActionsStart.first() as ActionButtonRes @@ -2883,7 +2877,7 @@ class BrowserToolbarMiddlewareTest { tabId = currentTab.id, excluded = false, ), - ).joinBlocking() + ) mainLooperRule.idle() siteInfo = toolbarStore.state.displayState.pageActionsStart.first() as ActionButtonRes diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserToolbarTelemetryMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserToolbarTelemetryMiddlewareTest.kt @@ -7,7 +7,6 @@ package org.mozilla.fenix.components.toolbar import androidx.test.ext.junit.runners.AndroidJUnit4 import mozilla.components.compose.browser.toolbar.store.BrowserToolbarInteraction.BrowserToolbarEvent.Source import mozilla.components.compose.browser.toolbar.store.BrowserToolbarStore -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull @@ -41,109 +40,109 @@ class BrowserToolbarTelemetryMiddlewareTest { @Test fun `WHEN menu button is clicked THEN record telemetry based on addressBar or navbar source`() { - buildStore.dispatch(MenuClicked(Source.AddressBar)).joinBlocking() + buildStore.dispatch(MenuClicked(Source.AddressBar)) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.MenuClicked.action) - buildStore.dispatch(MenuClicked(Source.NavigationBar)).joinBlocking() + buildStore.dispatch(MenuClicked(Source.NavigationBar)) assertTelemetryRecorded(Source.NavigationBar, item = ToolbarActionRecord.MenuClicked.action) } @Test fun `WHEN tab counter is clicked THEN record telemetry based on addressBar or navbar source`() { - buildStore.dispatch(TabCounterClicked(Source.AddressBar)).joinBlocking() + buildStore.dispatch(TabCounterClicked(Source.AddressBar)) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.TabCounterClicked.action) - buildStore.dispatch(TabCounterClicked(Source.NavigationBar)).joinBlocking() + buildStore.dispatch(TabCounterClicked(Source.NavigationBar)) assertTelemetryRecorded(Source.NavigationBar, item = ToolbarActionRecord.TabCounterClicked.action) } @Test fun `WHEN tab counter is long clicked THEN record telemetry based on addressBar or navbar source`() { - buildStore.dispatch(TabCounterLongClicked(Source.AddressBar)).joinBlocking() + buildStore.dispatch(TabCounterLongClicked(Source.AddressBar)) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.TabCounterLongClicked.action) - buildStore.dispatch(TabCounterLongClicked(Source.NavigationBar)).joinBlocking() + buildStore.dispatch(TabCounterLongClicked(Source.NavigationBar)) assertTelemetryRecorded(Source.NavigationBar, item = ToolbarActionRecord.TabCounterLongClicked.action) } @Test fun `WHEN adding a new tab THEN record telemetry based on addressBar or navbar source`() { - buildStore.dispatch(AddNewTab(Source.AddressBar)).joinBlocking() + buildStore.dispatch(AddNewTab(Source.AddressBar)) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.AddNewTab.action) - buildStore.dispatch(AddNewTab(Source.NavigationBar)).joinBlocking() + buildStore.dispatch(AddNewTab(Source.NavigationBar)) assertTelemetryRecorded(Source.NavigationBar, item = ToolbarActionRecord.AddNewTab.action) } @Test fun `WHEN adding a new private tab THEN record telemetry based on addressBar or navbar source`() { - buildStore.dispatch(AddNewPrivateTab(Source.AddressBar)).joinBlocking() + buildStore.dispatch(AddNewPrivateTab(Source.AddressBar)) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.AddNewPrivateTab.action) - buildStore.dispatch(AddNewPrivateTab(Source.NavigationBar)).joinBlocking() + buildStore.dispatch(AddNewPrivateTab(Source.NavigationBar)) assertTelemetryRecorded(Source.NavigationBar, item = ToolbarActionRecord.AddNewPrivateTab.action) } @Test fun `WHEN navigating back THEN record addressBar telemetry`() { - buildStore.dispatch(NavigateBackClicked).joinBlocking() + buildStore.dispatch(NavigateBackClicked) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.NavigateBackClicked.action) } @Test fun `WHEN navigating back is long clicked THEN record addressBar telemetry`() { - buildStore.dispatch(NavigateBackLongClicked).joinBlocking() + buildStore.dispatch(NavigateBackLongClicked) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.NavigateBackLongClicked.action) } @Test fun `WHEN navigating forward THEN record addressBar telemetry`() { - buildStore.dispatch(NavigateForwardClicked).joinBlocking() + buildStore.dispatch(NavigateForwardClicked) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.NavigateForwardClicked.action) } @Test fun `WHEN navigating forward is long clicked THEN record addressBar telemetry`() { - buildStore.dispatch(NavigateForwardLongClicked).joinBlocking() + buildStore.dispatch(NavigateForwardLongClicked) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.NavigateForwardLongClicked.action) } @Test fun `WHEN refreshing the page THEN record addressBar telemetry`() { - buildStore.dispatch(RefreshClicked(bypassCache = false)).joinBlocking() + buildStore.dispatch(RefreshClicked(bypassCache = false)) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.RefreshClicked.action) } @Test fun `WHEN refreshing the page is stopped THEN record addressBar telemetry`() { - buildStore.dispatch(StopRefreshClicked).joinBlocking() + buildStore.dispatch(StopRefreshClicked) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.StopRefreshClicked.action) } @Test fun `WHEN adding a bookmark THEN record telemetry based on addressBar or navbar source`() { - buildStore.dispatch(AddBookmarkClicked(Source.AddressBar)).joinBlocking() + buildStore.dispatch(AddBookmarkClicked(Source.AddressBar)) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.AddBookmarkClicked.action) - buildStore.dispatch(AddBookmarkClicked(Source.NavigationBar)).joinBlocking() + buildStore.dispatch(AddBookmarkClicked(Source.NavigationBar)) assertTelemetryRecorded(Source.NavigationBar, item = ToolbarActionRecord.AddBookmarkClicked.action) } @Test fun `WHEN navigating to edit a bookmark THEN record telemetry based on addressBar or navbar source`() { - buildStore.dispatch(EditBookmarkClicked(Source.AddressBar)).joinBlocking() + buildStore.dispatch(EditBookmarkClicked(Source.AddressBar)) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.EditBookmarkClicked.action) - buildStore.dispatch(EditBookmarkClicked(Source.NavigationBar)).joinBlocking() + buildStore.dispatch(EditBookmarkClicked(Source.NavigationBar)) assertTelemetryRecorded(Source.NavigationBar, item = ToolbarActionRecord.EditBookmarkClicked.action) } @Test fun `WHEN sharing a page THEN record telemetry based on addressBar or navbar source`() { - buildStore.dispatch(ShareClicked(Source.AddressBar)).joinBlocking() + buildStore.dispatch(ShareClicked(Source.AddressBar)) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.ShareClicked.action) - buildStore.dispatch(ShareClicked(Source.NavigationBar)).joinBlocking() + buildStore.dispatch(ShareClicked(Source.NavigationBar)) assertTelemetryRecorded(Source.NavigationBar, item = ToolbarActionRecord.ShareClicked.action) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/CustomTabBrowserToolbarMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/CustomTabBrowserToolbarMiddlewareTest.kt @@ -46,7 +46,6 @@ import mozilla.components.feature.session.TrackingProtectionUseCases import mozilla.components.feature.tabs.CustomTabsUseCases import mozilla.components.lib.publicsuffixlist.PublicSuffixList import mozilla.components.support.ktx.kotlin.getRegistrableDomainIndexRange -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainLooperTestRule import mozilla.components.support.utils.ClipboardHandler @@ -338,7 +337,7 @@ class CustomTabBrowserToolbarMiddlewareTest { var securityIndicator = toolbarPageActions[0] assertEquals(expectedInsecureIndicator, securityIndicator) - browserStore.dispatch(UpdateSecurityInfoAction(customTabId, SecurityInfoState(true))).joinBlocking() + browserStore.dispatch(UpdateSecurityInfoAction(customTabId, SecurityInfoState(true))) mainLooperRule.idle() toolbarPageActions = toolbarStore.state.displayState.pageActionsStart assertEquals(1, toolbarPageActions.size) @@ -366,7 +365,7 @@ class CustomTabBrowserToolbarMiddlewareTest { onClick = SiteInfoClicked, ) val toolbarStore = buildStore(middleware) - browserStore.dispatch(UpdateSecurityInfoAction(customTabId, SecurityInfoState(true))).joinBlocking() + browserStore.dispatch(UpdateSecurityInfoAction(customTabId, SecurityInfoState(true))) mainLooperRule.idle() val toolbarPageActions = toolbarStore.state.displayState.pageActionsStart assertEquals(1, toolbarPageActions.size) @@ -399,14 +398,14 @@ class CustomTabBrowserToolbarMiddlewareTest { onClick = SiteInfoClicked, ) val toolbarStore = buildStore(middleware) - browserStore.dispatch(UpdateSecurityInfoAction(customTabId, SecurityInfoState(true))).joinBlocking() + browserStore.dispatch(UpdateSecurityInfoAction(customTabId, SecurityInfoState(true))) mainLooperRule.idle() var toolbarPageActions = toolbarStore.state.displayState.pageActionsStart assertEquals(1, toolbarPageActions.size) var securityIndicator = toolbarPageActions[0] assertEquals(expectedInsecureIndicator, securityIndicator) browserStore.dispatch(TrackingProtectionAction.ToggleAction(tabId = customTabId, enabled = true)) - .joinBlocking() + mainLooperRule.idle() toolbarPageActions = toolbarStore.state.displayState.pageActionsStart assertEquals(1, toolbarPageActions.size) @@ -439,14 +438,13 @@ class CustomTabBrowserToolbarMiddlewareTest { onClick = SiteInfoClicked, ) val toolbarStore = buildStore(middleware) - browserStore.dispatch(UpdateSecurityInfoAction(customTabId, SecurityInfoState(true))).joinBlocking() + browserStore.dispatch(UpdateSecurityInfoAction(customTabId, SecurityInfoState(true))) mainLooperRule.idle() var toolbarPageActions = toolbarStore.state.displayState.pageActionsStart assertEquals(1, toolbarPageActions.size) var securityIndicator = toolbarPageActions[0] assertEquals(expectedSecureIndicator, securityIndicator) browserStore.dispatch(TrackingProtectionAction.ToggleAction(tabId = customTabId, enabled = false)) - .joinBlocking() mainLooperRule.idle() toolbarPageActions = toolbarStore.state.displayState.pageActionsStart assertEquals(1, toolbarPageActions.size) @@ -514,7 +512,7 @@ class CustomTabBrowserToolbarMiddlewareTest { var pageOrigin = toolbarStore.state.displayState.pageOrigin assertPageOriginEquals(expectedDetails, pageOrigin) - browserStore.dispatch(UpdateTitleAction(customTabId, "UpdatedTitle")).joinBlocking() + browserStore.dispatch(UpdateTitleAction(customTabId, "UpdatedTitle")) mainLooperRule.idle() pageOrigin = toolbarStore.state.displayState.pageOrigin assertPageOriginEquals(expectedDetails.copy(title = "UpdatedTitle"), pageOrigin) @@ -540,7 +538,7 @@ class CustomTabBrowserToolbarMiddlewareTest { var pageOrigin = toolbarStore.state.displayState.pageOrigin assertPageOriginEquals(expectedDetails, pageOrigin) - browserStore.dispatch(UpdateUrlAction(customTabId, "UpdatedURL")).joinBlocking() + browserStore.dispatch(UpdateUrlAction(customTabId, "UpdatedURL")) mainLooperRule.idle() pageOrigin = toolbarStore.state.displayState.pageOrigin assertPageOriginEquals(expectedDetails.copy(url = "UpdatedURL"), pageOrigin) @@ -566,7 +564,7 @@ class CustomTabBrowserToolbarMiddlewareTest { var pageOrigin = toolbarStore.state.displayState.pageOrigin assertPageOriginEquals(expectedDetails, pageOrigin) - browserStore.dispatch(UpdateUrlAction(customTabId, "UpdatedURL")).joinBlocking() + browserStore.dispatch(UpdateUrlAction(customTabId, "UpdatedURL")) mainLooperRule.idle() pageOrigin = toolbarStore.state.displayState.pageOrigin assertPageOriginEquals( @@ -682,7 +680,7 @@ class CustomTabBrowserToolbarMiddlewareTest { val middleware = buildMiddleware(browserStore) val toolbarStore = buildStore(middleware) - browserStore.dispatch(UpdateProgressAction(customTabId, 50)).joinBlocking() + browserStore.dispatch(UpdateProgressAction(customTabId, 50)) mainLooperRule.idle() assertEquals( ProgressBarConfig( @@ -692,7 +690,7 @@ class CustomTabBrowserToolbarMiddlewareTest { toolbarStore.state.displayState.progressBarConfig, ) - browserStore.dispatch(UpdateProgressAction(customTabId, 80)).joinBlocking() + browserStore.dispatch(UpdateProgressAction(customTabId, 80)) mainLooperRule.idle() assertEquals( ProgressBarConfig( @@ -715,7 +713,7 @@ class CustomTabBrowserToolbarMiddlewareTest { val middleware = buildMiddleware(browserStore) val toolbarStore = buildStore(middleware) - browserStore.dispatch(UpdateProgressAction(customTabId, 22)).joinBlocking() + browserStore.dispatch(UpdateProgressAction(customTabId, 22)) mainLooperRule.idle() assertEquals( ProgressBarConfig( @@ -725,7 +723,7 @@ class CustomTabBrowserToolbarMiddlewareTest { toolbarStore.state.displayState.progressBarConfig, ) - browserStore.dispatch(UpdateProgressAction(customTabId, 67)).joinBlocking() + browserStore.dispatch(UpdateProgressAction(customTabId, 67)) mainLooperRule.idle() assertEquals( ProgressBarConfig( diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultBrowserToolbarControllerTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultBrowserToolbarControllerTest.kt @@ -29,8 +29,6 @@ import mozilla.components.feature.search.SearchUseCases import mozilla.components.feature.session.SessionUseCases import mozilla.components.feature.tabs.TabsUseCases import mozilla.components.feature.top.sites.TopSitesUseCases -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.robolectric.testContext import mozilla.components.ui.tabcounter.TabCounterMenu @@ -195,8 +193,6 @@ class DefaultBrowserToolbarControllerTest { searchUseCases.defaultSearch.invoke(pastedText, "1") } - store.waitUntilIdle() - captureMiddleware.assertFirstAction(ContentAction.UpdateSearchTermsAction::class) { action -> assertEquals("1", action.sessionId) assertEquals(pastedText, action.searchTerms) @@ -214,8 +210,6 @@ class DefaultBrowserToolbarControllerTest { sessionUseCases.loadUrl(pastedText) } - store.waitUntilIdle() - captureMiddleware.assertFirstAction(ContentAction.UpdateSearchTermsAction::class) { action -> assertEquals("1", action.sessionId) assertEquals("", action.searchTerms) @@ -283,7 +277,7 @@ class DefaultBrowserToolbarControllerTest { @Test fun handleToolbackClickWithSearchTerms() { val searchResultsTab = createTab("https://google.com?q=mozilla+website", searchTerms = "mozilla website") - store.dispatch(TabListAction.AddTabAction(searchResultsTab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(searchResultsTab, select = true)) assertNull(Events.searchBarTapped.testGetValue()) @@ -326,8 +320,8 @@ class DefaultBrowserToolbarControllerTest { val item = TabCounterMenu.Item.CloseTab val testTab = createTab("https://www.firefox.com") - store.dispatch(TabListAction.AddTabAction(testTab)).joinBlocking() - store.dispatch(TabListAction.SelectTabAction(testTab.id)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(testTab)) + store.dispatch(TabListAction.SelectTabAction(testTab.id)) val controller = createController() controller.handleTabCounterItemInteraction(item) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultBrowserToolbarMenuControllerTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultBrowserToolbarMenuControllerTest.kt @@ -44,7 +44,6 @@ import mozilla.components.feature.top.sites.DefaultTopSitesStorage import mozilla.components.feature.top.sites.PinnedSiteStorage import mozilla.components.feature.top.sites.TopSitesUseCases import mozilla.components.support.base.feature.ViewBoundFeatureWrapper -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule import mozilla.components.support.test.rule.runTestOnMain @@ -242,7 +241,7 @@ class DefaultBrowserToolbarMenuControllerTest { @Test fun `WHEN open in Fenix menu item is pressed THEN menu item is handled correctly`() = runTest { val customTab = createCustomTab("https://mozilla.org") - browserStore.dispatch(CustomTabListAction.AddCustomTabAction(customTab)).joinBlocking() + browserStore.dispatch(CustomTabListAction.AddCustomTabAction(customTab)) val controller = createController( scope = this, store = browserStore, diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/MenuPresenterTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/MenuPresenterTest.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.browser.toolbar.BrowserToolbar -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Before import org.junit.Rule @@ -44,10 +43,10 @@ class MenuPresenterTest { fun `WHEN loading state is updated THEN toolbar is invalidated`() { verify(exactly = 0) { menuToolbar.invalidateActions() } - store.dispatch(ContentAction.UpdateLoadingStateAction(testTab.id, true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction(testTab.id, true)) verify(exactly = 1) { menuToolbar.invalidateActions() } - store.dispatch(ContentAction.UpdateLoadingStateAction(testTab.id, false)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction(testTab.id, false)) verify(exactly = 2) { menuToolbar.invalidateActions() } } @@ -55,10 +54,10 @@ class MenuPresenterTest { fun `WHEN back navigation state is updated THEN toolbar is invalidated`() { verify(exactly = 0) { menuToolbar.invalidateActions() } - store.dispatch(ContentAction.UpdateBackNavigationStateAction(testTab.id, true)).joinBlocking() + store.dispatch(ContentAction.UpdateBackNavigationStateAction(testTab.id, true)) verify(exactly = 1) { menuToolbar.invalidateActions() } - store.dispatch(ContentAction.UpdateBackNavigationStateAction(testTab.id, false)).joinBlocking() + store.dispatch(ContentAction.UpdateBackNavigationStateAction(testTab.id, false)) verify(exactly = 2) { menuToolbar.invalidateActions() } } @@ -66,10 +65,10 @@ class MenuPresenterTest { fun `WHEN forward navigation state is updated THEN toolbar is invalidated`() { verify(exactly = 0) { menuToolbar.invalidateActions() } - store.dispatch(ContentAction.UpdateForwardNavigationStateAction(testTab.id, true)).joinBlocking() + store.dispatch(ContentAction.UpdateForwardNavigationStateAction(testTab.id, true)) verify(exactly = 1) { menuToolbar.invalidateActions() } - store.dispatch(ContentAction.UpdateForwardNavigationStateAction(testTab.id, false)).joinBlocking() + store.dispatch(ContentAction.UpdateForwardNavigationStateAction(testTab.id, false)) verify(exactly = 2) { menuToolbar.invalidateActions() } } @@ -77,7 +76,7 @@ class MenuPresenterTest { fun `WHEN web app manifest is updated THEN toolbar is invalidated`() { verify(exactly = 0) { menuToolbar.invalidateActions() } - store.dispatch(ContentAction.UpdateWebAppManifestAction(testTab.id, mockk())).joinBlocking() + store.dispatch(ContentAction.UpdateWebAppManifestAction(testTab.id, mockk())) verify(exactly = 1) { menuToolbar.invalidateActions() } } } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/debugsettings/DebugDrawerNavigationMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/debugsettings/DebugDrawerNavigationMiddlewareTest.kt @@ -8,7 +8,6 @@ import androidx.navigation.NavHostController import io.mockk.called import io.mockk.mockk import io.mockk.verify -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Before import org.junit.Rule @@ -42,64 +41,64 @@ class DebugDrawerNavigationMiddlewareTest { @Test fun `WHEN home is the next destination THEN the back stack is cleared and the user is returned to home`() { - store.dispatch(DebugDrawerAction.NavigateTo.Home).joinBlocking() + store.dispatch(DebugDrawerAction.NavigateTo.Home) verify { navController.popBackStack(route = DEBUG_DRAWER_HOME_ROUTE, inclusive = false) } } @Test fun `WHEN the tab tools screen is the next destination THEN the tab tools screen is navigated to`() { - store.dispatch(DebugDrawerAction.NavigateTo.TabTools).joinBlocking() + store.dispatch(DebugDrawerAction.NavigateTo.TabTools) verify { navController.navigate(DebugDrawerRoute.TabTools.route) } } @Test fun `WHEN the logins screen is the next destination THEN the logins screen is navigated to`() { - store.dispatch(DebugDrawerAction.NavigateTo.Logins).joinBlocking() + store.dispatch(DebugDrawerAction.NavigateTo.Logins) verify { navController.navigate(DebugDrawerRoute.Logins.route) } } @Test fun `WHEN the CFR tools screen is the next destination THEN the CFR tools screen is navigated to`() { - store.dispatch(DebugDrawerAction.NavigateTo.CfrTools).joinBlocking() + store.dispatch(DebugDrawerAction.NavigateTo.CfrTools) verify { navController.navigate(DebugDrawerRoute.CfrTools.route) } } @Test fun `WHEN the glean debug tools screen is the next destination THEN the glean debug tools screen is navigated to`() { - store.dispatch(DebugDrawerAction.NavigateTo.GleanDebugTools).joinBlocking() + store.dispatch(DebugDrawerAction.NavigateTo.GleanDebugTools) verify { navController.navigate(DebugDrawerRoute.GleanDebugTools.route) } } @Test fun `WHEN the region tools screen is the next destination THEN the region tools screen is navigated to`() { - store.dispatch(DebugDrawerAction.NavigateTo.RegionDebugTools).joinBlocking() + store.dispatch(DebugDrawerAction.NavigateTo.RegionDebugTools) verify { navController.navigate(DebugDrawerRoute.RegionDebugTools.route) } } @Test fun `WHEN the add-ons tools screen is the next destination THEN the add-ons tools screen is navigated to`() { - store.dispatch(DebugDrawerAction.NavigateTo.AddonsDebugTools).joinBlocking() + store.dispatch(DebugDrawerAction.NavigateTo.AddonsDebugTools) verify { navController.navigate(DebugDrawerRoute.AddonsDebugTools.route) } } @Test fun `WHEN the back button is pressed THEN the drawer should go back one screen`() { - store.dispatch(DebugDrawerAction.OnBackPressed).joinBlocking() + store.dispatch(DebugDrawerAction.OnBackPressed) verify { navController.popBackStack() } } @Test fun `WHEN a non-navigation action is dispatched THEN the drawer should not navigate`() { - store.dispatch(DebugDrawerAction.DrawerOpened).joinBlocking() - store.dispatch(DebugDrawerAction.DrawerClosed).joinBlocking() + store.dispatch(DebugDrawerAction.DrawerOpened) + store.dispatch(DebugDrawerAction.DrawerClosed) verify { navController wasNot called } } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/debugsettings/DebugDrawerStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/debugsettings/DebugDrawerStoreTest.kt @@ -4,7 +4,6 @@ package org.mozilla.fenix.debugsettings -import mozilla.components.support.test.ext.joinBlocking import org.junit.Assert.assertEquals import org.junit.Test import org.mozilla.fenix.debugsettings.store.DebugDrawerAction @@ -19,7 +18,7 @@ class DebugDrawerStoreTest { val expected = DrawerStatus.Open val store = createStore() - store.dispatch(DebugDrawerAction.DrawerOpened).joinBlocking() + store.dispatch(DebugDrawerAction.DrawerOpened) assertEquals(expected, store.state.drawerStatus) } @@ -31,7 +30,7 @@ class DebugDrawerStoreTest { drawerStatus = DrawerStatus.Open, ) - store.dispatch(DebugDrawerAction.DrawerClosed).joinBlocking() + store.dispatch(DebugDrawerAction.DrawerClosed) assertEquals(expected, store.state.drawerStatus) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/exceptions/login/LoginExceptionFragmentStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/exceptions/login/LoginExceptionFragmentStoreTest.kt @@ -5,7 +5,6 @@ package org.mozilla.fenix.exceptions.login import mozilla.components.feature.logins.exceptions.LoginException -import mozilla.components.support.test.ext.joinBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertNotSame import org.junit.Test @@ -23,7 +22,7 @@ class LoginExceptionFragmentStoreTest { get() = "test" } - store.dispatch(ExceptionsFragmentAction.Change(listOf(newExceptionsItem))).joinBlocking() + store.dispatch(ExceptionsFragmentAction.Change(listOf(newExceptionsItem))) assertNotSame(initialState, store.state) assertEquals(listOf(newExceptionsItem), store.state.items) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/exceptions/trackingprotection/TrackingProtectionExceptionsFragmentStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/exceptions/trackingprotection/TrackingProtectionExceptionsFragmentStoreTest.kt @@ -17,7 +17,7 @@ class TrackingProtectionExceptionsFragmentStoreTest { val store = ExceptionsFragmentStore(initialState) val newExceptionsItem = ExceptionItem("URL") - store.dispatch(ExceptionsFragmentAction.Change(listOf(newExceptionsItem))).join() + store.dispatch(ExceptionsFragmentAction.Change(listOf(newExceptionsItem))) assertNotSame(initialState, store.state) assertEquals( store.state.items, diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/extension/WebExtensionPromptFeatureTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/extension/WebExtensionPromptFeatureTest.kt @@ -78,7 +78,7 @@ class WebExtensionPromptFeatureTest { mockk(), ), ), - ).joinBlocking() + ) verify { webExtensionPromptFeature.handleInstallationFailedRequest(any()) } } @@ -260,7 +260,7 @@ class WebExtensionPromptFeatureTest { mockk(), ), ), - ).joinBlocking() + ) verify { webExtensionPromptFeature.handleAfterInstallationRequest(any()) } } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt @@ -25,7 +25,6 @@ import mozilla.components.feature.session.SessionUseCases import mozilla.components.feature.tab.collections.TabCollection import mozilla.components.feature.tabs.TabsUseCases import mozilla.components.service.nimbus.messaging.Message -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertEquals @@ -224,9 +223,9 @@ class DefaultSessionControlControllerTest { val restoredTab = createTab(id = recoverableTab.state.id, url = recoverableTab.state.url) val otherTab = createTab(id = "otherTab", url = "https://mozilla.org") - store.dispatch(TabListAction.AddTabAction(otherTab)).joinBlocking() - store.dispatch(TabListAction.SelectTabAction(otherTab.id)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(restoredTab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(otherTab)) + store.dispatch(TabListAction.SelectTabAction(otherTab.id)) + store.dispatch(TabListAction.AddTabAction(restoredTab)) createController().handleCollectionOpenTabClicked(tab) @@ -261,7 +260,7 @@ class DefaultSessionControlControllerTest { } val restoredTab = createTab(id = recoverableTab.state.id, url = recoverableTab.state.url) - store.dispatch(TabListAction.AddTabAction(restoredTab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(restoredTab)) createController().handleCollectionOpenTabClicked(tab) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/PocketMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/PocketMiddlewareTest.kt @@ -19,8 +19,6 @@ import mozilla.components.service.pocket.PocketStory.ContentRecommendation import mozilla.components.service.pocket.PocketStory.PocketRecommendedStory import mozilla.components.service.pocket.PocketStory.SponsoredContent import mozilla.components.service.pocket.PocketStory.SponsoredContentCallbacks -import mozilla.components.support.test.ext.joinBlocking -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 @@ -84,7 +82,7 @@ class PocketMiddlewareTest { ), ), ), - ).joinBlocking() + ) coVerify { pocketService.updateStoriesTimesShown(listOf(story2.copy(timesShown = 1))) } } @@ -172,7 +170,7 @@ class PocketMiddlewareTest { ), ) - appStore.dispatch(ContentRecommendationsAction.PocketStoriesCategoriesChange(currentCategories)).joinBlocking() + appStore.dispatch(ContentRecommendationsAction.PocketStoriesCategoriesChange(currentCategories)) advanceUntilIdle() @@ -211,11 +209,11 @@ class PocketMiddlewareTest { dataStore.assertSelectedCategories() appStore.assertSelectedCategories() - appStore.dispatch(ContentRecommendationsAction.SelectPocketStoriesCategory(categ2.name)).joinBlocking() + appStore.dispatch(ContentRecommendationsAction.SelectPocketStoriesCategory(categ2.name)) dataStore.assertSelectedCategories(categ2.name) appStore.assertSelectedCategories(categ2.name) - appStore.dispatch(ContentRecommendationsAction.SelectPocketStoriesCategory(categ1.name)).joinBlocking() + appStore.dispatch(ContentRecommendationsAction.SelectPocketStoriesCategory(categ1.name)) dataStore.assertSelectedCategories(categ2.name, categ1.name) appStore.assertSelectedCategories(categ2.name, categ1.name) } @@ -248,11 +246,11 @@ class PocketMiddlewareTest { dataStore.assertSelectedCategories(persistedCateg1.name, persistedCateg2.name) appStore.assertSelectedCategories(persistedCateg1.name, persistedCateg2.name) - appStore.dispatch(ContentRecommendationsAction.DeselectPocketStoriesCategory(categ2.name)).joinBlocking() + appStore.dispatch(ContentRecommendationsAction.DeselectPocketStoriesCategory(categ2.name)) dataStore.assertSelectedCategories(persistedCateg1.name) appStore.assertSelectedCategories(persistedCateg1.name) - appStore.dispatch(ContentRecommendationsAction.DeselectPocketStoriesCategory(categ1.name)).joinBlocking() + appStore.dispatch(ContentRecommendationsAction.DeselectPocketStoriesCategory(categ1.name)) dataStore.assertSelectedCategories() appStore.assertSelectedCategories() } @@ -284,7 +282,6 @@ class PocketMiddlewareTest { store = appStore, selectedPocketCategoriesDataStore = dataStore, ) - appStore.waitUntilIdle() captorMiddleware.assertLastAction(PocketStoriesCategoriesSelectionsChange::class) { assertEquals(1, it.categoriesSelected.size) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/RecentTabsListFeatureTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/RecentTabsListFeatureTest.kt @@ -15,8 +15,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.mediasession.MediaSession import mozilla.components.feature.media.middleware.LastMediaAccessMiddleware -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.After @@ -64,8 +62,6 @@ class RecentTabsListFeatureTest { feature.start() - appStore.waitUntilIdle() - assertEquals(0, appStore.state.recentTabs.size) } @@ -86,8 +82,6 @@ class RecentTabsListFeatureTest { feature.start() - appStore.waitUntilIdle() - assertEquals(1, appStore.state.recentTabs.size) } @@ -111,8 +105,6 @@ class RecentTabsListFeatureTest { feature.start() - appStore.waitUntilIdle() - assertEquals(1, appStore.state.recentTabs.size) } @@ -137,7 +129,6 @@ class RecentTabsListFeatureTest { ) feature.start() - appStore.waitUntilIdle() assertEquals(2, appStore.state.recentTabs.size) assertTrue(appStore.state.recentTabs[0] is RecentTab.Tab) @@ -166,7 +157,6 @@ class RecentTabsListFeatureTest { ) feature.start() - appStore.waitUntilIdle() assertEquals(1, appStore.state.recentTabs.size) assertTrue(appStore.state.recentTabs[0] is RecentTab.Tab) @@ -197,15 +187,11 @@ class RecentTabsListFeatureTest { feature.start() - appStore.waitUntilIdle() - assertEquals(1, appStore.state.recentTabs.size) assertTrue(appStore.state.recentTabs[0] is RecentTab.Tab) assertEquals(tab1, (appStore.state.recentTabs[0] as RecentTab.Tab).state) - browserStore.dispatch(TabListAction.SelectTabAction(tab2.id)).joinBlocking() - - appStore.waitUntilIdle() + browserStore.dispatch(TabListAction.SelectTabAction(tab2.id)) assertEquals(1, appStore.state.recentTabs.size) assertTrue(appStore.state.recentTabs[0] is RecentTab.Tab) @@ -238,15 +224,13 @@ class RecentTabsListFeatureTest { ) feature.start() - appStore.waitUntilIdle() assertEquals(2, appStore.state.recentTabs.size) assertTrue(appStore.state.recentTabs[0] is RecentTab.Tab) assertEquals(initialMediaTab, (appStore.state.recentTabs[0] as RecentTab.Tab).state) browserStore.dispatch( MediaSessionAction.UpdateMediaPlaybackStateAction("2", MediaSession.PlaybackState.PLAYING), - ).joinBlocking() - appStore.waitUntilIdle() + ) assertEquals(2, appStore.state.recentTabs.size) assertTrue(appStore.state.recentTabs[0] is RecentTab.Tab) assertEquals(initialMediaTab, (appStore.state.recentTabs[0] as RecentTab.Tab).state) @@ -298,15 +282,11 @@ class RecentTabsListFeatureTest { feature.start() - appStore.waitUntilIdle() - assertEquals(1, appStore.state.recentTabs.size) assertTrue(appStore.state.recentTabs[0] is RecentTab.Tab) assertEquals(selectedNormalTab, (appStore.state.recentTabs[0] as RecentTab.Tab).state) - browserStore.dispatch(TabListAction.SelectTabAction(privateTab.id)).joinBlocking() - - appStore.waitUntilIdle() + browserStore.dispatch(TabListAction.SelectTabAction(privateTab.id)) // If the selected tab is a private tab the feature should show the last accessed normal tab. assertEquals(1, appStore.state.recentTabs.size) @@ -334,17 +314,13 @@ class RecentTabsListFeatureTest { feature.start() - appStore.waitUntilIdle() - middleware.assertLastAction(AppAction.RecentTabsChange::class) { val tab = it.recentTabs.first() as RecentTab.Tab assertTrue(tab.state.content.title.isEmpty()) assertNull(tab.state.content.icon) } - browserStore.dispatch(UpdateTitleAction("1", "test")).joinBlocking() - - appStore.waitUntilIdle() + browserStore.dispatch(UpdateTitleAction("1", "test")) middleware.assertLastAction(AppAction.RecentTabsChange::class) { val tab = it.recentTabs.first() as RecentTab.Tab @@ -353,9 +329,6 @@ class RecentTabsListFeatureTest { } browserStore.dispatch(UpdateIconAction("1", "https://www.mozilla.org", mockk())) - .joinBlocking() - - appStore.waitUntilIdle() middleware.assertLastAction(AppAction.RecentTabsChange::class) { val tab = it.recentTabs.first() as RecentTab.Tab @@ -378,8 +351,7 @@ class RecentTabsListFeatureTest { ) feature.start() - browserStore.dispatch(TabListAction.RemoveTabsAction(listOf("1"))).joinBlocking() - appStore.waitUntilIdle() + browserStore.dispatch(TabListAction.RemoveTabsAction(listOf("1"))) assertEquals(1, appStore.state.recentTabs.size) assertTrue(appStore.state.recentTabs[0] is RecentTab.Tab) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/blocklist/BlocklistMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/blocklist/BlocklistMiddlewareTest.kt @@ -8,7 +8,6 @@ import io.mockk.every import io.mockk.mockk import io.mockk.slot import mozilla.components.browser.state.state.createTab -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.mock import org.junit.Assert.assertEquals @@ -52,7 +51,7 @@ class BlocklistMiddlewareTest { recentHistory = appStore.state.recentHistory, recentSyncedTabState = appStore.state.recentSyncedTabState, ), - ).joinBlocking() + ) assertEquals(updatedBookmark, appStore.state.bookmarks[0]) } @@ -79,7 +78,7 @@ class BlocklistMiddlewareTest { recentHistory = appStore.state.recentHistory, recentSyncedTabState = appStore.state.recentSyncedTabState, ), - ).joinBlocking() + ) assertEquals(updatedBookmark, appStore.state.bookmarks[0]) } @@ -106,7 +105,7 @@ class BlocklistMiddlewareTest { recentHistory = appStore.state.recentHistory, recentSyncedTabState = appStore.state.recentSyncedTabState, ), - ).joinBlocking() + ) assertEquals(updatedBookmark, appStore.state.bookmarks[0]) } @@ -133,7 +132,7 @@ class BlocklistMiddlewareTest { recentHistory = appStore.state.recentHistory, recentSyncedTabState = appStore.state.recentSyncedTabState, ), - ).joinBlocking() + ) assertTrue(appStore.state.bookmarks.isEmpty()) } @@ -162,7 +161,7 @@ class BlocklistMiddlewareTest { recentHistory = appStore.state.recentHistory, recentSyncedTabState = appStore.state.recentSyncedTabState, ), - ).joinBlocking() + ) assertTrue(appStore.state.bookmarks.isEmpty()) assertTrue(appStore.state.recentTabs.isEmpty()) @@ -200,7 +199,7 @@ class BlocklistMiddlewareTest { recentHistory = appStore.state.recentHistory, recentSyncedTabState = appStore.state.recentSyncedTabState, ), - ).joinBlocking() + ) assertEquals(unblockedBookmark, appStore.state.bookmarks[0]) assertEquals(unblockedRecentTab, appStore.state.recentTabs[0]) @@ -223,7 +222,7 @@ class BlocklistMiddlewareTest { appStore.dispatch( AppAction.RemoveBookmark(removedBookmark), - ).joinBlocking() + ) val capturedAction = captureMiddleware.findFirstAction(AppAction.Change::class) assertEquals(emptyList<Bookmark>(), capturedAction.bookmarks) @@ -253,7 +252,7 @@ class BlocklistMiddlewareTest { recentHistory = appStore.state.recentHistory, recentSyncedTabState = appStore.state.recentSyncedTabState, ), - ).joinBlocking() + ) assertTrue(appStore.state.bookmarks.isEmpty()) } @@ -281,7 +280,7 @@ class BlocklistMiddlewareTest { recentHistory = appStore.state.recentHistory, recentSyncedTabState = appStore.state.recentSyncedTabState, ), - ).joinBlocking() + ) assertTrue(appStore.state.bookmarks.isEmpty()) } @@ -309,7 +308,7 @@ class BlocklistMiddlewareTest { recentHistory = appStore.state.recentHistory, recentSyncedTabState = appStore.state.recentSyncedTabState, ), - ).joinBlocking() + ) assertTrue(appStore.state.bookmarks.isEmpty()) } @@ -349,7 +348,7 @@ class BlocklistMiddlewareTest { ), ), ), - ).joinBlocking() + ) assertEquals( allowedTab, @@ -371,7 +370,7 @@ class BlocklistMiddlewareTest { AppAction.RecentSyncedTabStateChange( RecentSyncedTabState.None, ), - ).joinBlocking() + ) assertEquals(RecentSyncedTabState.None, appStore.state.recentSyncedTabState) } @@ -400,7 +399,7 @@ class BlocklistMiddlewareTest { listOf(blockedTab), ), ), - ).joinBlocking() + ) assertEquals( RecentSyncedTabState.None, @@ -447,7 +446,7 @@ class BlocklistMiddlewareTest { AppAction.RemoveRecentSyncedTab( currentTabs.first(), ), - ).joinBlocking() + ) assertEquals( 2, diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/middleware/HomeTelemetryMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/middleware/HomeTelemetryMiddlewareTest.kt @@ -6,7 +6,6 @@ package org.mozilla.fenix.home.middleware import androidx.test.ext.junit.runners.AndroidJUnit4 import mozilla.components.service.pocket.PocketStory -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull @@ -65,7 +64,7 @@ class HomeTelemetryMiddlewareTest { recommendation = recommendation, position = position, ), - ).joinBlocking() + ) job.join() assertTrue(pingReceived) @@ -114,7 +113,7 @@ class HomeTelemetryMiddlewareTest { ContentRecommendationsAction.PocketStoriesShown( impressions = impressions, ), - ).joinBlocking() + ) job.join() assertTrue(pingReceived) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/privatebrowsing/DefaultPrivateBrowsingControllerTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/privatebrowsing/DefaultPrivateBrowsingControllerTest.kt @@ -13,7 +13,6 @@ import io.mockk.verify import mozilla.components.browser.state.action.TabListAction import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertEquals import org.junit.Assert.assertNull @@ -138,7 +137,7 @@ class DefaultPrivateBrowsingControllerTest { private = false, engineSession = mockk(relaxed = true), ) - store.dispatch(TabListAction.AddTabAction(tab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab, select = true)) val newMode = BrowsingMode.Private @@ -168,7 +167,7 @@ class DefaultPrivateBrowsingControllerTest { private = true, engineSession = mockk(relaxed = true), ) - store.dispatch(TabListAction.AddTabAction(tab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab, select = true)) val newMode = BrowsingMode.Normal diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/recenttabs/controller/RecentTabControllerTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/recenttabs/controller/RecentTabControllerTest.kt @@ -16,7 +16,6 @@ import mozilla.components.browser.state.state.LastMediaAccessState import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.feature.tabs.TabsUseCases -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertNotNull import org.junit.Assert.assertNull @@ -73,8 +72,8 @@ class RecentTabControllerTest { url = "https://mozilla.org", title = "Mozilla", ) - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() - store.dispatch(TabListAction.SelectTabAction(tab.id)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) + store.dispatch(TabListAction.SelectTabAction(tab.id)) controller.handleRecentTabClicked(tab.id) @@ -99,8 +98,8 @@ class RecentTabControllerTest { lastMediaAccessState = LastMediaAccessState("https://mozilla.com", 123, true), ) - store.dispatch(TabListAction.AddTabAction(inProgressMediaTab)).joinBlocking() - store.dispatch(TabListAction.SelectTabAction(inProgressMediaTab.id)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(inProgressMediaTab)) + store.dispatch(TabListAction.SelectTabAction(inProgressMediaTab.id)) controller.handleRecentTabClicked(inProgressMediaTab.id) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/recentvisits/HistoryMetadataMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/recentvisits/HistoryMetadataMiddlewareTest.kt @@ -24,7 +24,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.history.HistoryItem import mozilla.components.concept.storage.HistoryMetadataKey -import mozilla.components.support.test.ext.joinBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Before @@ -58,23 +57,23 @@ class HistoryMetadataMiddlewareTest { val expectedKey = HistoryMetadataKey(url = tab.content.url) every { service.createMetadata(any(), any()) } returns expectedKey - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) verify(exactly = 1) { service.createMetadata(tab) } - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, emptyList(), currentIndex = 0)).joinBlocking() + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, emptyList(), currentIndex = 0)) val capturedTab = slot<TabSessionState>() verify(exactly = 1) { service.createMetadata(capture(capturedTab)) } // Not recording if url didn't change. - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, emptyList(), currentIndex = 0)).joinBlocking() + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, emptyList(), currentIndex = 0)) verify(exactly = 1) { service.createMetadata(capture(capturedTab)) } assertEquals(tab.id, capturedTab.captured.id) assertEquals(expectedKey, store.state.findTab(tab.id)?.historyMetadata) // Now, test that we'll record metadata for the same tab after url is changed. - store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://firefox.com")).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, emptyList(), currentIndex = 0)).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://firefox.com")) + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, emptyList(), currentIndex = 0)) val capturedTabs = mutableListOf<TabSessionState>() verify(exactly = 2) { service.createMetadata(capture(capturedTabs)) } @@ -92,10 +91,10 @@ class HistoryMetadataMiddlewareTest { fun `GIVEN normal tab has parent with session search terms WHEN history metadata is recorded THEN search terms and referrer url are provided`() { val parentTab = createTab("https://google.com?q=mozilla+website", searchTerms = "mozilla website") val tab = createTab("https://mozilla.org", parent = parentTab) - store.dispatch(TabListAction.AddTabAction(parentTab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(parentTab)) + store.dispatch(TabListAction.AddTabAction(tab)) - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, emptyList(), currentIndex = 0)).joinBlocking() + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, emptyList(), currentIndex = 0)) verify { service.createMetadata(any(), eq("mozilla website"), eq("https://google.com?q=mozilla+website")) } @@ -107,10 +106,10 @@ class HistoryMetadataMiddlewareTest { val parentTab = createTab("https://google.com?q=mozilla+website") val tab = createTab("https://mozilla.org", parent = parentTab) - store.dispatch(TabListAction.AddTabAction(parentTab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(parentTab)) + store.dispatch(TabListAction.AddTabAction(tab)) - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, emptyList(), currentIndex = 0)).joinBlocking() + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, emptyList(), currentIndex = 0)) verify { service.createMetadata(any(), eq("mozilla website"), eq("https://google.com?q=mozilla+website")) } @@ -130,9 +129,9 @@ class HistoryMetadataMiddlewareTest { setupGoogleSearchEngine() val serpUrl = "https://google.com?q=mozilla+website" - store.dispatch(EngineAction.LoadUrlAction(tab.id, serpUrl)).joinBlocking() - store.dispatch(ContentAction.UpdateUrlAction(tab.id, serpUrl)).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("Google Search", serpUrl)), currentIndex = 0)).joinBlocking() + store.dispatch(EngineAction.LoadUrlAction(tab.id, serpUrl)) + store.dispatch(ContentAction.UpdateUrlAction(tab.id, serpUrl)) + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("Google Search", serpUrl)), currentIndex = 0)) with((service as TestingMetadataService).createdMetadata) { assertEquals(1, this.count()) assertEquals("https://google.com?q=mozilla+website", this[0].url) @@ -155,8 +154,8 @@ class HistoryMetadataMiddlewareTest { setupGoogleSearchEngine() val serpUrl = "https://google.com?q=mozilla+website" - store.dispatch(ContentAction.UpdateUrlAction(tab.id, serpUrl)).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("Google Search", "https://google.com"), HistoryItem("Google Search", serpUrl)), currentIndex = 1)).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tab.id, serpUrl)) + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("Google Search", "https://google.com"), HistoryItem("Google Search", serpUrl)), currentIndex = 1)) with((service as TestingMetadataService).createdMetadata) { assertEquals(1, this.count()) assertEquals("https://google.com?q=mozilla+website", this[0].url) @@ -177,8 +176,8 @@ class HistoryMetadataMiddlewareTest { val parentTab = createTab("https://google.com?q=mozilla+website", searchTerms = "mozilla website") val tab = createTab("https://google.com?url=https://mozilla.org", parent = parentTab) - store.dispatch(TabListAction.AddTabAction(parentTab, select = true)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(parentTab, select = true)) + store.dispatch(TabListAction.AddTabAction(tab)) with((service as TestingMetadataService).createdMetadata) { assertEquals(2, this.count()) @@ -192,16 +191,16 @@ class HistoryMetadataMiddlewareTest { } // Both tabs load. - store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website")), 0)).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("", "https://google.com?url=mozilla+website")), currentIndex = 0)).joinBlocking() + store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website")), 0)) + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("", "https://google.com?url=mozilla+website")), currentIndex = 0)) with((service as TestingMetadataService).createdMetadata) { assertEquals(2, this.count()) } // Parent navigates away. - store.dispatch(ContentAction.UpdateUrlAction(parentTab.id, "https://firefox.com")).joinBlocking() - store.dispatch(ContentAction.UpdateSearchTermsAction(parentTab.id, "")).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website"), HistoryItem("Firefox", "https://firefox.com")), 1)).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(parentTab.id, "https://firefox.com")) + store.dispatch(ContentAction.UpdateSearchTermsAction(parentTab.id, "")) + store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website"), HistoryItem("Firefox", "https://firefox.com")), 1)) with((service as TestingMetadataService).createdMetadata) { assertEquals(3, this.count()) assertEquals("https://firefox.com", this[2].url) @@ -210,8 +209,8 @@ class HistoryMetadataMiddlewareTest { } // Redirect the child tab (url changed, history stack has single item). - store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://mozilla.org")).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("Mozilla", "https://mozilla.org")), currentIndex = 0)).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://mozilla.org")) + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("Mozilla", "https://mozilla.org")), currentIndex = 0)) val tab2 = store.state.findTab(tab.id)!! assertEquals("https://mozilla.org", tab2.content.url) with((service as TestingMetadataService).createdMetadata) { @@ -222,8 +221,8 @@ class HistoryMetadataMiddlewareTest { } // Navigate the child tab. - store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://mozilla.org/manifesto")).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("Mozilla", "https://mozilla.org"), HistoryItem("Mozilla Manifesto", "https://mozilla.org/manifesto")), currentIndex = 1)).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://mozilla.org/manifesto")) + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("Mozilla", "https://mozilla.org"), HistoryItem("Mozilla Manifesto", "https://mozilla.org/manifesto")), currentIndex = 1)) val tab3 = store.state.findTab(tab.id)!! assertEquals("https://mozilla.org/manifesto", tab3.content.url) @@ -247,8 +246,8 @@ class HistoryMetadataMiddlewareTest { val parentTab = createTab("https://google.com?q=mozilla+website", searchTerms = "mozilla website") val tab = createTab("https://google.com?url=https://mozilla.org", parent = parentTab) - store.dispatch(TabListAction.AddTabAction(parentTab, select = true)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(parentTab, select = true)) + store.dispatch(TabListAction.AddTabAction(tab)) with((service as TestingMetadataService).createdMetadata) { assertEquals(2, this.count()) @@ -262,22 +261,22 @@ class HistoryMetadataMiddlewareTest { } // Parent tab loads. - store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website")), 0)).joinBlocking() + store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website")), 0)) with((service as TestingMetadataService).createdMetadata) { assertEquals(2, this.count()) } // Simulate a state where search metadata is missing for the child tab. - store.dispatch(HistoryMetadataAction.SetHistoryMetadataKeyAction(tab.id, HistoryMetadataKey("https://google.com?url=https://mozilla.org", null, null))).joinBlocking() + store.dispatch(HistoryMetadataAction.SetHistoryMetadataKeyAction(tab.id, HistoryMetadataKey("https://google.com?url=https://mozilla.org", null, null))) // Parent navigates away, while the child starts loading. A mostly realistic sequence of events... - store.dispatch(ContentAction.UpdateUrlAction(parentTab.id, "https://firefox.com")).joinBlocking() - store.dispatch(ContentAction.UpdateSearchTermsAction(parentTab.id, "")).joinBlocking() - store.dispatch(EngineAction.LoadUrlAction(tab.id, "https://google.com?url=https://mozilla.org")).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("", "https://google.com?url=https://mozilla.org")), currentIndex = 0)).joinBlocking() - store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://mozilla.org")).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("Mozilla", "https://mozilla.org")), currentIndex = 0)).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website"), HistoryItem("Firefox", "https://firefox.com")), 1)).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(parentTab.id, "https://firefox.com")) + store.dispatch(ContentAction.UpdateSearchTermsAction(parentTab.id, "")) + store.dispatch(EngineAction.LoadUrlAction(tab.id, "https://google.com?url=https://mozilla.org")) + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("", "https://google.com?url=https://mozilla.org")), currentIndex = 0)) + store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://mozilla.org")) + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("Mozilla", "https://mozilla.org")), currentIndex = 0)) + store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website"), HistoryItem("Firefox", "https://firefox.com")), 1)) with((service as TestingMetadataService).createdMetadata) { assertEquals(4, this.count()) @@ -309,8 +308,8 @@ class HistoryMetadataMiddlewareTest { val parentTab = createTab("https://google.com?q=mozilla+website", searchTerms = "mozilla website") val tab = createTab("https://google.com?url=https://mozilla.org", parent = parentTab) - store.dispatch(TabListAction.AddTabAction(parentTab, select = true)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(parentTab, select = true)) + store.dispatch(TabListAction.AddTabAction(tab)) with((service as TestingMetadataService).createdMetadata) { assertEquals(2, this.count()) @@ -324,16 +323,16 @@ class HistoryMetadataMiddlewareTest { } // Both tabs load. - store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website")), 0)).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("", "https://google.com?url=mozilla+website")), currentIndex = 0)).joinBlocking() + store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website")), 0)) + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("", "https://google.com?url=mozilla+website")), currentIndex = 0)) with((service as TestingMetadataService).createdMetadata) { assertEquals(2, this.count()) } // Direct load occurs on child tab. Search terms should be cleared. - store.dispatch(EngineAction.LoadUrlAction(tab.id, "https://firefox.com")).joinBlocking() - store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://firefox.com")).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("", "https://google.com?url=mozilla+website"), HistoryItem("Firefox", "https://firefox.com")), 1)).joinBlocking() + store.dispatch(EngineAction.LoadUrlAction(tab.id, "https://firefox.com")) + store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://firefox.com")) + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("", "https://google.com?url=mozilla+website"), HistoryItem("Firefox", "https://firefox.com")), 1)) with((service as TestingMetadataService).createdMetadata) { assertEquals(3, this.count()) assertEquals("https://firefox.com", this[2].url) @@ -342,10 +341,10 @@ class HistoryMetadataMiddlewareTest { } // Direct load occurs on parent tab. Search terms should be cleared. - store.dispatch(EngineAction.LoadUrlAction(parentTab.id, "https://firefox.com")).joinBlocking() - store.dispatch(ContentAction.UpdateSearchTermsAction(parentTab.id, "")).joinBlocking() - store.dispatch(ContentAction.UpdateUrlAction(parentTab.id, "https://firefox.com")).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website"), HistoryItem("Firefox", "https://firefox.com")), 1)).joinBlocking() + store.dispatch(EngineAction.LoadUrlAction(parentTab.id, "https://firefox.com")) + store.dispatch(ContentAction.UpdateSearchTermsAction(parentTab.id, "")) + store.dispatch(ContentAction.UpdateUrlAction(parentTab.id, "https://firefox.com")) + store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website"), HistoryItem("Firefox", "https://firefox.com")), 1)) with((service as TestingMetadataService).createdMetadata) { assertEquals(4, this.count()) assertEquals("https://firefox.com", this[3].url) @@ -366,8 +365,8 @@ class HistoryMetadataMiddlewareTest { val parentTab = createTab("https://google.com?q=mozilla+website", searchTerms = "mozilla website") val tab = createTab("https://google.com?url=https://mozilla.org", parent = parentTab) - store.dispatch(TabListAction.AddTabAction(parentTab, select = true)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(parentTab, select = true)) + store.dispatch(TabListAction.AddTabAction(tab)) with((service as TestingMetadataService).createdMetadata) { assertEquals(2, this.count()) @@ -381,16 +380,16 @@ class HistoryMetadataMiddlewareTest { } // Both tabs load. - store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website")), 0)).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("", "https://google.com?url=mozilla+website")), currentIndex = 0)).joinBlocking() + store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website")), 0)) + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("", "https://google.com?url=mozilla+website")), currentIndex = 0)) with((service as TestingMetadataService).createdMetadata) { assertEquals(2, this.count()) } // Direct load occurs on child tab. Search terms should be cleared. - store.dispatch(EngineAction.OptimizedLoadUrlTriggeredAction(tab.id, "https://firefox.com")).joinBlocking() - store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://firefox.com")).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("", "https://google.com?url=mozilla+website"), HistoryItem("Firefox", "https://firefox.com")), 1)).joinBlocking() + store.dispatch(EngineAction.OptimizedLoadUrlTriggeredAction(tab.id, "https://firefox.com")) + store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://firefox.com")) + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, listOf(HistoryItem("", "https://google.com?url=mozilla+website"), HistoryItem("Firefox", "https://firefox.com")), 1)) with((service as TestingMetadataService).createdMetadata) { assertEquals(3, this.count()) assertEquals("https://firefox.com", this[2].url) @@ -399,10 +398,10 @@ class HistoryMetadataMiddlewareTest { } // Direct load occurs on parent tab. Search terms should be cleared. - store.dispatch(EngineAction.OptimizedLoadUrlTriggeredAction(parentTab.id, "https://firefox.com")).joinBlocking() - store.dispatch(ContentAction.UpdateSearchTermsAction(parentTab.id, "")).joinBlocking() - store.dispatch(ContentAction.UpdateUrlAction(parentTab.id, "https://firefox.com")).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website"), HistoryItem("Firefox", "https://firefox.com")), 1)).joinBlocking() + store.dispatch(EngineAction.OptimizedLoadUrlTriggeredAction(parentTab.id, "https://firefox.com")) + store.dispatch(ContentAction.UpdateSearchTermsAction(parentTab.id, "")) + store.dispatch(ContentAction.UpdateUrlAction(parentTab.id, "https://firefox.com")) + store.dispatch(ContentAction.UpdateHistoryStateAction(parentTab.id, listOf(HistoryItem("Google - mozilla website", "https://google.com?q=mozilla+website"), HistoryItem("Firefox", "https://firefox.com")), 1)) with((service as TestingMetadataService).createdMetadata) { assertEquals(4, this.count()) assertEquals("https://firefox.com", this[3].url) @@ -415,27 +414,27 @@ class HistoryMetadataMiddlewareTest { fun `GIVEN normal tab has parent WHEN url is the same THEN nothing happens`() { val parentTab = createTab("https://mozilla.org") val tab = createTab("https://mozilla.org", parent = parentTab) - store.dispatch(TabListAction.AddTabAction(parentTab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(parentTab)) + store.dispatch(TabListAction.AddTabAction(tab)) verify(exactly = 1) { service.createMetadata(parentTab, null, null) } // Without our referrer url check, we would have recorded this metadata. verify(exactly = 0) { service.createMetadata(tab, "mozilla website", "https://mozilla.org") } - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, emptyList(), currentIndex = 0)).joinBlocking() + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, emptyList(), currentIndex = 0)) verify(exactly = 1) { service.createMetadata(any(), any(), any()) } } @Test fun `GIVEN normal tab has no parent WHEN history metadata is recorded THEN search terms and referrer url are provided`() { val tab = createTab("https://mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) setupGoogleSearchEngine() val historyState = listOf( HistoryItem("firefox", "https://google.com?q=mozilla+website"), HistoryItem("mozilla", "https://mozilla.org"), ) - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, historyState, currentIndex = 1)).joinBlocking() + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, historyState, currentIndex = 1)) verify { service.createMetadata(any(), eq("mozilla website"), eq("https://google.com?q=mozilla+website")) @@ -445,14 +444,14 @@ class HistoryMetadataMiddlewareTest { @Test fun `GIVEN normal tab has no parent WHEN history metadata is recorded without search terms THEN no referrer is provided`() { val tab = createTab("https://mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) setupGoogleSearchEngine() val historyState = listOf( HistoryItem("firefox", "https://mozilla.org"), HistoryItem("mozilla", "https://firefox.com"), ) - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, historyState, currentIndex = 1)).joinBlocking() + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, historyState, currentIndex = 1)) verify { service.createMetadata(any(), null, null) @@ -462,22 +461,22 @@ class HistoryMetadataMiddlewareTest { @Test fun `GIVEN a normal tab with history state WHEN directly loaded THEN search terms and referrer not recorded`() { val tab = createTab("https://mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) setupGoogleSearchEngine() val historyState = listOf( HistoryItem("firefox", "https://google.com?q=mozilla+website"), HistoryItem("mozilla", "https://mozilla.org"), ) - store.dispatch(EngineAction.LoadUrlAction(tab.id, tab.content.url)).joinBlocking() - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, historyState, currentIndex = 1)).joinBlocking() + store.dispatch(EngineAction.LoadUrlAction(tab.id, tab.content.url)) + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, historyState, currentIndex = 1)) verify { service.createMetadata(any(), null, null) } // Once direct load is "consumed", we're looking up the history stack again. - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, historyState, currentIndex = 1)).joinBlocking() + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, historyState, currentIndex = 1)) verify { service.createMetadata(any(), eq("mozilla website"), eq("https://google.com?q=mozilla+website")) } @@ -490,10 +489,10 @@ class HistoryMetadataMiddlewareTest { val expectedKey = HistoryMetadataKey(url = tab.content.url) every { service.createMetadata(any(), any()) } returns expectedKey - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) verify { service wasNot Called } - store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, emptyList(), currentIndex = 0)).joinBlocking() + store.dispatch(ContentAction.UpdateHistoryStateAction(tab.id, emptyList(), currentIndex = 0)) verify { service wasNot Called } } @@ -502,10 +501,10 @@ class HistoryMetadataMiddlewareTest { val existingKey = HistoryMetadataKey(url = "https://mozilla.org") val tab = createTab(url = existingKey.url, historyMetadata = existingKey) - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) verify { service wasNot Called } - store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://www.someother.url")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tab.id, "https://www.someother.url")) val capturedTab = slot<TabSessionState>() verify { service.updateMetadata(existingKey, capture(capturedTab)) } @@ -517,10 +516,10 @@ class HistoryMetadataMiddlewareTest { val existingKey = HistoryMetadataKey(url = "https://mozilla.org") val tab = createTab(url = existingKey.url, historyMetadata = existingKey) - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) verify { service wasNot Called } - store.dispatch(ContentAction.UpdateUrlAction(tab.id, existingKey.url)).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tab.id, existingKey.url)) verify { service wasNot Called } } @@ -528,10 +527,10 @@ class HistoryMetadataMiddlewareTest { fun `GIVEN tab without metadata WHEN user navigates and new page starts loading THEN nothing happens`() { val tab = createTab(url = "https://mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) verify(exactly = 1) { service.createMetadata(tab) } - store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, true)) verify(exactly = 1) { service.createMetadata(any()) } verify(exactly = 0) { service.updateMetadata(any(), any()) } } @@ -542,13 +541,13 @@ class HistoryMetadataMiddlewareTest { val tab = createTab(url = "https://mozilla.org", historyMetadata = existingKey) val otherTab = createTab(url = "https://blog.mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(otherTab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) + store.dispatch(TabListAction.AddTabAction(otherTab, select = true)) val capturedTab = slot<TabSessionState>() verify(exactly = 1) { service.updateMetadata(existingKey, capture(capturedTab)) } assertEquals(tab.id, capturedTab.captured.id) - store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, true)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, true)) verify(exactly = 1) { service.updateMetadata(existingKey, capture(capturedTab)) } } @@ -559,7 +558,7 @@ class HistoryMetadataMiddlewareTest { val expectedKey = HistoryMetadataKey(url = tab.content.url) every { service.createMetadata(any(), any()) } returns expectedKey - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) val capturedTabs = mutableListOf<TabSessionState>() verify { service.createMetadata(capture(capturedTabs), null, null) @@ -568,7 +567,7 @@ class HistoryMetadataMiddlewareTest { assertNull(capturedTabs[0].historyMetadata) assertEquals(expectedKey, store.state.findTab(tab.id)?.historyMetadata) - store.dispatch(MediaSessionAction.UpdateMediaMetadataAction(tab.id, mockk())).joinBlocking() + store.dispatch(MediaSessionAction.UpdateMediaMetadataAction(tab.id, mockk())) verify { service.createMetadata(capture(capturedTabs), null, null) } @@ -586,10 +585,10 @@ class HistoryMetadataMiddlewareTest { val expectedKey = HistoryMetadataKey(url = tab.content.url) every { service.createMetadata(any(), any()) } returns expectedKey - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) verify { service wasNot Called } - store.dispatch(MediaSessionAction.UpdateMediaMetadataAction(tab.id, mockk())).joinBlocking() + store.dispatch(MediaSessionAction.UpdateMediaMetadataAction(tab.id, mockk())) verify { service wasNot Called } } @@ -600,12 +599,12 @@ class HistoryMetadataMiddlewareTest { val otherTab = createTab(url = "https://blog.mozilla.org") val yetAnotherTab = createTab(url = "https://media.mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(otherTab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) + store.dispatch(TabListAction.AddTabAction(otherTab)) verify(exactly = 1) { service.createMetadata(any()) } verify(exactly = 0) { service.updateMetadata(any(), any()) } - store.dispatch(TabListAction.AddTabAction(yetAnotherTab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(yetAnotherTab, select = true)) val capturedTab = slot<TabSessionState>() verify(exactly = 2) { service.createMetadata(any()) } verify(exactly = 1) { service.updateMetadata(existingKey, capture(capturedTab)) } @@ -619,12 +618,12 @@ class HistoryMetadataMiddlewareTest { val otherTab = createTab(url = "https://blog.mozilla.org") val yetAnotherTab = createTab(url = "https://media.mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) verify { service wasNot Called } - store.dispatch(TabListAction.AddTabAction(otherTab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(otherTab)) verify { service.createMetadata(otherTab) } - store.dispatch(TabListAction.AddTabAction(yetAnotherTab, select = true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(yetAnotherTab, select = true)) verify { service.createMetadata(yetAnotherTab) } } @@ -634,10 +633,10 @@ class HistoryMetadataMiddlewareTest { val tab = createTab(url = "https://mozilla.org", historyMetadata = existingKey) val otherTab = createTab(url = "https://blog.mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) verify { service wasNot Called } - store.dispatch(TabListAction.SelectTabAction(otherTab.id)).joinBlocking() + store.dispatch(TabListAction.SelectTabAction(otherTab.id)) val capturedTab = slot<TabSessionState>() verify(exactly = 1) { service.updateMetadata(existingKey, capture(capturedTab)) } assertEquals(tab.id, capturedTab.captured.id) @@ -649,10 +648,10 @@ class HistoryMetadataMiddlewareTest { val tab = createTab(url = "https://mozilla.org", historyMetadata = existingKey, private = true) val otherTab = createTab(url = "https://blog.mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) verify { service wasNot Called } - store.dispatch(TabListAction.SelectTabAction(otherTab.id)).joinBlocking() + store.dispatch(TabListAction.SelectTabAction(otherTab.id)) verify { service wasNot Called } } @@ -661,10 +660,10 @@ class HistoryMetadataMiddlewareTest { val existingKey = HistoryMetadataKey(url = "https://mozilla.org") val tab = createTab(url = "https://mozilla.org", historyMetadata = existingKey) - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) verify { service wasNot Called } - store.dispatch(TabListAction.RemoveTabAction(tab.id)).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction(tab.id)) val capturedTab = slot<TabSessionState>() verify(exactly = 1) { service.updateMetadata(existingKey, capture(capturedTab)) } assertEquals(tab.id, capturedTab.captured.id) @@ -675,10 +674,10 @@ class HistoryMetadataMiddlewareTest { val existingKey = HistoryMetadataKey(url = "https://mozilla.org") val tab = createTab(url = "https://mozilla.org", historyMetadata = existingKey, private = true) - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) verify { service wasNot Called } - store.dispatch(TabListAction.RemoveTabAction(tab.id)).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction(tab.id)) verify { service wasNot Called } } @@ -688,12 +687,12 @@ class HistoryMetadataMiddlewareTest { val tab = createTab(url = "https://mozilla.org", historyMetadata = existingKey) val otherTab = createTab(url = "https://blog.mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(otherTab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) + store.dispatch(TabListAction.AddTabAction(otherTab)) // 1 because 'tab' already has a metadata key set. verify(exactly = 1) { service.createMetadata(any()) } - store.dispatch(TabListAction.RemoveTabAction(otherTab.id)).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction(otherTab.id)) verify(exactly = 1) { service.createMetadata(any()) } } @@ -704,13 +703,13 @@ class HistoryMetadataMiddlewareTest { val otherTab = createTab(url = "https://blog.mozilla.org") val yetAnotherTab = createTab(url = "https://media.mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(otherTab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(yetAnotherTab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) + store.dispatch(TabListAction.AddTabAction(otherTab)) + store.dispatch(TabListAction.AddTabAction(yetAnotherTab)) // 'tab' already has an existing key, so metadata isn't created for it. verify(exactly = 2) { service.createMetadata(any()) } - store.dispatch(TabListAction.RemoveTabsAction(listOf(tab.id, otherTab.id))).joinBlocking() + store.dispatch(TabListAction.RemoveTabsAction(listOf(tab.id, otherTab.id))) val capturedTab = slot<TabSessionState>() verify(exactly = 1) { service.updateMetadata(existingKey, capture(capturedTab)) } assertEquals(tab.id, capturedTab.captured.id) @@ -723,13 +722,13 @@ class HistoryMetadataMiddlewareTest { val otherTab = createTab(url = "https://blog.mozilla.org") val yetAnotherTab = createTab(url = "https://media.mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) verify { service wasNot Called } - store.dispatch(TabListAction.AddTabAction(otherTab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(yetAnotherTab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(otherTab)) + store.dispatch(TabListAction.AddTabAction(yetAnotherTab)) verify(exactly = 2) { service.createMetadata(any()) } - store.dispatch(TabListAction.RemoveTabsAction(listOf(tab.id, otherTab.id))).joinBlocking() + store.dispatch(TabListAction.RemoveTabsAction(listOf(tab.id, otherTab.id))) verify(exactly = 2) { service.createMetadata(any()) } verify(exactly = 0) { service.updateMetadata(any(), any()) } } @@ -741,13 +740,13 @@ class HistoryMetadataMiddlewareTest { val otherTab = createTab(url = "https://blog.mozilla.org") val yetAnotherTab = createTab(url = "https://media.mozilla.org") - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(otherTab)).joinBlocking() - store.dispatch(TabListAction.AddTabAction(yetAnotherTab)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) + store.dispatch(TabListAction.AddTabAction(otherTab)) + store.dispatch(TabListAction.AddTabAction(yetAnotherTab)) verify(exactly = 2) { service.createMetadata(any()) } verify(exactly = 0) { service.updateMetadata(any(), any()) } - store.dispatch(TabListAction.RemoveTabsAction(listOf(otherTab.id, yetAnotherTab.id))).joinBlocking() + store.dispatch(TabListAction.RemoveTabsAction(listOf(otherTab.id, yetAnotherTab.id))) verify(exactly = 2) { service.createMetadata(any()) } verify(exactly = 0) { service.updateMetadata(any(), any()) } } @@ -774,7 +773,7 @@ class HistoryMetadataMiddlewareTest { additionalSearchEngines = emptyList(), regionSearchEnginesOrder = listOf("google"), ), - ).joinBlocking() + ) } // Provides a more convenient way of capturing arguments for the functions we care about. diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/toolbar/BrowserToolbarMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/toolbar/BrowserToolbarMiddlewareTest.kt @@ -48,7 +48,6 @@ import mozilla.components.compose.browser.toolbar.store.BrowserToolbarMenuItem.B import mozilla.components.compose.browser.toolbar.store.BrowserToolbarStore import mozilla.components.compose.browser.toolbar.store.EnvironmentCleared import mozilla.components.compose.browser.toolbar.store.EnvironmentRehydrated -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainLooperTestRule @@ -235,7 +234,7 @@ class BrowserToolbarMiddlewareTest { screenWidthDp = 700 } every { mockContext.resources.configuration } returns configuration - appStore.dispatch(AppAction.OrientationChange(Landscape)).joinBlocking() + appStore.dispatch(AppAction.OrientationChange(Landscape)) mainLooperRule.idle() navigationActions = toolbarStore.state.displayState.navigationActions @@ -342,7 +341,7 @@ class BrowserToolbarMiddlewareTest { screenWidthDp = 700 } every { mockContext.resources.configuration } returns configuration - appStore.dispatch(AppAction.OrientationChange(Landscape)).joinBlocking() + appStore.dispatch(AppAction.OrientationChange(Landscape)) mainLooperRule.idle() toolbarBrowserActions = toolbarStore.state.displayState.browserActionsEnd @@ -371,7 +370,7 @@ class BrowserToolbarMiddlewareTest { screenWidthDp = 400 } every { mockContext.resources.configuration } returns configuration - appStore.dispatch(AppAction.OrientationChange(Portrait)).joinBlocking() + appStore.dispatch(AppAction.OrientationChange(Portrait)) mainLooperRule.idle() toolbarBrowserActions = toolbarStore.state.displayState.browserActionsEnd @@ -404,7 +403,7 @@ class BrowserToolbarMiddlewareTest { screenWidthDp = 700 } every { mockContext.resources.configuration } returns configuration - appStore.dispatch(AppAction.OrientationChange(Portrait)).joinBlocking() + appStore.dispatch(AppAction.OrientationChange(Portrait)) mainLooperRule.idle() navigationActions = toolbarStore.state.displayState.navigationActions @@ -432,8 +431,8 @@ class BrowserToolbarMiddlewareTest { val newNormalTab = createTab("test.com", private = false) val newPrivateTab = createTab("test.com", private = true) - browserStore.dispatch(AddTabAction(newNormalTab)).joinBlocking() - browserStore.dispatch(AddTabAction(newPrivateTab)).joinBlocking() + browserStore.dispatch(AddTabAction(newNormalTab)) + browserStore.dispatch(AddTabAction(newPrivateTab)) mainLooperRule.idle() toolbarBrowserActions = toolbarStore.state.displayState.browserActionsEnd @@ -463,7 +462,7 @@ class BrowserToolbarMiddlewareTest { var tabCounterButton = toolbarBrowserActions[0] as TabCounterAction assertEqualsToolbarButton(expectedToolbarButton(1, true), tabCounterButton) - browserStore.dispatch(RemoveTabAction(initialPrivateTab.id)).joinBlocking() + browserStore.dispatch(RemoveTabAction(initialPrivateTab.id)) mainLooperRule.idle() toolbarBrowserActions = toolbarStore.state.displayState.browserActionsEnd @@ -674,7 +673,7 @@ class BrowserToolbarMiddlewareTest { val toolbarStore = buildStore(middleware) val newSearchEngine = SearchEngine("test", "Test", mock(), type = APPLICATION) - appStore.dispatch(SearchEngineSelected(newSearchEngine, true)).joinBlocking() + appStore.dispatch(SearchEngineSelected(newSearchEngine, true)) shadowOf(Looper.getMainLooper()).idle() // wait for observing and processing the search engine update assertSearchSelectorEquals( @@ -697,7 +696,7 @@ class BrowserToolbarMiddlewareTest { val middleware = BrowserToolbarMiddleware(appStore, browserStore, mockk(), mockk()) val toolbarStore = buildStore(middleware) - browserStore.dispatch(ApplicationSearchEnginesLoaded(listOf(otherSearchEngine))).joinBlocking() + browserStore.dispatch(ApplicationSearchEnginesLoaded(listOf(otherSearchEngine))) assertNotEquals( appStore.state.searchState.selectedSearchEngine?.searchEngine, @@ -771,7 +770,7 @@ class BrowserToolbarMiddlewareTest { AppAction.MenuNotification.AddMenuNotification( SupportedMenuNotifications.Downloads, ), - ).joinBlocking() + ) mainLooperRule.idle() val updatedMenuButton = toolbarStore.state.displayState.browserActionsEnd[1] as ActionButtonRes assertEquals(expectedMenuButton(true), updatedMenuButton) @@ -795,7 +794,7 @@ class BrowserToolbarMiddlewareTest { AppAction.MenuNotification.RemoveMenuNotification( SupportedMenuNotifications.Downloads, ), - ).joinBlocking() + ) mainLooperRule.idle() val updatedMenuButton = toolbarStore.state.displayState.browserActionsEnd[1] as ActionButtonRes assertEquals(expectedMenuButton(), updatedMenuButton) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/toolbar/BrowserToolbarTelemetryMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/toolbar/BrowserToolbarTelemetryMiddlewareTest.kt @@ -7,7 +7,6 @@ package org.mozilla.fenix.home.toolbar import androidx.test.ext.junit.runners.AndroidJUnit4 import mozilla.components.compose.browser.toolbar.store.BrowserToolbarInteraction.BrowserToolbarEvent.Source import mozilla.components.compose.browser.toolbar.store.BrowserToolbarStore -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull @@ -32,46 +31,46 @@ class BrowserToolbarTelemetryMiddlewareTest { @Test fun `WHEN menu button is clicked THEN record telemetry based on addressBar or navbar source`() { - buildStore.dispatch(MenuClicked(Source.AddressBar)).joinBlocking() + buildStore.dispatch(MenuClicked(Source.AddressBar)) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.MenuClicked.action) - buildStore.dispatch(MenuClicked(Source.NavigationBar)).joinBlocking() + buildStore.dispatch(MenuClicked(Source.NavigationBar)) assertTelemetryRecorded(Source.NavigationBar, item = ToolbarActionRecord.MenuClicked.action) } @Test fun `WHEN tab counter is clicked THEN record telemetry based on addressBar or navbar source`() { - buildStore.dispatch(TabCounterClicked(Source.AddressBar)).joinBlocking() + buildStore.dispatch(TabCounterClicked(Source.AddressBar)) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.TabCounterClicked.action) - buildStore.dispatch(TabCounterClicked(Source.NavigationBar)).joinBlocking() + buildStore.dispatch(TabCounterClicked(Source.NavigationBar)) assertTelemetryRecorded(Source.NavigationBar, item = ToolbarActionRecord.TabCounterClicked.action) } @Test fun `WHEN tab counter is long clicked THEN record telemetry based on addressBar or navbar source`() { - buildStore.dispatch(TabCounterLongClicked(Source.AddressBar)).joinBlocking() + buildStore.dispatch(TabCounterLongClicked(Source.AddressBar)) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.TabCounterLongClicked.action) - buildStore.dispatch(TabCounterLongClicked(Source.NavigationBar)).joinBlocking() + buildStore.dispatch(TabCounterLongClicked(Source.NavigationBar)) assertTelemetryRecorded(Source.NavigationBar, item = ToolbarActionRecord.TabCounterLongClicked.action) } @Test fun `WHEN adding a new tab THEN record telemetry based on addressBar or navbar source`() { - buildStore.dispatch(AddNewTab(Source.AddressBar)).joinBlocking() + buildStore.dispatch(AddNewTab(Source.AddressBar)) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.AddNewTab.action) - buildStore.dispatch(AddNewTab(Source.NavigationBar)).joinBlocking() + buildStore.dispatch(AddNewTab(Source.NavigationBar)) assertTelemetryRecorded(Source.NavigationBar, item = ToolbarActionRecord.AddNewTab.action) } @Test fun `WHEN adding a new private tab THEN record telemetry based on addressBar or navbar source`() { - buildStore.dispatch(AddNewPrivateTab(Source.AddressBar)).joinBlocking() + buildStore.dispatch(AddNewPrivateTab(Source.AddressBar)) assertTelemetryRecorded(Source.AddressBar, item = ToolbarActionRecord.AddNewPrivateTab.action) - buildStore.dispatch(AddNewPrivateTab(Source.NavigationBar)).joinBlocking() + buildStore.dispatch(AddNewPrivateTab(Source.NavigationBar)) assertTelemetryRecorded(Source.NavigationBar, item = ToolbarActionRecord.AddNewPrivateTab.action) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/topsites/controller/DefaultTopSiteControllerTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/home/topsites/controller/DefaultTopSiteControllerTest.kt @@ -406,7 +406,7 @@ class DefaultTopSiteControllerTest { every { controller.getAvailableSearchEngines() } returns listOf(searchEngine) - store.dispatch(SearchAction.SetRegionAction(RegionState("US", "US"))).joinBlocking() + store.dispatch(SearchAction.SetRegionAction(RegionState("US", "US"))) controller.handleSelectTopSite(topSite, position = 0) @@ -444,7 +444,7 @@ class DefaultTopSiteControllerTest { every { controller.getAvailableSearchEngines() } returns listOf(searchEngine) - store.dispatch(SearchAction.SetRegionAction(RegionState("DE", "FR"))).joinBlocking() + store.dispatch(SearchAction.SetRegionAction(RegionState("DE", "FR"))) controller.handleSelectTopSite(topSite, position = 0) @@ -531,7 +531,7 @@ class DefaultTopSiteControllerTest { every { controller.getAvailableSearchEngines() } returns listOf(searchEngine) - store.dispatch(SearchAction.SetRegionAction(RegionState("US", "US"))).joinBlocking() + store.dispatch(SearchAction.SetRegionAction(RegionState("US", "US"))) controller.handleSelectTopSite(topSite, position = 0) @@ -569,7 +569,7 @@ class DefaultTopSiteControllerTest { every { controller.getAvailableSearchEngines() } returns listOf(searchEngine) - store.dispatch(SearchAction.SetRegionAction(RegionState("DE", "FR"))).joinBlocking() + store.dispatch(SearchAction.SetRegionAction(RegionState("DE", "FR"))) controller.handleSelectTopSite(topSite, position = 0) @@ -607,7 +607,7 @@ class DefaultTopSiteControllerTest { every { controller.getAvailableSearchEngines() } returns listOf(searchEngine) - store.dispatch(SearchAction.SetRegionAction(RegionState("US", "US"))).joinBlocking() + store.dispatch(SearchAction.SetRegionAction(RegionState("US", "US"))) controller.handleSelectTopSite(topSite, position = 0) @@ -645,7 +645,7 @@ class DefaultTopSiteControllerTest { every { controller.getAvailableSearchEngines() } returns listOf(searchEngine) - store.dispatch(SearchAction.SetRegionAction(RegionState("DE", "FR"))).joinBlocking() + store.dispatch(SearchAction.SetRegionAction(RegionState("DE", "FR"))) controller.handleSelectTopSite(topSite, position = 0) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/library/history/HistoryFragmentStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/library/history/HistoryFragmentStoreTest.kt @@ -5,7 +5,6 @@ package org.mozilla.fenix.library.history import kotlinx.coroutines.test.runTest -import mozilla.components.support.test.ext.joinBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertNotSame @@ -22,7 +21,7 @@ class HistoryFragmentStoreTest { val initialState = oneItemEditState() val store = HistoryFragmentStore(initialState) - store.dispatch(HistoryFragmentAction.ExitEditMode).join() + store.dispatch(HistoryFragmentAction.ExitEditMode) assertNotSame(initialState, store.state) assertEquals(store.state.mode, HistoryFragmentState.Mode.Normal) } @@ -32,7 +31,7 @@ class HistoryFragmentStoreTest { val initialState = emptyDefaultState() val store = HistoryFragmentStore(initialState) - store.dispatch(HistoryFragmentAction.AddItemForRemoval(newHistoryItem)).join() + store.dispatch(HistoryFragmentAction.AddItemForRemoval(newHistoryItem)) assertNotSame(initialState, store.state) assertEquals( store.state.mode, @@ -45,7 +44,7 @@ class HistoryFragmentStoreTest { val initialState = twoItemEditState() val store = HistoryFragmentStore(initialState) - store.dispatch(HistoryFragmentAction.RemoveItemForRemoval(newHistoryItem)).join() + store.dispatch(HistoryFragmentAction.RemoveItemForRemoval(newHistoryItem)) assertNotSame(initialState, store.state) assertEquals(store.state.mode, HistoryFragmentState.Mode.Editing(setOf(historyItem))) } @@ -55,7 +54,7 @@ class HistoryFragmentStoreTest { val initialState = emptyDefaultState() val store = HistoryFragmentStore(initialState) - store.dispatch(HistoryFragmentAction.StartSync).join() + store.dispatch(HistoryFragmentAction.StartSync) assertNotSame(initialState, store.state) assertEquals(HistoryFragmentState.Mode.Syncing, store.state.mode) } @@ -72,7 +71,7 @@ class HistoryFragmentStoreTest { ) val store = HistoryFragmentStore(initialState) - store.dispatch(HistoryFragmentAction.FinishSync).join() + store.dispatch(HistoryFragmentAction.FinishSync) assertNotSame(initialState, store.state) assertEquals(HistoryFragmentState.Mode.Normal, store.state.mode) } @@ -82,11 +81,11 @@ class HistoryFragmentStoreTest { val initialState = emptyDefaultState() val store = HistoryFragmentStore(initialState) - store.dispatch(HistoryFragmentAction.ChangeEmptyState(true)).join() + store.dispatch(HistoryFragmentAction.ChangeEmptyState(true)) assertNotSame(initialState, store.state) assertTrue(store.state.isEmpty) - store.dispatch(HistoryFragmentAction.ChangeEmptyState(false)).join() + store.dispatch(HistoryFragmentAction.ChangeEmptyState(false)) assertNotSame(initialState, store.state) assertFalse(store.state.isEmpty) } @@ -96,11 +95,11 @@ class HistoryFragmentStoreTest { val initialState = emptyDefaultState() val store = HistoryFragmentStore(initialState) - store.dispatch(HistoryFragmentAction.UpdatePendingDeletionItems(setOf(pendingDeletionItem))).join() + store.dispatch(HistoryFragmentAction.UpdatePendingDeletionItems(setOf(pendingDeletionItem))) assertNotSame(initialState, store.state) assertEquals(setOf(pendingDeletionItem), store.state.pendingDeletionItems) - store.dispatch(HistoryFragmentAction.UpdatePendingDeletionItems(emptySet())).join() + store.dispatch(HistoryFragmentAction.UpdatePendingDeletionItems(emptySet())) assertNotSame(initialState, store.state) assertEquals(emptySet<PendingDeletionHistory>(), store.state.pendingDeletionItems) } @@ -109,7 +108,7 @@ class HistoryFragmentStoreTest { fun `GIVEN items have been selected WHEN selected item is clicked THEN item is unselected`() = runTest { val store = HistoryFragmentStore(twoItemEditState()) - store.dispatch(HistoryFragmentAction.HistoryItemClicked(historyItem)).joinBlocking() + store.dispatch(HistoryFragmentAction.HistoryItemClicked(historyItem)) assertEquals(1, store.state.mode.selectedItems.size) assertEquals(newHistoryItem, store.state.mode.selectedItems.first()) @@ -120,7 +119,7 @@ class HistoryFragmentStoreTest { val initialState = oneItemEditState().copy(items = listOf(newHistoryItem)) val store = HistoryFragmentStore(initialState) - store.dispatch(HistoryFragmentAction.HistoryItemClicked(newHistoryItem)).joinBlocking() + store.dispatch(HistoryFragmentAction.HistoryItemClicked(newHistoryItem)) assertEquals(2, store.state.mode.selectedItems.size) assertTrue(store.state.mode.selectedItems.contains(newHistoryItem)) @@ -130,7 +129,7 @@ class HistoryFragmentStoreTest { fun `GIVEN items have been selected WHEN last selected item is clicked THEN editing mode is exited`() { val store = HistoryFragmentStore(oneItemEditState()) - store.dispatch(HistoryFragmentAction.HistoryItemClicked(historyItem)).joinBlocking() + store.dispatch(HistoryFragmentAction.HistoryItemClicked(historyItem)) assertEquals(0, store.state.mode.selectedItems.size) assertTrue(store.state.mode is HistoryFragmentState.Mode.Normal) @@ -140,7 +139,7 @@ class HistoryFragmentStoreTest { fun `GIVEN items have not been selected WHEN item is clicked THEN state is unchanged`() { val store = HistoryFragmentStore(emptyDefaultState()) - store.dispatch(HistoryFragmentAction.HistoryItemClicked(historyItem)).joinBlocking() + store.dispatch(HistoryFragmentAction.HistoryItemClicked(historyItem)) assertEquals(0, store.state.mode.selectedItems.size) assertTrue(store.state.mode is HistoryFragmentState.Mode.Normal) @@ -150,7 +149,7 @@ class HistoryFragmentStoreTest { fun `GIVEN mode is syncing WHEN item is clicked THEN state is unchanged`() { val store = HistoryFragmentStore(emptyDefaultState().copy(mode = HistoryFragmentState.Mode.Syncing)) - store.dispatch(HistoryFragmentAction.HistoryItemClicked(historyItem)).joinBlocking() + store.dispatch(HistoryFragmentAction.HistoryItemClicked(historyItem)) assertEquals(0, store.state.mode.selectedItems.size) assertTrue(store.state.mode is HistoryFragmentState.Mode.Syncing) @@ -160,7 +159,7 @@ class HistoryFragmentStoreTest { fun `GIVEN mode is syncing WHEN item is long-clicked THEN state is unchanged`() { val store = HistoryFragmentStore(emptyDefaultState().copy(mode = HistoryFragmentState.Mode.Syncing)) - store.dispatch(HistoryFragmentAction.HistoryItemLongClicked(historyItem)).joinBlocking() + store.dispatch(HistoryFragmentAction.HistoryItemLongClicked(historyItem)) assertEquals(0, store.state.mode.selectedItems.size) assertTrue(store.state.mode is HistoryFragmentState.Mode.Syncing) @@ -170,7 +169,7 @@ class HistoryFragmentStoreTest { fun `GIVEN mode is not syncing WHEN item is long-clicked THEN mode becomes editing`() { val store = HistoryFragmentStore(oneItemEditState()) - store.dispatch(HistoryFragmentAction.HistoryItemLongClicked(newHistoryItem)).joinBlocking() + store.dispatch(HistoryFragmentAction.HistoryItemLongClicked(newHistoryItem)) assertEquals(2, store.state.mode.selectedItems.size) assertTrue(store.state.mode.selectedItems.contains(newHistoryItem)) @@ -180,7 +179,7 @@ class HistoryFragmentStoreTest { fun `GIVEN mode is not syncing WHEN item is long-clicked THEN item is selected`() { val store = HistoryFragmentStore(emptyDefaultState()) - store.dispatch(HistoryFragmentAction.HistoryItemLongClicked(historyItem)).joinBlocking() + store.dispatch(HistoryFragmentAction.HistoryItemLongClicked(historyItem)) assertEquals(1, store.state.mode.selectedItems.size) assertTrue(store.state.mode.selectedItems.contains(historyItem)) @@ -196,7 +195,7 @@ class HistoryFragmentStoreTest { ), ) - store.dispatch(HistoryFragmentAction.BackPressed).joinBlocking() + store.dispatch(HistoryFragmentAction.BackPressed) assertEquals(HistoryFragmentState.Mode.Normal, store.state.mode) } @@ -205,7 +204,7 @@ class HistoryFragmentStoreTest { fun `GIVEN mode is not editing WHEN back pressed THEN does not change`() { val store = HistoryFragmentStore(emptyDefaultState().copy(mode = HistoryFragmentState.Mode.Syncing)) - store.dispatch(HistoryFragmentAction.BackPressed).joinBlocking() + store.dispatch(HistoryFragmentAction.BackPressed) assertEquals(HistoryFragmentState.Mode.Syncing, store.state.mode) } @@ -214,7 +213,7 @@ class HistoryFragmentStoreTest { fun `WHEN search is clicked THEN update state`() { val store = HistoryFragmentStore(emptyDefaultState().copy(isSearching = true)) - store.dispatch(HistoryFragmentAction.SearchClicked).joinBlocking() + store.dispatch(HistoryFragmentAction.SearchClicked) assertTrue(store.state.isSearching) } @@ -223,7 +222,7 @@ class HistoryFragmentStoreTest { fun `WHEN search is dismissed THEN update state`() { val store = HistoryFragmentStore(emptyDefaultState().copy(isSearching = false)) - store.dispatch(HistoryFragmentAction.SearchDismissed).joinBlocking() + store.dispatch(HistoryFragmentAction.SearchDismissed) assertFalse(store.state.isSearching) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/library/history/state/HistoryTelemetryMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/library/history/state/HistoryTelemetryMiddlewareTest.kt @@ -4,7 +4,6 @@ package org.mozilla.fenix.library.history.state -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertNotNull import org.junit.Assert.assertNull @@ -36,7 +35,7 @@ class HistoryTelemetryMiddlewareTest { middleware = listOf(middleware), ) - store.dispatch(HistoryFragmentAction.HistoryItemClicked(history)).joinBlocking() + store.dispatch(HistoryFragmentAction.HistoryItemClicked(history)) assertNotNull(GleanHistory.openedItem.testGetValue()) } @@ -52,7 +51,7 @@ class HistoryTelemetryMiddlewareTest { middleware = listOf(middleware), ) - store.dispatch(HistoryFragmentAction.HistoryItemClicked(history)).joinBlocking() + store.dispatch(HistoryFragmentAction.HistoryItemClicked(history)) assertNull(GleanHistory.openedItem.testGetValue()) } @@ -63,7 +62,7 @@ class HistoryTelemetryMiddlewareTest { val store = HistoryFragmentStore(HistoryFragmentState.initial, middleware = listOf(middleware)) - store.dispatch(HistoryFragmentAction.HistoryItemClicked(history)).joinBlocking() + store.dispatch(HistoryFragmentAction.HistoryItemClicked(history)) assertNotNull(GleanHistory.searchTermGroupTapped.testGetValue()) } @@ -74,7 +73,7 @@ class HistoryTelemetryMiddlewareTest { val store = HistoryFragmentStore(HistoryFragmentState.initial, middleware = listOf(middleware)) - store.dispatch(HistoryFragmentAction.DeleteItems(setOf(history))).joinBlocking() + store.dispatch(HistoryFragmentAction.DeleteItems(setOf(history))) assertNotNull(GleanHistory.removed.testGetValue()) } @@ -84,7 +83,7 @@ class HistoryTelemetryMiddlewareTest { val store = HistoryFragmentStore(HistoryFragmentState.initial, middleware = listOf(middleware)) - store.dispatch(HistoryFragmentAction.DeleteTimeRange(RemoveTimeFrame.LastHour)).joinBlocking() + store.dispatch(HistoryFragmentAction.DeleteTimeRange(RemoveTimeFrame.LastHour)) assertNotNull(GleanHistory.removedLastHour.testGetValue()) } @@ -94,7 +93,7 @@ class HistoryTelemetryMiddlewareTest { val store = HistoryFragmentStore(HistoryFragmentState.initial, middleware = listOf(middleware)) - store.dispatch(HistoryFragmentAction.DeleteTimeRange(RemoveTimeFrame.TodayAndYesterday)).joinBlocking() + store.dispatch(HistoryFragmentAction.DeleteTimeRange(RemoveTimeFrame.TodayAndYesterday)) assertNotNull(GleanHistory.removedTodayAndYesterday.testGetValue()) } @@ -104,7 +103,7 @@ class HistoryTelemetryMiddlewareTest { val store = HistoryFragmentStore(HistoryFragmentState.initial, middleware = listOf(middleware)) - store.dispatch(HistoryFragmentAction.DeleteTimeRange(null)).joinBlocking() + store.dispatch(HistoryFragmentAction.DeleteTimeRange(null)) assertNotNull(GleanHistory.removedAll.testGetValue()) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/library/history/state/bindings/MenuBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/library/history/state/bindings/MenuBindingTest.kt @@ -4,7 +4,6 @@ package org.mozilla.fenix.library.history.state.bindings -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertTrue import org.junit.Rule @@ -27,7 +26,7 @@ class MenuBindingTest { ) binding.start() - store.dispatch(HistoryFragmentAction.FinishSync).joinBlocking() + store.dispatch(HistoryFragmentAction.FinishSync) assertTrue(menuInvalidated) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/library/historymetadata/HistoryMetadataGroupFragmentStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/library/historymetadata/HistoryMetadataGroupFragmentStoreTest.kt @@ -56,7 +56,7 @@ class HistoryMetadataGroupFragmentStoreTest { assertEquals(0, store.state.items.size) val items = listOf(mozillaHistoryMetadataItem, firefoxHistoryMetadataItem) - store.dispatch(HistoryMetadataGroupFragmentAction.UpdateHistoryItems(items)).join() + store.dispatch(HistoryMetadataGroupFragmentAction.UpdateHistoryItems(items)) assertEquals(items, store.state.items) } @@ -65,17 +65,17 @@ class HistoryMetadataGroupFragmentStoreTest { fun `Test selecting and deselecting an item in HistoryMetadataGroupFragmentStore`() = runTest { val items = listOf(mozillaHistoryMetadataItem, firefoxHistoryMetadataItem) - store.dispatch(HistoryMetadataGroupFragmentAction.UpdateHistoryItems(items)).join() + store.dispatch(HistoryMetadataGroupFragmentAction.UpdateHistoryItems(items)) assertFalse(store.state.items[0].selected) assertFalse(store.state.items[1].selected) - store.dispatch(HistoryMetadataGroupFragmentAction.Select(mozillaHistoryMetadataItem)).join() + store.dispatch(HistoryMetadataGroupFragmentAction.Select(mozillaHistoryMetadataItem)) assertTrue(store.state.items[0].selected) assertFalse(store.state.items[1].selected) - store.dispatch(HistoryMetadataGroupFragmentAction.Deselect(store.state.items[0])).join() + store.dispatch(HistoryMetadataGroupFragmentAction.Deselect(store.state.items[0])) assertFalse(store.state.items[0].selected) assertFalse(store.state.items[1].selected) @@ -85,9 +85,9 @@ class HistoryMetadataGroupFragmentStoreTest { fun `Test deselecting all items in HistoryMetadataGroupFragmentStore`() = runTest { val items = listOf(mozillaHistoryMetadataItem, firefoxHistoryMetadataItem) - store.dispatch(HistoryMetadataGroupFragmentAction.UpdateHistoryItems(items)).join() - store.dispatch(HistoryMetadataGroupFragmentAction.Select(mozillaHistoryMetadataItem)).join() - store.dispatch(HistoryMetadataGroupFragmentAction.DeselectAll).join() + store.dispatch(HistoryMetadataGroupFragmentAction.UpdateHistoryItems(items)) + store.dispatch(HistoryMetadataGroupFragmentAction.Select(mozillaHistoryMetadataItem)) + store.dispatch(HistoryMetadataGroupFragmentAction.DeselectAll) assertFalse(store.state.items[0].selected) assertFalse(store.state.items[1].selected) @@ -97,8 +97,8 @@ class HistoryMetadataGroupFragmentStoreTest { fun `Test deleting an item in HistoryMetadataGroupFragmentStore`() = runTest { val items = listOf(mozillaHistoryMetadataItem, firefoxHistoryMetadataItem) - store.dispatch(HistoryMetadataGroupFragmentAction.UpdateHistoryItems(items)).join() - store.dispatch(HistoryMetadataGroupFragmentAction.Delete(mozillaHistoryMetadataItem)).join() + store.dispatch(HistoryMetadataGroupFragmentAction.UpdateHistoryItems(items)) + store.dispatch(HistoryMetadataGroupFragmentAction.Delete(mozillaHistoryMetadataItem)) assertEquals(1, store.state.items.size) assertEquals(firefoxHistoryMetadataItem, store.state.items.first()) @@ -108,27 +108,27 @@ class HistoryMetadataGroupFragmentStoreTest { fun `Test deleting all items in HistoryMetadataGroupFragmentStore`() = runTest { val items = listOf(mozillaHistoryMetadataItem, firefoxHistoryMetadataItem) - store.dispatch(HistoryMetadataGroupFragmentAction.UpdateHistoryItems(items)).join() - store.dispatch(HistoryMetadataGroupFragmentAction.DeleteAll).join() + store.dispatch(HistoryMetadataGroupFragmentAction.UpdateHistoryItems(items)) + store.dispatch(HistoryMetadataGroupFragmentAction.DeleteAll) assertEquals(0, store.state.items.size) } @Test fun `Test changing the empty state of HistoryMetadataGroupFragmentStore`() = runTest { - store.dispatch(HistoryMetadataGroupFragmentAction.ChangeEmptyState(false)).join() + store.dispatch(HistoryMetadataGroupFragmentAction.ChangeEmptyState(false)) assertFalse(store.state.isEmpty) - store.dispatch(HistoryMetadataGroupFragmentAction.ChangeEmptyState(true)).join() + store.dispatch(HistoryMetadataGroupFragmentAction.ChangeEmptyState(true)) assertTrue(store.state.isEmpty) } @Test fun `Test updating pending deletion items in HistoryMetadataGroupFragmentStore`() = runTest { - store.dispatch(HistoryMetadataGroupFragmentAction.UpdatePendingDeletionItems(setOf(pendingDeletionItem))).join() + store.dispatch(HistoryMetadataGroupFragmentAction.UpdatePendingDeletionItems(setOf(pendingDeletionItem))) assertEquals(setOf(pendingDeletionItem), store.state.pendingDeletionItems) - store.dispatch(HistoryMetadataGroupFragmentAction.UpdatePendingDeletionItems(setOf())).join() + store.dispatch(HistoryMetadataGroupFragmentAction.UpdatePendingDeletionItems(setOf())) assertEquals(emptySet<PendingDeletionHistory>(), store.state.pendingDeletionItems) } } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/messaging/state/MessagingMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/messaging/state/MessagingMiddlewareTest.kt @@ -15,8 +15,6 @@ import mozilla.components.service.nimbus.messaging.Message import mozilla.components.service.nimbus.messaging.MessageData import mozilla.components.service.nimbus.messaging.NimbusMessagingController import mozilla.components.service.nimbus.messaging.StyleData -import mozilla.components.support.test.ext.joinBlocking -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 @@ -68,8 +66,7 @@ class MessagingMiddlewareTest { coEvery { controller.getMessages() } returns listOf(message) - store.dispatch(Restore).joinBlocking() - store.waitUntilIdle() + store.dispatch(Restore) coroutineScope.advanceUntilIdle() assertEquals(listOf(message), store.state.messaging.messages) @@ -100,8 +97,7 @@ class MessagingMiddlewareTest { assertEquals(0, store.state.messaging.messageToShow.size) - store.dispatch(Evaluate(FenixMessageSurfaceId.HOMESCREEN)).joinBlocking() - store.waitUntilIdle() + store.dispatch(Evaluate(FenixMessageSurfaceId.HOMESCREEN)) // UpdateMessageToShow to causes messageToShow to append assertEquals(1, store.state.messaging.messageToShow.size) @@ -123,8 +119,7 @@ class MessagingMiddlewareTest { assertEquals(message, store.state.messaging.messages.first()) - store.dispatch(MessageClicked(message)).joinBlocking() - store.waitUntilIdle() + store.dispatch(MessageClicked(message)) assertTrue(store.state.messaging.messages.isEmpty()) coVerify { controller.onMessageClicked(message = message) } @@ -148,8 +143,7 @@ class MessagingMiddlewareTest { assertEquals(message, store.state.messaging.messages.first()) - store.dispatch(MicrosurveyAction.Started(message.id)).joinBlocking() - store.waitUntilIdle() + store.dispatch(MicrosurveyAction.Started(message.id)) assertFalse(store.state.messaging.messages.isEmpty()) coVerify { controller.onMicrosurveyStarted(id = message.id) } @@ -169,8 +163,7 @@ class MessagingMiddlewareTest { MessagingMiddleware(controller, settings, coroutineScope), ), ) - store.dispatch(MessageDismissed(message)).joinBlocking() - store.waitUntilIdle() + store.dispatch(MessageDismissed(message)) assertTrue(store.state.messaging.messages.isEmpty()) coVerify { controller.onMessageDismissed(message = message) } @@ -190,8 +183,7 @@ class MessagingMiddlewareTest { MessagingMiddleware(controller, settings, coroutineScope), ), ) - store.dispatch(Dismissed(message.id)).joinBlocking() - store.waitUntilIdle() + store.dispatch(Dismissed(message.id)) assertTrue(store.state.messaging.messages.isEmpty()) coVerify { controller.onMicrosurveyDismissed(message = message) } @@ -216,8 +208,6 @@ class MessagingMiddlewareTest { assertEquals(message, store.state.messaging.messages.first()) store.dispatch(AppAction.MessagingAction.MicrosurveyAction.Shown(message.id)) - .joinBlocking() - store.waitUntilIdle() assertFalse(store.state.messaging.messages.isEmpty()) coVerify { controller.onMicrosurveyShown(id = message.id) } @@ -242,8 +232,6 @@ class MessagingMiddlewareTest { assertEquals(message, store.state.messaging.messages.first()) store.dispatch(AppAction.MessagingAction.MicrosurveyAction.SentConfirmationShown(message.id)) - .joinBlocking() - store.waitUntilIdle() assertFalse(store.state.messaging.messages.isEmpty()) coVerify { controller.onMicrosurveySentConfirmationShown(id = message.id) } @@ -268,8 +256,6 @@ class MessagingMiddlewareTest { assertEquals(message, store.state.messaging.messages.first()) store.dispatch(AppAction.MessagingAction.MicrosurveyAction.OnPrivacyNoticeTapped(message.id)) - .joinBlocking() - store.waitUntilIdle() assertFalse(store.state.messaging.messages.isEmpty()) coVerify { controller.onMicrosurveyPrivacyNoticeTapped(id = message.id) } @@ -292,8 +278,7 @@ class MessagingMiddlewareTest { ), ) - store.dispatch(MessageDismissed(message)).joinBlocking() - store.waitUntilIdle() + store.dispatch(MessageDismissed(message)) // removeMessages causes messages size to be 0 assertEquals(0, store.state.messaging.messages.size) @@ -318,8 +303,7 @@ class MessagingMiddlewareTest { ), ) - store.dispatch(Dismissed(message.id)).joinBlocking() - store.waitUntilIdle() + store.dispatch(Dismissed(message.id)) // removeMessages causes messages size to be 0 assertEquals(0, store.state.messaging.messages.size) @@ -344,8 +328,7 @@ class MessagingMiddlewareTest { ), ) - store.dispatch(MessageClicked(message)).joinBlocking() - store.waitUntilIdle() + store.dispatch(MessageClicked(message)) assertTrue(store.state.messaging.messages.isEmpty()) assertTrue(store.state.messaging.messageToShow.isEmpty()) @@ -379,8 +362,7 @@ class MessagingMiddlewareTest { controller.onMessageDisplayed(eq(message), any()) } returns messageDisplayed - store.dispatch(Evaluate(FenixMessageSurfaceId.HOMESCREEN)).joinBlocking() - store.waitUntilIdle() + store.dispatch(Evaluate(FenixMessageSurfaceId.HOMESCREEN)) assertEquals(1, store.state.messaging.messages.count()) assertEquals(1, store.state.messaging.messages.first().displayCount) @@ -420,8 +402,7 @@ class MessagingMiddlewareTest { controller.onMessageDisplayed(eq(message1), any()) } returns messageDisplayed1 - store.dispatch(Evaluate(FenixMessageSurfaceId.HOMESCREEN)).joinBlocking() - store.waitUntilIdle() + store.dispatch(Evaluate(FenixMessageSurfaceId.HOMESCREEN)) assertEquals(messageDisplayed1, store.state.messaging.messages[0]) assertEquals(message2, store.state.messaging.messages[1]) @@ -459,8 +440,7 @@ class MessagingMiddlewareTest { controller.onMessageDisplayed(eq(message), any()) } returns messageDisplayed - store.dispatch(Evaluate(FenixMessageSurfaceId.HOMESCREEN)).joinBlocking() - store.waitUntilIdle() + store.dispatch(Evaluate(FenixMessageSurfaceId.HOMESCREEN)) assertEquals(messageDisplayed.displayCount, store.state.messaging.messages[0].displayCount) assertEquals(1, store.state.messaging.messages.size) @@ -502,8 +482,7 @@ class MessagingMiddlewareTest { controller.onMessageDisplayed(eq(message), any()) } returns messageDisplayed - store.dispatch(Evaluate(FenixMessageSurfaceId.HOMESCREEN)).joinBlocking() - store.waitUntilIdle() + store.dispatch(Evaluate(FenixMessageSurfaceId.HOMESCREEN)) assertEquals(0, store.state.messaging.messages.size) assertEquals(1, store.state.messaging.messageToShow.size) @@ -535,8 +514,7 @@ class MessagingMiddlewareTest { ) coEvery { controller.onMessageDisplayed(eq(message), any()) } returns messageDisplayed - store.dispatch(Evaluate(FenixMessageSurfaceId.MICROSURVEY)).joinBlocking() - store.waitUntilIdle() + store.dispatch(Evaluate(FenixMessageSurfaceId.MICROSURVEY)) verify { settings.shouldShowMicrosurveyPrompt = false } assertEquals(0, store.state.messaging.messages.size) @@ -571,8 +549,7 @@ class MessagingMiddlewareTest { controller.onMessageDisplayed(eq(message), any()) } returns message2 - store.dispatch(Evaluate(FenixMessageSurfaceId.HOMESCREEN)).joinBlocking() - store.waitUntilIdle() + store.dispatch(Evaluate(FenixMessageSurfaceId.HOMESCREEN)) assertEquals(1, store.state.messaging.messages.count()) assertEquals(message, store.state.messaging.messages.first()) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/nimbus/NimbusBranchesStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/nimbus/NimbusBranchesStoreTest.kt @@ -32,7 +32,6 @@ class NimbusBranchesStoreTest { val selectedBranch = "control" nimbusBranchesStore.dispatch(NimbusBranchesAction.UpdateBranches(branches, selectedBranch)) - .join() assertEquals(branches, nimbusBranchesStore.state.branches) assertEquals(selectedBranch, nimbusBranchesStore.state.selectedBranch) @@ -45,7 +44,7 @@ class NimbusBranchesStoreTest { val selectedBranch = "control" - nimbusBranchesStore.dispatch(NimbusBranchesAction.UpdateSelectedBranch(selectedBranch)).join() + nimbusBranchesStore.dispatch(NimbusBranchesAction.UpdateSelectedBranch(selectedBranch)) assertEquals(selectedBranch, nimbusBranchesStore.state.selectedBranch) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/onboarding/store/OnboardingStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/onboarding/store/OnboardingStoreTest.kt @@ -1,6 +1,5 @@ package org.mozilla.fenix.onboarding.store -import mozilla.components.support.test.ext.joinBlocking import org.junit.Assert.assertEquals import org.junit.Test import org.mozilla.fenix.onboarding.view.ThemeOptionType @@ -12,7 +11,7 @@ class OnboardingStoreTest { fun `WHEN init action is dispatched THEN state is updated as expected`() { val store = OnboardingStore() - store.dispatch(OnboardingAction.Init).joinBlocking() + store.dispatch(OnboardingAction.Init) val expected = OnboardingState( toolbarOptionSelected = ToolbarOptionType.TOOLBAR_TOP, @@ -25,11 +24,11 @@ class OnboardingStoreTest { val store = OnboardingStore() store.dispatch(OnboardingAction.OnboardingToolbarAction.UpdateSelected(ToolbarOptionType.TOOLBAR_BOTTOM)) - .joinBlocking() + assertEquals(ToolbarOptionType.TOOLBAR_BOTTOM, store.state.toolbarOptionSelected) store.dispatch(OnboardingAction.OnboardingToolbarAction.UpdateSelected(ToolbarOptionType.TOOLBAR_TOP)) - .joinBlocking() + assertEquals(ToolbarOptionType.TOOLBAR_TOP, store.state.toolbarOptionSelected) } @@ -38,15 +37,15 @@ class OnboardingStoreTest { val store = OnboardingStore() store.dispatch(OnboardingAction.OnboardingThemeAction.UpdateSelected(ThemeOptionType.THEME_SYSTEM)) - .joinBlocking() + assertEquals(ThemeOptionType.THEME_SYSTEM, store.state.themeOptionSelected) store.dispatch(OnboardingAction.OnboardingThemeAction.UpdateSelected(ThemeOptionType.THEME_LIGHT)) - .joinBlocking() + assertEquals(ThemeOptionType.THEME_LIGHT, store.state.themeOptionSelected) store.dispatch(OnboardingAction.OnboardingThemeAction.UpdateSelected(ThemeOptionType.THEME_DARK)) - .joinBlocking() + assertEquals(ThemeOptionType.THEME_DARK, store.state.themeOptionSelected) } } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/onboarding/store/PrivacyPreferencesStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/onboarding/store/PrivacyPreferencesStoreTest.kt @@ -5,8 +5,6 @@ package org.mozilla.fenix.onboarding.store import androidx.test.ext.junit.runners.AndroidJUnit4 -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -20,7 +18,7 @@ class PrivacyPreferencesStoreTest { fun `WHEN the init action is dispatched THEN the state remains the same`() { val state = PrivacyPreferencesState() val store = PrivacyPreferencesStore(initialState = state) - safeDispatch(store, PrivacyPreferencesAction.Init) + store.dispatch(PrivacyPreferencesAction.Init) assertEquals(state, store.state) assertFalse(state.crashReportingEnabled) assertTrue(state.usageDataEnabled) @@ -31,10 +29,10 @@ class PrivacyPreferencesStoreTest { val store = PrivacyPreferencesStore(initialState = PrivacyPreferencesState()) assertFalse(store.state.crashReportingEnabled) - safeDispatch(store, PrivacyPreferencesAction.CrashReportingPreferenceUpdatedTo(true)) + store.dispatch(PrivacyPreferencesAction.CrashReportingPreferenceUpdatedTo(true)) assertTrue(store.state.crashReportingEnabled) - safeDispatch(store, PrivacyPreferencesAction.CrashReportingPreferenceUpdatedTo(false)) + store.dispatch(PrivacyPreferencesAction.CrashReportingPreferenceUpdatedTo(false)) assertFalse(store.state.crashReportingEnabled) } @@ -43,10 +41,10 @@ class PrivacyPreferencesStoreTest { val store = PrivacyPreferencesStore(initialState = PrivacyPreferencesState()) assertTrue(store.state.usageDataEnabled) - safeDispatch(store, PrivacyPreferencesAction.UsageDataPreferenceUpdatedTo(false)) + store.dispatch(PrivacyPreferencesAction.UsageDataPreferenceUpdatedTo(false)) assertFalse(store.state.usageDataEnabled) - safeDispatch(store, PrivacyPreferencesAction.UsageDataPreferenceUpdatedTo(true)) + store.dispatch(PrivacyPreferencesAction.UsageDataPreferenceUpdatedTo(true)) assertTrue(store.state.usageDataEnabled) } @@ -59,7 +57,7 @@ class PrivacyPreferencesStoreTest { assertFalse(state.crashReportingEnabled) assertTrue(state.usageDataEnabled) - safeDispatch(store, PrivacyPreferencesAction.UsageDataUserLearnMore) + store.dispatch(PrivacyPreferencesAction.UsageDataUserLearnMore) assertEquals(state, store.state) assertFalse(state.crashReportingEnabled) @@ -75,18 +73,10 @@ class PrivacyPreferencesStoreTest { assertFalse(state.crashReportingEnabled) assertTrue(state.usageDataEnabled) - safeDispatch(store, PrivacyPreferencesAction.CrashReportingLearnMore) + store.dispatch(PrivacyPreferencesAction.CrashReportingLearnMore) assertEquals(state, store.state) assertFalse(state.crashReportingEnabled) assertTrue(state.usageDataEnabled) } } - -/** - * Dispatches the [action] and ensures all [store] processing is completed. - */ -private fun safeDispatch(store: PrivacyPreferencesStore, action: PrivacyPreferencesAction) { - store.dispatch(action).joinBlocking() - store.waitUntilIdle() -} diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/pbmlock/PrivateBrowsingLockFeatureTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/pbmlock/PrivateBrowsingLockFeatureTest.kt @@ -20,8 +20,6 @@ import mozilla.components.browser.state.selector.privateTabs import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Rule import org.junit.Test @@ -54,12 +52,10 @@ class PrivateBrowsingLockFeatureTest { ), ) createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() assertTrue(appStore.state.isPrivateScreenLocked) - browserStore.dispatch(TabListAction.RemoveAllPrivateTabsAction).joinBlocking() - appStore.waitUntilIdle() + browserStore.dispatch(TabListAction.RemoveAllPrivateTabsAction) assertFalse(appStore.state.isPrivateScreenLocked) } @@ -82,12 +78,10 @@ class PrivateBrowsingLockFeatureTest { val useCase = PrivateBrowsingLockUseCases.AuthenticatedUseCase(appStore) useCase.invoke() - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) - browserStore.dispatch(TabListAction.RemoveAllPrivateTabsAction).joinBlocking() - appStore.waitUntilIdle() + browserStore.dispatch(TabListAction.RemoveAllPrivateTabsAction) assertFalse(appStore.state.isPrivateScreenLocked) } @@ -108,12 +102,10 @@ class PrivateBrowsingLockFeatureTest { ), ) createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) - browserStore.dispatch(TabListAction.RemoveAllPrivateTabsAction).joinBlocking() - appStore.waitUntilIdle() + browserStore.dispatch(TabListAction.RemoveAllPrivateTabsAction) assertFalse(appStore.state.isPrivateScreenLocked) } @@ -134,12 +126,10 @@ class PrivateBrowsingLockFeatureTest { ), ) createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) - browserStore.dispatch(TabListAction.RemoveAllPrivateTabsAction).joinBlocking() - appStore.waitUntilIdle() + browserStore.dispatch(TabListAction.RemoveAllPrivateTabsAction) assertFalse(appStore.state.isPrivateScreenLocked) } @@ -161,7 +151,6 @@ class PrivateBrowsingLockFeatureTest { ), ) createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() assertTrue(appStore.state.isPrivateScreenLocked) } @@ -182,7 +171,6 @@ class PrivateBrowsingLockFeatureTest { ), ) createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() assertTrue(appStore.state.isPrivateScreenLocked) } @@ -203,7 +191,6 @@ class PrivateBrowsingLockFeatureTest { ), ) createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) } @@ -224,7 +211,6 @@ class PrivateBrowsingLockFeatureTest { ), ) createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) } @@ -244,7 +230,6 @@ class PrivateBrowsingLockFeatureTest { ), ) createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) } @@ -264,7 +249,6 @@ class PrivateBrowsingLockFeatureTest { ), ) createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) } @@ -339,11 +323,9 @@ class PrivateBrowsingLockFeatureTest { ), ) val feature = createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() // imitate user passing auth - appStore.dispatch(AppAction.PrivateBrowsingLockAction.UpdatePrivateBrowsingLock(isLocked = false)).joinBlocking() - appStore.waitUntilIdle() + appStore.dispatch(AppAction.PrivateBrowsingLockAction.UpdatePrivateBrowsingLock(isLocked = false)) assertTrue(appStore.state.mode == mode) assertFalse(appStore.state.isPrivateScreenLocked) @@ -352,7 +334,6 @@ class PrivateBrowsingLockFeatureTest { every { activity.isChangingConfigurations } returns false feature.onStop(activity) - appStore.waitUntilIdle() assertTrue(appStore.state.isPrivateScreenLocked) } @@ -373,11 +354,9 @@ class PrivateBrowsingLockFeatureTest { ), ) val feature = createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() // imitate user passing auth - appStore.dispatch(AppAction.PrivateBrowsingLockAction.UpdatePrivateBrowsingLock(isLocked = false)).joinBlocking() - appStore.waitUntilIdle() + appStore.dispatch(AppAction.PrivateBrowsingLockAction.UpdatePrivateBrowsingLock(isLocked = false)) assertTrue(appStore.state.mode == mode) assertFalse(appStore.state.isPrivateScreenLocked) @@ -386,7 +365,6 @@ class PrivateBrowsingLockFeatureTest { every { activity.isChangingConfigurations } returns false feature.onStop(activity) - appStore.waitUntilIdle() assertTrue(appStore.state.mode == mode) assertTrue(appStore.state.isPrivateScreenLocked) @@ -407,7 +385,6 @@ class PrivateBrowsingLockFeatureTest { ), ) val feature = createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() assertTrue(appStore.state.mode == mode) assertFalse(appStore.state.isPrivateScreenLocked) @@ -416,7 +393,6 @@ class PrivateBrowsingLockFeatureTest { every { activity.isChangingConfigurations } returns false feature.onStop(activity) - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) } @@ -436,7 +412,6 @@ class PrivateBrowsingLockFeatureTest { ), ) val feature = createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() assertTrue(appStore.state.mode == mode) assertFalse(appStore.state.isPrivateScreenLocked) @@ -445,7 +420,6 @@ class PrivateBrowsingLockFeatureTest { every { activity.isChangingConfigurations } returns false feature.onStop(activity) - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) } @@ -466,7 +440,6 @@ class PrivateBrowsingLockFeatureTest { ), ) val feature = createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() assertTrue(appStore.state.mode == mode) assertFalse(appStore.state.isPrivateScreenLocked) @@ -475,7 +448,6 @@ class PrivateBrowsingLockFeatureTest { every { activity.isChangingConfigurations } returns false feature.onStop(activity) - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) } @@ -496,7 +468,6 @@ class PrivateBrowsingLockFeatureTest { ), ) val feature = createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() assertTrue(appStore.state.mode == mode) assertFalse(appStore.state.isPrivateScreenLocked) @@ -505,7 +476,6 @@ class PrivateBrowsingLockFeatureTest { every { activity.isChangingConfigurations } returns false feature.onStop(activity) - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) } @@ -531,16 +501,13 @@ class PrivateBrowsingLockFeatureTest { ) val useCase = PrivateBrowsingLockUseCases.AuthenticatedUseCase(appStore) val feature = createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() useCase.invoke() - appStore.waitUntilIdle() val activity = mockk<AppCompatActivity>(relaxed = true) every { activity.isChangingConfigurations } returns true feature.onStop(activity) - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) } @@ -560,15 +527,12 @@ class PrivateBrowsingLockFeatureTest { ), ) val feature = createFeature(browserStore = browserStore, appStore = appStore, storage = createStorage(isFeatureEnabled = isFeatureEnabled)) - appStore.waitUntilIdle() - appStore.dispatch(AppAction.OpenInFirefoxStarted).joinBlocking() - appStore.waitUntilIdle() + appStore.dispatch(AppAction.OpenInFirefoxStarted) val activity = mockk<AppCompatActivity>(relaxed = true) feature.onStop(activity) - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) } @@ -592,14 +556,12 @@ class PrivateBrowsingLockFeatureTest { val storage = createStorage(isFeatureEnabled = isFeatureEnabled) val feature = createFeature(browserStore = browserStore, appStore = appStore, storage = storage) - appStore.waitUntilIdle() assertTrue(appStore.state.isPrivateScreenLocked) // verify that disabled feature state unlocks private mode val sharedPrefUpdate = false storage.listener?.invoke(sharedPrefUpdate) - appStore.waitUntilIdle() assertTrue(browserStore.state.privateTabs.isNotEmpty()) assertFalse(appStore.state.isPrivateScreenLocked) @@ -609,13 +571,12 @@ class PrivateBrowsingLockFeatureTest { every { activity.isChangingConfigurations } returns false feature.onStop(activity) - appStore.waitUntilIdle() assertTrue(browserStore.state.privateTabs.isNotEmpty()) assertFalse(appStore.state.isPrivateScreenLocked) // verify that going to normal mode doesn't lock private mode - appStore.dispatch(AppAction.BrowsingModeManagerModeChanged(mode = BrowsingMode.Normal)).joinBlocking() + appStore.dispatch(AppAction.BrowsingModeManagerModeChanged(mode = BrowsingMode.Normal)) assertTrue(browserStore.state.privateTabs.isNotEmpty()) assertFalse(appStore.state.isPrivateScreenLocked) @@ -639,14 +600,12 @@ class PrivateBrowsingLockFeatureTest { val storage = createStorage(isFeatureEnabled = isFeatureEnabled) createFeature(browserStore = browserStore, appStore = appStore, storage = storage) - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) // verify that disabled feature state unlocks private mode val sharedPrefUpdate = true storage.listener?.invoke(sharedPrefUpdate) - appStore.waitUntilIdle() assertTrue(browserStore.state.privateTabs.isNotEmpty()) assertTrue(appStore.state.isPrivateScreenLocked) @@ -670,14 +629,12 @@ class PrivateBrowsingLockFeatureTest { val storage = createStorage(isFeatureEnabled = isFeatureEnabled) createFeature(browserStore = browserStore, appStore = appStore, storage = storage) - appStore.waitUntilIdle() assertFalse(appStore.state.isPrivateScreenLocked) // verify that disabled feature state unlocks private mode val sharedPrefUpdate = true storage.listener?.invoke(sharedPrefUpdate) - appStore.waitUntilIdle() assertTrue(browserStore.state.privateTabs.isNotEmpty()) assertFalse(appStore.state.isPrivateScreenLocked) @@ -702,20 +659,17 @@ class PrivateBrowsingLockFeatureTest { val storage = createStorage(isFeatureEnabled = isFeatureEnabled) createFeature(browserStore = browserStore, appStore = appStore, storage = storage) - appStore.waitUntilIdle() assertTrue(appStore.state.isPrivateScreenLocked) // imitate user passing auth - appStore.dispatch(AppAction.PrivateBrowsingLockAction.UpdatePrivateBrowsingLock(isLocked = false)).joinBlocking() - appStore.waitUntilIdle() + appStore.dispatch(AppAction.PrivateBrowsingLockAction.UpdatePrivateBrowsingLock(isLocked = false)) assertTrue(appStore.state.mode == BrowsingMode.Private) assertFalse(appStore.state.isPrivateScreenLocked) // verify that going to normal mode doesn't lock private mode - appStore.dispatch(AppAction.BrowsingModeManagerModeChanged(mode = BrowsingMode.Normal)).joinBlocking() - appStore.waitUntilIdle() + appStore.dispatch(AppAction.BrowsingModeManagerModeChanged(mode = BrowsingMode.Normal)) assertTrue(appStore.state.mode == BrowsingMode.Normal) assertFalse(appStore.state.isPrivateScreenLocked) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/reviewprompt/CustomReviewPromptTelemetryMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/reviewprompt/CustomReviewPromptTelemetryMiddlewareTest.kt @@ -4,7 +4,6 @@ package org.mozilla.fenix.reviewprompt -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import mozilla.telemetry.glean.private.RecordedEvent import org.junit.Assert.assertEquals @@ -28,7 +27,7 @@ class CustomReviewPromptTelemetryMiddlewareTest { assertNull(CustomReviewPrompt.promptDisplayed.testGetValue()) val store = createStore() - store.dispatch(CustomReviewPromptAction.Displayed).joinBlocking() + store.dispatch(CustomReviewPromptAction.Displayed) assertEventRecorded("prompt_displayed") { CustomReviewPrompt.promptDisplayed.testGetValue() @@ -40,7 +39,7 @@ class CustomReviewPromptTelemetryMiddlewareTest { assertNull(CustomReviewPrompt.positiveFeedbackClicked.testGetValue()) val store = createStore() - store.dispatch(CustomReviewPromptAction.PositivePrePromptButtonClicked).joinBlocking() + store.dispatch(CustomReviewPromptAction.PositivePrePromptButtonClicked) assertEventRecorded("positive_feedback_clicked") { CustomReviewPrompt.positiveFeedbackClicked.testGetValue() @@ -52,7 +51,7 @@ class CustomReviewPromptTelemetryMiddlewareTest { assertNull(CustomReviewPrompt.negativeFeedbackClicked.testGetValue()) val store = createStore() - store.dispatch(CustomReviewPromptAction.NegativePrePromptButtonClicked).joinBlocking() + store.dispatch(CustomReviewPromptAction.NegativePrePromptButtonClicked) assertEventRecorded("negative_feedback_clicked") { CustomReviewPrompt.negativeFeedbackClicked.testGetValue() @@ -64,7 +63,7 @@ class CustomReviewPromptTelemetryMiddlewareTest { assertNull(CustomReviewPrompt.rateOnPlayStoreClicked.testGetValue()) val store = createStore(CustomReviewPromptState.Rate) - store.dispatch(CustomReviewPromptAction.RateButtonClicked).joinBlocking() + store.dispatch(CustomReviewPromptAction.RateButtonClicked) assertEventRecorded("rate_on_play_store_clicked") { CustomReviewPrompt.rateOnPlayStoreClicked.testGetValue() @@ -76,7 +75,7 @@ class CustomReviewPromptTelemetryMiddlewareTest { assertNull(CustomReviewPrompt.leaveFeedbackClicked.testGetValue()) val store = createStore(CustomReviewPromptState.Feedback) - store.dispatch(CustomReviewPromptAction.LeaveFeedbackButtonClicked).joinBlocking() + store.dispatch(CustomReviewPromptAction.LeaveFeedbackButtonClicked) assertEventRecorded("leave_feedback_clicked") { CustomReviewPrompt.leaveFeedbackClicked.testGetValue() @@ -88,7 +87,7 @@ class CustomReviewPromptTelemetryMiddlewareTest { assertNull(CustomReviewPrompt.promptDismissed.testGetValue()) val store = createStore() - store.dispatch(CustomReviewPromptAction.Dismissed).joinBlocking() + store.dispatch(CustomReviewPromptAction.Dismissed) assertEventRecorded("prompt_dismissed") { CustomReviewPrompt.promptDismissed.testGetValue() diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/reviewprompt/ReviewPromptMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/reviewprompt/ReviewPromptMiddlewareTest.kt @@ -5,7 +5,6 @@ package org.mozilla.fenix.reviewprompt import mozilla.components.support.test.assertUnused -import mozilla.components.support.test.ext.joinBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -67,7 +66,7 @@ class ReviewPromptMiddlewareTest { yield(true) } - store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt).joinBlocking() + store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt) assertTrue(mainCriteriaChecked) assertTrue(subCriteriaChecked) @@ -94,7 +93,7 @@ class ReviewPromptMiddlewareTest { yield(true) } - store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt).joinBlocking() + store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt) assertFalse(mainCriteriaChecked) assertFalse(subCriteriaChecked) @@ -106,7 +105,7 @@ class ReviewPromptMiddlewareTest { mainCriteria = sequenceOf(true) subCriteria = sequenceOf(false, true, false) - store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt).joinBlocking() + store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt) assertTrue(store.state.reviewPrompt is ReviewPromptState.Eligible) } @@ -121,7 +120,7 @@ class ReviewPromptMiddlewareTest { yield(true) } - store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt).joinBlocking() + store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt) assertFalse(continuedPastFirstSatisfied) } @@ -131,7 +130,7 @@ class ReviewPromptMiddlewareTest { mainCriteria = emptySequence() subCriteria = sequenceOf(false, true, false) - store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt).joinBlocking() + store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt) assertTrue(store.state.reviewPrompt is ReviewPromptState.Eligible) } @@ -141,7 +140,7 @@ class ReviewPromptMiddlewareTest { mainCriteria = sequenceOf(true) subCriteria = sequenceOf(false) - store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt).joinBlocking() + store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt) assertEquals( AppState(reviewPrompt = ReviewPromptState.NotEligible), @@ -154,7 +153,7 @@ class ReviewPromptMiddlewareTest { mainCriteria = sequenceOf(true) subCriteria = emptySequence() - store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt).joinBlocking() + store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt) assertEquals( AppState(reviewPrompt = ReviewPromptState.NotEligible), @@ -167,7 +166,7 @@ class ReviewPromptMiddlewareTest { mainCriteria = sequenceOf(true, false, true) subCriteria = sequenceOf(true) - store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt).joinBlocking() + store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt) assertEquals( AppState(reviewPrompt = ReviewPromptState.NotEligible), @@ -188,7 +187,7 @@ class ReviewPromptMiddlewareTest { yield(false) } - store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt).joinBlocking() + store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt) assertFalse(continuedPastFirstNotSatisfied) } @@ -207,17 +206,17 @@ class ReviewPromptMiddlewareTest { @Test fun `GIVEN review prompt shown WHEN check requested THEN does nothing`() { - store.dispatch(ReviewPromptAction.ReviewPromptShown).joinBlocking() + store.dispatch(ReviewPromptAction.ReviewPromptShown) val expectedState = store.state - store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt).joinBlocking() + store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt) assertEquals(expectedState, store.state) } @Test fun `WHEN review prompt shown THEN an event is recorded`() { - store.dispatch(ReviewPromptAction.ReviewPromptShown).joinBlocking() + store.dispatch(ReviewPromptAction.ReviewPromptShown) eventStore.assertSingleEventEquals("review_prompt_shown") } @@ -243,7 +242,7 @@ class ReviewPromptMiddlewareTest { mainCriteria = sequenceOf(true) subCriteria = sequenceOf(true) - store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt).joinBlocking() + store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt) assertEquals( AppState(reviewPrompt = ReviewPromptState.Eligible(Type.Custom)), @@ -257,7 +256,7 @@ class ReviewPromptMiddlewareTest { mainCriteria = sequenceOf(true) subCriteria = sequenceOf(true) - store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt).joinBlocking() + store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt) assertEquals( AppState(reviewPrompt = ReviewPromptState.Eligible(Type.PlayStore)), @@ -271,7 +270,7 @@ class ReviewPromptMiddlewareTest { isTelemetryEnabled = true legacyCriteria = sequenceOf(true) - store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt).joinBlocking() + store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt) assertEquals( AppState(reviewPrompt = ReviewPromptState.Eligible(Type.Custom)), @@ -285,7 +284,7 @@ class ReviewPromptMiddlewareTest { isTelemetryEnabled = false legacyCriteria = sequenceOf(true) - store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt).joinBlocking() + store.dispatch(ReviewPromptAction.CheckIfEligibleForReviewPrompt) assertEquals( AppState(reviewPrompt = ReviewPromptState.Eligible(Type.PlayStore)), @@ -367,10 +366,10 @@ class ReviewPromptMiddlewareTest { private fun assertNoOp(action: ReviewPromptAction) { val withoutMiddleware = AppStore() - withoutMiddleware.dispatch(action).joinBlocking() + withoutMiddleware.dispatch(action) val expectedState = withoutMiddleware.state - store.dispatch(action).joinBlocking() + store.dispatch(action) assertEquals( expectedState, diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/BrowserToolbarSearchMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/BrowserToolbarSearchMiddlewareTest.kt @@ -521,7 +521,7 @@ class BrowserToolbarSearchMiddlewareTest { SearchSelectorItemClicked( fakeSearchState().applicationSearchEngines.first { it.id == TABS_SEARCH_ENGINE_ID }, ), - ).joinBlocking() + ) shadowOf(Looper.getMainLooper()).idle() coVerify(exactly = 0) { middleware.fetchAutocomplete( @@ -576,7 +576,7 @@ class BrowserToolbarSearchMiddlewareTest { SearchSelectorItemClicked( fakeSearchState().applicationSearchEngines.first { it.id == BOOKMARKS_SEARCH_ENGINE_ID }, ), - ).joinBlocking() + ) shadowOf(Looper.getMainLooper()).idle() coVerify(exactly = 0) { middleware.fetchAutocomplete( @@ -628,7 +628,7 @@ class BrowserToolbarSearchMiddlewareTest { SearchSelectorItemClicked( fakeSearchState().applicationSearchEngines.first { it.id == HISTORY_SEARCH_ENGINE_ID }, ), - ).joinBlocking() + ) coVerify(exactly = 0) { middleware.fetchAutocomplete( @@ -672,7 +672,7 @@ class BrowserToolbarSearchMiddlewareTest { configureAutocompleteProvidersInComponents() val store = buildStore(middleware) - store.dispatch(SearchSelectorItemClicked(mockk(relaxed = true))).joinBlocking() + store.dispatch(SearchSelectorItemClicked(mockk(relaxed = true))) store.dispatch(EnterEditMode) shadowOf(Looper.getMainLooper()).idle() @@ -695,7 +695,7 @@ class BrowserToolbarSearchMiddlewareTest { store.dispatch(EnterEditMode) val newSearchEngines = fakeSearchState().applicationSearchEngines - browserStore.dispatch(ApplicationSearchEnginesLoaded(newSearchEngines)).joinBlocking() + browserStore.dispatch(ApplicationSearchEnginesLoaded(newSearchEngines)) shadowOf(Looper.getMainLooper()).idle() // wait for observing and processing the search engines update assertSearchSelectorEquals( @@ -719,7 +719,7 @@ class BrowserToolbarSearchMiddlewareTest { store.dispatch(EnterEditMode) val newSearchEngines = fakeSearchState().applicationSearchEngines - browserStore.dispatch(ApplicationSearchEnginesLoaded(newSearchEngines)).joinBlocking() + browserStore.dispatch(ApplicationSearchEnginesLoaded(newSearchEngines)) shadowOf(Looper.getMainLooper()).idle() // wait for observing and processing the search engines update assertSearchSelectorEquals( @@ -818,7 +818,7 @@ class BrowserToolbarSearchMiddlewareTest { assertNull(Events.enteredUrl.testGetValue()) - store.dispatch(CommitUrl("moz://a")).joinBlocking() + store.dispatch(CommitUrl("moz://a")) verifyOrder { navController.navigate(NavGraphDirections.actionGlobalBrowser()) @@ -876,7 +876,7 @@ class BrowserToolbarSearchMiddlewareTest { assertNull(Events.enteredUrl.testGetValue()) - store.dispatch(CommitUrl(url)).joinBlocking() + store.dispatch(CommitUrl(url)) verifyOrder { navController.navigate(NavGraphDirections.actionGlobalBrowser()) @@ -983,8 +983,8 @@ class BrowserToolbarSearchMiddlewareTest { store.dispatch(EnterEditMode) val qrScannerButton = store.state.editState.editActionsEnd.last() as ActionButtonRes - store.dispatch(qrScannerButton.onClick as BrowserToolbarEvent).joinBlocking() - appStore.dispatch(QrScannerInputAvailable("mozilla.test")).joinBlocking() + store.dispatch(qrScannerButton.onClick as BrowserToolbarEvent) + appStore.dispatch(QrScannerInputAvailable("mozilla.test")) shadowOf(Looper.getMainLooper()).idle() // wait for observing and processing qr scan result assertEquals("mozilla.test", store.state.editState.query.current) @@ -1017,8 +1017,8 @@ class BrowserToolbarSearchMiddlewareTest { store.dispatch(EnterEditMode) val qrScannerButton = store.state.editState.editActionsEnd.last() as ActionButtonRes - store.dispatch(qrScannerButton.onClick as BrowserToolbarEvent).joinBlocking() - appStore.dispatch(QrScannerInputAvailable("test.mozilla")).joinBlocking() + store.dispatch(qrScannerButton.onClick as BrowserToolbarEvent) + appStore.dispatch(QrScannerInputAvailable("test.mozilla")) shadowOf(Looper.getMainLooper()).idle() // wait for observing and processing qr scan result assertEquals("test.mozilla", store.state.editState.query.current) @@ -1056,8 +1056,8 @@ class BrowserToolbarSearchMiddlewareTest { store.dispatch(EnterEditMode) val qrScannerButton = store.state.editState.editActionsEnd.last() as ActionButtonRes - store.dispatch(qrScannerButton.onClick as BrowserToolbarEvent).joinBlocking() - appStore.dispatch(QrScannerInputAvailable("test.com")).joinBlocking() + store.dispatch(qrScannerButton.onClick as BrowserToolbarEvent) + appStore.dispatch(QrScannerInputAvailable("test.com")) shadowOf(Looper.getMainLooper()).idle() // wait for observing and processing qr scan result assertEquals("test.com", store.state.editState.query.current) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/BrowserToolbarSearchStatusSyncMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/BrowserToolbarSearchStatusSyncMiddlewareTest.kt @@ -16,8 +16,6 @@ import mozilla.components.compose.browser.toolbar.store.BrowserToolbarAction.Exi import mozilla.components.compose.browser.toolbar.store.BrowserToolbarStore import mozilla.components.compose.browser.toolbar.store.EnvironmentCleared import mozilla.components.compose.browser.toolbar.store.EnvironmentRehydrated -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainLooperTestRule import org.junit.Assert.assertFalse @@ -71,13 +69,12 @@ class BrowserToolbarSearchStatusSyncMiddlewareTest { assertFalse(appStore.state.searchState.isSearchActive) assertFalse(toolbarStore.state.isEditMode()) - appStore.dispatch(SearchStarted()).joinBlocking() + appStore.dispatch(SearchStarted()) mainLooperRule.idle() assertTrue(appStore.state.searchState.isSearchActive) assertTrue(toolbarStore.state.isEditMode()) - toolbarStore.dispatch(ExitEditMode).joinBlocking() - appStore.waitUntilIdle() + toolbarStore.dispatch(ExitEditMode) mainLooperRule.idle() assertFalse(appStore.state.searchState.isSearchActive) assertFalse(toolbarStore.state.isEditMode()) @@ -89,7 +86,7 @@ class BrowserToolbarSearchStatusSyncMiddlewareTest { assertFalse(toolbarStore.state.isEditMode()) assertFalse(appStore.state.searchState.isSearchActive) - toolbarStore.dispatch(EnterEditMode).joinBlocking() + toolbarStore.dispatch(EnterEditMode) mainLooperRule.idle() assertFalse(appStore.state.searchState.isSearchActive) @@ -100,7 +97,7 @@ class BrowserToolbarSearchStatusSyncMiddlewareTest { every { browsingModeManager.mode } returns BrowsingMode.Private val (_, toolbarStore) = buildMiddlewareAndAddToSearchStore() - appStore.dispatch(SearchStarted()).joinBlocking() + appStore.dispatch(SearchStarted()) mainLooperRule.idle() assertTrue(toolbarStore.state.isEditMode()) @@ -113,7 +110,7 @@ class BrowserToolbarSearchStatusSyncMiddlewareTest { every { browsingModeManager.mode } returns BrowsingMode.Normal val (_, toolbarStore) = buildMiddlewareAndAddToSearchStore() - appStore.dispatch(SearchStarted()).joinBlocking() + appStore.dispatch(SearchStarted()) mainLooperRule.idle() assertTrue(toolbarStore.state.isEditMode()) @@ -124,12 +121,12 @@ class BrowserToolbarSearchStatusSyncMiddlewareTest { @Test fun `WHEN search is closed in the application THEN synchronize exiting edit mode in the toolbar`() = runTest { val (_, toolbarStore) = buildMiddlewareAndAddToSearchStore() - appStore.dispatch(SearchStarted()).joinBlocking() + appStore.dispatch(SearchStarted()) mainLooperRule.idle() assertTrue(toolbarStore.state.isEditMode()) assertTrue(appStore.state.searchState.isSearchActive) - appStore.dispatch(SearchEnded).joinBlocking() + appStore.dispatch(SearchEnded) mainLooperRule.idle() assertFalse(appStore.state.searchState.isSearchActive) assertFalse(toolbarStore.state.isEditMode()) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/FenixSearchMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/FenixSearchMiddlewareTest.kt @@ -33,8 +33,6 @@ import mozilla.components.concept.engine.EngineSession.LoadUrlFlags import mozilla.components.feature.tabs.TabsUseCases import mozilla.components.lib.state.MiddlewareContext import mozilla.components.lib.state.Store -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.robolectric.testContext import mozilla.telemetry.glean.testing.GleanTestRule @@ -256,7 +254,7 @@ class FenixSearchMiddlewareTest { every { settings.shouldShowSearchSuggestions } returns true val defaultSearchEngine = fakeSearchEnginesState().selectedOrDefaultSearchEngine - store.dispatch(SearchStarted(defaultSearchEngine, false, false, true)).joinBlocking() + store.dispatch(SearchStarted(defaultSearchEngine, false, false, true)) searchActionsCaptor.assertLastAction(SearchSuggestionsVisibilityUpdated::class) { assertTrue(it.visible) @@ -270,7 +268,7 @@ class FenixSearchMiddlewareTest { every { settings.shouldShowSearchSuggestions } returns true val defaultSearchEngine = fakeSearchEnginesState().selectedOrDefaultSearchEngine - store.dispatch(SearchStarted(defaultSearchEngine, false, false, true)).joinBlocking() + store.dispatch(SearchStarted(defaultSearchEngine, false, false, true)) searchActionsCaptor.assertLastAction(SearchSuggestionsVisibilityUpdated::class) { assertTrue(it.visible) @@ -412,8 +410,8 @@ class FenixSearchMiddlewareTest { val (_, store) = buildMiddlewareAndAddToSearchStore(appStore = appStore) appStore.dispatch(AppAction.SearchAction.SearchStarted()) - store.dispatch(SearchStarted(defaultSearchEngine, false, false, false)).joinBlocking() - appStore.dispatch(SearchEngineSelected(searchEngineClicked, true)).joinBlocking() + store.dispatch(SearchStarted(defaultSearchEngine, false, false, false)) + appStore.dispatch(SearchEngineSelected(searchEngineClicked, true)) shadowOf(Looper.getMainLooper()).idle() assertEquals(Bookmarks(searchEngineClicked), store.state.searchEngineSource) @@ -515,7 +513,6 @@ class FenixSearchMiddlewareTest { every { middleware.buildSearchSuggestionsProvider(any()) } returns mockk(relaxed = true) val store = buildStore(middleware) - store.waitUntilIdle() return middleware to store } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/SearchFragmentStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/search/SearchFragmentStoreTest.kt @@ -18,8 +18,6 @@ import mozilla.components.browser.state.state.ContentState import mozilla.components.browser.state.state.SearchState import mozilla.components.browser.state.state.TabSessionState import mozilla.components.concept.awesomebar.AwesomeBar.SuggestionProvider -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse @@ -236,7 +234,7 @@ class SearchFragmentStoreTest { val store = SearchFragmentStore(initialState) val query = "test query" - store.dispatch(SearchFragmentAction.UpdateQuery(query)).join() + store.dispatch(SearchFragmentAction.UpdateQuery(query)) assertNotSame(initialState, store.state) assertEquals(query, store.state.query) } @@ -254,7 +252,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertFalse(store.state.showSearchShortcuts) @@ -273,7 +271,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertTrue(store.state.showSearchShortcuts) @@ -292,7 +290,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertFalse(store.state.showSearchShortcuts) @@ -311,7 +309,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertFalse(store.state.showSearchShortcuts) @@ -338,7 +336,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertFalse(store.state.showSearchShortcuts) @@ -363,7 +361,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertTrue(store.state.showSearchShortcuts) @@ -388,7 +386,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertFalse(store.state.showSearchShortcuts) @@ -413,7 +411,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertFalse(store.state.showSearchShortcuts) @@ -433,7 +431,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertTrue(store.state.showSponsoredSuggestions) @@ -454,7 +452,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertFalse(store.state.showSponsoredSuggestions) @@ -475,7 +473,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertTrue(store.state.showSponsoredSuggestions) @@ -496,7 +494,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertFalse(store.state.showSponsoredSuggestions) @@ -517,7 +515,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertFalse(store.state.showSponsoredSuggestions) @@ -539,7 +537,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertFalse(store.state.showSponsoredSuggestions) @@ -555,7 +553,7 @@ class SearchFragmentStoreTest { every { settings.showSponsoredSuggestions } returns true every { settings.showNonSponsoredSuggestions } returns true - store.dispatch(SearchFragmentAction.SearchHistoryEngineSelected(searchEngine)).join() + store.dispatch(SearchFragmentAction.SearchHistoryEngineSelected(searchEngine)) assertNotSame(initialState, store.state) assertFalse(store.state.showSponsoredSuggestions) @@ -571,7 +569,7 @@ class SearchFragmentStoreTest { every { settings.showSponsoredSuggestions } returns true every { settings.showNonSponsoredSuggestions } returns true - store.dispatch(SearchFragmentAction.SearchBookmarksEngineSelected(searchEngine)).join() + store.dispatch(SearchFragmentAction.SearchBookmarksEngineSelected(searchEngine)) assertNotSame(initialState, store.state) assertFalse(store.state.showSponsoredSuggestions) @@ -587,7 +585,7 @@ class SearchFragmentStoreTest { every { settings.showSponsoredSuggestions } returns true every { settings.showNonSponsoredSuggestions } returns true - store.dispatch(SearchFragmentAction.SearchTabsEngineSelected(searchEngine)).join() + store.dispatch(SearchFragmentAction.SearchTabsEngineSelected(searchEngine)) assertNotSame(initialState, store.state) assertFalse(store.state.showSponsoredSuggestions) @@ -616,7 +614,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Private, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertEquals(SearchEngineSource.Default(searchEngine), store.state.searchEngineSource) @@ -657,7 +655,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertEquals(SearchEngineSource.Default(searchEngine), store.state.searchEngineSource) @@ -700,7 +698,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertEquals(SearchEngineSource.Shortcut(topicSpecificEngine), store.state.searchEngineSource) @@ -730,7 +728,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertEquals(SearchEngineSource.Shortcut(generalEngine), store.state.searchEngineSource) assertFalse(store.state.showSearchSuggestionsFromCurrentEngine) @@ -774,7 +772,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Normal, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertEquals(SearchEngineSource.Shortcut(searchEngine), store.state.searchEngineSource) @@ -818,7 +816,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Private, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertEquals(SearchEngineSource.Shortcut(searchEngine), store.state.searchEngineSource) @@ -853,7 +851,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Private, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertEquals(SearchEngineSource.Shortcut(topicSpecificEngine1), store.state.searchEngineSource) assertFalse(store.state.showBookmarksSuggestionsForCurrentEngine) @@ -874,7 +872,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Private, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertEquals(SearchEngineSource.Shortcut(topicSpecificEngine2), store.state.searchEngineSource) assertTrue(store.state.showBookmarksSuggestionsForCurrentEngine) @@ -903,7 +901,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Private, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertEquals(SearchEngineSource.Shortcut(topicSpecificEngine1), store.state.searchEngineSource) assertFalse(store.state.showAllBookmarkSuggestions) @@ -923,7 +921,7 @@ class SearchFragmentStoreTest { browsingMode = BrowsingMode.Private, settings = settings, ), - ).join() + ) assertNotSame(initialState, store.state) assertEquals(SearchEngineSource.Shortcut(topicSpecificEngine2), store.state.searchEngineSource) assertTrue(store.state.showBookmarksSuggestionsForCurrentEngine) @@ -939,7 +937,7 @@ class SearchFragmentStoreTest { val initialState = emptyDefaultState(showHistorySuggestionsForCurrentEngine = true) val store = SearchFragmentStore(initialState) - store.dispatch(SearchFragmentAction.SearchHistoryEngineSelected(searchEngine)).join() + store.dispatch(SearchFragmentAction.SearchHistoryEngineSelected(searchEngine)) assertNotSame(initialState, store.state) assertEquals(SearchEngineSource.History(searchEngine), store.state.searchEngineSource) @@ -961,7 +959,7 @@ class SearchFragmentStoreTest { val initialState = emptyDefaultState(showHistorySuggestionsForCurrentEngine = true) val store = SearchFragmentStore(initialState) - store.dispatch(SearchFragmentAction.SearchBookmarksEngineSelected(searchEngine)).join() + store.dispatch(SearchFragmentAction.SearchBookmarksEngineSelected(searchEngine)) assertNotSame(initialState, store.state) assertEquals(SearchEngineSource.Bookmarks(searchEngine), store.state.searchEngineSource) @@ -983,7 +981,7 @@ class SearchFragmentStoreTest { val initialState = emptyDefaultState(showHistorySuggestionsForCurrentEngine = true) val store = SearchFragmentStore(initialState) - store.dispatch(SearchFragmentAction.SearchTabsEngineSelected(searchEngine)).join() + store.dispatch(SearchFragmentAction.SearchTabsEngineSelected(searchEngine)) assertNotSame(initialState, store.state) assertEquals(SearchEngineSource.Tabs(searchEngine), store.state.searchEngineSource) @@ -1005,7 +1003,7 @@ class SearchFragmentStoreTest { val initialState = emptyDefaultState() val store = SearchFragmentStore(initialState) - store.dispatch(SearchFragmentAction.SearchTabsEngineSelected(searchEngine)).join() + store.dispatch(SearchFragmentAction.SearchTabsEngineSelected(searchEngine)) assertNotSame(initialState, store.state) assertEquals(SearchEngineSource.Tabs(searchEngine), store.state.searchEngineSource) } @@ -1015,11 +1013,11 @@ class SearchFragmentStoreTest { val initialState = emptyDefaultState() val store = SearchFragmentStore(initialState) - store.dispatch(SearchFragmentAction.SetShowSearchSuggestions(true)).join() + store.dispatch(SearchFragmentAction.SetShowSearchSuggestions(true)) assertNotSame(initialState, store.state) assertTrue(store.state.showSearchSuggestionsFromCurrentEngine) - store.dispatch(SearchFragmentAction.SetShowSearchSuggestions(false)).join() + store.dispatch(SearchFragmentAction.SetShowSearchSuggestions(false)) assertFalse(store.state.showSearchSuggestionsFromCurrentEngine) } @@ -1028,11 +1026,11 @@ class SearchFragmentStoreTest { val initialState = emptyDefaultState() val store = SearchFragmentStore(initialState) - store.dispatch(SearchFragmentAction.AllowSearchSuggestionsInPrivateModePrompt(true)).join() + store.dispatch(SearchFragmentAction.AllowSearchSuggestionsInPrivateModePrompt(true)) assertNotSame(initialState, store.state) assertTrue(store.state.showSearchSuggestionsHint) - store.dispatch(SearchFragmentAction.AllowSearchSuggestionsInPrivateModePrompt(false)).join() + store.dispatch(SearchFragmentAction.AllowSearchSuggestionsInPrivateModePrompt(false)) assertFalse(store.state.showSearchSuggestionsHint) } @@ -1045,7 +1043,7 @@ class SearchFragmentStoreTest { store.dispatch( SearchFragmentAction.UpdateClipboardHasUrl(true), - ).joinBlocking() + ) assertTrue(store.state.clipboardHasUrl) } @@ -1097,8 +1095,6 @@ class SearchFragmentStoreTest { ), ) - store.waitUntilIdle() - assertNotNull(store.state.defaultEngine) assertEquals("Engine B", store.state.defaultEngine!!.name) @@ -1157,8 +1153,6 @@ class SearchFragmentStoreTest { ), ) - store.waitUntilIdle() - assertNotNull(store.state.defaultEngine) assertEquals("Engine B", store.state.defaultEngine!!.name) @@ -1202,8 +1196,6 @@ class SearchFragmentStoreTest { isUnifiedSearchEnabled = true, ), ) - store.waitUntilIdle() - assertFalse(store.state.showSearchShortcuts) } @@ -1311,7 +1303,7 @@ class SearchFragmentStoreTest { val newSearchProviders = listOf(mockk<SuggestionProvider>()) val store = SearchFragmentStore(emptyDefaultState()) - store.dispatch(SearchProvidersUpdated(newSearchProviders)).joinBlocking() + store.dispatch(SearchProvidersUpdated(newSearchProviders)) assertEquals(newSearchProviders, store.state.searchSuggestionsProviders) } @@ -1322,7 +1314,7 @@ class SearchFragmentStoreTest { val initialState = emptyDefaultState() val store = SearchFragmentStore(initialState) - store.dispatch(SearchStarted(selectedSearchEngine, false, true, false)).joinBlocking() + store.dispatch(SearchStarted(selectedSearchEngine, false, true, false)) assertEquals(initialState, store.state) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/account/AccountSettingsFragmentStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/account/AccountSettingsFragmentStoreTest.kt @@ -17,7 +17,7 @@ class AccountSettingsFragmentStoreTest { val store = AccountSettingsFragmentStore(initialState) val duration = 1L - store.dispatch(AccountSettingsFragmentAction.SyncFailed(duration)).join() + store.dispatch(AccountSettingsFragmentAction.SyncFailed(duration)) assertNotSame(initialState, store.state) assertEquals(LastSyncTime.Failed(duration), store.state.lastSyncedDate) } @@ -28,7 +28,7 @@ class AccountSettingsFragmentStoreTest { val store = AccountSettingsFragmentStore(initialState) val duration = 1L - store.dispatch(AccountSettingsFragmentAction.SyncEnded(duration)).join() + store.dispatch(AccountSettingsFragmentAction.SyncEnded(duration)) assertNotSame(initialState, store.state) assertEquals(LastSyncTime.Success(duration), store.state.lastSyncedDate) } @@ -39,7 +39,7 @@ class AccountSettingsFragmentStoreTest { val store = AccountSettingsFragmentStore(initialState) val deviceName = "testing" - store.dispatch(AccountSettingsFragmentAction.UpdateDeviceName(deviceName)).join() + store.dispatch(AccountSettingsFragmentAction.UpdateDeviceName(deviceName)) assertNotSame(initialState, store.state) assertEquals(deviceName, store.state.deviceName) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/advanced/LocaleSettingsStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/advanced/LocaleSettingsStoreTest.kt @@ -30,14 +30,14 @@ class LocaleSettingsStoreTest { @Test fun `change selected locale`() = runTest { - localeSettingsStore.dispatch(LocaleSettingsAction.Select(otherLocale)).join() + localeSettingsStore.dispatch(LocaleSettingsAction.Select(otherLocale)) assertEquals(otherLocale, localeSettingsStore.state.selectedLocale) } @Test fun `change selected list by search query`() = runTest { - localeSettingsStore.dispatch(LocaleSettingsAction.Search("Eng")).join() + localeSettingsStore.dispatch(LocaleSettingsAction.Search("Eng")) assertEquals(2, localeSettingsStore.state.searchedLocaleList.size) assertEquals(selectedLocale, localeSettingsStore.state.searchedLocaleList[1]) @@ -45,11 +45,11 @@ class LocaleSettingsStoreTest { @Test fun `GIVEN search list is amended WHEN locale selected THEN reset search list`() = runTest { - localeSettingsStore.dispatch(LocaleSettingsAction.Search("Eng")).join() + localeSettingsStore.dispatch(LocaleSettingsAction.Search("Eng")) assertEquals(2, localeSettingsStore.state.searchedLocaleList.size) - localeSettingsStore.dispatch(LocaleSettingsAction.Search("fr")).join() - localeSettingsStore.dispatch(LocaleSettingsAction.Select(otherLocale)).join() + localeSettingsStore.dispatch(LocaleSettingsAction.Search("fr")) + localeSettingsStore.dispatch(LocaleSettingsAction.Select(otherLocale)) assertEquals(localeSettingsStore.state.localeList.size, localeSettingsStore.state.searchedLocaleList.size) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/autofill/AutofillFragmentStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/autofill/AutofillFragmentStoreTest.kt @@ -30,7 +30,7 @@ class AutofillFragmentStoreTest { assertTrue(store.state.isLoading) val creditCards: List<CreditCard> = listOf(mockk(), mockk()) - store.dispatch(AutofillAction.UpdateCreditCards(creditCards)).join() + store.dispatch(AutofillAction.UpdateCreditCards(creditCards)) assertEquals(creditCards, store.state.creditCards) assertFalse(store.state.isLoading) @@ -41,7 +41,7 @@ class AutofillFragmentStoreTest { assertTrue(store.state.isLoading) val addresses: List<Address> = listOf(mockk(), mockk()) - store.dispatch(AutofillAction.UpdateAddresses(addresses)).join() + store.dispatch(AutofillAction.UpdateAddresses(addresses)) assertEquals(addresses, store.state.addresses) assertFalse(store.state.isLoading) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/logins/LoginsFragmentStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/logins/LoginsFragmentStoreTest.kt @@ -7,7 +7,6 @@ package org.mozilla.fenix.settings.logins import io.mockk.every import io.mockk.mockk import mozilla.components.concept.storage.Login -import mozilla.components.support.test.ext.joinBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertNull @@ -77,7 +76,7 @@ class LoginsFragmentStoreTest { fun `UpdateLoginsList action`() { val store = LoginsFragmentStore(baseState.copy(isLoading = true)) - store.dispatch(LoginsAction.UpdateLoginsList(loginList)).joinBlocking() + store.dispatch(LoginsAction.UpdateLoginsList(loginList)) assertFalse(store.state.isLoading) assertEquals(loginList, store.state.loginList) @@ -90,12 +89,12 @@ class LoginsFragmentStoreTest { baseState.copy(isLoading = true), ) - store.dispatch(LoginsAction.AddLogin(exampleLogin)).joinBlocking() + store.dispatch(LoginsAction.AddLogin(exampleLogin)) assertFalse(store.state.isLoading) assertEquals(listOf(exampleLogin), store.state.loginList) // Select a login to force "isLoading = true" - store.dispatch(LoginsAction.AddLogin(firefoxLogin)).joinBlocking() + store.dispatch(LoginsAction.AddLogin(firefoxLogin)) assertFalse(store.state.isLoading) assertEquals(loginList, store.state.loginList) assertEquals(listOf(firefoxLogin, exampleLogin), store.state.filteredItems) @@ -111,12 +110,12 @@ class LoginsFragmentStoreTest { ) val updatedLogin = firefoxLogin.copy(origin = "test") - store.dispatch(LoginsAction.UpdateLogin(firefoxLogin.guid, updatedLogin)).joinBlocking() + store.dispatch(LoginsAction.UpdateLogin(firefoxLogin.guid, updatedLogin)) assertFalse(store.state.isLoading) assertEquals(listOf(exampleLogin, updatedLogin), store.state.loginList) // Test updating a non-existent login - store.dispatch(LoginsAction.UpdateLogin("test", updatedLogin.copy(origin = "none"))).joinBlocking() + store.dispatch(LoginsAction.UpdateLogin("test", updatedLogin.copy(origin = "none"))) assertFalse(store.state.isLoading) assertEquals(listOf(exampleLogin, updatedLogin), store.state.loginList) } @@ -130,20 +129,20 @@ class LoginsFragmentStoreTest { ), ) - store.dispatch(LoginsAction.DeleteLogin("not_existing")).joinBlocking() + store.dispatch(LoginsAction.DeleteLogin("not_existing")) assertEquals(loginList, store.state.loginList) assertEquals(listOf(firefoxLogin, exampleLogin), store.state.filteredItems) - store.dispatch(LoginsAction.DeleteLogin(exampleLogin.guid)).joinBlocking() + store.dispatch(LoginsAction.DeleteLogin(exampleLogin.guid)) assertEquals(listOf(firefoxLogin), store.state.loginList) assertEquals(listOf(firefoxLogin), store.state.filteredItems) - store.dispatch(LoginsAction.DeleteLogin(firefoxLogin.guid)).joinBlocking() + store.dispatch(LoginsAction.DeleteLogin(firefoxLogin.guid)) assertEquals(emptyList<SavedLogin>(), store.state.loginList) assertEquals(emptyList<SavedLogin>(), store.state.filteredItems) // Test deleting from an empty store - store.dispatch(LoginsAction.DeleteLogin(firefoxLogin.guid)).joinBlocking() + store.dispatch(LoginsAction.DeleteLogin(firefoxLogin.guid)) assertEquals(emptyList<SavedLogin>(), store.state.loginList) assertEquals(emptyList<SavedLogin>(), store.state.filteredItems) } @@ -158,7 +157,7 @@ class LoginsFragmentStoreTest { ), ) - store.dispatch(LoginsAction.FilterLogins(null)).joinBlocking() + store.dispatch(LoginsAction.FilterLogins(null)) assertFalse(store.state.isLoading) assertNull(store.state.searchedForText) @@ -169,7 +168,7 @@ class LoginsFragmentStoreTest { fun `UpdateCurrentLogin action`() { val store = LoginsFragmentStore(baseState.copy(isLoading = true)) - store.dispatch(LoginsAction.UpdateCurrentLogin(baseLogin)).joinBlocking() + store.dispatch(LoginsAction.UpdateCurrentLogin(baseLogin)) assertEquals(baseLogin, store.state.currentItem) } @@ -187,7 +186,7 @@ class LoginsFragmentStoreTest { ), ) - store.dispatch(LoginsAction.SortLogins(lastUsed)).joinBlocking() + store.dispatch(LoginsAction.SortLogins(lastUsed)) assertFalse(store.state.isLoading) assertEquals(lastUsed, store.state.sortingStrategy) @@ -209,7 +208,7 @@ class LoginsFragmentStoreTest { ), ) - store.dispatch(LoginsAction.SortLogins(lastUsed)).joinBlocking() + store.dispatch(LoginsAction.SortLogins(lastUsed)) assertFalse(store.state.isLoading) assertEquals(lastUsed, store.state.sortingStrategy) @@ -228,7 +227,7 @@ class LoginsFragmentStoreTest { ), ) - store.dispatch(LoginsAction.LoginSelected(mockk())).joinBlocking() + store.dispatch(LoginsAction.LoginSelected(mockk())) assertTrue(store.state.isLoading) assertTrue(store.state.loginList.isNotEmpty()) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStoreTest.kt @@ -353,7 +353,7 @@ class QuickSettingsFragmentStoreTest { updatedMicrophoneStatus, updatedMicrophoneEnabledStatus, ), - ).join() + ) assertNotNull(store.state) assertNotSame(initialState, store.state) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsSheetDialogFragmentTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsSheetDialogFragmentTest.kt @@ -22,7 +22,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.content.blocking.TrackerLog import mozilla.components.feature.session.TrackingProtectionUseCases -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Before import org.junit.Rule @@ -68,7 +67,7 @@ class QuickSettingsSheetDialogFragmentTest { fragment.updateTrackers(tab) } - store.dispatch(TrackerLoadedAction(tab.id, mockk())).joinBlocking() + store.dispatch(TrackerLoadedAction(tab.id, mockk())) val updatedTab = store.state.findTab(tab.id)!! @@ -94,7 +93,7 @@ class QuickSettingsSheetDialogFragmentTest { fragment.updateTrackers(tab) } - store.dispatch(TrackerBlockedAction(tab.id, mockk())).joinBlocking() + store.dispatch(TrackerBlockedAction(tab.id, mockk())) val updatedTab = store.state.findTab(tab.id)!! @@ -160,8 +159,8 @@ class QuickSettingsSheetDialogFragmentTest { } private fun addAndSelectTab(tab: TabSessionState) { - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() - store.dispatch(TabListAction.SelectTabAction(tab.id)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) + store.dispatch(TabListAction.SelectTabAction(tab.id)) } internal class MockedLifecycleOwner(initialState: Lifecycle.State) : LifecycleOwner { diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/trustpanel/TrustPanelNavigationMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/trustpanel/TrustPanelNavigationMiddlewareTest.kt @@ -38,7 +38,7 @@ class TrustPanelNavigationMiddlewareTest { fun `WHEN navigate to privacy security settings action is dispatched THEN navigate to privacy and security settings`() = runTest { val privacySecurityPrefKey = "pref_key_privacy_security_category" val store = createStore(privacySecurityPrefKey = privacySecurityPrefKey) - store.dispatch(TrustPanelAction.Navigate.PrivacySecuritySettings).join() + store.dispatch(TrustPanelAction.Navigate.PrivacySecuritySettings) verify { navController.navigate( @@ -53,7 +53,7 @@ class TrustPanelNavigationMiddlewareTest { @Test fun `WHEN navigate to manage phone feature is dispatched THEN navigate to manage phone feature`() = runTest { val store = createStore() - store.dispatch(TrustPanelAction.Navigate.ManagePhoneFeature(PhoneFeature.CAMERA)).join() + store.dispatch(TrustPanelAction.Navigate.ManagePhoneFeature(PhoneFeature.CAMERA)) verify { navController.navigate( diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/trustpanel/TrustPanelStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/trustpanel/TrustPanelStoreTest.kt @@ -34,7 +34,7 @@ class TrustPanelStoreTest { fun `WHEN toggle tracking protection action is dispatched THEN tracking protection enabled state is updated`() = runTest { val store = TrustPanelStore(initialState = TrustPanelState()) - store.dispatch(TrustPanelAction.ToggleTrackingProtection).join() + store.dispatch(TrustPanelAction.ToggleTrackingProtection) assertFalse(store.state.isTrackingProtectionEnabled) } @@ -43,7 +43,7 @@ class TrustPanelStoreTest { fun `WHEN update number of trackers blocked action is dispatched THEN number of trackers blocked state is updated`() = runTest { val store = TrustPanelStore(initialState = TrustPanelState()) - store.dispatch(TrustPanelAction.UpdateNumberOfTrackersBlocked(1)).join() + store.dispatch(TrustPanelAction.UpdateNumberOfTrackersBlocked(1)) assertEquals(store.state.numberOfTrackersBlocked, 1) } @@ -53,7 +53,7 @@ class TrustPanelStoreTest { val store = TrustPanelStore(initialState = TrustPanelState()) val baseDomain = "mozilla.org" - store.dispatch(TrustPanelAction.UpdateBaseDomain(baseDomain)).join() + store.dispatch(TrustPanelAction.UpdateBaseDomain(baseDomain)) assertEquals(store.state.baseDomain, baseDomain) } @@ -63,7 +63,7 @@ class TrustPanelStoreTest { val store = TrustPanelStore(initialState = TrustPanelState()) val trackerCategory = TrackingProtectionCategory.CRYPTOMINERS - store.dispatch(TrustPanelAction.UpdateDetailedTrackerCategory(trackerCategory)).join() + store.dispatch(TrustPanelAction.UpdateDetailedTrackerCategory(trackerCategory)) assertEquals(store.state.detailedTrackerCategory, trackerCategory) } @@ -234,7 +234,7 @@ class TrustPanelStoreTest { val store = TrustPanelStore(initialState = TrustPanelState()) val newSitePermissions: SitePermissions = mock() - store.dispatch(TrustPanelAction.UpdateSitePermissions(newSitePermissions)).join() + store.dispatch(TrustPanelAction.UpdateSitePermissions(newSitePermissions)) assertEquals(store.state.sitePermissions, newSitePermissions) } @@ -254,7 +254,7 @@ class TrustPanelStoreTest { ), ) - store.dispatch(TrustPanelAction.WebsitePermissionAction.GrantPermissionBlockedByAndroid(PhoneFeature.CAMERA)).join() + store.dispatch(TrustPanelAction.WebsitePermissionAction.GrantPermissionBlockedByAndroid(PhoneFeature.CAMERA)) assertEquals( (store.state.websitePermissionsState[PhoneFeature.CAMERA]as? WebsitePermission.Toggleable) @@ -278,7 +278,7 @@ class TrustPanelStoreTest { ), ) - store.dispatch(TrustPanelAction.WebsitePermissionAction.TogglePermission(PhoneFeature.CAMERA)).join() + store.dispatch(TrustPanelAction.WebsitePermissionAction.TogglePermission(PhoneFeature.CAMERA)) assertEquals( (store.state.websitePermissionsState[PhoneFeature.CAMERA]as? WebsitePermission.Toggleable) @@ -303,7 +303,7 @@ class TrustPanelStoreTest { store.dispatch( TrustPanelAction.WebsitePermissionAction.ChangeAutoplay(AutoplayValue.AUTOPLAY_ALLOW_ALL), - ).join() + ) assertEquals( (store.state.websitePermissionsState[PhoneFeature.AUTOPLAY]as? WebsitePermission.Autoplay) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/trustpanel/TrustPanelTelemetryMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/settings/trustpanel/TrustPanelTelemetryMiddlewareTest.kt @@ -4,7 +4,6 @@ package org.mozilla.fenix.settings.trustpanel -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertNotNull import org.junit.Assert.assertNull @@ -34,7 +33,7 @@ class TrustPanelTelemetryMiddlewareTest { ) assertNull(TrackingProtection.exceptionAdded.testGetValue()) - store.dispatch(TrustPanelAction.ToggleTrackingProtection).joinBlocking() + store.dispatch(TrustPanelAction.ToggleTrackingProtection) assertNotNull(TrackingProtection.exceptionAdded.testGetValue()) } @@ -48,7 +47,7 @@ class TrustPanelTelemetryMiddlewareTest { ) assertNull(TrackingProtection.exceptionAdded.testGetValue()) - store.dispatch(TrustPanelAction.ToggleTrackingProtection).joinBlocking() + store.dispatch(TrustPanelAction.ToggleTrackingProtection) assertNull(TrackingProtection.exceptionAdded.testGetValue()) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/shortcut/PwaOnboardingObserverTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/shortcut/PwaOnboardingObserverTest.kt @@ -17,7 +17,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.pwa.WebAppUseCases -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.After import org.junit.Before @@ -82,7 +81,7 @@ class PwaOnboardingObserverTest { every { settings.lastKnownMode } returns BrowsingMode.Private pwaOnboardingObserver.start() - store.dispatch(ContentAction.UpdateWebAppManifestAction("1", mockk())).joinBlocking() + store.dispatch(ContentAction.UpdateWebAppManifestAction("1", mockk())) verify(exactly = 0) { settings.incrementVisitedInstallableCount() } verify(exactly = 0) { pwaOnboardingObserver.navigateToPwaOnboarding() } } @@ -95,7 +94,7 @@ class PwaOnboardingObserverTest { every { settings.lastKnownMode } returns BrowsingMode.Normal pwaOnboardingObserver.start() - store.dispatch(ContentAction.UpdateWebAppManifestAction("1", mockk())).joinBlocking() + store.dispatch(ContentAction.UpdateWebAppManifestAction("1", mockk())) verify { settings.incrementVisitedInstallableCount() } verify(exactly = 0) { pwaOnboardingObserver.navigateToPwaOnboarding() } } @@ -108,7 +107,7 @@ class PwaOnboardingObserverTest { every { settings.lastKnownMode } returns BrowsingMode.Normal pwaOnboardingObserver.start() - store.dispatch(ContentAction.UpdateWebAppManifestAction("1", mockk())).joinBlocking() + store.dispatch(ContentAction.UpdateWebAppManifestAction("1", mockk())) verify { settings.incrementVisitedInstallableCount() } verify { pwaOnboardingObserver.navigateToPwaOnboarding() } } @@ -120,7 +119,7 @@ class PwaOnboardingObserverTest { every { settings.shouldShowPwaCfr } returns true pwaOnboardingObserver.start() - store.dispatch(ContentAction.UpdateWebAppManifestAction("1", mockk())).joinBlocking() + store.dispatch(ContentAction.UpdateWebAppManifestAction("1", mockk())) verify(exactly = 0) { settings.incrementVisitedInstallableCount() } verify(exactly = 0) { pwaOnboardingObserver.navigateToPwaOnboarding() } } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/DefaultTabsTrayControllerTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/DefaultTabsTrayControllerTest.kt @@ -35,8 +35,6 @@ import mozilla.components.concept.storage.BookmarkNodeType import mozilla.components.concept.storage.BookmarksStorage import mozilla.components.feature.accounts.push.CloseTabsUseCases import mozilla.components.feature.tabs.TabsUseCases -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule @@ -685,7 +683,6 @@ class DefaultTabsTrayControllerTest { ), ) trayStore.dispatch(TabsTrayAction.ExitSelectMode) - trayStore.waitUntilIdle() controller.handleTabSelected(tab1, "Tabs tray") verify(exactly = 1) { controller.handleTabSelected(tab1, "Tabs tray") } @@ -714,7 +711,6 @@ class DefaultTabsTrayControllerTest { trayStore.dispatch(TabsTrayAction.EnterSelectMode) trayStore.dispatch(TabsTrayAction.AddSelectTab(tab1)) trayStore.dispatch(TabsTrayAction.AddSelectTab(tab2)) - trayStore.waitUntilIdle() controller.handleTabSelected(tab1, "Tabs tray") middleware.assertLastAction(TabsTrayAction.RemoveSelectTab::class) { @@ -732,7 +728,6 @@ class DefaultTabsTrayControllerTest { val middleware = CaptureActionsMiddleware<TabsTrayState, TabsTrayAction>() trayStore = TabsTrayStore(middlewares = listOf(middleware)) trayStore.dispatch(TabsTrayAction.EnterSelectMode) - trayStore.waitUntilIdle() val controller = createController() val tab1 = TabSessionState( id = "1", @@ -749,7 +744,6 @@ class DefaultTabsTrayControllerTest { trayStore.dispatch(TabsTrayAction.EnterSelectMode) trayStore.dispatch(TabsTrayAction.AddSelectTab(tab1)) - trayStore.waitUntilIdle() controller.handleTabSelected(tab2, "Tabs tray") @@ -763,7 +757,6 @@ class DefaultTabsTrayControllerTest { val middleware = CaptureActionsMiddleware<TabsTrayState, TabsTrayAction>() trayStore = TabsTrayStore(middlewares = listOf(middleware)) trayStore.dispatch(TabsTrayAction.EnterSelectMode) - trayStore.waitUntilIdle() val controller = createController() val normalTab = TabSessionState( id = "1", @@ -780,7 +773,6 @@ class DefaultTabsTrayControllerTest { trayStore.dispatch(TabsTrayAction.EnterSelectMode) trayStore.dispatch(TabsTrayAction.AddSelectTab(normalTab)) - trayStore.waitUntilIdle() controller.handleTabSelected(inactiveTab, INACTIVE_TABS_FEATURE_NAME) @@ -804,8 +796,6 @@ class DefaultTabsTrayControllerTest { createController().handleForceSelectedTabsAsInactiveClicked(numDays = 5) - browserStore.waitUntilIdle() - val updatedCurrentTab = browserStore.state.tabs.first { it.id == currentTab.id } assertEquals(updatedCurrentTab, currentTab) val updatedSecondTab = browserStore.state.tabs.first { it.id == secondTab.id } @@ -827,8 +817,6 @@ class DefaultTabsTrayControllerTest { createController().handleForceSelectedTabsAsInactiveClicked(numDays = 5) - browserStore.waitUntilIdle() - val updatedCurrentTab = browserStore.state.tabs.first { it.id == currentTab.id } assertEquals(updatedCurrentTab, currentTab) val updatedSecondTab = browserStore.state.tabs.first { it.id == secondTab.id } @@ -1090,7 +1078,7 @@ class DefaultTabsTrayControllerTest { val controller = createController() - browserStore.dispatch(TabListAction.SelectTabAction(privateTab.id)).joinBlocking() + browserStore.dispatch(TabListAction.SelectTabAction(privateTab.id)) controller.handleTabSelected(privateTab, null) assertEquals(privateTab.id, browserStore.state.selectedTabId) @@ -1098,7 +1086,7 @@ class DefaultTabsTrayControllerTest { assertEquals(BrowsingMode.Private, appStateModeUpdate) controller.handleTabDeletion("privateTab") - browserStore.dispatch(TabListAction.SelectTabAction(normalTab.id)).joinBlocking() + browserStore.dispatch(TabListAction.SelectTabAction(normalTab.id)) controller.handleTabSelected(normalTab, null) assertEquals(normalTab.id, browserStore.state.selectedTabId) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/TabsTrayStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/TabsTrayStoreTest.kt @@ -5,8 +5,6 @@ package org.mozilla.fenix.tabstray import mozilla.components.browser.state.state.createTab -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -20,8 +18,6 @@ class TabsTrayStoreTest { store.dispatch(TabsTrayAction.EnterSelectMode) - store.waitUntilIdle() - assertTrue(store.state.mode.selectedTabs.isEmpty()) assertTrue(store.state.mode is TabsTrayState.Mode.Select) @@ -30,8 +26,6 @@ class TabsTrayStoreTest { store.dispatch(TabsTrayAction.ExitSelectMode) store.dispatch(TabsTrayAction.EnterSelectMode) - store.waitUntilIdle() - assertTrue(store.state.mode.selectedTabs.isEmpty()) assertTrue(store.state.mode is TabsTrayState.Mode.Select) } @@ -42,14 +36,10 @@ class TabsTrayStoreTest { store.dispatch(TabsTrayAction.EnterSelectMode) - store.waitUntilIdle() - assertTrue(store.state.mode is TabsTrayState.Mode.Select) store.dispatch(TabsTrayAction.ExitSelectMode) - store.waitUntilIdle() - assertTrue(store.state.mode is TabsTrayState.Mode.Normal) } @@ -59,8 +49,6 @@ class TabsTrayStoreTest { store.dispatch(TabsTrayAction.AddSelectTab(createTab(url = "url", id = "tab1"))) - store.waitUntilIdle() - assertEquals("tab1", store.state.mode.selectedTabs.take(1).first().id) } @@ -72,14 +60,10 @@ class TabsTrayStoreTest { store.dispatch(TabsTrayAction.AddSelectTab(tabForRemoval)) store.dispatch(TabsTrayAction.AddSelectTab(createTab(url = "url", id = "tab2"))) - store.waitUntilIdle() - assertEquals(2, store.state.mode.selectedTabs.size) store.dispatch(TabsTrayAction.RemoveSelectTab(tabForRemoval)) - store.waitUntilIdle() - assertEquals(1, store.state.mode.selectedTabs.size) assertEquals("tab2", store.state.mode.selectedTabs.take(1).first().id) } @@ -99,8 +83,6 @@ class TabsTrayStoreTest { store.dispatch(TabsTrayAction.PageSelected(Page.SyncedTabs)) - store.waitUntilIdle() - assertEquals(Page.SyncedTabs, store.state.selectedPage) } @@ -144,8 +126,6 @@ class TabsTrayStoreTest { store.dispatch(TabsTrayAction.SyncNow) - store.waitUntilIdle() - assertTrue(store.state.syncing) } @@ -157,8 +137,6 @@ class TabsTrayStoreTest { store.dispatch(TabsTrayAction.SyncCompleted) - store.waitUntilIdle() - assertFalse(store.state.syncing) } @@ -169,8 +147,6 @@ class TabsTrayStoreTest { store.dispatch(TabsTrayAction.UpdateSelectedTabId(tabId = expected)) - store.waitUntilIdle() - assertEquals(expected, store.state.selectedTabId) } @@ -180,7 +156,7 @@ class TabsTrayStoreTest { assertFalse(tabsTrayStore.state.inactiveTabsExpanded) - tabsTrayStore.dispatch(TabsTrayAction.UpdateInactiveExpanded(true)).joinBlocking() + tabsTrayStore.dispatch(TabsTrayAction.UpdateInactiveExpanded(true)) assertTrue(tabsTrayStore.state.inactiveTabsExpanded) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/controller/DefaultTabManagerControllerTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/tabstray/controller/DefaultTabManagerControllerTest.kt @@ -36,8 +36,6 @@ import mozilla.components.concept.storage.BookmarksStorage import mozilla.components.feature.accounts.push.CloseTabsUseCases import mozilla.components.feature.tabs.TabsUseCases import mozilla.components.service.fxa.manager.FxaAccountManager -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.middleware.CaptureActionsMiddleware import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.rule.MainCoroutineRule @@ -674,7 +672,6 @@ class DefaultTabManagerControllerTest { ), ) trayStore.dispatch(TabsTrayAction.ExitSelectMode) - trayStore.waitUntilIdle() controller.handleTabSelected(tab1, "Tab Manager") verify(exactly = 1) { controller.handleTabSelected(tab1, "Tab Manager") } @@ -703,7 +700,6 @@ class DefaultTabManagerControllerTest { trayStore.dispatch(TabsTrayAction.EnterSelectMode) trayStore.dispatch(TabsTrayAction.AddSelectTab(tab1)) trayStore.dispatch(TabsTrayAction.AddSelectTab(tab2)) - trayStore.waitUntilIdle() controller.handleTabSelected(tab1, "Tab Manager") middleware.assertLastAction(TabsTrayAction.RemoveSelectTab::class) { @@ -721,7 +717,6 @@ class DefaultTabManagerControllerTest { val middleware = CaptureActionsMiddleware<TabsTrayState, TabsTrayAction>() trayStore = TabsTrayStore(middlewares = listOf(middleware)) trayStore.dispatch(TabsTrayAction.EnterSelectMode) - trayStore.waitUntilIdle() val controller = createController() val tab1 = TabSessionState( id = "1", @@ -738,7 +733,6 @@ class DefaultTabManagerControllerTest { trayStore.dispatch(TabsTrayAction.EnterSelectMode) trayStore.dispatch(TabsTrayAction.AddSelectTab(tab1)) - trayStore.waitUntilIdle() controller.handleTabSelected(tab2, "Tab Manager") @@ -752,7 +746,6 @@ class DefaultTabManagerControllerTest { val middleware = CaptureActionsMiddleware<TabsTrayState, TabsTrayAction>() trayStore = TabsTrayStore(middlewares = listOf(middleware)) trayStore.dispatch(TabsTrayAction.EnterSelectMode) - trayStore.waitUntilIdle() val controller = spyk(createController()) val normalTab = TabSessionState( id = "1", @@ -769,7 +762,6 @@ class DefaultTabManagerControllerTest { trayStore.dispatch(TabsTrayAction.EnterSelectMode) trayStore.dispatch(TabsTrayAction.AddSelectTab(normalTab)) - trayStore.waitUntilIdle() controller.handleTabSelected(inactiveTab, INACTIVE_TABS_FEATURE_NAME) @@ -793,8 +785,6 @@ class DefaultTabManagerControllerTest { createController().handleForceSelectedTabsAsInactiveClicked(numDays = 5) - browserStore.waitUntilIdle() - val updatedCurrentTab = browserStore.state.tabs.first { it.id == currentTab.id } assertEquals(updatedCurrentTab, currentTab) val updatedSecondTab = browserStore.state.tabs.first { it.id == secondTab.id } @@ -816,8 +806,6 @@ class DefaultTabManagerControllerTest { createController().handleForceSelectedTabsAsInactiveClicked(numDays = 5) - browserStore.waitUntilIdle() - val updatedCurrentTab = browserStore.state.tabs.first { it.id == currentTab.id } assertEquals(updatedCurrentTab, currentTab) val updatedSecondTab = browserStore.state.tabs.first { it.id == secondTab.id } @@ -1079,7 +1067,7 @@ class DefaultTabManagerControllerTest { val controller = createController() - browserStore.dispatch(TabListAction.SelectTabAction(privateTab.id)).joinBlocking() + browserStore.dispatch(TabListAction.SelectTabAction(privateTab.id)) controller.handleTabSelected(privateTab, null) assertEquals(privateTab.id, browserStore.state.selectedTabId) @@ -1087,7 +1075,7 @@ class DefaultTabManagerControllerTest { assertEquals(BrowsingMode.Private, appStateModeUpdate) controller.handleTabDeletion("privateTab") - browserStore.dispatch(TabListAction.SelectTabAction(normalTab.id)).joinBlocking() + browserStore.dispatch(TabListAction.SelectTabAction(normalTab.id)) controller.handleTabSelected(normalTab, null) assertEquals(normalTab.id, browserStore.state.selectedTabId) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/telemetry/TelemetryMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/telemetry/TelemetryMiddlewareTest.kt @@ -9,7 +9,6 @@ import io.mockk.every import io.mockk.just import io.mockk.mockk import io.mockk.runs -import io.mockk.verify import kotlinx.coroutines.test.runTest import mozilla.components.browser.state.action.ContentAction import mozilla.components.browser.state.action.EngineAction @@ -27,7 +26,6 @@ import mozilla.components.concept.engine.translate.TranslationError import mozilla.components.concept.engine.translate.TranslationOperation import mozilla.components.feature.tabs.TabsUseCases import mozilla.components.support.base.android.Clock -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import org.junit.After import org.junit.Assert.assertEquals @@ -47,7 +45,6 @@ import org.mozilla.fenix.components.AppStore import org.mozilla.fenix.components.appstate.AppAction import org.mozilla.fenix.components.fake.FakeMetricController import org.mozilla.fenix.components.metrics.Event -import org.mozilla.fenix.components.metrics.MetricController import org.mozilla.fenix.ext.components import org.mozilla.fenix.helpers.FenixGleanTestRule import org.mozilla.fenix.utils.Settings @@ -105,7 +102,7 @@ class TelemetryMiddlewareTest { assertEquals(0, settings.openTabsCount) assertNull(Metrics.hasOpenTabs.testGetValue()) - store.dispatch(TabListAction.AddTabAction(createTab("https://mozilla.org"))).joinBlocking() + store.dispatch(TabListAction.AddTabAction(createTab("https://mozilla.org"))) assertEquals(1, settings.openTabsCount) assertTrue(Metrics.hasOpenTabs.testGetValue()!!) @@ -117,7 +114,7 @@ class TelemetryMiddlewareTest { assertNull(Metrics.hasOpenTabs.testGetValue()) store.dispatch(TabListAction.AddTabAction(createTab("https://mozilla.org", private = true))) - .joinBlocking() + assertEquals(0, settings.openTabsCount) assertFalse(Metrics.hasOpenTabs.testGetValue()!!) @@ -135,7 +132,7 @@ class TelemetryMiddlewareTest { createTab("https://firefox.com"), ), ), - ).joinBlocking() + ) assertEquals(2, settings.openTabsCount) @@ -153,10 +150,10 @@ class TelemetryMiddlewareTest { createTab(id = "2", url = "https://firefox.com"), ), ), - ).joinBlocking() + ) assertEquals(2, settings.openTabsCount) - store.dispatch(TabListAction.RemoveTabAction("1")).joinBlocking() + store.dispatch(TabListAction.RemoveTabAction("1")) assertEquals(1, settings.openTabsCount) assertTrue(Metrics.hasOpenTabs.testGetValue()!!) @@ -173,12 +170,12 @@ class TelemetryMiddlewareTest { createTab("https://firefox.com"), ), ), - ).joinBlocking() + ) assertEquals(2, settings.openTabsCount) assertTrue(Metrics.hasOpenTabs.testGetValue()!!) - store.dispatch(TabListAction.RemoveAllTabsAction()).joinBlocking() + store.dispatch(TabListAction.RemoveAllTabsAction()) assertEquals(0, settings.openTabsCount) assertFalse(Metrics.hasOpenTabs.testGetValue()!!) @@ -196,11 +193,11 @@ class TelemetryMiddlewareTest { createTab("https://getpocket.com", private = true), ), ), - ).joinBlocking() + ) assertEquals(2, settings.openTabsCount) assertTrue(Metrics.hasOpenTabs.testGetValue()!!) - store.dispatch(TabListAction.RemoveAllNormalTabsAction).joinBlocking() + store.dispatch(TabListAction.RemoveAllNormalTabsAction) assertEquals(0, settings.openTabsCount) assertFalse(Metrics.hasOpenTabs.testGetValue()!!) } @@ -220,7 +217,7 @@ class TelemetryMiddlewareTest { tabs = tabsToRestore, restoreLocation = TabListAction.RestoreAction.RestoreLocation.BEGINNING, ), - ).joinBlocking() + ) assertEquals(2, settings.openTabsCount) assertTrue(Metrics.hasOpenTabs.testGetValue()!!) @@ -232,11 +229,11 @@ class TelemetryMiddlewareTest { val tab = createTab(id = "1", url = "https://mozilla.org") assertNull(Events.normalAndPrivateUriCount.testGetValue()) - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() - store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) + store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, true)) assertNull(Events.normalAndPrivateUriCount.testGetValue()) - store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, false)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, false)) val count = Events.normalAndPrivateUriCount.testGetValue()!! assertEquals(1, count) } @@ -247,11 +244,11 @@ class TelemetryMiddlewareTest { val tab = createTab(id = "1", url = "https://mozilla.org", private = true) assertNull(Events.normalAndPrivateUriCount.testGetValue()) - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() - store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, true)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) + store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, true)) assertNull(Events.normalAndPrivateUriCount.testGetValue()) - store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, false)).joinBlocking() + store.dispatch(ContentAction.UpdateLoadingStateAction(tab.id, false)) val count = Events.normalAndPrivateUriCount.testGetValue()!! assertEquals(1, count) } @@ -277,13 +274,13 @@ class TelemetryMiddlewareTest { selectedTabId = "foreground", restoreLocation = TabListAction.RestoreAction.RestoreLocation.BEGINNING, ), - ).joinBlocking() + ) assertNull(EngineMetrics.tabKilled.testGetValue()) store.dispatch( EngineAction.KillEngineSessionAction("background_pocket"), - ).joinBlocking() + ) assertEquals(1, EngineMetrics.tabKilled.testGetValue()?.size) EngineMetrics.tabKilled.testGetValue()?.get(0)?.extra?.also { @@ -294,11 +291,11 @@ class TelemetryMiddlewareTest { appStore.dispatch( AppAction.AppLifecycleAction.PauseAction, - ).joinBlocking() + ) store.dispatch( EngineAction.KillEngineSessionAction("foreground"), - ).joinBlocking() + ) assertEquals(2, EngineMetrics.tabKilled.testGetValue()?.size) EngineMetrics.tabKilled.testGetValue()?.get(1)?.extra?.also { @@ -318,7 +315,7 @@ class TelemetryMiddlewareTest { "1", RuntimeException("session form data request failed"), ), - ).joinBlocking() + ) // Wait for the main looper to process the re-thrown exception. ShadowLooper.idleMainLooper() @@ -338,16 +335,15 @@ class TelemetryMiddlewareTest { ), ), ) - .joinBlocking() store.dispatch( EngineAction.KillEngineSessionAction(tabId), - ).joinBlocking() + ) assertTrue(store.state.recentlyKilledTabs.contains(tabId)) store.dispatch( EngineAction.CreateEngineSessionAction(tabId), - ).joinBlocking() + ) ShadowLooper.idleMainLooper() @@ -365,11 +361,11 @@ class TelemetryMiddlewareTest { store.dispatch( TabListAction.AddTabAction(createTab(id = tabId, url = "https://firefox.com")), - ).joinBlocking() + ) store.dispatch( EngineAction.CreateEngineSessionAction(tabId), - ).joinBlocking() + ) ShadowLooper.idleMainLooper() @@ -382,8 +378,8 @@ class TelemetryMiddlewareTest { runTest { val tabId = "test-tab-id" - store.dispatch(EngineAction.KillEngineSessionAction(tabId)).joinBlocking() - store.dispatch(EngineAction.KillEngineSessionAction(tabId)).joinBlocking() + store.dispatch(EngineAction.KillEngineSessionAction(tabId)) + store.dispatch(EngineAction.KillEngineSessionAction(tabId)) assertEquals(1, store.state.recentlyKilledTabs.count { it == tabId }) } @@ -394,7 +390,7 @@ class TelemetryMiddlewareTest { repeat(51) { i -> val tab = createTab("https://www.mozilla.org") store.dispatch(TabListAction.AddTabAction(tab)) - store.dispatch(EngineAction.KillEngineSessionAction(tab.id)).joinBlocking() + store.dispatch(EngineAction.KillEngineSessionAction(tab.id)) } assertEquals(50, store.state.recentlyKilledTabs.size) @@ -416,8 +412,8 @@ class TelemetryMiddlewareTest { url = "https://example.com/$i", ), ), - ).joinBlocking() - store.dispatch(EngineAction.KillEngineSessionAction(tabId)).joinBlocking() + ) + store.dispatch(EngineAction.KillEngineSessionAction(tabId)) } assertTrue(store.state.recentlyKilledTabs.contains(oldestTabId)) assertEquals(50, store.state.recentlyKilledTabs.size) @@ -430,15 +426,15 @@ class TelemetryMiddlewareTest { url = "https://example.com/$newTabId", ), ), - ).joinBlocking() - store.dispatch(EngineAction.KillEngineSessionAction(newTabId)).joinBlocking() + ) + store.dispatch(EngineAction.KillEngineSessionAction(newTabId)) assertFalse(store.state.recentlyKilledTabs.contains(oldestTabId)) assertTrue(store.state.recentlyKilledTabs.contains(newTabId)) assertEquals(50, store.state.recentlyKilledTabs.size) // Verify the reload of the newest tab was recorded val recordedEventsBefore = EngineMetrics.reloaded.testGetValue()?.size ?: 0 - store.dispatch(EngineAction.CreateEngineSessionAction(newTabId)).joinBlocking() + store.dispatch(EngineAction.CreateEngineSessionAction(newTabId)) ShadowLooper.idleMainLooper() val recordedEventsAfter = EngineMetrics.reloaded.testGetValue() assertNotNull(recordedEventsAfter) @@ -447,7 +443,7 @@ class TelemetryMiddlewareTest { @Test fun `WHEN uri loaded to engine THEN matching event is sent to metrics`() = runTest { - store.dispatch(EngineAction.LoadUrlAction("", "")).joinBlocking() + store.dispatch(EngineAction.LoadUrlAction("", "")) assertTrue(metrics.trackedEvents.contains(Event.GrowthData.FirstUriLoadForDay)) } @@ -457,7 +453,7 @@ class TelemetryMiddlewareTest { assertNull(Addons.extensionsProcessUiRetry.testGetValue()) assertNull(Addons.extensionsProcessUiDisable.testGetValue()) - store.dispatch(ExtensionsProcessAction.EnabledAction).joinBlocking() + store.dispatch(ExtensionsProcessAction.EnabledAction) assertEquals(1, Addons.extensionsProcessUiRetry.testGetValue()) assertNull(Addons.extensionsProcessUiDisable.testGetValue()) @@ -468,7 +464,7 @@ class TelemetryMiddlewareTest { assertNull(Addons.extensionsProcessUiRetry.testGetValue()) assertNull(Addons.extensionsProcessUiDisable.testGetValue()) - store.dispatch(ExtensionsProcessAction.DisabledAction).joinBlocking() + store.dispatch(ExtensionsProcessAction.DisabledAction) assertEquals(1, Addons.extensionsProcessUiDisable.testGetValue()) assertNull(Addons.extensionsProcessUiRetry.testGetValue()) @@ -485,7 +481,7 @@ class TelemetryMiddlewareTest { toLanguage = "es", options = null, ), - ).joinBlocking() + ) val telemetry = Translations.translateRequested.testGetValue()?.firstOrNull() assertEquals("es", telemetry?.extra?.get("to_language")) @@ -502,7 +498,7 @@ class TelemetryMiddlewareTest { tabId = "1", operation = TranslationOperation.FETCH_SUPPORTED_LANGUAGES, ), - ).joinBlocking() + ) assertNull(Translations.translateSuccess.testGetValue()) // Should record translate operations @@ -511,7 +507,7 @@ class TelemetryMiddlewareTest { tabId = "1", operation = TranslationOperation.TRANSLATE, ), - ).joinBlocking() + ) val telemetry = Translations.translateSuccess.testGetValue()?.firstOrNull() assertNotNull(telemetry) @@ -529,7 +525,7 @@ class TelemetryMiddlewareTest { operation = TranslationOperation.FETCH_SUPPORTED_LANGUAGES, translationError = TranslationError.UnknownError(IllegalStateException()), ), - ).joinBlocking() + ) assertNull(Translations.translateFailed.testGetValue()) // Should record translate operations @@ -539,7 +535,7 @@ class TelemetryMiddlewareTest { operation = TranslationOperation.TRANSLATE, translationError = TranslationError.CouldNotTranslateError(null), ), - ).joinBlocking() + ) val telemetry = Translations.translateFailed.testGetValue()?.firstOrNull() assertEquals( @@ -557,7 +553,7 @@ class TelemetryMiddlewareTest { TranslationsAction.SetEngineSupportedAction( isEngineSupported = false, ), - ).joinBlocking() + ) assertNotNull(Translations.engineUnsupported.testGetValue()) } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/trackingprotection/ProtectionsStoreTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/trackingprotection/ProtectionsStoreTest.kt @@ -27,7 +27,6 @@ class ProtectionsStoreTest { true, ), ) - .join() assertNotSame(initialState, store.state) assertEquals( store.state.mode, @@ -41,7 +40,7 @@ class ProtectionsStoreTest { val initialState = detailsState() val store = ProtectionsStore(initialState) - store.dispatch(ProtectionsAction.ExitDetailsMode).join() + store.dispatch(ProtectionsAction.ExitDetailsMode) assertNotSame(initialState, store.state) assertEquals( store.state.mode, @@ -56,7 +55,7 @@ class ProtectionsStoreTest { val store = ProtectionsStore(initialState) val tracker = TrackerLog("url", listOf()) - store.dispatch(ProtectionsAction.TrackerLogChange(listOf(tracker))).join() + store.dispatch(ProtectionsAction.TrackerLogChange(listOf(tracker))) assertNotSame(initialState, store.state) assertEquals( listOf(tracker), @@ -69,7 +68,7 @@ class ProtectionsStoreTest { val initialState = defaultState() val store = ProtectionsStore(initialState) - store.dispatch(ProtectionsAction.UrlChange("newURL")).join() + store.dispatch(ProtectionsAction.UrlChange("newURL")) assertNotSame(initialState, store.state) assertEquals( "newURL", @@ -94,7 +93,7 @@ class ProtectionsStoreTest { true, ), ), - ).join() + ) assertNotSame(initialState, store.state) assertEquals( "newURL", @@ -127,7 +126,7 @@ class ProtectionsStoreTest { ProtectionsAction.ToggleCookieBannerHandlingProtectionEnabled( cookieBannerUIMode = CookieBannerUIMode.ENABLE, ), - ).join() + ) assertEquals( CookieBannerUIMode.ENABLE, @@ -144,7 +143,7 @@ class ProtectionsStoreTest { ProtectionsAction.RequestReportSiteDomain( url = "youtube.com", ), - ).join() + ) assertEquals( "youtube.com", @@ -161,7 +160,7 @@ class ProtectionsStoreTest { ProtectionsAction.UpdateCookieBannerMode( cookieBannerUIMode = CookieBannerUIMode.DISABLE, ), - ).join() + ) assertEquals( CookieBannerUIMode.DISABLE, diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/trackingprotection/TrackingProtectionPanelDialogFragmentTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/trackingprotection/TrackingProtectionPanelDialogFragmentTest.kt @@ -64,7 +64,7 @@ class TrackingProtectionPanelDialogFragmentTest { protectionsStore.dispatch(ProtectionsAction.UrlChange("mozilla.org")) } - store.dispatch(ContentAction.UpdateUrlAction(tab.id, "wikipedia.org")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(tab.id, "wikipedia.org")) verify(exactly = 1) { protectionsStore.dispatch(ProtectionsAction.UrlChange("wikipedia.org")) @@ -87,7 +87,7 @@ class TrackingProtectionPanelDialogFragmentTest { fragment.updateTrackers(tab) } - store.dispatch(TrackerLoadedAction(tab.id, mockk())).joinBlocking() + store.dispatch(TrackerLoadedAction(tab.id, mockk())) val updatedTab = store.state.findTab(tab.id)!! @@ -114,7 +114,7 @@ class TrackingProtectionPanelDialogFragmentTest { fragment.updateTrackers(tab) } - store.dispatch(TrackerBlockedAction(tab.id, mockk())).joinBlocking() + store.dispatch(TrackerBlockedAction(tab.id, mockk())) val updatedTab = store.state.findTab(tab.id)!! @@ -126,8 +126,8 @@ class TrackingProtectionPanelDialogFragmentTest { } private fun addAndSelectTab(tab: TabSessionState) { - store.dispatch(TabListAction.AddTabAction(tab)).joinBlocking() - store.dispatch(TabListAction.SelectTabAction(tab.id)).joinBlocking() + store.dispatch(TabListAction.AddTabAction(tab)) + store.dispatch(TabListAction.SelectTabAction(tab.id)) } internal class MockedLifecycleOwner(initialState: Lifecycle.State) : LifecycleOwner { diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/translations/TranslationsDialogBindingTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/translations/TranslationsDialogBindingTest.kt @@ -92,14 +92,14 @@ class TranslationsDialogBindingTest { TranslationsAction.SetSupportedLanguagesAction( supportedLanguages = supportLanguages, ), - ).joinBlocking() + ) browserStore.dispatch( TranslationsAction.TranslateStateChangeAction( tabId = tabId, translationEngineState = translationEngineState, ), - ).joinBlocking() + ) verify(translationsDialogStore).dispatch( TranslationsDialogAction.UpdateFromSelectedLanguage( @@ -155,7 +155,7 @@ class TranslationsDialogBindingTest { toLanguage = spanishLanguage.code, null, ), - ).joinBlocking() + ) verify(translationsDialogStore).dispatch( TranslationsDialogAction.UpdateTranslationInProgress( @@ -200,7 +200,7 @@ class TranslationsDialogBindingTest { TranslationsAction.SetSupportedLanguagesAction( supportedLanguages = supportedLanguages, ), - ).joinBlocking() + ) verify(translationsDialogStore).dispatch( TranslationsDialogAction.UpdateTranslateFromLanguages( @@ -244,7 +244,7 @@ class TranslationsDialogBindingTest { tabId = tab.id, operation = TranslationOperation.TRANSLATE, ), - ).joinBlocking() + ) // Simulate success response post-translate val detectedLanguages = DetectedLanguages( @@ -269,7 +269,7 @@ class TranslationsDialogBindingTest { tabId = tabId, translationEngineState = translationEngineState, ), - ).joinBlocking() + ) verify(translationsDialogStore).dispatch( TranslationsDialogAction.UpdateTranslated( @@ -320,7 +320,7 @@ class TranslationsDialogBindingTest { operation = TranslationOperation.FETCH_SUPPORTED_LANGUAGES, translationError = fetchError, ), - ).joinBlocking() + ) verify(translationsDialogStore).dispatch( TranslationsDialogAction.UpdateTranslationError(fetchError), @@ -357,7 +357,7 @@ class TranslationsDialogBindingTest { TranslationsAction.EngineExceptionAction( error = fetchError, ), - ).joinBlocking() + ) verify(translationsDialogStore, never()).dispatch( TranslationsDialogAction.UpdateTranslationError(fetchError), @@ -396,7 +396,7 @@ class TranslationsDialogBindingTest { operation = TranslationOperation.FETCH_SUPPORTED_LANGUAGES, translationError = sessionError, ), - ).joinBlocking() + ) verify(translationsDialogStore).dispatch( TranslationsDialogAction.UpdateTranslationError(sessionError), @@ -407,7 +407,7 @@ class TranslationsDialogBindingTest { TranslationsAction.EngineExceptionAction( error = engineError, ), - ).joinBlocking() + ) verify(translationsDialogStore, never()).dispatch( TranslationsDialogAction.UpdateTranslationError(engineError), @@ -451,7 +451,7 @@ class TranslationsDialogBindingTest { tabId = tab.id, translationSize = translationDownloadSize, ), - ).joinBlocking() + ) verify(translationsDialogStore).dispatch( TranslationsDialogAction.UpdateDownloadTranslationDownloadSize(translationDownloadSize), diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/translations/TranslationsDialogMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/translations/TranslationsDialogMiddlewareTest.kt @@ -14,8 +14,6 @@ import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.translate.Language import mozilla.components.concept.engine.translate.TranslationOperation import mozilla.components.concept.engine.translate.TranslationPageSettingOperation -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -46,9 +44,6 @@ class TranslationsDialogMiddlewareTest { middlewares = listOf(translationsDialogMiddleware), ) translationStore.dispatch(TranslationsDialogAction.FetchSupportedLanguages) - .joinBlocking() - - translationStore.waitUntilIdle() verify { browserStore.dispatch( @@ -70,9 +65,7 @@ class TranslationsDialogMiddlewareTest { ), middlewares = listOf(translationsDialogMiddleware), ) - translationStore.dispatch(TranslationsDialogAction.TranslateAction).joinBlocking() - - translationStore.waitUntilIdle() + translationStore.dispatch(TranslationsDialogAction.TranslateAction) verify { browserStore.dispatch( @@ -93,9 +86,7 @@ class TranslationsDialogMiddlewareTest { initialState = TranslationsDialogState(), middlewares = listOf(translationsDialogMiddleware), ) - translationStore.dispatch(TranslationsDialogAction.RestoreTranslation).joinBlocking() - - translationStore.waitUntilIdle() + translationStore.dispatch(TranslationsDialogAction.RestoreTranslation) verify { browserStore.dispatch( @@ -118,9 +109,7 @@ class TranslationsDialogMiddlewareTest { toLanguage = Language("en", "English"), fromLanguage = Language("fr", "France"), ), - ).joinBlocking() - - translationStore.waitUntilIdle() + ) verify { browserStore.dispatch( @@ -140,9 +129,7 @@ class TranslationsDialogMiddlewareTest { initialState = TranslationsDialogState(), middlewares = listOf(translationsDialogMiddleware), ) - translationStore.dispatch(TranslationsDialogAction.FetchPageSettings).joinBlocking() - - translationStore.waitUntilIdle() + translationStore.dispatch(TranslationsDialogAction.FetchPageSettings) verify { browserStore.dispatch( @@ -167,9 +154,7 @@ class TranslationsDialogMiddlewareTest { type = TranslationPageSettingsOption.AlwaysOfferPopup(), checkValue = false, ), - ).joinBlocking() - - translationStore.waitUntilIdle() + ) verify { browserStore.dispatch( @@ -193,9 +178,7 @@ class TranslationsDialogMiddlewareTest { type = TranslationPageSettingsOption.AlwaysTranslateLanguage(), checkValue = false, ), - ).joinBlocking() - - translationStore.waitUntilIdle() + ) verify { browserStore.dispatch( @@ -220,9 +203,7 @@ class TranslationsDialogMiddlewareTest { type = TranslationPageSettingsOption.NeverTranslateLanguage(), checkValue = true, ), - ).joinBlocking() - - translationStore.waitUntilIdle() + ) verify { browserStore.dispatch( @@ -247,9 +228,7 @@ class TranslationsDialogMiddlewareTest { type = TranslationPageSettingsOption.NeverTranslateSite(), checkValue = false, ), - ).joinBlocking() - - translationStore.waitUntilIdle() + ) verify { browserStore.dispatch( diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/utils/ToolbarPopupWindowTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/utils/ToolbarPopupWindowTest.kt @@ -10,7 +10,6 @@ import mozilla.components.browser.state.state.ReaderState import mozilla.components.browser.state.state.createCustomTab import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.rule.MainCoroutineRule import org.junit.Assert.assertEquals import org.junit.Rule @@ -53,7 +52,7 @@ class ToolbarPopupWindowTest { // Custom tab val customTabSession = createCustomTab("https://mozilla.org") var store = BrowserStore(BrowserState(customTabs = listOf(customTabSession))) - store.dispatch(ContentAction.UpdateUrlAction(customTabSession.id, "https://firefox.com")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(customTabSession.id, "https://firefox.com")) assertEquals( "https://firefox.com", ToolbarPopupWindow.getUrlForClipboard(store, customTabSession.id), @@ -62,7 +61,7 @@ class ToolbarPopupWindowTest { // Regular tab val regularTab = createTab(url = "http://firefox.com") store = BrowserStore(BrowserState(tabs = listOf(regularTab), selectedTabId = regularTab.id)) - store.dispatch(ContentAction.UpdateUrlAction(regularTab.id, "https://mozilla.org")).joinBlocking() + store.dispatch(ContentAction.UpdateUrlAction(regularTab.id, "https://mozilla.org")) assertEquals("https://mozilla.org", ToolbarPopupWindow.getUrlForClipboard(store)) } } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/webcompat/middleware/WebCompatReporterTelemetryMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/webcompat/middleware/WebCompatReporterTelemetryMiddlewareTest.kt @@ -4,7 +4,6 @@ package org.mozilla.fenix.webcompat.middleware -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull @@ -29,7 +28,7 @@ class WebCompatReporterTelemetryMiddlewareTest { val store = createStore() assertNull(Webcompatreporting.reasonDropdown.testGetValue()) - store.dispatch(WebCompatReporterAction.ReasonChanged(WebCompatReporterState.BrokenSiteReason.Media)).joinBlocking() + store.dispatch(WebCompatReporterAction.ReasonChanged(WebCompatReporterState.BrokenSiteReason.Media)) assertNotNull(Webcompatreporting.reasonDropdown.testGetValue()) val snapshot = Webcompatreporting.reasonDropdown.testGetValue()!! @@ -41,7 +40,7 @@ class WebCompatReporterTelemetryMiddlewareTest { val store = createStore() assertNull(Webcompatreporting.sendMoreInfo.testGetValue()) - store.dispatch(WebCompatReporterAction.SendMoreInfoClicked).joinBlocking() + store.dispatch(WebCompatReporterAction.SendMoreInfoClicked) val snapshot = Webcompatreporting.sendMoreInfo.testGetValue()!! assertEquals(1, snapshot.size) @@ -53,7 +52,7 @@ class WebCompatReporterTelemetryMiddlewareTest { val store = createStore() assertNull(Webcompatreporting.send.testGetValue()) - store.dispatch(WebCompatReporterAction.SendReportClicked).joinBlocking() + store.dispatch(WebCompatReporterAction.SendReportClicked) val snapshot = Webcompatreporting.send.testGetValue()!! assertEquals(1, snapshot.size) @@ -65,7 +64,7 @@ class WebCompatReporterTelemetryMiddlewareTest { val store = createStore() assertNull(Webcompatreporting.send.testGetValue()) - store.dispatch(WebCompatReporterAction.SendReportClicked).joinBlocking() + store.dispatch(WebCompatReporterAction.SendReportClicked) val snapshot = Webcompatreporting.send.testGetValue()!! assertEquals(1, snapshot.size) @@ -78,7 +77,7 @@ class WebCompatReporterTelemetryMiddlewareTest { val store = createStore() store.dispatch(WebCompatReporterAction.IncludeEtpBlockedUrlsChanged(true)) - store.dispatch(WebCompatReporterAction.SendReportClicked).joinBlocking() + store.dispatch(WebCompatReporterAction.SendReportClicked) val snapshot = Webcompatreporting.send.testGetValue()!!.single() assertEquals("true", snapshot.extra?.get("sent_with_blocked_trackers")) diff --git a/mobile/android/focus-android/app/src/androidTest/java/org/mozilla/focus/helpers/MainActivityTestRule.kt b/mobile/android/focus-android/app/src/androidTest/java/org/mozilla/focus/helpers/MainActivityTestRule.kt @@ -110,17 +110,15 @@ private fun updateFirstRun(showFirstRun: Boolean) { } private fun showFirstRun(appStore: AppStore) { - val job = appStore.dispatch( + appStore.dispatch( AppAction.ShowFirstRun, ) - runBlocking { job.join() } } private fun hideFirstRun(appStore: AppStore) { - val job = appStore.dispatch( + appStore.dispatch( AppAction.FinishFirstRun(tabId = null), ) - runBlocking { job.join() } } // changing the device preference for Touch and Hold delay, to avoid long-clicks instead of a single-click diff --git a/mobile/android/focus-android/app/src/test/java/org/mozilla/focus/browser/integration/BrowserToolbarIntegrationTest.kt b/mobile/android/focus-android/app/src/test/java/org/mozilla/focus/browser/integration/BrowserToolbarIntegrationTest.kt @@ -15,8 +15,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.browser.toolbar.BrowserToolbar import mozilla.components.browser.toolbar.display.DisplayToolbar.Indicators -import mozilla.components.support.test.ext.joinBlocking -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.whenever @@ -209,14 +207,12 @@ class BrowserToolbarIntegrationTest { ), ), ) - - store.waitUntilIdle() } private fun updateTabUrl(url: String) { store.dispatch( ContentAction.UpdateUrlAction(selectedTab.id, url), - ).joinBlocking() + ) } private fun createSecureTab(): TabSessionState { diff --git a/mobile/android/focus-android/app/src/test/java/org/mozilla/focus/browser/integration/InputToolbarIntegrationTest.kt b/mobile/android/focus-android/app/src/test/java/org/mozilla/focus/browser/integration/InputToolbarIntegrationTest.kt @@ -7,7 +7,6 @@ package org.mozilla.focus.browser.integration import android.view.View import kotlinx.coroutines.isActive import mozilla.components.browser.toolbar.BrowserToolbar -import mozilla.components.support.test.ext.joinBlocking import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.whenever @@ -60,7 +59,7 @@ class InputToolbarIntegrationTest { @Test fun `GIVEN app fresh install WHEN input toolbar integration is starting THEN start browsing scope is populated`() { - appStore.dispatch(AppAction.ShowStartBrowsingCfrChange(true)).joinBlocking() + appStore.dispatch(AppAction.ShowStartBrowsingCfrChange(true)) assertNull(inputToolbarIntegration.startBrowsingCfrScope) diff --git a/mobile/android/focus-android/app/src/test/java/org/mozilla/focus/cfr/CfrMiddlewareTest.kt b/mobile/android/focus-android/app/src/test/java/org/mozilla/focus/cfr/CfrMiddlewareTest.kt @@ -12,8 +12,6 @@ import mozilla.components.browser.state.state.createTab import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.content.blocking.Tracker -import mozilla.components.support.test.ext.joinBlocking -import mozilla.components.support.test.libstate.ext.waitUntilIdle import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -62,9 +60,8 @@ class CfrMiddlewareTest { ), ) - browserStore.dispatch(updateSecurityInfoAction).joinBlocking() - browserStore.dispatch(trackerBlockedAction).joinBlocking() - appStore.waitUntilIdle() + browserStore.dispatch(updateSecurityInfoAction) + browserStore.dispatch(trackerBlockedAction) assertTrue(appStore.state.showTrackingProtectionCfrForTab.getOrDefault("1", false)) } @@ -83,9 +80,8 @@ class CfrMiddlewareTest { ), ) - browserStore.dispatch(TabListAction.AddTabAction(insecureTab)).joinBlocking() - browserStore.dispatch(updateSecurityInfoAction).joinBlocking() - appStore.waitUntilIdle() + browserStore.dispatch(TabListAction.AddTabAction(insecureTab)) + browserStore.dispatch(updateSecurityInfoAction) assertFalse(appStore.state.showTrackingProtectionCfrForTab.getOrDefault("1", false)) } @@ -103,9 +99,8 @@ class CfrMiddlewareTest { issuer = "Test", ), ) - browserStore.dispatch(TabListAction.AddTabAction(mozillaTab)).joinBlocking() - browserStore.dispatch(updateSecurityInfoAction).joinBlocking() - appStore.waitUntilIdle() + browserStore.dispatch(TabListAction.AddTabAction(mozillaTab)) + browserStore.dispatch(updateSecurityInfoAction) assertFalse(appStore.state.showTrackingProtectionCfrForTab.getOrDefault("1", false)) }