1
0
Fork 0

No issue: Fix BreadCrumbReporterTest

master
Emily Kager 2019-09-11 17:44:51 -07:00 committed by Emily Kager
parent b3eca65614
commit a16015cd21
1 changed files with 10 additions and 13 deletions

View File

@ -8,10 +8,10 @@ import androidx.navigation.NavController
import androidx.navigation.NavDestination import androidx.navigation.NavDestination
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import kotlinx.coroutines.ObsoleteCoroutinesApi import kotlinx.coroutines.ObsoleteCoroutinesApi
import mozilla.components.lib.crash.Breadcrumb
import mozilla.components.lib.crash.Crash import mozilla.components.lib.crash.Crash
import mozilla.components.lib.crash.CrashReporter import mozilla.components.lib.crash.CrashReporter
import mozilla.components.lib.crash.service.CrashReporterService import mozilla.components.lib.crash.service.CrashReporterService
import mozilla.components.support.test.any
import mozilla.components.support.test.mock import mozilla.components.support.test.mock
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@ -34,10 +34,12 @@ internal class BreadcrumbRecorderTest {
} }
} }
val reporter = spy(CrashReporter( val reporter = spy(
services = listOf(service), CrashReporter(
shouldPrompt = CrashReporter.Prompt.NEVER services = listOf(service),
)) shouldPrompt = CrashReporter.Prompt.NEVER
)
)
fun getBreadcrumbMessage(@Suppress("UNUSED_PARAMETER") destination: NavDestination): String { fun getBreadcrumbMessage(@Suppress("UNUSED_PARAMETER") destination: NavDestination): String {
return "test" return "test"
@ -46,15 +48,10 @@ internal class BreadcrumbRecorderTest {
val navController: NavController = mock() val navController: NavController = mock()
val navDestination: NavDestination = mock() val navDestination: NavDestination = mock()
val breadcrumb = Breadcrumb( val breadCrumbRecorder =
message = getBreadcrumbMessage(navDestination), BreadcrumbsRecorder(reporter, navController, ::getBreadcrumbMessage)
category = "DestinationChanged",
level = Breadcrumb.Level.INFO
)
val breadCrumbRecorder = BreadcrumbsRecorder(reporter, navController, ::getBreadcrumbMessage)
breadCrumbRecorder.onDestinationChanged(navController, navDestination, null) breadCrumbRecorder.onDestinationChanged(navController, navDestination, null)
verify(reporter).recordCrashBreadcrumb(breadcrumb) verify(reporter).recordCrashBreadcrumb(any())
} }
} }