Add test for push distributor change.
This commit is contained in:
parent
92d6b72b2a
commit
ada777e45c
4 changed files with 102 additions and 7 deletions
|
|
@ -23,25 +23,29 @@ import io.element.android.libraries.pushproviders.api.PushProvider
|
|||
import io.element.android.tests.testutils.simulateLongTask
|
||||
|
||||
class FakePushService(
|
||||
private val testPushBlock: suspend () -> Boolean = { true }
|
||||
private val testPushBlock: suspend () -> Boolean = { true },
|
||||
private val availablePushProviders: List<PushProvider> = emptyList(),
|
||||
private val registerWithLambda: suspend (MatrixClient, PushProvider, Distributor) -> Result<Unit> = { _, _, _ ->
|
||||
Result.success(Unit)
|
||||
},
|
||||
) : PushService {
|
||||
override fun notificationStyleChanged() {
|
||||
}
|
||||
|
||||
override suspend fun getCurrentPushProvider(): PushProvider? {
|
||||
return null
|
||||
return availablePushProviders.firstOrNull()
|
||||
}
|
||||
|
||||
override fun getAvailablePushProviders(): List<PushProvider> {
|
||||
return emptyList()
|
||||
return availablePushProviders
|
||||
}
|
||||
|
||||
override suspend fun registerWith(
|
||||
matrixClient: MatrixClient,
|
||||
pushProvider: PushProvider,
|
||||
distributor: Distributor,
|
||||
): Result<Unit> {
|
||||
return Result.success(Unit)
|
||||
): Result<Unit> = simulateLongTask {
|
||||
return registerWithLambda(matrixClient, pushProvider, distributor)
|
||||
}
|
||||
|
||||
override suspend fun testPush(): Boolean = simulateLongTask {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class FakePushProvider(
|
|||
override val index: Int = 0,
|
||||
override val name: String = "aFakePushProvider",
|
||||
private val isAvailable: Boolean = true,
|
||||
private val distributors: List<Distributor> = emptyList()
|
||||
private val distributors: List<Distributor> = listOf(Distributor("aDistributorValue", "aDistributorName")),
|
||||
) : PushProvider {
|
||||
override fun isAvailable(): Boolean = isAvailable
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ class FakePushProvider(
|
|||
}
|
||||
|
||||
override suspend fun getCurrentDistributor(matrixClient: MatrixClient): Distributor? {
|
||||
return null
|
||||
return distributors.firstOrNull()
|
||||
}
|
||||
|
||||
override suspend fun unregister(matrixClient: MatrixClient): Result<Unit> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue