Localize Troubleshoot notification feature.
This commit is contained in:
parent
37712298c5
commit
a3253bbe5c
26 changed files with 221 additions and 64 deletions
|
|
@ -40,6 +40,8 @@ dependencies {
|
|||
implementation(projects.libraries.core)
|
||||
implementation(projects.libraries.di)
|
||||
implementation(projects.libraries.matrix.api)
|
||||
implementation(projects.libraries.uiStrings)
|
||||
implementation(projects.services.toolbox.api)
|
||||
|
||||
implementation(projects.libraries.pushstore.api)
|
||||
implementation(projects.libraries.pushproviders.api)
|
||||
|
|
@ -57,4 +59,5 @@ dependencies {
|
|||
testImplementation(libs.test.turbine)
|
||||
testImplementation(projects.libraries.matrix.test)
|
||||
testImplementation(projects.tests.testutils)
|
||||
testImplementation(projects.services.toolbox.test)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ import io.element.android.libraries.core.notifications.TestFilterData
|
|||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.libraries.pushproviders.firebase.FirebaseConfig
|
||||
import io.element.android.libraries.pushproviders.firebase.IsPlayServiceAvailable
|
||||
import io.element.android.libraries.pushproviders.firebase.R
|
||||
import io.element.android.services.toolbox.api.strings.StringProvider
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import javax.inject.Inject
|
||||
|
|
@ -31,11 +33,12 @@ import javax.inject.Inject
|
|||
@ContributesMultibinding(AppScope::class)
|
||||
class FirebaseAvailabilityTest @Inject constructor(
|
||||
private val isPlayServiceAvailable: IsPlayServiceAvailable,
|
||||
private val stringProvider: StringProvider,
|
||||
) : NotificationTroubleshootTest {
|
||||
override val order = 300
|
||||
private val delegate = NotificationTroubleshootTestDelegate(
|
||||
defaultName = "Check Firebase",
|
||||
defaultDescription = "Ensure that Firebase is available.",
|
||||
defaultName = stringProvider.getString(R.string.troubleshoot_notifications_test_firebase_availability_title),
|
||||
defaultDescription = stringProvider.getString(R.string.troubleshoot_notifications_test_firebase_availability_description),
|
||||
visibleWhenIdle = false,
|
||||
fakeDelay = NotificationTroubleshootTestDelegate.LONG_DELAY,
|
||||
)
|
||||
|
|
@ -50,12 +53,12 @@ class FirebaseAvailabilityTest @Inject constructor(
|
|||
val result = isPlayServiceAvailable.isAvailable()
|
||||
if (result) {
|
||||
delegate.updateState(
|
||||
description = "Firebase is available",
|
||||
description = stringProvider.getString(R.string.troubleshoot_notifications_test_firebase_availability_success),
|
||||
status = NotificationTroubleshootTestState.Status.Success
|
||||
)
|
||||
} else {
|
||||
delegate.updateState(
|
||||
description = "Firebase is not available",
|
||||
description = stringProvider.getString(R.string.troubleshoot_notifications_test_firebase_availability_failure),
|
||||
status = NotificationTroubleshootTestState.Status.Failure(false)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import io.element.android.libraries.di.AppScope
|
|||
import io.element.android.libraries.pushproviders.firebase.FirebaseConfig
|
||||
import io.element.android.libraries.pushproviders.firebase.FirebaseStore
|
||||
import io.element.android.libraries.pushproviders.firebase.FirebaseTroubleshooter
|
||||
import io.element.android.libraries.pushproviders.firebase.R
|
||||
import io.element.android.services.toolbox.api.strings.StringProvider
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import javax.inject.Inject
|
||||
|
|
@ -33,11 +35,12 @@ import javax.inject.Inject
|
|||
class FirebaseTokenTest @Inject constructor(
|
||||
private val firebaseStore: FirebaseStore,
|
||||
private val firebaseTroubleshooter: FirebaseTroubleshooter,
|
||||
private val stringProvider: StringProvider,
|
||||
) : NotificationTroubleshootTest {
|
||||
override val order = 310
|
||||
private val delegate = NotificationTroubleshootTestDelegate(
|
||||
defaultName = "Check Firebase token",
|
||||
defaultDescription = "Ensure that Firebase token is available.",
|
||||
defaultName = stringProvider.getString(R.string.troubleshoot_notifications_test_firebase_token_title),
|
||||
defaultDescription = stringProvider.getString(R.string.troubleshoot_notifications_test_firebase_token_description),
|
||||
visibleWhenIdle = false,
|
||||
fakeDelay = NotificationTroubleshootTestDelegate.LONG_DELAY,
|
||||
)
|
||||
|
|
@ -52,12 +55,15 @@ class FirebaseTokenTest @Inject constructor(
|
|||
val token = firebaseStore.getFcmToken()
|
||||
if (token != null) {
|
||||
delegate.updateState(
|
||||
description = "Firebase token: ${token.take(8)}*****",
|
||||
description = stringProvider.getString(
|
||||
R.string.troubleshoot_notifications_test_firebase_token_success,
|
||||
"${token.take(8)}*****"
|
||||
),
|
||||
status = NotificationTroubleshootTestState.Status.Success
|
||||
)
|
||||
} else {
|
||||
delegate.updateState(
|
||||
description = "Firebase token is not known",
|
||||
description = stringProvider.getString(R.string.troubleshoot_notifications_test_firebase_token_failure),
|
||||
status = NotificationTroubleshootTestState.Status.Failure(true)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<string name="troubleshoot_notifications_test_firebase_availability_description">"Ensure that Firebase is available."</string>
|
||||
<string name="troubleshoot_notifications_test_firebase_availability_failure">"Firebase is not available."</string>
|
||||
<string name="troubleshoot_notifications_test_firebase_availability_success">"Firebase is available."</string>
|
||||
<string name="troubleshoot_notifications_test_firebase_availability_title">"Check Firebase"</string>
|
||||
<string name="troubleshoot_notifications_test_firebase_token_description">"Ensure that Firebase token is available."</string>
|
||||
<string name="troubleshoot_notifications_test_firebase_token_failure">"Firebase token is not known."</string>
|
||||
<string name="troubleshoot_notifications_test_firebase_token_success">"Firebase token: %1$s."</string>
|
||||
<string name="troubleshoot_notifications_test_firebase_token_title">"Check Firebase token"</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.firebase.IsPlayServiceAvailable
|
||||
import io.element.android.services.toolbox.test.strings.FakeStringProvider
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
|
|
@ -32,7 +33,8 @@ class FirebaseAvailabilityTestTest {
|
|||
override fun isAvailable(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
},
|
||||
stringProvider = FakeStringProvider(),
|
||||
)
|
||||
launch {
|
||||
sut.run(this)
|
||||
|
|
@ -52,7 +54,8 @@ class FirebaseAvailabilityTestTest {
|
|||
override fun isAvailable(): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
stringProvider = FakeStringProvider(),
|
||||
)
|
||||
launch {
|
||||
sut.run(this)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.google.common.truth.Truth.assertThat
|
|||
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
|
||||
import io.element.android.libraries.pushproviders.firebase.FakeFirebaseTroubleshooter
|
||||
import io.element.android.libraries.pushproviders.firebase.InMemoryFirebaseStore
|
||||
import io.element.android.services.toolbox.test.strings.FakeStringProvider
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
|
|
@ -31,6 +32,7 @@ class FirebaseTokenTestTest {
|
|||
val sut = FirebaseTokenTest(
|
||||
firebaseStore = InMemoryFirebaseStore(FAKE_TOKEN),
|
||||
firebaseTroubleshooter = FakeFirebaseTroubleshooter(),
|
||||
stringProvider = FakeStringProvider(),
|
||||
)
|
||||
launch {
|
||||
sut.run(this)
|
||||
|
|
@ -56,6 +58,7 @@ class FirebaseTokenTestTest {
|
|||
Result.success(Unit)
|
||||
}
|
||||
),
|
||||
stringProvider = FakeStringProvider(),
|
||||
)
|
||||
launch {
|
||||
sut.run(this)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ dependencies {
|
|||
implementation(projects.libraries.androidutils)
|
||||
implementation(projects.libraries.core)
|
||||
implementation(projects.libraries.matrix.api)
|
||||
implementation(projects.libraries.uiStrings)
|
||||
|
||||
implementation(projects.libraries.pushstore.api)
|
||||
implementation(projects.libraries.pushproviders.api)
|
||||
|
|
@ -57,4 +58,5 @@ dependencies {
|
|||
testImplementation(libs.test.turbine)
|
||||
testImplementation(projects.libraries.matrix.test)
|
||||
testImplementation(projects.tests.testutils)
|
||||
testImplementation(projects.services.toolbox.test)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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