Remove dependency on AppNavigationStateService from DefaultGetCurrentPushProvider
This commit is contained in:
parent
2acc6db70f
commit
705b1b08f2
15 changed files with 66 additions and 70 deletions
|
|
@ -7,10 +7,11 @@
|
|||
|
||||
package io.element.android.libraries.push.test
|
||||
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.libraries.push.api.GetCurrentPushProvider
|
||||
|
||||
class FakeGetCurrentPushProvider(
|
||||
private val currentPushProvider: String?
|
||||
) : GetCurrentPushProvider {
|
||||
override suspend fun getCurrentPushProvider(): String? = currentPushProvider
|
||||
override suspend fun getCurrentPushProvider(sessionId: SessionId): String? = currentPushProvider
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,19 +19,19 @@ import kotlinx.coroutines.flow.Flow
|
|||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
||||
class FakePushService(
|
||||
private val testPushBlock: suspend () -> Boolean = { true },
|
||||
private val testPushBlock: suspend (SessionId) -> Boolean = { true },
|
||||
private val availablePushProviders: List<PushProvider> = emptyList(),
|
||||
private val registerWithLambda: suspend (MatrixClient, PushProvider, Distributor) -> Result<Unit> = { _, _, _ ->
|
||||
Result.success(Unit)
|
||||
},
|
||||
private val currentPushProvider: () -> PushProvider? = { availablePushProviders.firstOrNull() },
|
||||
private val currentPushProvider: (SessionId) -> PushProvider? = { availablePushProviders.firstOrNull() },
|
||||
private val selectPushProviderLambda: suspend (SessionId, PushProvider) -> Unit = { _, _ -> lambdaError() },
|
||||
private val setIgnoreRegistrationErrorLambda: (SessionId, Boolean) -> Unit = { _, _ -> lambdaError() },
|
||||
private val resetPushHistoryResult: () -> Unit = { lambdaError() },
|
||||
private val resetBatteryOptimizationStateResult: () -> Unit = { lambdaError() },
|
||||
) : PushService {
|
||||
override suspend fun getCurrentPushProvider(): PushProvider? {
|
||||
return registeredPushProvider ?: currentPushProvider()
|
||||
override suspend fun getCurrentPushProvider(sessionId: SessionId): PushProvider? {
|
||||
return registeredPushProvider ?: currentPushProvider(sessionId)
|
||||
}
|
||||
|
||||
override fun getAvailablePushProviders(): List<PushProvider> {
|
||||
|
|
@ -68,8 +68,8 @@ class FakePushService(
|
|||
setIgnoreRegistrationErrorLambda(sessionId, ignore)
|
||||
}
|
||||
|
||||
override suspend fun testPush(): Boolean = simulateLongTask {
|
||||
testPushBlock()
|
||||
override suspend fun testPush(sessionId: SessionId): Boolean = simulateLongTask {
|
||||
testPushBlock(sessionId)
|
||||
}
|
||||
|
||||
private val pushHistoryItemsFlow = MutableStateFlow<List<PushHistoryItem>>(emptyList())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue