Skip to content

Commit c124eb1

Browse files
committed
LifeCycleIntegrationTest
1 parent d0f9805 commit c124eb1

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

sentry-android-core/src/test/java/io/sentry/android/core/ActivityLifecycleIntegrationTest.kt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,10 +1385,11 @@ class ActivityLifecycleIntegrationTest {
13851385
}
13861386

13871387
@Test
1388-
fun `starts new trace if performance is disabled`() {
1388+
fun `starts new trace if performance is disabled and trace ID generation is enabled`() {
13891389
val sut = fixture.getSut()
13901390
val activity = mock<Activity>()
13911391
fixture.options.tracesSampleRate = null
1392+
fixture.options.isEnableAutoTraceIdGeneration = true;
13921393

13931394
val argumentCaptor: ArgumentCaptor<ScopeCallback> = ArgumentCaptor.forClass(ScopeCallback::class.java)
13941395
val scope = Scope(fixture.options)
@@ -1405,6 +1406,28 @@ class ActivityLifecycleIntegrationTest {
14051406
assertNotSame(propagationContextAtStart, scope.propagationContext)
14061407
}
14071408

1409+
@Test
1410+
fun `does not start a new trace if performance is disabled and trace ID generation is disabled`() {
1411+
val sut = fixture.getSut()
1412+
val activity = mock<Activity>()
1413+
fixture.options.tracesSampleRate = null
1414+
fixture.options.isEnableAutoTraceIdGeneration = false;
1415+
1416+
val argumentCaptor: ArgumentCaptor<ScopeCallback> = ArgumentCaptor.forClass(ScopeCallback::class.java)
1417+
val scope = Scope(fixture.options)
1418+
val propagationContextAtStart = scope.propagationContext
1419+
whenever(fixture.scopes.configureScope(argumentCaptor.capture())).thenAnswer {
1420+
argumentCaptor.value.run(scope)
1421+
}
1422+
1423+
sut.register(fixture.scopes, fixture.options)
1424+
sut.onActivityCreated(activity, fixture.bundle)
1425+
1426+
// once for the screen
1427+
verify(fixture.scopes).configureScope(any())
1428+
assertSame(propagationContextAtStart, scope.propagationContext)
1429+
}
1430+
14081431
@Test
14091432
fun `sets the activity as the current screen`() {
14101433
val sut = fixture.getSut()

0 commit comments

Comments
 (0)