mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
Use bufferedMutableSharedFlow where appropriate (#476)
This commit is contained in:
parent
b3bee9ae20
commit
0d3038a717
34 changed files with 92 additions and 170 deletions
|
@ -4,6 +4,7 @@ import android.content.SharedPreferences
|
||||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.UserStateJson
|
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
|
||||||
import com.x8bit.bitwarden.data.platform.datasource.disk.BaseDiskSource.Companion.BASE_KEY
|
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 com.x8bit.bitwarden.data.vault.datasource.network.model.SyncResponseJson
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
|
@ -58,10 +59,7 @@ class AuthDiskSourceImpl(
|
||||||
get() = mutableUserStateFlow
|
get() = mutableUserStateFlow
|
||||||
.onSubscription { emit(userState) }
|
.onSubscription { emit(userState) }
|
||||||
|
|
||||||
private val mutableUserStateFlow = MutableSharedFlow<UserStateJson?>(
|
private val mutableUserStateFlow = bufferedMutableSharedFlow<UserStateJson?>(replay = 1)
|
||||||
replay = 1,
|
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
|
|
||||||
override fun getUserKey(userId: String): String? =
|
override fun getUserKey(userId: String): String? =
|
||||||
getString(key = "${MASTER_KEY_ENCRYPTION_USER_KEY}_$userId")
|
getString(key = "${MASTER_KEY_ENCRYPTION_USER_KEY}_$userId")
|
||||||
|
@ -132,9 +130,6 @@ class AuthDiskSourceImpl(
|
||||||
userId: String,
|
userId: String,
|
||||||
): MutableSharedFlow<List<SyncResponseJson.Profile.Organization>?> =
|
): MutableSharedFlow<List<SyncResponseJson.Profile.Organization>?> =
|
||||||
mutableOrganizationsFlowMap.getOrPut(userId) {
|
mutableOrganizationsFlowMap.getOrPut(userId) {
|
||||||
MutableSharedFlow(
|
bufferedMutableSharedFlow(replay = 1)
|
||||||
replay = 1,
|
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.auth.util.toSdkParams
|
||||||
import com.x8bit.bitwarden.data.platform.manager.dispatcher.DispatcherManager
|
import com.x8bit.bitwarden.data.platform.manager.dispatcher.DispatcherManager
|
||||||
import com.x8bit.bitwarden.data.platform.repository.EnvironmentRepository
|
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.asFailure
|
||||||
import com.x8bit.bitwarden.data.platform.util.flatMap
|
import com.x8bit.bitwarden.data.platform.util.flatMap
|
||||||
import com.x8bit.bitwarden.data.vault.repository.VaultRepository
|
import com.x8bit.bitwarden.data.vault.repository.VaultRepository
|
||||||
|
@ -40,7 +41,6 @@ import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
@ -124,7 +124,7 @@ class AuthRepositoryImpl constructor(
|
||||||
)
|
)
|
||||||
|
|
||||||
private val mutableCaptchaTokenFlow =
|
private val mutableCaptchaTokenFlow =
|
||||||
MutableSharedFlow<CaptchaCallbackTokenResult>(extraBufferCapacity = Int.MAX_VALUE)
|
bufferedMutableSharedFlow<CaptchaCallbackTokenResult>()
|
||||||
override val captchaTokenResultFlow: Flow<CaptchaCallbackTokenResult> =
|
override val captchaTokenResultFlow: Flow<CaptchaCallbackTokenResult> =
|
||||||
mutableCaptchaTokenFlow.asSharedFlow()
|
mutableCaptchaTokenFlow.asSharedFlow()
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ package com.x8bit.bitwarden.data.platform.datasource.disk
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.EnvironmentUrlDataJson
|
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.datasource.disk.BaseDiskSource.Companion.BASE_KEY
|
||||||
|
import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.onSubscription
|
import kotlinx.coroutines.flow.onSubscription
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
@ -33,8 +33,6 @@ class EnvironmentDiskSourceImpl(
|
||||||
get() = mutableEnvironmentUrlDataFlow
|
get() = mutableEnvironmentUrlDataFlow
|
||||||
.onSubscription { emit(preAuthEnvironmentUrlData) }
|
.onSubscription { emit(preAuthEnvironmentUrlData) }
|
||||||
|
|
||||||
private val mutableEnvironmentUrlDataFlow = MutableSharedFlow<EnvironmentUrlDataJson?>(
|
private val mutableEnvironmentUrlDataFlow =
|
||||||
replay = 1,
|
bufferedMutableSharedFlow<EnvironmentUrlDataJson?>(replay = 1)
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,12 @@ package com.x8bit.bitwarden.data.platform.repository.util
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
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 <T> bufferedMutableSharedFlow(): MutableSharedFlow<T> =
|
fun <T> bufferedMutableSharedFlow(
|
||||||
MutableSharedFlow(extraBufferCapacity = Int.MAX_VALUE)
|
replay: Int = 0,
|
||||||
|
): MutableSharedFlow<T> =
|
||||||
|
MutableSharedFlow(
|
||||||
|
replay = replay,
|
||||||
|
extraBufferCapacity = Int.MAX_VALUE,
|
||||||
|
)
|
||||||
|
|
|
@ -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.AuthDiskSource
|
||||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.UserStateJson
|
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 com.x8bit.bitwarden.data.vault.datasource.network.model.SyncResponseJson
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
|
@ -16,11 +17,7 @@ class FakeAuthDiskSource : AuthDiskSource {
|
||||||
|
|
||||||
private val mutableOrganizationsFlowMap =
|
private val mutableOrganizationsFlowMap =
|
||||||
mutableMapOf<String, MutableSharedFlow<List<SyncResponseJson.Profile.Organization>?>>()
|
mutableMapOf<String, MutableSharedFlow<List<SyncResponseJson.Profile.Organization>?>>()
|
||||||
private val mutableUserStateFlow =
|
private val mutableUserStateFlow = bufferedMutableSharedFlow<UserStateJson?>(replay = 1)
|
||||||
MutableSharedFlow<UserStateJson?>(
|
|
||||||
replay = 1,
|
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
|
|
||||||
private val storedUserKeys = mutableMapOf<String, String?>()
|
private val storedUserKeys = mutableMapOf<String, String?>()
|
||||||
private val storedPrivateKeys = mutableMapOf<String, String?>()
|
private val storedPrivateKeys = mutableMapOf<String, String?>()
|
||||||
|
@ -121,10 +118,7 @@ class FakeAuthDiskSource : AuthDiskSource {
|
||||||
userId: String,
|
userId: String,
|
||||||
): MutableSharedFlow<List<SyncResponseJson.Profile.Organization>?> =
|
): MutableSharedFlow<List<SyncResponseJson.Profile.Organization>?> =
|
||||||
mutableOrganizationsFlowMap.getOrPut(userId) {
|
mutableOrganizationsFlowMap.getOrPut(userId) {
|
||||||
MutableSharedFlow(
|
bufferedMutableSharedFlow(replay = 1)
|
||||||
replay = 1,
|
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion Private helper functions
|
//endregion Private helper functions
|
||||||
|
|
|
@ -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.datasource.disk.EnvironmentDiskSource
|
||||||
import com.x8bit.bitwarden.data.platform.manager.dispatcher.DispatcherManager
|
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.model.Environment
|
||||||
|
import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow
|
||||||
import com.x8bit.bitwarden.data.platform.repository.util.toEnvironmentUrls
|
import com.x8bit.bitwarden.data.platform.repository.util.toEnvironmentUrls
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.mockkStatic
|
import io.mockk.mockkStatic
|
||||||
import io.mockk.unmockkStatic
|
import io.mockk.unmockkStatic
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.onSubscription
|
import kotlinx.coroutines.flow.onSubscription
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.jupiter.api.AfterEach
|
import org.junit.jupiter.api.AfterEach
|
||||||
|
@ -179,8 +179,5 @@ private class FakeEnvironmentDiskSource : EnvironmentDiskSource {
|
||||||
.onSubscription { emit(preAuthEnvironmentUrlData) }
|
.onSubscription { emit(preAuthEnvironmentUrlData) }
|
||||||
|
|
||||||
private val mutablePreAuthEnvironmentUrlDataFlow =
|
private val mutablePreAuthEnvironmentUrlDataFlow =
|
||||||
MutableSharedFlow<EnvironmentUrlDataJson?>(
|
bufferedMutableSharedFlow<EnvironmentUrlDataJson?>(replay = 1)
|
||||||
replay = 1,
|
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
package com.x8bit.bitwarden.data.tools.generator.datasource.disk.dao
|
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 com.x8bit.bitwarden.data.tools.generator.datasource.disk.entity.PasswordHistoryEntity
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
|
|
||||||
class FakePasswordHistoryDao : PasswordHistoryDao {
|
class FakePasswordHistoryDao : PasswordHistoryDao {
|
||||||
val storedPasswordHistories = mutableListOf<PasswordHistoryEntity>()
|
val storedPasswordHistories = mutableListOf<PasswordHistoryEntity>()
|
||||||
|
|
||||||
private val passwordHistoriesFlow = MutableSharedFlow<List<PasswordHistoryEntity>>(
|
private val passwordHistoriesFlow =
|
||||||
replay = 1,
|
bufferedMutableSharedFlow<List<PasswordHistoryEntity>>(replay = 1)
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
passwordHistoriesFlow.tryEmit(emptyList())
|
passwordHistoriesFlow.tryEmit(emptyList())
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.x8bit.bitwarden.data.vault.datasource.disk.dao
|
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 com.x8bit.bitwarden.data.vault.datasource.disk.entity.CipherEntity
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
|
|
||||||
class FakeCiphersDao : CiphersDao {
|
class FakeCiphersDao : CiphersDao {
|
||||||
|
@ -11,10 +11,7 @@ class FakeCiphersDao : CiphersDao {
|
||||||
|
|
||||||
var deleteCiphersCalled: Boolean = false
|
var deleteCiphersCalled: Boolean = false
|
||||||
|
|
||||||
private val ciphersFlow = MutableSharedFlow<List<CipherEntity>>(
|
private val ciphersFlow = bufferedMutableSharedFlow<List<CipherEntity>>(replay = 1)
|
||||||
replay = 1,
|
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
ciphersFlow.tryEmit(emptyList())
|
ciphersFlow.tryEmit(emptyList())
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.x8bit.bitwarden.data.vault.datasource.disk.dao
|
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 com.x8bit.bitwarden.data.vault.datasource.disk.entity.CollectionEntity
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
|
|
||||||
class FakeCollectionsDao : CollectionsDao {
|
class FakeCollectionsDao : CollectionsDao {
|
||||||
|
@ -12,10 +12,7 @@ class FakeCollectionsDao : CollectionsDao {
|
||||||
var deleteCollectionCalled: Boolean = false
|
var deleteCollectionCalled: Boolean = false
|
||||||
var deleteCollectionsCalled: Boolean = false
|
var deleteCollectionsCalled: Boolean = false
|
||||||
|
|
||||||
private val collectionsFlow = MutableSharedFlow<List<CollectionEntity>>(
|
private val collectionsFlow = bufferedMutableSharedFlow<List<CollectionEntity>>(replay = 1)
|
||||||
replay = 1,
|
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
collectionsFlow.tryEmit(emptyList())
|
collectionsFlow.tryEmit(emptyList())
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.x8bit.bitwarden.data.vault.datasource.disk.dao
|
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 com.x8bit.bitwarden.data.vault.datasource.disk.entity.FolderEntity
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
|
|
||||||
class FakeFoldersDao : FoldersDao {
|
class FakeFoldersDao : FoldersDao {
|
||||||
|
@ -12,10 +12,7 @@ class FakeFoldersDao : FoldersDao {
|
||||||
var deleteFolderCalled: Boolean = false
|
var deleteFolderCalled: Boolean = false
|
||||||
var deleteFoldersCalled: Boolean = false
|
var deleteFoldersCalled: Boolean = false
|
||||||
|
|
||||||
private val foldersFlow = MutableSharedFlow<List<FolderEntity>>(
|
private val foldersFlow = bufferedMutableSharedFlow<List<FolderEntity>>(replay = 1)
|
||||||
replay = 1,
|
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
foldersFlow.tryEmit(emptyList())
|
foldersFlow.tryEmit(emptyList())
|
||||||
|
|
|
@ -60,7 +60,6 @@ import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.jupiter.api.Assertions.assertEquals
|
import org.junit.jupiter.api.Assertions.assertEquals
|
||||||
|
@ -92,10 +91,8 @@ class VaultRepositoryTest {
|
||||||
val mockCipherList = listOf(createMockCipher(number = 1))
|
val mockCipherList = listOf(createMockCipher(number = 1))
|
||||||
val mockEncryptedCipherList = mockCipherList.toEncryptedSdkCipherList()
|
val mockEncryptedCipherList = mockCipherList.toEncryptedSdkCipherList()
|
||||||
val mockCipherViewList = listOf(createMockCipherView(number = 1))
|
val mockCipherViewList = listOf(createMockCipherView(number = 1))
|
||||||
val mutableCiphersStateFlow = MutableSharedFlow<List<SyncResponseJson.Cipher>>(
|
val mutableCiphersStateFlow =
|
||||||
replay = 1,
|
bufferedMutableSharedFlow<List<SyncResponseJson.Cipher>>(replay = 1)
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
every {
|
every {
|
||||||
vaultDiskSource.getCiphers(userId = MOCK_USER_STATE.activeUserId)
|
vaultDiskSource.getCiphers(userId = MOCK_USER_STATE.activeUserId)
|
||||||
} returns mutableCiphersStateFlow
|
} returns mutableCiphersStateFlow
|
||||||
|
@ -118,10 +115,8 @@ class VaultRepositoryTest {
|
||||||
val throwable = Throwable("Fail")
|
val throwable = Throwable("Fail")
|
||||||
val mockCipherList = listOf(createMockCipher(number = 1))
|
val mockCipherList = listOf(createMockCipher(number = 1))
|
||||||
val mockEncryptedCipherList = mockCipherList.toEncryptedSdkCipherList()
|
val mockEncryptedCipherList = mockCipherList.toEncryptedSdkCipherList()
|
||||||
val mutableCiphersStateFlow = MutableSharedFlow<List<SyncResponseJson.Cipher>>(
|
val mutableCiphersStateFlow =
|
||||||
replay = 1,
|
bufferedMutableSharedFlow<List<SyncResponseJson.Cipher>>(replay = 1)
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
every {
|
every {
|
||||||
vaultDiskSource.getCiphers(userId = MOCK_USER_STATE.activeUserId)
|
vaultDiskSource.getCiphers(userId = MOCK_USER_STATE.activeUserId)
|
||||||
} returns mutableCiphersStateFlow
|
} returns mutableCiphersStateFlow
|
||||||
|
@ -146,10 +141,8 @@ class VaultRepositoryTest {
|
||||||
val mockCollectionList = listOf(createMockCollection(number = 1))
|
val mockCollectionList = listOf(createMockCollection(number = 1))
|
||||||
val mockEncryptedCollectionList = mockCollectionList.toEncryptedSdkCollectionList()
|
val mockEncryptedCollectionList = mockCollectionList.toEncryptedSdkCollectionList()
|
||||||
val mockCollectionViewList = listOf(createMockCollectionView(number = 1))
|
val mockCollectionViewList = listOf(createMockCollectionView(number = 1))
|
||||||
val mutableCollectionsStateFlow = MutableSharedFlow<List<SyncResponseJson.Collection>>(
|
val mutableCollectionsStateFlow =
|
||||||
replay = 1,
|
bufferedMutableSharedFlow<List<SyncResponseJson.Collection>>(replay = 1)
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
every {
|
every {
|
||||||
vaultDiskSource.getCollections(userId = MOCK_USER_STATE.activeUserId)
|
vaultDiskSource.getCollections(userId = MOCK_USER_STATE.activeUserId)
|
||||||
} returns mutableCollectionsStateFlow
|
} returns mutableCollectionsStateFlow
|
||||||
|
@ -172,10 +165,8 @@ class VaultRepositoryTest {
|
||||||
val throwable = Throwable("Fail")
|
val throwable = Throwable("Fail")
|
||||||
val mockCollectionList = listOf(createMockCollection(number = 1))
|
val mockCollectionList = listOf(createMockCollection(number = 1))
|
||||||
val mockEncryptedCollectionList = mockCollectionList.toEncryptedSdkCollectionList()
|
val mockEncryptedCollectionList = mockCollectionList.toEncryptedSdkCollectionList()
|
||||||
val mutableCollectionStateFlow = MutableSharedFlow<List<SyncResponseJson.Collection>>(
|
val mutableCollectionStateFlow =
|
||||||
replay = 1,
|
bufferedMutableSharedFlow<List<SyncResponseJson.Collection>>(replay = 1)
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
every {
|
every {
|
||||||
vaultDiskSource.getCollections(userId = MOCK_USER_STATE.activeUserId)
|
vaultDiskSource.getCollections(userId = MOCK_USER_STATE.activeUserId)
|
||||||
} returns mutableCollectionStateFlow
|
} returns mutableCollectionStateFlow
|
||||||
|
@ -200,10 +191,8 @@ class VaultRepositoryTest {
|
||||||
val mockFolderList = listOf(createMockFolder(number = 1))
|
val mockFolderList = listOf(createMockFolder(number = 1))
|
||||||
val mockEncryptedFolderList = mockFolderList.toEncryptedSdkFolderList()
|
val mockEncryptedFolderList = mockFolderList.toEncryptedSdkFolderList()
|
||||||
val mockFolderViewList = listOf(createMockFolderView(number = 1))
|
val mockFolderViewList = listOf(createMockFolderView(number = 1))
|
||||||
val mutableFoldersStateFlow = MutableSharedFlow<List<SyncResponseJson.Folder>>(
|
val mutableFoldersStateFlow =
|
||||||
replay = 1,
|
bufferedMutableSharedFlow<List<SyncResponseJson.Folder>>(replay = 1)
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
every {
|
every {
|
||||||
vaultDiskSource.getFolders(userId = MOCK_USER_STATE.activeUserId)
|
vaultDiskSource.getFolders(userId = MOCK_USER_STATE.activeUserId)
|
||||||
} returns mutableFoldersStateFlow
|
} returns mutableFoldersStateFlow
|
||||||
|
@ -226,10 +215,8 @@ class VaultRepositoryTest {
|
||||||
val throwable = Throwable("Fail")
|
val throwable = Throwable("Fail")
|
||||||
val mockFolderList = listOf(createMockFolder(number = 1))
|
val mockFolderList = listOf(createMockFolder(number = 1))
|
||||||
val mockEncryptedFolderList = mockFolderList.toEncryptedSdkFolderList()
|
val mockEncryptedFolderList = mockFolderList.toEncryptedSdkFolderList()
|
||||||
val mutableFoldersStateFlow = MutableSharedFlow<List<SyncResponseJson.Folder>>(
|
val mutableFoldersStateFlow =
|
||||||
replay = 1,
|
bufferedMutableSharedFlow<List<SyncResponseJson.Folder>>(replay = 1)
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
every {
|
every {
|
||||||
vaultDiskSource.getFolders(userId = MOCK_USER_STATE.activeUserId)
|
vaultDiskSource.getFolders(userId = MOCK_USER_STATE.activeUserId)
|
||||||
} returns mutableFoldersStateFlow
|
} returns mutableFoldersStateFlow
|
||||||
|
|
|
@ -11,13 +11,13 @@ import androidx.compose.ui.test.onNodeWithContentDescription
|
||||||
import androidx.compose.ui.test.onNodeWithText
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performTextInput
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import junit.framework.TestCase.assertTrue
|
import junit.framework.TestCase.assertTrue
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
@ -25,9 +25,7 @@ import org.junit.Test
|
||||||
|
|
||||||
class EnterpriseSignOnScreenTest : BaseComposeTest() {
|
class EnterpriseSignOnScreenTest : BaseComposeTest() {
|
||||||
private var onNavigateBackCalled = false
|
private var onNavigateBackCalled = false
|
||||||
private val mutableEventFlow = MutableSharedFlow<EnterpriseSignOnEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<EnterpriseSignOnEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||||
private val viewModel = mockk<EnterpriseSignOnViewModel>(relaxed = true) {
|
private val viewModel = mockk<EnterpriseSignOnViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -11,11 +11,11 @@ import androidx.compose.ui.test.onNodeWithContentDescription
|
||||||
import androidx.compose.ui.test.onNodeWithText
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performTextInput
|
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.BaseComposeTest
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
|
@ -24,9 +24,7 @@ import org.junit.Test
|
||||||
|
|
||||||
class EnvironmentScreenTest : BaseComposeTest() {
|
class EnvironmentScreenTest : BaseComposeTest() {
|
||||||
private var onNavigateBackCalled = false
|
private var onNavigateBackCalled = false
|
||||||
private val mutableEventFlow = MutableSharedFlow<EnvironmentEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<EnvironmentEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||||
private val viewModel = mockk<EnvironmentViewModel>(relaxed = true) {
|
private val viewModel = mockk<EnvironmentViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -19,6 +19,7 @@ import androidx.compose.ui.test.performScrollTo
|
||||||
import androidx.compose.ui.test.performTextInput
|
import androidx.compose.ui.test.performTextInput
|
||||||
import androidx.test.core.app.ApplicationProvider
|
import androidx.test.core.app.ApplicationProvider
|
||||||
import com.x8bit.bitwarden.data.platform.repository.model.Environment
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
import com.x8bit.bitwarden.ui.platform.components.model.AccountSummary
|
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.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
@ -49,9 +49,7 @@ class LandingScreenTest : BaseComposeTest() {
|
||||||
private var onNavigateToCreateAccountCalled = false
|
private var onNavigateToCreateAccountCalled = false
|
||||||
private var onNavigateToLoginCalled = false
|
private var onNavigateToLoginCalled = false
|
||||||
private var onNavigateToEnvironmentCalled = false
|
private var onNavigateToEnvironmentCalled = false
|
||||||
private val mutableEventFlow = MutableSharedFlow<LandingEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<LandingEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||||
private val viewModel = mockk<LandingViewModel>(relaxed = true) {
|
private val viewModel = mockk<LandingViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -13,6 +13,7 @@ import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performScrollTo
|
import androidx.compose.ui.test.performScrollTo
|
||||||
import androidx.compose.ui.test.performTextInput
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler
|
import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler
|
||||||
import com.x8bit.bitwarden.ui.platform.components.BasicDialogState
|
import com.x8bit.bitwarden.ui.platform.components.BasicDialogState
|
||||||
|
@ -34,7 +35,6 @@ import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import junit.framework.TestCase.assertTrue
|
import junit.framework.TestCase.assertTrue
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
@ -47,9 +47,7 @@ class LoginScreenTest : BaseComposeTest() {
|
||||||
private var onNavigateBackCalled = false
|
private var onNavigateBackCalled = false
|
||||||
private var onNavigateToEnterpriseSignOnCalled = false
|
private var onNavigateToEnterpriseSignOnCalled = false
|
||||||
private var onNavigateToLoginWithDeviceCalled = false
|
private var onNavigateToLoginWithDeviceCalled = false
|
||||||
private val mutableEventFlow = MutableSharedFlow<LoginEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<LoginEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||||
private val viewModel = mockk<LoginViewModel>(relaxed = true) {
|
private val viewModel = mockk<LoginViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -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.auth.repository.util.generateUriForCaptcha
|
||||||
import com.x8bit.bitwarden.data.platform.repository.model.Environment
|
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.FakeEnvironmentRepository
|
||||||
|
import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow
|
||||||
import com.x8bit.bitwarden.data.vault.repository.VaultRepository
|
import com.x8bit.bitwarden.data.vault.repository.VaultRepository
|
||||||
import com.x8bit.bitwarden.ui.platform.base.BaseViewModelTest
|
import com.x8bit.bitwarden.ui.platform.base.BaseViewModelTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
|
@ -28,7 +29,6 @@ import io.mockk.mockkStatic
|
||||||
import io.mockk.runs
|
import io.mockk.runs
|
||||||
import io.mockk.unmockkStatic
|
import io.mockk.unmockkStatic
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.jupiter.api.AfterEach
|
import org.junit.jupiter.api.AfterEach
|
||||||
|
@ -41,9 +41,8 @@ class LoginViewModelTest : BaseViewModelTest() {
|
||||||
private val savedStateHandle = SavedStateHandle().also {
|
private val savedStateHandle = SavedStateHandle().also {
|
||||||
it["email_address"] = "test@gmail.com"
|
it["email_address"] = "test@gmail.com"
|
||||||
}
|
}
|
||||||
private val mutableCaptchaTokenResultFlow = MutableSharedFlow<CaptchaCallbackTokenResult>(
|
private val mutableCaptchaTokenResultFlow =
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
bufferedMutableSharedFlow<CaptchaCallbackTokenResult>()
|
||||||
)
|
|
||||||
private val mutableUserStateFlow = MutableStateFlow<UserState?>(null)
|
private val mutableUserStateFlow = MutableStateFlow<UserState?>(null)
|
||||||
private val authRepository: AuthRepository = mockk(relaxed = true) {
|
private val authRepository: AuthRepository = mockk(relaxed = true) {
|
||||||
every { captchaTokenResultFlow } returns mutableCaptchaTokenResultFlow
|
every { captchaTokenResultFlow } returns mutableCaptchaTokenResultFlow
|
||||||
|
|
|
@ -5,6 +5,7 @@ import androidx.compose.ui.test.onNodeWithContentDescription
|
||||||
import androidx.compose.ui.test.onNodeWithText
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performScrollTo
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
import com.x8bit.bitwarden.ui.util.isProgressBar
|
import com.x8bit.bitwarden.ui.util.isProgressBar
|
||||||
|
@ -12,7 +13,6 @@ import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import junit.framework.TestCase
|
import junit.framework.TestCase
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
@ -20,9 +20,7 @@ import org.junit.Test
|
||||||
|
|
||||||
class LoginWithDeviceScreenTest : BaseComposeTest() {
|
class LoginWithDeviceScreenTest : BaseComposeTest() {
|
||||||
private var onNavigateBackCalled = false
|
private var onNavigateBackCalled = false
|
||||||
private val mutableEventFlow = MutableSharedFlow<LoginWithDeviceEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<LoginWithDeviceEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||||
private val viewModel = mockk<LoginWithDeviceViewModel>(relaxed = true) {
|
private val viewModel = mockk<LoginWithDeviceViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -13,6 +13,7 @@ import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performScrollTo
|
import androidx.compose.ui.test.performScrollTo
|
||||||
import androidx.compose.ui.test.performTextInput
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.platform.components.model.AccountSummary
|
import com.x8bit.bitwarden.ui.platform.components.model.AccountSummary
|
||||||
import com.x8bit.bitwarden.ui.util.assertLockOrLogoutDialogIsDisplayed
|
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.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
@ -38,9 +38,7 @@ import org.junit.Test
|
||||||
|
|
||||||
class VaultUnlockScreenTest : BaseComposeTest() {
|
class VaultUnlockScreenTest : BaseComposeTest() {
|
||||||
|
|
||||||
private val mutableEventFlow = MutableSharedFlow<VaultUnlockEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<VaultUnlockEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||||
private val viewModel = mockk<VaultUnlockViewModel>(relaxed = true) {
|
private val viewModel = mockk<VaultUnlockViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -15,6 +15,7 @@ import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performScrollTo
|
import androidx.compose.ui.test.performScrollTo
|
||||||
import androidx.core.net.toUri
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler
|
import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
|
@ -23,7 +24,6 @@ import io.mockk.just
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.runs
|
import io.mockk.runs
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
|
@ -38,9 +38,7 @@ class AccountSecurityScreenTest : BaseComposeTest() {
|
||||||
private val intentHandler = mockk<IntentHandler> {
|
private val intentHandler = mockk<IntentHandler> {
|
||||||
every { launchUri(any()) } just runs
|
every { launchUri(any()) } just runs
|
||||||
}
|
}
|
||||||
private val mutableEventFlow = MutableSharedFlow<AccountSecurityEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<AccountSecurityEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||||
private val viewModel = mockk<AccountSecurityViewModel>(relaxed = true) {
|
private val viewModel = mockk<AccountSecurityViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -11,12 +11,12 @@ import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performScrollTo
|
import androidx.compose.ui.test.performScrollTo
|
||||||
import androidx.compose.ui.test.performTextInput
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
|
@ -27,9 +27,7 @@ class DeleteAccountScreenTest : BaseComposeTest() {
|
||||||
|
|
||||||
private var onNavigateBackCalled = false
|
private var onNavigateBackCalled = false
|
||||||
|
|
||||||
private val mutableEventFlow = MutableSharedFlow<DeleteAccountEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<DeleteAccountEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||||
private val viewModel = mockk<DeleteAccountViewModel>(relaxed = true) {
|
private val viewModel = mockk<DeleteAccountViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -11,11 +11,11 @@ import androidx.compose.ui.test.onNodeWithContentDescription
|
||||||
import androidx.compose.ui.test.onNodeWithText
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performScrollTo
|
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.BaseComposeTest
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
|
@ -26,9 +26,7 @@ class AutoFillScreenTest : BaseComposeTest() {
|
||||||
|
|
||||||
private var onNavigateBackCalled = false
|
private var onNavigateBackCalled = false
|
||||||
|
|
||||||
private val mutableEventFlow = MutableSharedFlow<AutoFillEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<AutoFillEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||||
private val viewModel = mockk<AutoFillViewModel>(relaxed = true) {
|
private val viewModel = mockk<AutoFillViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -2,11 +2,11 @@ package com.x8bit.bitwarden.ui.platform.feature.settings.folders
|
||||||
|
|
||||||
import androidx.compose.ui.test.onNodeWithContentDescription
|
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||||
import androidx.compose.ui.test.performClick
|
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.BaseComposeTest
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
@ -15,9 +15,7 @@ import org.junit.Test
|
||||||
class FoldersScreenTest : BaseComposeTest() {
|
class FoldersScreenTest : BaseComposeTest() {
|
||||||
|
|
||||||
private var onNavigateBackCalled = false
|
private var onNavigateBackCalled = false
|
||||||
private val mutableEventFlow = MutableSharedFlow<FoldersEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<FoldersEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(Unit)
|
private val mutableStateFlow = MutableStateFlow(Unit)
|
||||||
val viewModel = mockk<FoldersViewModel>(relaxed = true) {
|
val viewModel = mockk<FoldersViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -7,11 +7,11 @@ import androidx.compose.ui.test.isDialog
|
||||||
import androidx.compose.ui.test.onNodeWithContentDescription
|
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||||
import androidx.compose.ui.test.onNodeWithText
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
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.BaseComposeTest
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
@ -21,9 +21,7 @@ class VaultSettingsScreenTest : BaseComposeTest() {
|
||||||
|
|
||||||
private var onNavigateBackCalled = false
|
private var onNavigateBackCalled = false
|
||||||
private var onNavigateToFoldersCalled = false
|
private var onNavigateToFoldersCalled = false
|
||||||
private val mutableEventFlow = MutableSharedFlow<VaultSettingsEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<VaultSettingsEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(Unit)
|
private val mutableStateFlow = MutableStateFlow(Unit)
|
||||||
val viewModel = mockk<VaultSettingsViewModel>(relaxed = true) {
|
val viewModel = mockk<VaultSettingsViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -3,21 +3,19 @@ package com.x8bit.bitwarden.ui.platform.feature.vaultunlockednavbar
|
||||||
import androidx.compose.ui.test.onNodeWithText
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.navigation.navOptions
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.FakeNavHostController
|
import com.x8bit.bitwarden.ui.platform.base.FakeNavHostController
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class VaultUnlockedNavBarScreenTest : BaseComposeTest() {
|
class VaultUnlockedNavBarScreenTest : BaseComposeTest() {
|
||||||
private val fakeNavHostController = FakeNavHostController()
|
private val fakeNavHostController = FakeNavHostController()
|
||||||
private val mutableEventFlow = MutableSharedFlow<VaultUnlockedNavBarEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<VaultUnlockedNavBarEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(Unit)
|
private val mutableStateFlow = MutableStateFlow(Unit)
|
||||||
val viewModel = mockk<VaultUnlockedNavBarViewModel>(relaxed = true) {
|
val viewModel = mockk<VaultUnlockedNavBarViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -24,12 +24,12 @@ import androidx.compose.ui.test.performTextInput
|
||||||
import androidx.compose.ui.test.performTouchInput
|
import androidx.compose.ui.test.performTouchInput
|
||||||
import androidx.compose.ui.test.swipeRight
|
import androidx.compose.ui.test.swipeRight
|
||||||
import androidx.compose.ui.text.AnnotatedString
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -54,10 +54,7 @@ class GeneratorScreenTest : BaseComposeTest() {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
private val mutableEventFlow = MutableSharedFlow<GeneratorEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<GeneratorEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
|
|
||||||
private val viewModel = mockk<GeneratorViewModel>(relaxed = true) {
|
private val viewModel = mockk<GeneratorViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
every { stateFlow } returns mutableStateFlow
|
every { stateFlow } returns mutableStateFlow
|
||||||
|
|
|
@ -4,12 +4,12 @@ import androidx.compose.ui.test.assertIsDisplayed
|
||||||
import androidx.compose.ui.test.onNodeWithContentDescription
|
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||||
import androidx.compose.ui.test.onNodeWithText
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -18,9 +18,7 @@ import org.junit.jupiter.api.Assertions.assertTrue
|
||||||
class PasswordHistoryScreenTest : BaseComposeTest() {
|
class PasswordHistoryScreenTest : BaseComposeTest() {
|
||||||
private var onNavigateBackCalled = false
|
private var onNavigateBackCalled = false
|
||||||
|
|
||||||
private val mutableEventFlow = MutableSharedFlow<PasswordHistoryEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<PasswordHistoryEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
|
|
||||||
private val mutableStateFlow = MutableStateFlow(
|
private val mutableStateFlow = MutableStateFlow(
|
||||||
PasswordHistoryState(PasswordHistoryState.ViewState.Loading),
|
PasswordHistoryState(PasswordHistoryState.ViewState.Loading),
|
||||||
|
|
|
@ -11,11 +11,11 @@ import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performScrollTo
|
import androidx.compose.ui.test.performScrollTo
|
||||||
import androidx.compose.ui.test.performTextInput
|
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.BaseComposeTest
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
|
@ -25,9 +25,7 @@ import org.junit.Test
|
||||||
class AddSendScreenTest : BaseComposeTest() {
|
class AddSendScreenTest : BaseComposeTest() {
|
||||||
|
|
||||||
private var onNavigateBackCalled = false
|
private var onNavigateBackCalled = false
|
||||||
private val mutableEventFlow = MutableSharedFlow<AddSendEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<AddSendEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||||
private val viewModel = mockk<NewSendViewModel>(relaxed = true) {
|
private val viewModel = mockk<NewSendViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -25,6 +25,7 @@ import androidx.compose.ui.test.performScrollTo
|
||||||
import androidx.compose.ui.test.performTextClearance
|
import androidx.compose.ui.test.performTextClearance
|
||||||
import androidx.compose.ui.test.performTextInput
|
import androidx.compose.ui.test.performTextInput
|
||||||
import androidx.compose.ui.test.performTouchInput
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.FakePermissionManager
|
import com.x8bit.bitwarden.ui.platform.base.util.FakePermissionManager
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
|
@ -40,7 +41,6 @@ import io.mockk.just
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.runs
|
import io.mockk.runs
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
|
@ -55,7 +55,7 @@ class VaultAddItemScreenTest : BaseComposeTest() {
|
||||||
|
|
||||||
private val clipboardManager = mockk<ClipboardManager>()
|
private val clipboardManager = mockk<ClipboardManager>()
|
||||||
|
|
||||||
private val mutableEventFlow = MutableSharedFlow<VaultAddItemEvent>(Int.MAX_VALUE)
|
private val mutableEventFlow = bufferedMutableSharedFlow<VaultAddItemEvent>()
|
||||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE_LOGIN)
|
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE_LOGIN)
|
||||||
|
|
||||||
private val fakePermissionManager: FakePermissionManager = FakePermissionManager()
|
private val fakePermissionManager: FakePermissionManager = FakePermissionManager()
|
||||||
|
|
|
@ -5,6 +5,7 @@ import app.cash.turbine.test
|
||||||
import com.bitwarden.core.CipherView
|
import com.bitwarden.core.CipherView
|
||||||
import com.x8bit.bitwarden.R
|
import com.x8bit.bitwarden.R
|
||||||
import com.x8bit.bitwarden.data.platform.repository.model.DataState
|
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.VaultRepository
|
||||||
import com.x8bit.bitwarden.data.vault.repository.model.CreateCipherResult
|
import com.x8bit.bitwarden.data.vault.repository.model.CreateCipherResult
|
||||||
import com.x8bit.bitwarden.data.vault.repository.model.UpdateCipherResult
|
import com.x8bit.bitwarden.data.vault.repository.model.UpdateCipherResult
|
||||||
|
@ -43,9 +44,7 @@ class VaultAddItemViewModelTest : BaseViewModelTest() {
|
||||||
vaultAddEditType = VaultAddEditType.AddItem,
|
vaultAddEditType = VaultAddEditType.AddItem,
|
||||||
)
|
)
|
||||||
|
|
||||||
private val totpTestCodeFlow: MutableSharedFlow<String> = MutableSharedFlow(
|
private val totpTestCodeFlow: MutableSharedFlow<String> = bufferedMutableSharedFlow()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
|
|
||||||
private val mutableVaultItemFlow = MutableStateFlow<DataState<CipherView?>>(DataState.Loading)
|
private val mutableVaultItemFlow = MutableStateFlow<DataState<CipherView?>>(DataState.Loading)
|
||||||
private val vaultRepository: VaultRepository = mockk {
|
private val vaultRepository: VaultRepository = mockk {
|
||||||
|
@ -493,7 +492,7 @@ class VaultAddItemViewModelTest : BaseViewModelTest() {
|
||||||
viewModel.eventFlow.test {
|
viewModel.eventFlow.test {
|
||||||
viewModel.actionChannel.trySend(
|
viewModel.actionChannel.trySend(
|
||||||
VaultAddItemAction.ItemType.LoginType.SetupTotpClick(
|
VaultAddItemAction.ItemType.LoginType.SetupTotpClick(
|
||||||
isGranted = true,
|
isGranted = true,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
@ -512,7 +511,7 @@ class VaultAddItemViewModelTest : BaseViewModelTest() {
|
||||||
viewModel.eventFlow.test {
|
viewModel.eventFlow.test {
|
||||||
viewModel.actionChannel.trySend(
|
viewModel.actionChannel.trySend(
|
||||||
VaultAddItemAction.ItemType.LoginType.SetupTotpClick(
|
VaultAddItemAction.ItemType.LoginType.SetupTotpClick(
|
||||||
isGranted = false,
|
isGranted = false,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
|
|
@ -16,6 +16,7 @@ import androidx.compose.ui.test.onSiblings
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performTextInput
|
import androidx.compose.ui.test.performTextInput
|
||||||
import androidx.core.net.toUri
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler
|
import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
|
@ -30,7 +31,6 @@ import io.mockk.just
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.runs
|
import io.mockk.runs
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
|
@ -47,9 +47,7 @@ class VaultItemScreenTest : BaseComposeTest() {
|
||||||
private val clipboardManager = mockk<ClipboardManager>()
|
private val clipboardManager = mockk<ClipboardManager>()
|
||||||
private val intentHandler = mockk<IntentHandler>()
|
private val intentHandler = mockk<IntentHandler>()
|
||||||
|
|
||||||
private val mutableEventFlow = MutableSharedFlow<VaultItemEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<VaultItemEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||||
private val viewModel = mockk<VaultItemViewModel>(relaxed = true) {
|
private val viewModel = mockk<VaultItemViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -9,20 +9,20 @@ import androidx.compose.ui.test.onNodeWithContentDescription
|
||||||
import androidx.compose.ui.test.onNodeWithText
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performScrollToNode
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
import com.x8bit.bitwarden.ui.util.isProgressBar
|
import com.x8bit.bitwarden.ui.util.isProgressBar
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import com.x8bit.bitwarden.R
|
|
||||||
|
|
||||||
class VaultItemListingScreenTest : BaseComposeTest() {
|
class VaultItemListingScreenTest : BaseComposeTest() {
|
||||||
|
|
||||||
|
@ -30,9 +30,7 @@ class VaultItemListingScreenTest : BaseComposeTest() {
|
||||||
private var onNavigateToVaultAddItemScreenCalled = false
|
private var onNavigateToVaultAddItemScreenCalled = false
|
||||||
private var onNavigateToVaultItemId: String? = null
|
private var onNavigateToVaultItemId: String? = null
|
||||||
|
|
||||||
private val mutableEventFlow = MutableSharedFlow<VaultItemListingEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<VaultItemListingEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||||
private val viewModel = mockk<VaultItemListingViewModel>(relaxed = true) {
|
private val viewModel = mockk<VaultItemListingViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -3,13 +3,13 @@ package com.x8bit.bitwarden.ui.vault.feature.qrcodescan
|
||||||
import androidx.camera.core.ImageProxy
|
import androidx.camera.core.ImageProxy
|
||||||
import androidx.compose.ui.test.onNodeWithText
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.vault.feature.qrcodescan.util.FakeQrCodeAnalyzer
|
import com.x8bit.bitwarden.ui.vault.feature.qrcodescan.util.FakeQrCodeAnalyzer
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import junit.framework.TestCase.assertTrue
|
import junit.framework.TestCase.assertTrue
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -21,9 +21,7 @@ class QrCodeScanScreenTest : BaseComposeTest() {
|
||||||
private val imageProxy: ImageProxy = mockk()
|
private val imageProxy: ImageProxy = mockk()
|
||||||
private val qrCodeAnalyzer = FakeQrCodeAnalyzer()
|
private val qrCodeAnalyzer = FakeQrCodeAnalyzer()
|
||||||
|
|
||||||
private val mutableEventFlow = MutableSharedFlow<QrCodeScanEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<QrCodeScanEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
|
|
||||||
private val viewModel = mockk<QrCodeScanViewModel>(relaxed = true) {
|
private val viewModel = mockk<QrCodeScanViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.x8bit.bitwarden.ui.vault.feature.qrcodescan
|
package com.x8bit.bitwarden.ui.vault.feature.qrcodescan
|
||||||
|
|
||||||
import app.cash.turbine.test
|
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.data.vault.repository.VaultRepository
|
||||||
import com.x8bit.bitwarden.ui.platform.base.BaseViewModelTest
|
import com.x8bit.bitwarden.ui.platform.base.BaseViewModelTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
|
@ -10,16 +11,13 @@ import io.mockk.mockk
|
||||||
import io.mockk.runs
|
import io.mockk.runs
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.jupiter.api.Assertions.assertEquals
|
import org.junit.jupiter.api.Assertions.assertEquals
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class QrCodeScanViewModelTest : BaseViewModelTest() {
|
class QrCodeScanViewModelTest : BaseViewModelTest() {
|
||||||
|
|
||||||
private val totpTestCodeFlow: Flow<String> = MutableSharedFlow(
|
private val totpTestCodeFlow: Flow<String> = bufferedMutableSharedFlow()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val vaultRepository: VaultRepository = mockk {
|
private val vaultRepository: VaultRepository = mockk {
|
||||||
every { totpCodeFlow } returns totpTestCodeFlow
|
every { totpCodeFlow } returns totpTestCodeFlow
|
||||||
every { emitTotpCode(any()) } just runs
|
every { emitTotpCode(any()) } just runs
|
||||||
|
|
|
@ -15,6 +15,7 @@ import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performScrollToNode
|
import androidx.compose.ui.test.performScrollToNode
|
||||||
import com.x8bit.bitwarden.R
|
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.BaseComposeTest
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler
|
import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler
|
||||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||||
|
@ -40,7 +41,6 @@ import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
|
@ -59,9 +59,7 @@ class VaultScreenTest : BaseComposeTest() {
|
||||||
private var onDimBottomNavBarRequestCalled = false
|
private var onDimBottomNavBarRequestCalled = false
|
||||||
private val intentHandler = mockk<IntentHandler>(relaxed = true)
|
private val intentHandler = mockk<IntentHandler>(relaxed = true)
|
||||||
|
|
||||||
private val mutableEventFlow = MutableSharedFlow<VaultEvent>(
|
private val mutableEventFlow = bufferedMutableSharedFlow<VaultEvent>()
|
||||||
extraBufferCapacity = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||||
private val viewModel = mockk<VaultViewModel>(relaxed = true) {
|
private val viewModel = mockk<VaultViewModel>(relaxed = true) {
|
||||||
every { eventFlow } returns mutableEventFlow
|
every { eventFlow } returns mutableEventFlow
|
||||||
|
|
Loading…
Reference in a new issue