Bug 1840894 - Adjust Print Error UI to use Snackbars

This bug adjusts print errors to use the new snackbar component and
removes the prior toast used for errors.
fenix/117.0
Olivia Hall 11 months ago committed by mergify[bot]
parent 1a27d9bf6c
commit 6b53dd0ada

@ -5,8 +5,6 @@
package org.mozilla.fenix.share
import android.content.Context
import android.widget.Toast
import android.widget.Toast.LENGTH_LONG
import androidx.annotation.VisibleForTesting
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@ -23,7 +21,6 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.browser.StandardSnackbarError
import org.mozilla.fenix.components.appstate.AppAction
import org.mozilla.fenix.ext.components
import org.mozilla.gecko.util.ThreadUtils
import org.mozilla.geckoview.GeckoSession
import org.mozilla.geckoview.GeckoSession.GeckoPrintException.ERROR_NO_ACTIVITY_CONTEXT
import org.mozilla.geckoview.GeckoSession.GeckoPrintException.ERROR_NO_ACTIVITY_CONTEXT_DELEGATE
@ -78,11 +75,13 @@ class SaveToPDFMiddleware(
postTelemetryCompleted(ctx.state.findTab(action.tabId), isPrint = true)
}
is EngineAction.PrintContentExceptionAction -> {
// Bug 1840894 - will update this toast to a snackbar with new snackbar error component
ThreadUtils.runOnUiThread {
Toast.makeText(context, R.string.unable_to_print_error, LENGTH_LONG).show()
}
context.components.appStore.dispatch(
AppAction.UpdateStandardSnackbarErrorAction(
StandardSnackbarError(
context.getString(R.string.unable_to_print_error),
),
),
)
postTelemetryFailed(ctx.state.findTab(action.tabId), action.throwable, isPrint = true)
}
else -> {

@ -274,7 +274,7 @@ class SaveToPDFMiddlewareTest {
}
@Test
fun `GIVEN a print request WHEN it fails unexpectedly THEN unknown failure telemetry is sent`() = runTestOnMain {
fun `GIVEN a print request WHEN it fails unexpectedly THEN unknown failure telemetry is sent AND a snackbar error is shown`() = runTestOnMain {
val exceptionToThrow = RuntimeException("No Print Spooler")
val middleware = SaveToPDFMiddleware(testContext)
val mockEngineSession: EngineSession = mockk<EngineSession>().apply {
@ -307,10 +307,19 @@ class SaveToPDFMiddlewareTest {
assertEquals("unknown", reason)
val source = response?.extra?.get("source")
assertEquals("unknown", source)
verify {
appStore.dispatch(
AppAction.UpdateStandardSnackbarErrorAction(
StandardSnackbarError(
testContext.getString(R.string.unable_to_print_error),
),
),
)
}
}
@Test
fun `GIVEN a print request WHEN it fails due to print exception THEN print exception failure telemetry is sent`() = runTestOnMain {
fun `GIVEN a print request WHEN it fails due to print exception THEN print exception failure telemetry is sent AND a snackbar error is shown`() = runTestOnMain {
val exceptionToThrow = MockGeckoPrintException()
val middleware = SaveToPDFMiddleware(testContext)
val mockEngineSession: EngineSession = mockk<EngineSession>().apply {
@ -341,6 +350,15 @@ class SaveToPDFMiddlewareTest {
assertEquals("no_settings_service", reason)
val source = response?.extra?.get("source")
assertEquals("unknown", source)
verify {
appStore.dispatch(
AppAction.UpdateStandardSnackbarErrorAction(
StandardSnackbarError(
testContext.getString(R.string.unable_to_print_error),
),
),
)
}
}
@Test

Loading…
Cancel
Save