Localize Troubleshoot notification feature.
This commit is contained in:
parent
33526db485
commit
09b2cbaaf5
26 changed files with 221 additions and 64 deletions
|
|
@ -22,8 +22,10 @@ import io.element.android.libraries.core.notifications.NotificationTroubleshootT
|
|||
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
|
||||
import io.element.android.libraries.core.notifications.TestFilterData
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.libraries.pushproviders.unifiedpush.R
|
||||
import io.element.android.libraries.pushproviders.unifiedpush.UnifiedPushConfig
|
||||
import io.element.android.libraries.pushproviders.unifiedpush.UnifiedPushDistributorProvider
|
||||
import io.element.android.services.toolbox.api.strings.StringProvider
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import javax.inject.Inject
|
||||
|
|
@ -32,11 +34,12 @@ import javax.inject.Inject
|
|||
class UnifiedPushTest @Inject constructor(
|
||||
private val unifiedPushDistributorProvider: UnifiedPushDistributorProvider,
|
||||
private val openDistributorWebPageAction: OpenDistributorWebPageAction,
|
||||
private val stringProvider: StringProvider,
|
||||
) : NotificationTroubleshootTest {
|
||||
override val order = 400
|
||||
private val delegate = NotificationTroubleshootTestDelegate(
|
||||
defaultName = "Check UnifiedPush",
|
||||
defaultDescription = "Ensure that UnifiedPush distributors are available.",
|
||||
defaultName = stringProvider.getString(R.string.troubleshoot_notifications_test_unified_push_title),
|
||||
defaultDescription = stringProvider.getString(R.string.troubleshoot_notifications_test_unified_push_description),
|
||||
visibleWhenIdle = false,
|
||||
fakeDelay = NotificationTroubleshootTestDelegate.SHORT_DELAY,
|
||||
)
|
||||
|
|
@ -51,12 +54,17 @@ class UnifiedPushTest @Inject constructor(
|
|||
val distributors = unifiedPushDistributorProvider.getDistributors()
|
||||
if (distributors.isNotEmpty()) {
|
||||
delegate.updateState(
|
||||
description = "Distributors found: ${distributors.joinToString { it.name }}",
|
||||
description = stringProvider.getQuantityString(
|
||||
resId = R.plurals.troubleshoot_notifications_test_unified_push_success,
|
||||
quantity = distributors.size,
|
||||
distributors.size,
|
||||
distributors.joinToString { it.name }
|
||||
),
|
||||
status = NotificationTroubleshootTestState.Status.Success
|
||||
)
|
||||
} else {
|
||||
delegate.updateState(
|
||||
description = "No push distributors found",
|
||||
description = stringProvider.getString(R.string.troubleshoot_notifications_test_unified_push_failure),
|
||||
status = NotificationTroubleshootTestState.Status.Failure(true)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<string name="troubleshoot_notifications_test_unified_push_description">"Ensure that UnifiedPush distributors are available."</string>
|
||||
<string name="troubleshoot_notifications_test_unified_push_failure">"No push distributors found."</string>
|
||||
<plurals name="troubleshoot_notifications_test_unified_push_success">
|
||||
<item quantity="one">"%1$d distributor found: %2$s."</item>
|
||||
<item quantity="other">"%1$d distributors found: %2$s."</item>
|
||||
</plurals>
|
||||
<string name="troubleshoot_notifications_test_unified_push_title">"Check UnifiedPush"</string>
|
||||
</resources>
|
||||
|
|
@ -20,6 +20,7 @@ import app.cash.turbine.test
|
|||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
|
||||
import io.element.android.libraries.pushproviders.api.Distributor
|
||||
import io.element.android.services.toolbox.test.strings.FakeStringProvider
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
|
|
@ -34,6 +35,7 @@ class UnifiedPushTestTest {
|
|||
)
|
||||
),
|
||||
openDistributorWebPageAction = FakeOpenDistributorWebPageAction(),
|
||||
stringProvider = FakeStringProvider(),
|
||||
)
|
||||
launch {
|
||||
sut.run(this)
|
||||
|
|
@ -60,6 +62,7 @@ class UnifiedPushTestTest {
|
|||
)
|
||||
}
|
||||
),
|
||||
stringProvider = FakeStringProvider(),
|
||||
)
|
||||
launch {
|
||||
sut.run(this)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue