mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
wip
This commit is contained in:
parent
c88157fbce
commit
991c82b277
5 changed files with 54 additions and 1 deletions
|
@ -21,7 +21,7 @@ fun NotificationCenterActionItem(
|
||||||
val contentDescription = stringResource(id = R.string.account)
|
val contentDescription = stringResource(id = R.string.account)
|
||||||
|
|
||||||
BitwardenStandardIconButton(
|
BitwardenStandardIconButton(
|
||||||
vectorIconRes = R.drawable.ic_search,
|
vectorIconRes = R.drawable.ic,
|
||||||
contentDescription = contentDescription,
|
contentDescription = contentDescription,
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
modifier = Modifier.testTag(tag = "NotificationCenter"),
|
modifier = Modifier.testTag(tag = "NotificationCenter"),
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeCiphersDao
|
||||||
import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeCollectionsDao
|
import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeCollectionsDao
|
||||||
import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeDomainsDao
|
import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeDomainsDao
|
||||||
import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeFoldersDao
|
import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeFoldersDao
|
||||||
|
import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeOfflineCiphersDao
|
||||||
import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeSendsDao
|
import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeSendsDao
|
||||||
import com.x8bit.bitwarden.data.vault.datasource.disk.entity.CipherEntity
|
import com.x8bit.bitwarden.data.vault.datasource.disk.entity.CipherEntity
|
||||||
import com.x8bit.bitwarden.data.vault.datasource.disk.entity.CollectionEntity
|
import com.x8bit.bitwarden.data.vault.datasource.disk.entity.CollectionEntity
|
||||||
|
@ -37,6 +38,7 @@ class VaultDiskSourceTest {
|
||||||
private val json = PlatformNetworkModule.providesJson()
|
private val json = PlatformNetworkModule.providesJson()
|
||||||
private val dispatcherManager: FakeDispatcherManager = FakeDispatcherManager()
|
private val dispatcherManager: FakeDispatcherManager = FakeDispatcherManager()
|
||||||
private lateinit var ciphersDao: FakeCiphersDao
|
private lateinit var ciphersDao: FakeCiphersDao
|
||||||
|
private lateinit var offlineCiphersDao: FakeOfflineCiphersDao
|
||||||
private lateinit var collectionsDao: FakeCollectionsDao
|
private lateinit var collectionsDao: FakeCollectionsDao
|
||||||
private lateinit var domainsDao: FakeDomainsDao
|
private lateinit var domainsDao: FakeDomainsDao
|
||||||
private lateinit var foldersDao: FakeFoldersDao
|
private lateinit var foldersDao: FakeFoldersDao
|
||||||
|
@ -47,6 +49,7 @@ class VaultDiskSourceTest {
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
fun setup() {
|
fun setup() {
|
||||||
ciphersDao = FakeCiphersDao()
|
ciphersDao = FakeCiphersDao()
|
||||||
|
offlineCiphersDao = FakeOfflineCiphersDao()
|
||||||
collectionsDao = FakeCollectionsDao()
|
collectionsDao = FakeCollectionsDao()
|
||||||
domainsDao = FakeDomainsDao()
|
domainsDao = FakeDomainsDao()
|
||||||
foldersDao = FakeFoldersDao()
|
foldersDao = FakeFoldersDao()
|
||||||
|
@ -57,6 +60,7 @@ class VaultDiskSourceTest {
|
||||||
domainsDao = domainsDao,
|
domainsDao = domainsDao,
|
||||||
foldersDao = foldersDao,
|
foldersDao = foldersDao,
|
||||||
sendsDao = sendsDao,
|
sendsDao = sendsDao,
|
||||||
|
offlineCiphersDao = offlineCiphersDao,
|
||||||
json = json,
|
json = json,
|
||||||
dispatcherManager = dispatcherManager,
|
dispatcherManager = dispatcherManager,
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
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.OfflineCipherEntity
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.map
|
||||||
|
|
||||||
|
class FakeOfflineCiphersDao : OfflineCiphersDao {
|
||||||
|
|
||||||
|
val storedCiphers = mutableListOf<OfflineCipherEntity>()
|
||||||
|
|
||||||
|
var deleteCipherCalled: Boolean = false
|
||||||
|
var deleteCiphersCalled: Boolean = false
|
||||||
|
var insertCiphersCalled: Boolean = false
|
||||||
|
|
||||||
|
private val ciphersFlow = bufferedMutableSharedFlow<List<OfflineCipherEntity>>(replay = 1)
|
||||||
|
|
||||||
|
init {
|
||||||
|
ciphersFlow.tryEmit(emptyList())
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun deleteAllCiphers(userId: String): Int {
|
||||||
|
deleteCiphersCalled = true
|
||||||
|
val count = storedCiphers.count { it.userId == userId }
|
||||||
|
storedCiphers.removeAll { it.userId == userId }
|
||||||
|
ciphersFlow.tryEmit(storedCiphers.toList())
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun deleteCipher(userId: String, cipherId: String): Int {
|
||||||
|
deleteCipherCalled = true
|
||||||
|
val count = storedCiphers.count { it.userId == userId && it.id == cipherId }
|
||||||
|
storedCiphers.removeAll { it.userId == userId && it.id == cipherId }
|
||||||
|
ciphersFlow.tryEmit(storedCiphers.toList())
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun insertCiphers(ciphers: List<OfflineCipherEntity>) {
|
||||||
|
storedCiphers.addAll(ciphers)
|
||||||
|
ciphersFlow.tryEmit(ciphers.toList())
|
||||||
|
insertCiphersCalled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getAllCiphers(userId: String): Flow<List<OfflineCipherEntity>> =
|
||||||
|
ciphersFlow.map { ciphers -> ciphers.filter { it.userId == userId } }
|
||||||
|
}
|
|
@ -43,6 +43,7 @@ import com.x8bit.bitwarden.ui.util.performLockAccountClick
|
||||||
import com.x8bit.bitwarden.ui.util.performLogoutAccountClick
|
import com.x8bit.bitwarden.ui.util.performLogoutAccountClick
|
||||||
import com.x8bit.bitwarden.ui.util.performRemoveAccountClick
|
import com.x8bit.bitwarden.ui.util.performRemoveAccountClick
|
||||||
import com.x8bit.bitwarden.ui.util.performYesDialogButtonClick
|
import com.x8bit.bitwarden.ui.util.performYesDialogButtonClick
|
||||||
|
import com.x8bit.bitwarden.ui.vault.feature.vault.model.NotificationSummary
|
||||||
import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterData
|
import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterData
|
||||||
import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterType
|
import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterType
|
||||||
import com.x8bit.bitwarden.ui.vault.model.VaultItemListingType
|
import com.x8bit.bitwarden.ui.vault.model.VaultItemListingType
|
||||||
|
@ -1256,6 +1257,7 @@ private val DEFAULT_STATE: VaultState = VaultState(
|
||||||
hideNotificationsDialog = true,
|
hideNotificationsDialog = true,
|
||||||
isRefreshing = false,
|
isRefreshing = false,
|
||||||
showImportActionCard = false,
|
showImportActionCard = false,
|
||||||
|
notificationSummaries = listOf()
|
||||||
)
|
)
|
||||||
|
|
||||||
private val DEFAULT_CONTENT_VIEW_STATE: VaultState.ViewState.Content = VaultState.ViewState.Content(
|
private val DEFAULT_CONTENT_VIEW_STATE: VaultState.ViewState.Content = VaultState.ViewState.Content(
|
||||||
|
|
|
@ -1729,4 +1729,5 @@ private fun createMockVaultState(
|
||||||
hideNotificationsDialog = true,
|
hideNotificationsDialog = true,
|
||||||
showImportActionCard = true,
|
showImportActionCard = true,
|
||||||
isRefreshing = false,
|
isRefreshing = false,
|
||||||
|
notificationSummaries = listOf()
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue