Browse Source

Localize Troubleshoot notification feature.

pull/2596/head
Benoit Marty 6 months ago committed by Benoit Marty
parent
commit
09b2cbaaf5
  1. 4
      features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt
  2. 22
      features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/troubleshoot/TroubleshootNotificationsView.kt
  3. 10
      features/preferences/impl/src/main/res/values/localazy.xml
  4. 7
      libraries/permissions/impl/src/main/kotlin/io/element/android/libraries/permissions/impl/troubleshoot/NotificationTroubleshootCheckPermissionTest.kt
  5. 5
      libraries/permissions/impl/src/main/res/values/localazy.xml
  6. 10
      libraries/permissions/impl/src/test/kotlin/io/element/android/libraries/permissions/impl/troubleshoot/NotificationTroubleshootCheckPermissionTestTest.kt
  7. 11
      libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/troubleshoot/CurrentPushProviderTest.kt
  8. 17
      libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/troubleshoot/NotificationTest.kt
  9. 17
      libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/troubleshoot/PushLoopbackTest.kt
  10. 16
      libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/troubleshoot/PushProvidersTest.kt
  11. 24
      libraries/push/impl/src/main/res/values/localazy.xml
  12. 7
      libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/troubleshoot/CurrentPushProviderTestTest.kt
  13. 4
      libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/troubleshoot/NotificationTestTest.kt
  14. 19
      libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/troubleshoot/PushLoopbackTestTest.kt
  15. 4
      libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/troubleshoot/PushProvidersTestTest.kt
  16. 3
      libraries/pushproviders/firebase/build.gradle.kts
  17. 11
      libraries/pushproviders/firebase/src/main/kotlin/io/element/android/libraries/pushproviders/firebase/troubleshoot/FirebaseAvailabilityTest.kt
  18. 14
      libraries/pushproviders/firebase/src/main/kotlin/io/element/android/libraries/pushproviders/firebase/troubleshoot/FirebaseTokenTest.kt
  19. 11
      libraries/pushproviders/firebase/src/main/res/values/localazy.xml
  20. 7
      libraries/pushproviders/firebase/src/test/kotlin/io/element/android/libraries/pushproviders/firebase/troubleshoot/FirebaseAvailabilityTestTest.kt
  21. 3
      libraries/pushproviders/firebase/src/test/kotlin/io/element/android/libraries/pushproviders/firebase/troubleshoot/FirebaseTokenTestTest.kt
  22. 2
      libraries/pushproviders/unifiedpush/build.gradle.kts
  23. 16
      libraries/pushproviders/unifiedpush/src/main/kotlin/io/element/android/libraries/pushproviders/unifiedpush/troubleshoot/UnifiedPushTest.kt
  24. 10
      libraries/pushproviders/unifiedpush/src/main/res/values/localazy.xml
  25. 3
      libraries/pushproviders/unifiedpush/src/test/kotlin/io/element/android/libraries/pushproviders/unifiedpush/troubleshoot/UnifiedPushTestTest.kt
  26. 28
      tools/localazy/config.json

4
features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/NotificationSettingsView.kt

@ -166,10 +166,10 @@ private fun NotificationSettingsContentView( @@ -166,10 +166,10 @@ private fun NotificationSettingsContentView(
onCheckedChange = onInviteForMeNotificationsChanged
)
}
PreferenceCategory(title = "Troubleshoot") {
PreferenceCategory(title = stringResource(id = R.string.troubleshoot_notifications_entry_point_section)) {
PreferenceText(
modifier = Modifier,
title = "Troubleshoot notifications",
title = stringResource(id = R.string.troubleshoot_notifications_entry_point_title),
onClick = onTroubleshootNotificationsClicked
)
}

22
features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/troubleshoot/TroubleshootNotificationsView.kt

@ -21,11 +21,13 @@ import androidx.compose.foundation.layout.size @@ -21,11 +21,13 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.progressSemantics
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
import androidx.lifecycle.Lifecycle
import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.features.preferences.impl.R
import io.element.android.libraries.architecture.AsyncAction
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState.Status
@ -63,7 +65,7 @@ fun TroubleshootNotificationsView( @@ -63,7 +65,7 @@ fun TroubleshootNotificationsView(
PreferencePage(
modifier = modifier,
onBackPressed = onBackPressed,
title = "Troubleshoot notifications",
title = stringResource(id = R.string.troubleshoot_notifications_screen_title),
) {
TroubleshootNotificationsContent(state)
}
@ -120,7 +122,7 @@ private fun TroubleshootTestView( @@ -120,7 +122,7 @@ private fun TroubleshootTestView(
},
trailingContent = ListItemContent.Custom {
Button(
text = "Attempt to fix",
text = stringResource(id = R.string.troubleshoot_notifications_screen_quick_fix_action),
onClick = onQuickFixClicked
)
}
@ -148,8 +150,7 @@ private fun TroubleshootNotificationsContent(state: TroubleshootNotificationsSta @@ -148,8 +150,7 @@ private fun TroubleshootNotificationsContent(state: TroubleshootNotificationsSta
AsyncAction.Uninitialized -> {
ListItem(headlineContent = {
Text(
text = "Run the tests to detect any issue in your configuration " +
"that may make notifications not behave as expected."
text = stringResource(id = R.string.troubleshoot_notifications_screen_notice)
)
})
RunTestButton(state = state)
@ -157,21 +158,21 @@ private fun TroubleshootNotificationsContent(state: TroubleshootNotificationsSta @@ -157,21 +158,21 @@ private fun TroubleshootNotificationsContent(state: TroubleshootNotificationsSta
AsyncAction.Loading -> Unit
is AsyncAction.Failure -> {
ListItem(headlineContent = {
Text(text = "Some tests failed, please check the details.")
Text(text = stringResource(id = R.string.troubleshoot_notifications_screen_failure))
})
RunTestButton(state = state)
}
AsyncAction.Confirming -> {
ListItem(headlineContent = {
Text(
text = "Some tests require your attention. Please check the details."
text = stringResource(id = R.string.troubleshoot_notifications_screen_waiting)
)
})
}
is AsyncAction.Success -> {
ListItem(headlineContent = {
Text(
text = "All tests passed successfully."
text = stringResource(id = R.string.troubleshoot_notifications_screen_success)
)
})
}
@ -183,7 +184,12 @@ private fun RunTestButton(state: TroubleshootNotificationsState) { @@ -183,7 +184,12 @@ private fun RunTestButton(state: TroubleshootNotificationsState) {
ListItem(
headlineContent = {
Button(
text = if (state.testSuiteState.mainState is AsyncAction.Failure) "Run tests again" else "Run tests",
text = stringResource(
id = if (state.testSuiteState.mainState is AsyncAction.Failure)
R.string.troubleshoot_notifications_screen_action_again
else
R.string.troubleshoot_notifications_screen_action
),
onClick = {
state.eventSink(TroubleshootNotificationsEvents.StartTests)
},

10
features/preferences/impl/src/main/res/values/localazy.xml

@ -49,4 +49,14 @@ If you proceed, some of your settings may change."</string> @@ -49,4 +49,14 @@ If you proceed, some of your settings may change."</string>
<string name="screen_notification_settings_system_notifications_action_required_content_link">"system settings"</string>
<string name="screen_notification_settings_system_notifications_turned_off">"System notifications turned off"</string>
<string name="screen_notification_settings_title">"Notifications"</string>
<string name="troubleshoot_notifications_entry_point_section">"Troubleshoot"</string>
<string name="troubleshoot_notifications_entry_point_title">"Troubleshoot notifications"</string>
<string name="troubleshoot_notifications_screen_action">"Run tests"</string>
<string name="troubleshoot_notifications_screen_action_again">"Run tests again"</string>
<string name="troubleshoot_notifications_screen_failure">"Some tests failed. Please check the details."</string>
<string name="troubleshoot_notifications_screen_notice">"Run the tests to detect any issue in your configuration that may make notifications not behave as expected."</string>
<string name="troubleshoot_notifications_screen_quick_fix_action">"Attempt to fix"</string>
<string name="troubleshoot_notifications_screen_success">"All tests passed successfully."</string>
<string name="troubleshoot_notifications_screen_title">"Troubleshoot notifications"</string>
<string name="troubleshoot_notifications_screen_waiting">"Some tests require your attention. Please check the details."</string>
</resources>

7
libraries/permissions/impl/src/main/kotlin/io/element/android/libraries/permissions/impl/troubleshoot/NotificationTroubleshootCheckPermissionTest.kt

@ -24,8 +24,10 @@ import io.element.android.libraries.core.notifications.NotificationTroubleshootT @@ -24,8 +24,10 @@ import io.element.android.libraries.core.notifications.NotificationTroubleshootT
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
import io.element.android.libraries.di.AppScope
import io.element.android.libraries.permissions.api.PermissionStateProvider
import io.element.android.libraries.permissions.impl.R
import io.element.android.libraries.permissions.impl.action.PermissionActions
import io.element.android.services.toolbox.api.sdk.BuildVersionSdkIntProvider
import io.element.android.services.toolbox.api.strings.StringProvider
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.StateFlow
import javax.inject.Inject
@ -35,12 +37,13 @@ class NotificationTroubleshootCheckPermissionTest @Inject constructor( @@ -35,12 +37,13 @@ class NotificationTroubleshootCheckPermissionTest @Inject constructor(
private val permissionStateProvider: PermissionStateProvider,
private val sdkVersionProvider: BuildVersionSdkIntProvider,
private val permissionActions: PermissionActions,
private val stringProvider: StringProvider,
) : NotificationTroubleshootTest {
override val order: Int = 0
private val delegate = NotificationTroubleshootTestDelegate(
defaultName = "Check permissions",
defaultDescription = "Ensure that the application can show notifications.",
defaultName = stringProvider.getString(R.string.troubleshoot_notifications_test_check_permission_title),
defaultDescription = stringProvider.getString(R.string.troubleshoot_notifications_test_check_permission_description),
hasQuickFix = true,
fakeDelay = NotificationTroubleshootTestDelegate.SHORT_DELAY,
)

5
libraries/permissions/impl/src/main/res/values/localazy.xml

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="troubleshoot_notifications_test_check_permission_description">"Ensure that the application can show notifications."</string>
<string name="troubleshoot_notifications_test_check_permission_title">"Check permissions"</string>
</resources>

10
libraries/permissions/impl/src/test/kotlin/io/element/android/libraries/permissions/impl/troubleshoot/NotificationTroubleshootCheckPermissionTestTest.kt

@ -23,6 +23,7 @@ import io.element.android.libraries.core.notifications.NotificationTroubleshootT @@ -23,6 +23,7 @@ import io.element.android.libraries.core.notifications.NotificationTroubleshootT
import io.element.android.libraries.permissions.impl.FakePermissionStateProvider
import io.element.android.libraries.permissions.impl.action.FakePermissionActions
import io.element.android.services.toolbox.test.sdk.FakeBuildVersionSdkIntProvider
import io.element.android.services.toolbox.test.strings.FakeStringProvider
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runTest
import org.junit.Test
@ -33,7 +34,8 @@ class NotificationTroubleshootCheckPermissionTestTest { @@ -33,7 +34,8 @@ class NotificationTroubleshootCheckPermissionTestTest {
val sut = NotificationTroubleshootCheckPermissionTest(
permissionStateProvider = FakePermissionStateProvider(),
sdkVersionProvider = FakeBuildVersionSdkIntProvider(sdkInt = Build.VERSION_CODES.TIRAMISU - 1),
permissionActions = FakePermissionActions()
permissionActions = FakePermissionActions(),
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)
@ -51,7 +53,8 @@ class NotificationTroubleshootCheckPermissionTestTest { @@ -51,7 +53,8 @@ class NotificationTroubleshootCheckPermissionTestTest {
val sut = NotificationTroubleshootCheckPermissionTest(
permissionStateProvider = FakePermissionStateProvider(),
sdkVersionProvider = FakeBuildVersionSdkIntProvider(sdkInt = Build.VERSION_CODES.TIRAMISU),
permissionActions = FakePermissionActions()
permissionActions = FakePermissionActions(),
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)
@ -77,7 +80,8 @@ class NotificationTroubleshootCheckPermissionTestTest { @@ -77,7 +80,8 @@ class NotificationTroubleshootCheckPermissionTestTest {
val sut = NotificationTroubleshootCheckPermissionTest(
permissionStateProvider = permissionStateProvider,
sdkVersionProvider = FakeBuildVersionSdkIntProvider(sdkInt = Build.VERSION_CODES.TIRAMISU),
permissionActions = actions
permissionActions = actions,
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)

11
libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/troubleshoot/CurrentPushProviderTest.kt

@ -22,6 +22,8 @@ import io.element.android.libraries.core.notifications.NotificationTroubleshootT @@ -22,6 +22,8 @@ import io.element.android.libraries.core.notifications.NotificationTroubleshootT
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
import io.element.android.libraries.di.AppScope
import io.element.android.libraries.push.api.GetCurrentPushProvider
import io.element.android.libraries.push.impl.R
import io.element.android.services.toolbox.api.strings.StringProvider
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.StateFlow
import javax.inject.Inject
@ -29,11 +31,12 @@ import javax.inject.Inject @@ -29,11 +31,12 @@ import javax.inject.Inject
@ContributesMultibinding(AppScope::class)
class CurrentPushProviderTest @Inject constructor(
private val getCurrentPushProvider: GetCurrentPushProvider,
private val stringProvider: StringProvider,
) : NotificationTroubleshootTest {
override val order = 110
private val delegate = NotificationTroubleshootTestDelegate(
defaultName = "Current push provider",
defaultDescription = "Get the name of the current provider.",
defaultName = stringProvider.getString(R.string.troubleshoot_notifications_test_current_push_provider_title),
defaultDescription = stringProvider.getString(R.string.troubleshoot_notifications_test_current_push_provider_description),
fakeDelay = NotificationTroubleshootTestDelegate.SHORT_DELAY,
)
override val state: StateFlow<NotificationTroubleshootTestState> = delegate.state
@ -43,12 +46,12 @@ class CurrentPushProviderTest @Inject constructor( @@ -43,12 +46,12 @@ class CurrentPushProviderTest @Inject constructor(
val provider = getCurrentPushProvider.getCurrentPushProvider()
if (provider != null) {
delegate.updateState(
description = "Current push provider: $provider",
description = stringProvider.getString(R.string.troubleshoot_notifications_test_current_push_provider_success, provider),
status = NotificationTroubleshootTestState.Status.Success
)
} else {
delegate.updateState(
description = "No push providers selected",
description = stringProvider.getString(R.string.troubleshoot_notifications_test_current_push_provider_failure),
status = NotificationTroubleshootTestState.Status.Failure(false)
)
}

17
libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/troubleshoot/NotificationTest.kt

@ -21,8 +21,10 @@ import io.element.android.libraries.core.notifications.NotificationTroubleshootT @@ -21,8 +21,10 @@ import io.element.android.libraries.core.notifications.NotificationTroubleshootT
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestDelegate
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
import io.element.android.libraries.di.AppScope
import io.element.android.libraries.push.impl.R
import io.element.android.libraries.push.impl.notifications.NotificationDisplayer
import io.element.android.libraries.push.impl.notifications.factories.NotificationCreator
import io.element.android.services.toolbox.api.strings.StringProvider
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.first
@ -36,12 +38,13 @@ import kotlin.time.Duration.Companion.seconds @@ -36,12 +38,13 @@ import kotlin.time.Duration.Companion.seconds
class NotificationTest @Inject constructor(
private val notificationCreator: NotificationCreator,
private val notificationDisplayer: NotificationDisplayer,
private val notificationClickHandler: NotificationClickHandler
private val notificationClickHandler: NotificationClickHandler,
private val stringProvider: StringProvider,
) : NotificationTroubleshootTest {
override val order = 50
private val delegate = NotificationTroubleshootTestDelegate(
defaultName = "Display notification",
defaultDescription = "Check that the application can display notification",
defaultName = stringProvider.getString(R.string.troubleshoot_notifications_test_display_notification_title),
defaultDescription = stringProvider.getString(R.string.troubleshoot_notifications_test_display_notification_description),
fakeDelay = NotificationTroubleshootTestDelegate.SHORT_DELAY,
)
override val state: StateFlow<NotificationTroubleshootTestState> = delegate.state
@ -53,12 +56,12 @@ class NotificationTest @Inject constructor( @@ -53,12 +56,12 @@ class NotificationTest @Inject constructor(
if (result) {
coroutineScope.listenToNotificationClick()
delegate.updateState(
description = "Please click on the notification to continue the test.",
description = stringProvider.getString(R.string.troubleshoot_notifications_test_display_notification_waiting),
status = NotificationTroubleshootTestState.Status.WaitingForUser
)
} else {
delegate.updateState(
description = "Cannot display the notification.",
description = stringProvider.getString(R.string.troubleshoot_notifications_test_display_notification_permission_failure),
status = NotificationTroubleshootTestState.Status.Failure(false)
)
}
@ -76,12 +79,12 @@ class NotificationTest @Inject constructor( @@ -76,12 +79,12 @@ class NotificationTest @Inject constructor(
if (s == null) {
notificationDisplayer.dismissDiagnosticNotification()
delegate.updateState(
description = "The notification has not been clicked.",
description = stringProvider.getString(R.string.troubleshoot_notifications_test_display_notification_failure),
status = NotificationTroubleshootTestState.Status.Failure(false)
)
} else {
delegate.updateState(
description = "The notification has been clicked!",
description = stringProvider.getString(R.string.troubleshoot_notifications_test_display_notification_success),
status = NotificationTroubleshootTestState.Status.Success
)
}

17
libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/troubleshoot/PushLoopbackTest.kt

@ -23,6 +23,8 @@ import io.element.android.libraries.core.notifications.NotificationTroubleshootT @@ -23,6 +23,8 @@ import io.element.android.libraries.core.notifications.NotificationTroubleshootT
import io.element.android.libraries.di.AppScope
import io.element.android.libraries.push.api.PushService
import io.element.android.libraries.push.api.gateway.PushGatewayFailure
import io.element.android.libraries.push.impl.R
import io.element.android.services.toolbox.api.strings.StringProvider
import io.element.android.services.toolbox.api.systemclock.SystemClock
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.CoroutineScope
@ -39,11 +41,12 @@ class PushLoopbackTest @Inject constructor( @@ -39,11 +41,12 @@ class PushLoopbackTest @Inject constructor(
private val pushService: PushService,
private val diagnosticPushHandler: DiagnosticPushHandler,
private val clock: SystemClock,
private val stringProvider: StringProvider,
) : NotificationTroubleshootTest {
override val order = 500
private val delegate = NotificationTroubleshootTestDelegate(
defaultName = "Test Push loopback",
defaultDescription = "Ensure that the application is receiving push.",
defaultName = stringProvider.getString(R.string.troubleshoot_notifications_test_push_loop_back_title),
defaultDescription = stringProvider.getString(R.string.troubleshoot_notifications_test_push_loop_back_description),
)
override val state: StateFlow<NotificationTroubleshootTestState> = delegate.state
@ -59,7 +62,7 @@ class PushLoopbackTest @Inject constructor( @@ -59,7 +62,7 @@ class PushLoopbackTest @Inject constructor(
pushService.testPush()
} catch (pusherRejected: PushGatewayFailure.PusherRejected) {
delegate.updateState(
description = "Error: pusher has rejected the request.",
description = stringProvider.getString(R.string.troubleshoot_notifications_test_push_loop_back_failure_1),
status = NotificationTroubleshootTestState.Status.Failure(false)
)
job.cancel()
@ -67,7 +70,7 @@ class PushLoopbackTest @Inject constructor( @@ -67,7 +70,7 @@ class PushLoopbackTest @Inject constructor(
} catch (e: Exception) {
Timber.e(e, "Failed to test push")
delegate.updateState(
description = "Error: ${e.message}.",
description = stringProvider.getString(R.string.troubleshoot_notifications_test_push_loop_back_failure_2, e.message),
status = NotificationTroubleshootTestState.Status.Failure(false)
)
job.cancel()
@ -75,7 +78,7 @@ class PushLoopbackTest @Inject constructor( @@ -75,7 +78,7 @@ class PushLoopbackTest @Inject constructor(
}
if (!testPushResult) {
delegate.updateState(
description = "Error, cannot test push.",
description = stringProvider.getString(R.string.troubleshoot_notifications_test_push_loop_back_failure_3),
status = NotificationTroubleshootTestState.Status.Failure(false)
)
job.cancel()
@ -87,12 +90,12 @@ class PushLoopbackTest @Inject constructor( @@ -87,12 +90,12 @@ class PushLoopbackTest @Inject constructor(
job.cancel()
if (result == null) {
delegate.updateState(
description = "Error, timeout waiting for push.",
description = stringProvider.getString(R.string.troubleshoot_notifications_test_push_loop_back_failure_4),
status = NotificationTroubleshootTestState.Status.Failure(false)
)
} else {
delegate.updateState(
description = "Push loopback took $result ms",
description = stringProvider.getString(R.string.troubleshoot_notifications_test_push_loop_back_success, result),
status = NotificationTroubleshootTestState.Status.Success
)
}

16
libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/troubleshoot/PushProvidersTest.kt

@ -21,7 +21,9 @@ import io.element.android.libraries.core.notifications.NotificationTroubleshootT @@ -21,7 +21,9 @@ import io.element.android.libraries.core.notifications.NotificationTroubleshootT
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestDelegate
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
import io.element.android.libraries.di.AppScope
import io.element.android.libraries.push.impl.R
import io.element.android.libraries.pushproviders.api.PushProvider
import io.element.android.services.toolbox.api.strings.StringProvider
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.StateFlow
import javax.inject.Inject
@ -29,12 +31,13 @@ import javax.inject.Inject @@ -29,12 +31,13 @@ import javax.inject.Inject
@ContributesMultibinding(AppScope::class)
class PushProvidersTest @Inject constructor(
pushProviders: Set<@JvmSuppressWildcards PushProvider>,
private val stringProvider: StringProvider,
) : NotificationTroubleshootTest {
private val sortedPushProvider = pushProviders.sortedBy { it.index }
override val order = 100
private val delegate = NotificationTroubleshootTestDelegate(
defaultName = "Detect push providers",
defaultDescription = "Ensure that the application has at least one push provider.",
defaultName = stringProvider.getString(R.string.troubleshoot_notifications_test_detect_push_provider_title),
defaultDescription = stringProvider.getString(R.string.troubleshoot_notifications_test_detect_push_provider_description),
fakeDelay = NotificationTroubleshootTestDelegate.SHORT_DELAY,
)
override val state: StateFlow<NotificationTroubleshootTestState> = delegate.state
@ -44,12 +47,17 @@ class PushProvidersTest @Inject constructor( @@ -44,12 +47,17 @@ class PushProvidersTest @Inject constructor(
val result = sortedPushProvider.isNotEmpty()
if (result) {
delegate.updateState(
description = "Found ${sortedPushProvider.size} push providers: ${sortedPushProvider.joinToString { it.name }}",
description = stringProvider.getQuantityString(
resId = R.plurals.troubleshoot_notifications_test_detect_push_provider_success,
quantity = sortedPushProvider.size,
sortedPushProvider.size,
sortedPushProvider.joinToString { it.name }
),
status = NotificationTroubleshootTestState.Status.Success
)
} else {
delegate.updateState(
description = "No push providers found",
description = stringProvider.getString(R.string.troubleshoot_notifications_test_detect_push_provider_failure),
status = NotificationTroubleshootTestState.Status.Failure(false)
)
}

24
libraries/push/impl/src/main/res/values/localazy.xml

@ -50,4 +50,28 @@ @@ -50,4 +50,28 @@
<string name="push_distributor_background_sync_android">"Background synchronization"</string>
<string name="push_distributor_firebase_android">"Google Services"</string>
<string name="push_no_valid_google_play_services_apk_android">"No valid Google Play Services found. Notifications may not work properly."</string>
<string name="troubleshoot_notifications_test_current_push_provider_description">"Get the name of the current provider."</string>
<string name="troubleshoot_notifications_test_current_push_provider_failure">"No push providers selected."</string>
<string name="troubleshoot_notifications_test_current_push_provider_success">"Current push provider: %1$s."</string>
<string name="troubleshoot_notifications_test_current_push_provider_title">"Current push provider"</string>
<string name="troubleshoot_notifications_test_detect_push_provider_description">"Ensure that the application has at least one push provider."</string>
<string name="troubleshoot_notifications_test_detect_push_provider_failure">"No push providers found."</string>
<plurals name="troubleshoot_notifications_test_detect_push_provider_success">
<item quantity="one">"Found %1$d push provider: %2$s"</item>
<item quantity="other">"Found %1$d push providers: %2$s"</item>
</plurals>
<string name="troubleshoot_notifications_test_detect_push_provider_title">"Detect push providers"</string>
<string name="troubleshoot_notifications_test_display_notification_description">"Check that the application can display notification."</string>
<string name="troubleshoot_notifications_test_display_notification_failure">"The notification has not been clicked."</string>
<string name="troubleshoot_notifications_test_display_notification_permission_failure">"Cannot display the notification."</string>
<string name="troubleshoot_notifications_test_display_notification_success">"The notification has been clicked!"</string>
<string name="troubleshoot_notifications_test_display_notification_title">"Display notification"</string>
<string name="troubleshoot_notifications_test_display_notification_waiting">"Please click on the notification to continue the test."</string>
<string name="troubleshoot_notifications_test_push_loop_back_description">"Ensure that the application is receiving push."</string>
<string name="troubleshoot_notifications_test_push_loop_back_failure_1">"Error: pusher has rejected the request."</string>
<string name="troubleshoot_notifications_test_push_loop_back_failure_2">"Error: %1$s."</string>
<string name="troubleshoot_notifications_test_push_loop_back_failure_3">"Error, cannot test push."</string>
<string name="troubleshoot_notifications_test_push_loop_back_failure_4">"Error, timeout waiting for push."</string>
<string name="troubleshoot_notifications_test_push_loop_back_success">"Push loop back took %1$d ms."</string>
<string name="troubleshoot_notifications_test_push_loop_back_title">"Test Push loop back"</string>
</resources>

7
libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/troubleshoot/CurrentPushProviderTestTest.kt

@ -20,6 +20,7 @@ import app.cash.turbine.test @@ -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.push.test.FakeGetCurrentPushProvider
import io.element.android.services.toolbox.test.strings.FakeStringProvider
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runTest
import org.junit.Test
@ -28,7 +29,8 @@ class CurrentPushProviderTestTest { @@ -28,7 +29,8 @@ class CurrentPushProviderTestTest {
@Test
fun `test CurrentPushProviderTest with a push provider`() = runTest {
val sut = CurrentPushProviderTest(
getCurrentPushProvider = FakeGetCurrentPushProvider("foo")
getCurrentPushProvider = FakeGetCurrentPushProvider("foo"),
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)
@ -45,7 +47,8 @@ class CurrentPushProviderTestTest { @@ -45,7 +47,8 @@ class CurrentPushProviderTestTest {
@Test
fun `test CurrentPushProviderTest without push provider`() = runTest {
val sut = CurrentPushProviderTest(
getCurrentPushProvider = FakeGetCurrentPushProvider(null)
getCurrentPushProvider = FakeGetCurrentPushProvider(null),
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)

4
libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/troubleshoot/NotificationTestTest.kt

@ -21,6 +21,7 @@ import com.google.common.truth.Truth.assertThat @@ -21,6 +21,7 @@ import com.google.common.truth.Truth.assertThat
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
import io.element.android.libraries.push.impl.notifications.fake.MockkNotificationCreator
import io.element.android.libraries.push.impl.notifications.fake.MockkNotificationDisplayer
import io.element.android.services.toolbox.test.strings.FakeStringProvider
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runTest
import org.junit.Test
@ -82,7 +83,8 @@ class NotificationTestTest { @@ -82,7 +83,8 @@ class NotificationTestTest {
return NotificationTest(
notificationCreator = mockkNotificationCreator.instance,
notificationDisplayer = mockkNotificationDisplayer.instance,
notificationClickHandler = notificationClickHandler
notificationClickHandler = notificationClickHandler,
stringProvider = FakeStringProvider(),
)
}
}

19
libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/troubleshoot/PushLoopbackTestTest.kt

@ -23,6 +23,7 @@ import io.element.android.libraries.matrix.test.AN_EXCEPTION @@ -23,6 +23,7 @@ import io.element.android.libraries.matrix.test.AN_EXCEPTION
import io.element.android.libraries.matrix.test.A_FAILURE_REASON
import io.element.android.libraries.push.api.gateway.PushGatewayFailure
import io.element.android.libraries.push.test.FakePushService
import io.element.android.services.toolbox.test.strings.FakeStringProvider
import io.element.android.services.toolbox.test.systemclock.FakeSystemClock
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runTest
@ -35,7 +36,8 @@ class PushLoopbackTestTest { @@ -35,7 +36,8 @@ class PushLoopbackTestTest {
val sut = PushLoopbackTest(
pushService = FakePushService(),
diagnosticPushHandler = diagnosticPushHandler,
clock = FakeSystemClock()
clock = FakeSystemClock(),
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)
@ -45,7 +47,6 @@ class PushLoopbackTestTest { @@ -45,7 +47,6 @@ class PushLoopbackTestTest {
assertThat(awaitItem().status).isEqualTo(NotificationTroubleshootTestState.Status.InProgress)
val lastItem = awaitItem()
assertThat(lastItem.status).isEqualTo(NotificationTroubleshootTestState.Status.Failure(false))
assertThat(lastItem.description).contains("timeout")
}
}
@ -59,7 +60,8 @@ class PushLoopbackTestTest { @@ -59,7 +60,8 @@ class PushLoopbackTestTest {
}
),
diagnosticPushHandler = diagnosticPushHandler,
clock = FakeSystemClock()
clock = FakeSystemClock(),
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)
@ -69,7 +71,6 @@ class PushLoopbackTestTest { @@ -69,7 +71,6 @@ class PushLoopbackTestTest {
assertThat(awaitItem().status).isEqualTo(NotificationTroubleshootTestState.Status.InProgress)
val lastItem = awaitItem()
assertThat(lastItem.status).isEqualTo(NotificationTroubleshootTestState.Status.Failure(false))
assertThat(lastItem.description).contains("rejected")
}
}
@ -81,7 +82,8 @@ class PushLoopbackTestTest { @@ -81,7 +82,8 @@ class PushLoopbackTestTest {
testPushBlock = { false }
),
diagnosticPushHandler = diagnosticPushHandler,
clock = FakeSystemClock()
clock = FakeSystemClock(),
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)
@ -91,7 +93,6 @@ class PushLoopbackTestTest { @@ -91,7 +93,6 @@ class PushLoopbackTestTest {
assertThat(awaitItem().status).isEqualTo(NotificationTroubleshootTestState.Status.InProgress)
val lastItem = awaitItem()
assertThat(lastItem.status).isEqualTo(NotificationTroubleshootTestState.Status.Failure(false))
assertThat(lastItem.description).contains("cannot test push")
}
}
@ -105,7 +106,8 @@ class PushLoopbackTestTest { @@ -105,7 +106,8 @@ class PushLoopbackTestTest {
}
),
diagnosticPushHandler = diagnosticPushHandler,
clock = FakeSystemClock()
clock = FakeSystemClock(),
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)
@ -128,7 +130,8 @@ class PushLoopbackTestTest { @@ -128,7 +130,8 @@ class PushLoopbackTestTest {
true
}),
diagnosticPushHandler = diagnosticPushHandler,
clock = FakeSystemClock()
clock = FakeSystemClock(),
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)

4
libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/troubleshoot/PushProvidersTestTest.kt

@ -20,6 +20,7 @@ import app.cash.turbine.test @@ -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.test.FakePushProvider
import io.element.android.services.toolbox.test.strings.FakeStringProvider
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runTest
import org.junit.Test
@ -29,6 +30,7 @@ class PushProvidersTestTest { @@ -29,6 +30,7 @@ class PushProvidersTestTest {
fun `test PushProvidersTest with empty list`() = runTest {
val sut = PushProvidersTest(
pushProviders = emptySet(),
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)
@ -48,6 +50,7 @@ class PushProvidersTestTest { @@ -48,6 +50,7 @@ class PushProvidersTestTest {
FakePushProvider(name = "foo"),
FakePushProvider(name = "bar"),
),
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)
@ -57,6 +60,7 @@ class PushProvidersTestTest { @@ -57,6 +60,7 @@ class PushProvidersTestTest {
assertThat(awaitItem().status).isEqualTo(NotificationTroubleshootTestState.Status.InProgress)
val lastItem = awaitItem()
assertThat(lastItem.status).isEqualTo(NotificationTroubleshootTestState.Status.Success)
assertThat(lastItem.description).contains("2")
assertThat(lastItem.description).contains("foo")
assertThat(lastItem.description).contains("bar")
}

3
libraries/pushproviders/firebase/build.gradle.kts

@ -40,6 +40,8 @@ dependencies { @@ -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 { @@ -57,4 +59,5 @@ dependencies {
testImplementation(libs.test.turbine)
testImplementation(projects.libraries.matrix.test)
testImplementation(projects.tests.testutils)
testImplementation(projects.services.toolbox.test)
}

11
libraries/pushproviders/firebase/src/main/kotlin/io/element/android/libraries/pushproviders/firebase/troubleshoot/FirebaseAvailabilityTest.kt

@ -24,6 +24,8 @@ import io.element.android.libraries.core.notifications.TestFilterData @@ -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 @@ -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( @@ -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)
)
}

14
libraries/pushproviders/firebase/src/main/kotlin/io/element/android/libraries/pushproviders/firebase/troubleshoot/FirebaseTokenTest.kt

@ -25,6 +25,8 @@ import io.element.android.libraries.di.AppScope @@ -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 @@ -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( @@ -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)
)
}

11
libraries/pushproviders/firebase/src/main/res/values/localazy.xml

@ -0,0 +1,11 @@ @@ -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>

7
libraries/pushproviders/firebase/src/test/kotlin/io/element/android/libraries/pushproviders/firebase/troubleshoot/FirebaseAvailabilityTestTest.kt

@ -20,6 +20,7 @@ import app.cash.turbine.test @@ -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 { @@ -32,7 +33,8 @@ class FirebaseAvailabilityTestTest {
override fun isAvailable(): Boolean {
return true
}
}
},
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)
@ -52,7 +54,8 @@ class FirebaseAvailabilityTestTest { @@ -52,7 +54,8 @@ class FirebaseAvailabilityTestTest {
override fun isAvailable(): Boolean {
return false
}
}
},
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)

3
libraries/pushproviders/firebase/src/test/kotlin/io/element/android/libraries/pushproviders/firebase/troubleshoot/FirebaseTokenTestTest.kt

@ -21,6 +21,7 @@ import com.google.common.truth.Truth.assertThat @@ -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 { @@ -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 { @@ -56,6 +58,7 @@ class FirebaseTokenTestTest {
Result.success(Unit)
}
),
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)

2
libraries/pushproviders/unifiedpush/build.gradle.kts

@ -32,6 +32,7 @@ dependencies { @@ -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 { @@ -57,4 +58,5 @@ dependencies {
testImplementation(libs.test.turbine)
testImplementation(projects.libraries.matrix.test)
testImplementation(projects.tests.testutils)
testImplementation(projects.services.toolbox.test)
}

16
libraries/pushproviders/unifiedpush/src/main/kotlin/io/element/android/libraries/pushproviders/unifiedpush/troubleshoot/UnifiedPushTest.kt

@ -22,8 +22,10 @@ import io.element.android.libraries.core.notifications.NotificationTroubleshootT @@ -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 @@ -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( @@ -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)
)
}

10
libraries/pushproviders/unifiedpush/src/main/res/values/localazy.xml

@ -0,0 +1,10 @@ @@ -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>

3
libraries/pushproviders/unifiedpush/src/test/kotlin/io/element/android/libraries/pushproviders/unifiedpush/troubleshoot/UnifiedPushTestTest.kt

@ -20,6 +20,7 @@ import app.cash.turbine.test @@ -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 { @@ -34,6 +35,7 @@ class UnifiedPushTestTest {
)
),
openDistributorWebPageAction = FakeOpenDistributorWebPageAction(),
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)
@ -60,6 +62,7 @@ class UnifiedPushTestTest { @@ -60,6 +62,7 @@ class UnifiedPushTestTest {
)
}
),
stringProvider = FakeStringProvider(),
)
launch {
sut.run(this)

28
tools/localazy/config.json

@ -80,7 +80,29 @@ @@ -80,7 +80,29 @@
"name" : ":libraries:push:impl",
"includeRegex" : [
"push_.*",
"notification_.*"
"notification_.*",
"troubleshoot_notifications_test_current_push_provider.*",
"troubleshoot_notifications_test_detect_push_provider.*",
"troubleshoot_notifications_test_display_notification_.*",
"troubleshoot_notifications_test_push_loop_back_.*"
]
},
{
"name" : ":libraries:permissions:impl",
"includeRegex" : [
"troubleshoot_notifications_test_check_permission_.*"
]
},
{
"name" : ":libraries:pushproviders:firebase",
"includeRegex" : [
"troubleshoot_notifications_test_firebase_.*"
]
},
{
"name" : ":libraries:pushproviders:unifiedpush",
"includeRegex" : [
"troubleshoot_notifications_test_unified_push_.*"
]
},
{
@ -182,7 +204,9 @@ @@ -182,7 +204,9 @@
"screen\\.advanced_settings\\..*",
"screen_edit_profile_.*",
"screen_notification_settings_.*",
"screen_blocked_users_.*"
"screen_blocked_users_.*",
"troubleshoot_notifications_entry_point_.*",
"troubleshoot_notifications_screen_.*"
]
},
{

Loading…
Cancel
Save