diff --git a/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/disk/AuthDiskSourceImpl.kt b/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/disk/AuthDiskSourceImpl.kt index 48f33483e..54e006b45 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/disk/AuthDiskSourceImpl.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/disk/AuthDiskSourceImpl.kt @@ -4,6 +4,7 @@ import android.content.SharedPreferences import com.x8bit.bitwarden.data.auth.datasource.disk.model.UserStateJson import com.x8bit.bitwarden.data.platform.datasource.disk.BaseDiskSource import com.x8bit.bitwarden.data.platform.datasource.disk.BaseDiskSource.Companion.BASE_KEY +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.data.vault.datasource.network.model.SyncResponseJson import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow @@ -58,10 +59,7 @@ class AuthDiskSourceImpl( get() = mutableUserStateFlow .onSubscription { emit(userState) } - private val mutableUserStateFlow = MutableSharedFlow( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableUserStateFlow = bufferedMutableSharedFlow(replay = 1) override fun getUserKey(userId: String): String? = getString(key = "${MASTER_KEY_ENCRYPTION_USER_KEY}_$userId") @@ -132,9 +130,6 @@ class AuthDiskSourceImpl( userId: String, ): MutableSharedFlow?> = mutableOrganizationsFlowMap.getOrPut(userId) { - MutableSharedFlow( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + bufferedMutableSharedFlow(replay = 1) } } diff --git a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt index 51229721c..d61a512be 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt @@ -33,6 +33,7 @@ import com.x8bit.bitwarden.data.auth.util.KdfParamsConstants.DEFAULT_PBKDF2_ITER import com.x8bit.bitwarden.data.auth.util.toSdkParams import com.x8bit.bitwarden.data.platform.manager.dispatcher.DispatcherManager import com.x8bit.bitwarden.data.platform.repository.EnvironmentRepository +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.data.platform.util.asFailure import com.x8bit.bitwarden.data.platform.util.flatMap import com.x8bit.bitwarden.data.vault.repository.VaultRepository @@ -40,7 +41,6 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow @@ -124,7 +124,7 @@ class AuthRepositoryImpl constructor( ) private val mutableCaptchaTokenFlow = - MutableSharedFlow(extraBufferCapacity = Int.MAX_VALUE) + bufferedMutableSharedFlow() override val captchaTokenResultFlow: Flow = mutableCaptchaTokenFlow.asSharedFlow() diff --git a/app/src/main/java/com/x8bit/bitwarden/data/platform/datasource/disk/EnvironmentDiskSourceImpl.kt b/app/src/main/java/com/x8bit/bitwarden/data/platform/datasource/disk/EnvironmentDiskSourceImpl.kt index f0d463dbf..ff60cb746 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/platform/datasource/disk/EnvironmentDiskSourceImpl.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/platform/datasource/disk/EnvironmentDiskSourceImpl.kt @@ -3,8 +3,8 @@ package com.x8bit.bitwarden.data.platform.datasource.disk import android.content.SharedPreferences import com.x8bit.bitwarden.data.auth.datasource.disk.model.EnvironmentUrlDataJson import com.x8bit.bitwarden.data.platform.datasource.disk.BaseDiskSource.Companion.BASE_KEY +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.onSubscription import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json @@ -33,8 +33,6 @@ class EnvironmentDiskSourceImpl( get() = mutableEnvironmentUrlDataFlow .onSubscription { emit(preAuthEnvironmentUrlData) } - private val mutableEnvironmentUrlDataFlow = MutableSharedFlow( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEnvironmentUrlDataFlow = + bufferedMutableSharedFlow(replay = 1) } diff --git a/app/src/main/java/com/x8bit/bitwarden/data/platform/repository/util/SharedFlowExtensions.kt b/app/src/main/java/com/x8bit/bitwarden/data/platform/repository/util/SharedFlowExtensions.kt index 6aa968b44..8735fd4ab 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/platform/repository/util/SharedFlowExtensions.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/platform/repository/util/SharedFlowExtensions.kt @@ -3,7 +3,12 @@ package com.x8bit.bitwarden.data.platform.repository.util import kotlinx.coroutines.flow.MutableSharedFlow /** - * Creates a [MutableSharedFlow] with a buffer of [Int.MAX_VALUE]. + * Creates a [MutableSharedFlow] with a buffer of [Int.MAX_VALUE] and the given [replay] count. */ -fun bufferedMutableSharedFlow(): MutableSharedFlow = - MutableSharedFlow(extraBufferCapacity = Int.MAX_VALUE) +fun bufferedMutableSharedFlow( + replay: Int = 0, +): MutableSharedFlow = + MutableSharedFlow( + replay = replay, + extraBufferCapacity = Int.MAX_VALUE, + ) diff --git a/app/src/test/java/com/x8bit/bitwarden/data/auth/datasource/disk/util/FakeAuthDiskSource.kt b/app/src/test/java/com/x8bit/bitwarden/data/auth/datasource/disk/util/FakeAuthDiskSource.kt index 00e0ccfe8..c80c25087 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/auth/datasource/disk/util/FakeAuthDiskSource.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/auth/datasource/disk/util/FakeAuthDiskSource.kt @@ -2,6 +2,7 @@ package com.x8bit.bitwarden.data.auth.datasource.disk.util import com.x8bit.bitwarden.data.auth.datasource.disk.AuthDiskSource import com.x8bit.bitwarden.data.auth.datasource.disk.model.UserStateJson +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.data.vault.datasource.network.model.SyncResponseJson import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow @@ -16,11 +17,7 @@ class FakeAuthDiskSource : AuthDiskSource { private val mutableOrganizationsFlowMap = mutableMapOf?>>() - private val mutableUserStateFlow = - MutableSharedFlow( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableUserStateFlow = bufferedMutableSharedFlow(replay = 1) private val storedUserKeys = mutableMapOf() private val storedPrivateKeys = mutableMapOf() @@ -121,10 +118,7 @@ class FakeAuthDiskSource : AuthDiskSource { userId: String, ): MutableSharedFlow?> = mutableOrganizationsFlowMap.getOrPut(userId) { - MutableSharedFlow( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + bufferedMutableSharedFlow(replay = 1) } //endregion Private helper functions diff --git a/app/src/test/java/com/x8bit/bitwarden/data/platform/repository/EnvironmentRepositoryTest.kt b/app/src/test/java/com/x8bit/bitwarden/data/platform/repository/EnvironmentRepositoryTest.kt index 20d55a6f8..b0dc30cbf 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/platform/repository/EnvironmentRepositoryTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/platform/repository/EnvironmentRepositoryTest.kt @@ -9,13 +9,13 @@ import com.x8bit.bitwarden.data.platform.base.FakeDispatcherManager import com.x8bit.bitwarden.data.platform.datasource.disk.EnvironmentDiskSource import com.x8bit.bitwarden.data.platform.manager.dispatcher.DispatcherManager import com.x8bit.bitwarden.data.platform.repository.model.Environment +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.data.platform.repository.util.toEnvironmentUrls import io.mockk.every import io.mockk.mockk import io.mockk.mockkStatic import io.mockk.unmockkStatic import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.onSubscription import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.AfterEach @@ -179,8 +179,5 @@ private class FakeEnvironmentDiskSource : EnvironmentDiskSource { .onSubscription { emit(preAuthEnvironmentUrlData) } private val mutablePreAuthEnvironmentUrlDataFlow = - MutableSharedFlow( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + bufferedMutableSharedFlow(replay = 1) } diff --git a/app/src/test/java/com/x8bit/bitwarden/data/tools/generator/datasource/disk/dao/FakePasswordHistoryDao.kt b/app/src/test/java/com/x8bit/bitwarden/data/tools/generator/datasource/disk/dao/FakePasswordHistoryDao.kt index 7af6d274e..db172200a 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/tools/generator/datasource/disk/dao/FakePasswordHistoryDao.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/tools/generator/datasource/disk/dao/FakePasswordHistoryDao.kt @@ -1,17 +1,15 @@ package com.x8bit.bitwarden.data.tools.generator.datasource.disk.dao +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.data.tools.generator.datasource.disk.entity.PasswordHistoryEntity import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.map class FakePasswordHistoryDao : PasswordHistoryDao { val storedPasswordHistories = mutableListOf() - private val passwordHistoriesFlow = MutableSharedFlow>( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + private val passwordHistoriesFlow = + bufferedMutableSharedFlow>(replay = 1) init { passwordHistoriesFlow.tryEmit(emptyList()) diff --git a/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/disk/dao/FakeCiphersDao.kt b/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/disk/dao/FakeCiphersDao.kt index 29ffc2367..9dbfa7d23 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/disk/dao/FakeCiphersDao.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/disk/dao/FakeCiphersDao.kt @@ -1,8 +1,8 @@ package com.x8bit.bitwarden.data.vault.datasource.disk.dao +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.data.vault.datasource.disk.entity.CipherEntity import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.map class FakeCiphersDao : CiphersDao { @@ -11,10 +11,7 @@ class FakeCiphersDao : CiphersDao { var deleteCiphersCalled: Boolean = false - private val ciphersFlow = MutableSharedFlow>( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + private val ciphersFlow = bufferedMutableSharedFlow>(replay = 1) init { ciphersFlow.tryEmit(emptyList()) diff --git a/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/disk/dao/FakeCollectionsDao.kt b/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/disk/dao/FakeCollectionsDao.kt index 8444e6205..ee3ba3c2b 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/disk/dao/FakeCollectionsDao.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/disk/dao/FakeCollectionsDao.kt @@ -1,8 +1,8 @@ package com.x8bit.bitwarden.data.vault.datasource.disk.dao +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.data.vault.datasource.disk.entity.CollectionEntity import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.map class FakeCollectionsDao : CollectionsDao { @@ -12,10 +12,7 @@ class FakeCollectionsDao : CollectionsDao { var deleteCollectionCalled: Boolean = false var deleteCollectionsCalled: Boolean = false - private val collectionsFlow = MutableSharedFlow>( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + private val collectionsFlow = bufferedMutableSharedFlow>(replay = 1) init { collectionsFlow.tryEmit(emptyList()) diff --git a/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/disk/dao/FakeFoldersDao.kt b/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/disk/dao/FakeFoldersDao.kt index 218d28c32..a73fd086e 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/disk/dao/FakeFoldersDao.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/disk/dao/FakeFoldersDao.kt @@ -1,8 +1,8 @@ package com.x8bit.bitwarden.data.vault.datasource.disk.dao +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.data.vault.datasource.disk.entity.FolderEntity import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.map class FakeFoldersDao : FoldersDao { @@ -12,10 +12,7 @@ class FakeFoldersDao : FoldersDao { var deleteFolderCalled: Boolean = false var deleteFoldersCalled: Boolean = false - private val foldersFlow = MutableSharedFlow>( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + private val foldersFlow = bufferedMutableSharedFlow>(replay = 1) init { foldersFlow.tryEmit(emptyList()) diff --git a/app/src/test/java/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryTest.kt b/app/src/test/java/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryTest.kt index ed8a7bfb4..e3490c67b 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/vault/repository/VaultRepositoryTest.kt @@ -60,7 +60,6 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.launch import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.Assertions.assertEquals @@ -92,10 +91,8 @@ class VaultRepositoryTest { val mockCipherList = listOf(createMockCipher(number = 1)) val mockEncryptedCipherList = mockCipherList.toEncryptedSdkCipherList() val mockCipherViewList = listOf(createMockCipherView(number = 1)) - val mutableCiphersStateFlow = MutableSharedFlow>( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + val mutableCiphersStateFlow = + bufferedMutableSharedFlow>(replay = 1) every { vaultDiskSource.getCiphers(userId = MOCK_USER_STATE.activeUserId) } returns mutableCiphersStateFlow @@ -118,10 +115,8 @@ class VaultRepositoryTest { val throwable = Throwable("Fail") val mockCipherList = listOf(createMockCipher(number = 1)) val mockEncryptedCipherList = mockCipherList.toEncryptedSdkCipherList() - val mutableCiphersStateFlow = MutableSharedFlow>( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + val mutableCiphersStateFlow = + bufferedMutableSharedFlow>(replay = 1) every { vaultDiskSource.getCiphers(userId = MOCK_USER_STATE.activeUserId) } returns mutableCiphersStateFlow @@ -146,10 +141,8 @@ class VaultRepositoryTest { val mockCollectionList = listOf(createMockCollection(number = 1)) val mockEncryptedCollectionList = mockCollectionList.toEncryptedSdkCollectionList() val mockCollectionViewList = listOf(createMockCollectionView(number = 1)) - val mutableCollectionsStateFlow = MutableSharedFlow>( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + val mutableCollectionsStateFlow = + bufferedMutableSharedFlow>(replay = 1) every { vaultDiskSource.getCollections(userId = MOCK_USER_STATE.activeUserId) } returns mutableCollectionsStateFlow @@ -172,10 +165,8 @@ class VaultRepositoryTest { val throwable = Throwable("Fail") val mockCollectionList = listOf(createMockCollection(number = 1)) val mockEncryptedCollectionList = mockCollectionList.toEncryptedSdkCollectionList() - val mutableCollectionStateFlow = MutableSharedFlow>( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + val mutableCollectionStateFlow = + bufferedMutableSharedFlow>(replay = 1) every { vaultDiskSource.getCollections(userId = MOCK_USER_STATE.activeUserId) } returns mutableCollectionStateFlow @@ -200,10 +191,8 @@ class VaultRepositoryTest { val mockFolderList = listOf(createMockFolder(number = 1)) val mockEncryptedFolderList = mockFolderList.toEncryptedSdkFolderList() val mockFolderViewList = listOf(createMockFolderView(number = 1)) - val mutableFoldersStateFlow = MutableSharedFlow>( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + val mutableFoldersStateFlow = + bufferedMutableSharedFlow>(replay = 1) every { vaultDiskSource.getFolders(userId = MOCK_USER_STATE.activeUserId) } returns mutableFoldersStateFlow @@ -226,10 +215,8 @@ class VaultRepositoryTest { val throwable = Throwable("Fail") val mockFolderList = listOf(createMockFolder(number = 1)) val mockEncryptedFolderList = mockFolderList.toEncryptedSdkFolderList() - val mutableFoldersStateFlow = MutableSharedFlow>( - replay = 1, - extraBufferCapacity = Int.MAX_VALUE, - ) + val mutableFoldersStateFlow = + bufferedMutableSharedFlow>(replay = 1) every { vaultDiskSource.getFolders(userId = MOCK_USER_STATE.activeUserId) } returns mutableFoldersStateFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/enterprisesignon/EnterpriseSignOnScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/enterprisesignon/EnterpriseSignOnScreenTest.kt index f6eac96c6..3fa839b2e 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/enterprisesignon/EnterpriseSignOnScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/enterprisesignon/EnterpriseSignOnScreenTest.kt @@ -11,13 +11,13 @@ import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performTextInput +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.platform.base.util.asText import io.mockk.every import io.mockk.mockk import io.mockk.verify import junit.framework.TestCase.assertTrue -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import org.junit.Before @@ -25,9 +25,7 @@ import org.junit.Test class EnterpriseSignOnScreenTest : BaseComposeTest() { private var onNavigateBackCalled = false - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE) private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/environment/EnvironmentScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/environment/EnvironmentScreenTest.kt index 5d56d7d5e..9e9ddd3c8 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/environment/EnvironmentScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/environment/EnvironmentScreenTest.kt @@ -11,11 +11,11 @@ import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performTextInput +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import org.junit.Assert.assertTrue @@ -24,9 +24,7 @@ import org.junit.Test class EnvironmentScreenTest : BaseComposeTest() { private var onNavigateBackCalled = false - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE) private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingScreenTest.kt index 741c40990..28f6fb438 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/landing/LandingScreenTest.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.test.performScrollTo import androidx.compose.ui.test.performTextInput import androidx.test.core.app.ApplicationProvider import com.x8bit.bitwarden.data.platform.repository.model.Environment +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.platform.base.util.asText import com.x8bit.bitwarden.ui.platform.components.model.AccountSummary @@ -36,7 +37,6 @@ import com.x8bit.bitwarden.ui.util.performLogoutAccountConfirmationClick import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import org.junit.Before @@ -49,9 +49,7 @@ class LandingScreenTest : BaseComposeTest() { private var onNavigateToCreateAccountCalled = false private var onNavigateToLoginCalled = false private var onNavigateToEnvironmentCalled = false - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE) private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginScreenTest.kt index f27d467ee..39df9d74e 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginScreenTest.kt @@ -13,6 +13,7 @@ import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollTo import androidx.compose.ui.test.performTextInput +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler import com.x8bit.bitwarden.ui.platform.components.BasicDialogState @@ -34,7 +35,6 @@ import io.mockk.every import io.mockk.mockk import io.mockk.verify import junit.framework.TestCase.assertTrue -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import org.junit.Before @@ -47,9 +47,7 @@ class LoginScreenTest : BaseComposeTest() { private var onNavigateBackCalled = false private var onNavigateToEnterpriseSignOnCalled = false private var onNavigateToLoginWithDeviceCalled = false - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE) private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModelTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModelTest.kt index bce939f61..73ac1b8a5 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModelTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModelTest.kt @@ -12,6 +12,7 @@ import com.x8bit.bitwarden.data.auth.repository.util.CaptchaCallbackTokenResult import com.x8bit.bitwarden.data.auth.repository.util.generateUriForCaptcha import com.x8bit.bitwarden.data.platform.repository.model.Environment import com.x8bit.bitwarden.data.platform.repository.util.FakeEnvironmentRepository +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.data.vault.repository.VaultRepository import com.x8bit.bitwarden.ui.platform.base.BaseViewModelTest import com.x8bit.bitwarden.ui.platform.base.util.asText @@ -28,7 +29,6 @@ import io.mockk.mockkStatic import io.mockk.runs import io.mockk.unmockkStatic import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.AfterEach @@ -41,9 +41,8 @@ class LoginViewModelTest : BaseViewModelTest() { private val savedStateHandle = SavedStateHandle().also { it["email_address"] = "test@gmail.com" } - private val mutableCaptchaTokenResultFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableCaptchaTokenResultFlow = + bufferedMutableSharedFlow() private val mutableUserStateFlow = MutableStateFlow(null) private val authRepository: AuthRepository = mockk(relaxed = true) { every { captchaTokenResultFlow } returns mutableCaptchaTokenResultFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/loginwithdevice/LoginWithDeviceScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/loginwithdevice/LoginWithDeviceScreenTest.kt index d0c350557..12972673c 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/loginwithdevice/LoginWithDeviceScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/loginwithdevice/LoginWithDeviceScreenTest.kt @@ -5,6 +5,7 @@ import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollTo +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.platform.base.util.asText import com.x8bit.bitwarden.ui.util.isProgressBar @@ -12,7 +13,6 @@ import io.mockk.every import io.mockk.mockk import io.mockk.verify import junit.framework.TestCase -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import org.junit.Before @@ -20,9 +20,7 @@ import org.junit.Test class LoginWithDeviceScreenTest : BaseComposeTest() { private var onNavigateBackCalled = false - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE) private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/vaultunlock/VaultUnlockScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/vaultunlock/VaultUnlockScreenTest.kt index e9606d6ef..bf3de5ba5 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/vaultunlock/VaultUnlockScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/vaultunlock/VaultUnlockScreenTest.kt @@ -13,6 +13,7 @@ import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollTo import androidx.compose.ui.test.performTextInput +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.platform.components.model.AccountSummary import com.x8bit.bitwarden.ui.util.assertLockOrLogoutDialogIsDisplayed @@ -30,7 +31,6 @@ import com.x8bit.bitwarden.ui.util.performLogoutAccountConfirmationClick import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import org.junit.Before @@ -38,9 +38,7 @@ import org.junit.Test class VaultUnlockScreenTest : BaseComposeTest() { - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE) private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/accountsecurity/AccountSecurityScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/accountsecurity/AccountSecurityScreenTest.kt index 994b5ea8e..601584027 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/accountsecurity/AccountSecurityScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/accountsecurity/AccountSecurityScreenTest.kt @@ -15,6 +15,7 @@ import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollTo import androidx.core.net.toUri +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler import com.x8bit.bitwarden.ui.platform.base.util.asText @@ -23,7 +24,6 @@ import io.mockk.just import io.mockk.mockk import io.mockk.runs import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import org.junit.Assert.assertTrue @@ -38,9 +38,7 @@ class AccountSecurityScreenTest : BaseComposeTest() { private val intentHandler = mockk { every { launchUri(any()) } just runs } - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE) private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/accountsecurity/deleteaccount/DeleteAccountScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/accountsecurity/deleteaccount/DeleteAccountScreenTest.kt index 796de01aa..9be4976e8 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/accountsecurity/deleteaccount/DeleteAccountScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/accountsecurity/deleteaccount/DeleteAccountScreenTest.kt @@ -11,12 +11,12 @@ import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollTo import androidx.compose.ui.test.performTextInput +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.platform.base.util.asText import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import org.junit.Assert.assertTrue @@ -27,9 +27,7 @@ class DeleteAccountScreenTest : BaseComposeTest() { private var onNavigateBackCalled = false - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE) private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/autofill/AutoFillScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/autofill/AutoFillScreenTest.kt index ed9c18b62..c69900db2 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/autofill/AutoFillScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/autofill/AutoFillScreenTest.kt @@ -11,11 +11,11 @@ import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollTo +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import org.junit.Assert.assertTrue @@ -26,9 +26,7 @@ class AutoFillScreenTest : BaseComposeTest() { private var onNavigateBackCalled = false - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE) private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/folders/FoldersScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/folders/FoldersScreenTest.kt index 60f977ae7..af7034087 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/folders/FoldersScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/folders/FoldersScreenTest.kt @@ -2,11 +2,11 @@ package com.x8bit.bitwarden.ui.platform.feature.settings.folders import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.performClick +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import org.junit.Assert.assertTrue import org.junit.Before @@ -15,9 +15,7 @@ import org.junit.Test class FoldersScreenTest : BaseComposeTest() { private var onNavigateBackCalled = false - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(Unit) val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsScreenTest.kt index 16810aa90..60a6d384a 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/settings/vault/VaultSettingsScreenTest.kt @@ -7,11 +7,11 @@ import androidx.compose.ui.test.isDialog import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import org.junit.Assert.assertTrue import org.junit.Before @@ -21,9 +21,7 @@ class VaultSettingsScreenTest : BaseComposeTest() { private var onNavigateBackCalled = false private var onNavigateToFoldersCalled = false - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(Unit) val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarScreenTest.kt index b7908be73..a3cdb7634 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarScreenTest.kt @@ -3,21 +3,19 @@ package com.x8bit.bitwarden.ui.platform.feature.vaultunlockednavbar import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.navigation.navOptions +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.platform.base.FakeNavHostController import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import org.junit.Before import org.junit.Test class VaultUnlockedNavBarScreenTest : BaseComposeTest() { private val fakeNavHostController = FakeNavHostController() - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(Unit) val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorScreenTest.kt index 09db7f3d5..51736d6f6 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/generator/GeneratorScreenTest.kt @@ -24,12 +24,12 @@ import androidx.compose.ui.test.performTextInput import androidx.compose.ui.test.performTouchInput import androidx.compose.ui.test.swipeRight import androidx.compose.ui.text.AnnotatedString +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.platform.base.util.asText import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import org.junit.Before import org.junit.Test @@ -54,10 +54,7 @@ class GeneratorScreenTest : BaseComposeTest() { ), ) - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) - + private val mutableEventFlow = bufferedMutableSharedFlow() private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow every { stateFlow } returns mutableStateFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/generator/passwordhistory/PasswordHistoryScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/generator/passwordhistory/PasswordHistoryScreenTest.kt index 3eacb9fec..11e2681da 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/generator/passwordhistory/PasswordHistoryScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/generator/passwordhistory/PasswordHistoryScreenTest.kt @@ -4,12 +4,12 @@ import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.platform.base.util.asText import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import org.junit.Before import org.junit.Test @@ -18,9 +18,7 @@ import org.junit.jupiter.api.Assertions.assertTrue class PasswordHistoryScreenTest : BaseComposeTest() { private var onNavigateBackCalled = false - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow( PasswordHistoryState(PasswordHistoryState.ViewState.Loading), diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendScreenTest.kt index 3a2010476..cb9558c74 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/send/addsend/AddSendScreenTest.kt @@ -11,11 +11,11 @@ import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollTo import androidx.compose.ui.test.performTextInput +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.test.runTest @@ -25,9 +25,7 @@ import org.junit.Test class AddSendScreenTest : BaseComposeTest() { private var onNavigateBackCalled = false - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE) private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/additem/VaultAddItemScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/additem/VaultAddItemScreenTest.kt index 371b34f73..dd3c7b465 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/additem/VaultAddItemScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/additem/VaultAddItemScreenTest.kt @@ -25,6 +25,7 @@ import androidx.compose.ui.test.performScrollTo import androidx.compose.ui.test.performTextClearance import androidx.compose.ui.test.performTextInput import androidx.compose.ui.test.performTouchInput +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.platform.base.util.FakePermissionManager import com.x8bit.bitwarden.ui.platform.base.util.asText @@ -40,7 +41,6 @@ import io.mockk.just import io.mockk.mockk import io.mockk.runs import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import org.junit.Assert.assertTrue @@ -55,7 +55,7 @@ class VaultAddItemScreenTest : BaseComposeTest() { private val clipboardManager = mockk() - private val mutableEventFlow = MutableSharedFlow(Int.MAX_VALUE) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE_LOGIN) private val fakePermissionManager: FakePermissionManager = FakePermissionManager() diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/additem/VaultAddItemViewModelTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/additem/VaultAddItemViewModelTest.kt index 3337c9b79..ebe4c026f 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/additem/VaultAddItemViewModelTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/additem/VaultAddItemViewModelTest.kt @@ -5,6 +5,7 @@ import app.cash.turbine.test import com.bitwarden.core.CipherView import com.x8bit.bitwarden.R import com.x8bit.bitwarden.data.platform.repository.model.DataState +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.data.vault.repository.VaultRepository import com.x8bit.bitwarden.data.vault.repository.model.CreateCipherResult import com.x8bit.bitwarden.data.vault.repository.model.UpdateCipherResult @@ -43,9 +44,7 @@ class VaultAddItemViewModelTest : BaseViewModelTest() { vaultAddEditType = VaultAddEditType.AddItem, ) - private val totpTestCodeFlow: MutableSharedFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val totpTestCodeFlow: MutableSharedFlow = bufferedMutableSharedFlow() private val mutableVaultItemFlow = MutableStateFlow>(DataState.Loading) private val vaultRepository: VaultRepository = mockk { @@ -493,7 +492,7 @@ class VaultAddItemViewModelTest : BaseViewModelTest() { viewModel.eventFlow.test { viewModel.actionChannel.trySend( VaultAddItemAction.ItemType.LoginType.SetupTotpClick( - isGranted = true, + isGranted = true, ), ) assertEquals( @@ -512,7 +511,7 @@ class VaultAddItemViewModelTest : BaseViewModelTest() { viewModel.eventFlow.test { viewModel.actionChannel.trySend( VaultAddItemAction.ItemType.LoginType.SetupTotpClick( - isGranted = false, + isGranted = false, ), ) assertEquals( diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/item/VaultItemScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/item/VaultItemScreenTest.kt index 90dbd6fec..a860c9d45 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/item/VaultItemScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/item/VaultItemScreenTest.kt @@ -16,6 +16,7 @@ import androidx.compose.ui.test.onSiblings import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performTextInput import androidx.core.net.toUri +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler import com.x8bit.bitwarden.ui.platform.base.util.asText @@ -30,7 +31,6 @@ import io.mockk.just import io.mockk.mockk import io.mockk.runs import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import org.junit.Assert.assertEquals @@ -47,9 +47,7 @@ class VaultItemScreenTest : BaseComposeTest() { private val clipboardManager = mockk() private val intentHandler = mockk() - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE) private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreenTest.kt index d650e9382..049049b81 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreenTest.kt @@ -9,20 +9,20 @@ import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollToNode +import com.x8bit.bitwarden.R +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.platform.base.util.asText import com.x8bit.bitwarden.ui.util.isProgressBar import io.mockk.every import io.mockk.mockk import io.mockk.verify -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test -import com.x8bit.bitwarden.R class VaultItemListingScreenTest : BaseComposeTest() { @@ -30,9 +30,7 @@ class VaultItemListingScreenTest : BaseComposeTest() { private var onNavigateToVaultAddItemScreenCalled = false private var onNavigateToVaultItemId: String? = null - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE) private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/qrcodescan/QrCodeScanScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/qrcodescan/QrCodeScanScreenTest.kt index 327e305ab..90e0d1e7f 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/qrcodescan/QrCodeScanScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/qrcodescan/QrCodeScanScreenTest.kt @@ -3,13 +3,13 @@ package com.x8bit.bitwarden.ui.vault.feature.qrcodescan import androidx.camera.core.ImageProxy import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.vault.feature.qrcodescan.util.FakeQrCodeAnalyzer import io.mockk.every import io.mockk.mockk import io.mockk.verify import junit.framework.TestCase.assertTrue -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test @@ -21,9 +21,7 @@ class QrCodeScanScreenTest : BaseComposeTest() { private val imageProxy: ImageProxy = mockk() private val qrCodeAnalyzer = FakeQrCodeAnalyzer() - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/qrcodescan/QrCodeScanViewModelTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/qrcodescan/QrCodeScanViewModelTest.kt index b9b098d6b..0e2c7a6f6 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/qrcodescan/QrCodeScanViewModelTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/qrcodescan/QrCodeScanViewModelTest.kt @@ -1,6 +1,7 @@ package com.x8bit.bitwarden.ui.vault.feature.qrcodescan import app.cash.turbine.test +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.data.vault.repository.VaultRepository import com.x8bit.bitwarden.ui.platform.base.BaseViewModelTest import com.x8bit.bitwarden.ui.platform.base.util.asText @@ -10,16 +11,13 @@ import io.mockk.mockk import io.mockk.runs import io.mockk.verify import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test class QrCodeScanViewModelTest : BaseViewModelTest() { - private val totpTestCodeFlow: Flow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val totpTestCodeFlow: Flow = bufferedMutableSharedFlow() private val vaultRepository: VaultRepository = mockk { every { totpCodeFlow } returns totpTestCodeFlow every { emitTotpCode(any()) } just runs diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreenTest.kt index e655c813d..a95b699fc 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreenTest.kt @@ -15,6 +15,7 @@ import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollToNode import com.x8bit.bitwarden.R +import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler import com.x8bit.bitwarden.ui.platform.base.util.asText @@ -40,7 +41,6 @@ import io.mockk.every import io.mockk.mockk import io.mockk.verify import kotlinx.collections.immutable.persistentListOf -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import org.junit.Assert.assertEquals @@ -59,9 +59,7 @@ class VaultScreenTest : BaseComposeTest() { private var onDimBottomNavBarRequestCalled = false private val intentHandler = mockk(relaxed = true) - private val mutableEventFlow = MutableSharedFlow( - extraBufferCapacity = Int.MAX_VALUE, - ) + private val mutableEventFlow = bufferedMutableSharedFlow() private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE) private val viewModel = mockk(relaxed = true) { every { eventFlow } returns mutableEventFlow