Skip to content

Commit

Permalink
For mozilla-mobile#11670: Use explicit intent for setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarare committed Mar 8, 2022
1 parent 242991b commit e72156a
Showing 1 changed file with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,36 @@ import org.robolectric.Robolectric
@RunWith(AndroidJUnit4::class)
class SendCrashTelemetryServiceTest {
private var service: SendCrashTelemetryService? = null
private val intent = Intent("org.mozilla.gecko.ACTION_CRASHED")

@get:Rule
val coroutinesTestRule = MainCoroutineRule()
private val scope = TestCoroutineScope(coroutinesTestRule.testDispatcher)

@Before
fun setUp() {
intent.component = ComponentName(
"org.mozilla.samples.browser",
"mozilla.components.lib.crash.handler.CrashHandlerService"
)
intent.putExtra(
"minidumpPath",
"/data/data/org.mozilla.samples.browser/files/mozilla/Crash Reports/pending/3ba5f665-8422-dc8e-a88e-fc65c081d304.dmp"
)
intent.putExtra("fatal", false)
intent.putExtra(
"extrasPath",
"/data/data/org.mozilla.samples.browser/files/mozilla/Crash Reports/pending/3ba5f665-8422-dc8e-a88e-fc65c081d304.extra"
)
intent.putExtra("minidumpSuccess", true)
intent.putParcelableArrayListExtra("breadcrumbs", null)
service = spy(Robolectric.setupService(SendCrashTelemetryService::class.java))
service?.startService(Intent())
service?.startService(intent)
}

@After
fun tearDown() {
service?.stopService(Intent())
service?.stopService(intent)
CrashReporter.reset()
}

Expand Down Expand Up @@ -80,22 +96,6 @@ class SendCrashTelemetryServiceTest {
arrayListOf()
)

val intent = Intent("org.mozilla.gecko.ACTION_CRASHED")
intent.component = ComponentName(
"org.mozilla.samples.browser",
"mozilla.components.lib.crash.handler.CrashHandlerService"
)
intent.putExtra(
"minidumpPath",
"/data/data/org.mozilla.samples.browser/files/mozilla/Crash Reports/pending/3ba5f665-8422-dc8e-a88e-fc65c081d304.dmp"
)
intent.putExtra("fatal", false)
intent.putExtra(
"extrasPath",
"/data/data/org.mozilla.samples.browser/files/mozilla/Crash Reports/pending/3ba5f665-8422-dc8e-a88e-fc65c081d304.extra"
)
intent.putExtra("minidumpSuccess", true)
intent.putParcelableArrayListExtra("breadcrumbs", null)
originalCrash.fillIn(intent)

service?.onStartCommand(intent, 0, 0)
Expand Down

0 comments on commit e72156a

Please sign in to comment.