@@ -13,8 +13,6 @@ import io.sentry.ProfileLifecycle
1313import io.sentry.SentryLevel
1414import io.sentry.SentryReplayOptions
1515import io.sentry.TransactionOptions
16- import io.sentry.test.createSentryClientMock
17- import io.sentry.test.createTestScopes
1816import kotlin.test.AfterTest
1917import kotlin.test.BeforeTest
2018import kotlin.test.Test
@@ -25,7 +23,6 @@ import kotlin.test.assertNull
2523import kotlin.test.assertTrue
2624import org.junit.runner.RunWith
2725import org.mockito.kotlin.any
28- import org.mockito.kotlin.anyOrNull
2926import org.mockito.kotlin.eq
3027import org.mockito.kotlin.mock
3128import org.mockito.kotlin.never
@@ -36,7 +33,7 @@ import org.mockito.kotlin.verifyNoInteractions
3633class ManifestMetadataReaderTest {
3734 private class Fixture {
3835 val logger = mock<ILogger >()
39- val options = SentryAndroidOptions ().apply { setLogger(this @Fixture. logger) }
36+ val options = SentryAndroidOptions ().apply { setLogger(logger) }
4037 val buildInfoProvider = mock<BuildInfoProvider >()
4138
4239 fun getContext (metaData : Bundle = Bundle ()): Context =
@@ -2178,64 +2175,6 @@ class ManifestMetadataReaderTest {
21782175 assertTrue(fixture.options.inAppExcludes.isEmpty())
21792176 }
21802177
2181- @Test
2182- fun `applyMetadata does not warn when legacy logs enabled metadata is absent` () {
2183- fixture.options.isDebug = true
2184- val context = fixture.getContext()
2185-
2186- ManifestMetadataReader .applyMetadata(context, fixture.options, fixture.buildInfoProvider)
2187-
2188- verify(fixture.logger, never()).log(eq(SentryLevel .WARNING ), any<String >())
2189- }
2190-
2191- @Test
2192- fun `applyMetadata warns when legacy logs enabled metadata is true` () {
2193- val bundle =
2194- bundleOf(
2195- ManifestMetadataReader .DEBUG to true ,
2196- ManifestMetadataReader .ENABLE_LOGS to true ,
2197- )
2198- val context = fixture.getContext(metaData = bundle)
2199-
2200- ManifestMetadataReader .applyMetadata(context, fixture.options, fixture.buildInfoProvider)
2201-
2202- verify(fixture.logger)
2203- .log(
2204- SentryLevel .WARNING ,
2205- " The Android manifest option 'io.sentry.logs.enabled' is no longer supported. " +
2206- " Manual Sentry.logger() calls no longer require it, and automatic logging " +
2207- " integrations now require their own opt-ins." ,
2208- * emptyArray(),
2209- )
2210- assertThat(fixture.options.isEnableTimberLogs).isFalse()
2211- assertThat(fixture.options.isEnableLogcatLogs).isFalse()
2212- }
2213-
2214- @Test
2215- fun `applyMetadata warns when legacy logs enabled metadata is false` () {
2216- fixture.options.isEnableTimberLogs = true
2217- fixture.options.isEnableLogcatLogs = true
2218- val bundle =
2219- bundleOf(
2220- ManifestMetadataReader .DEBUG to true ,
2221- ManifestMetadataReader .ENABLE_LOGS to false ,
2222- )
2223- val context = fixture.getContext(metaData = bundle)
2224-
2225- ManifestMetadataReader .applyMetadata(context, fixture.options, fixture.buildInfoProvider)
2226-
2227- verify(fixture.logger)
2228- .log(
2229- SentryLevel .WARNING ,
2230- " The Android manifest option 'io.sentry.logs.enabled' no longer disables manual " +
2231- " Sentry.logger() calls. Automatic logging integrations remain disabled unless " +
2232- " enabled through their own opt-ins." ,
2233- * emptyArray(),
2234- )
2235- assertThat(fixture.options.isEnableTimberLogs).isTrue()
2236- assertThat(fixture.options.isEnableLogcatLogs).isTrue()
2237- }
2238-
22392178 @Test
22402179 fun `applyMetadata keeps Timber logs disabled if not found` () {
22412180 val context = fixture.getContext()
@@ -2285,66 +2224,6 @@ class ManifestMetadataReaderTest {
22852224 assertThat(fixture.options.isEnableLogcatLogs).isFalse()
22862225 }
22872226
2288- @Test
2289- fun `applyMetadata does not warn when legacy metrics enabled metadata is absent` () {
2290- fixture.options.isDebug = true
2291- val context = fixture.getContext()
2292-
2293- ManifestMetadataReader .applyMetadata(context, fixture.options, fixture.buildInfoProvider)
2294-
2295- verify(fixture.logger, never()).log(eq(SentryLevel .WARNING ), any<String >())
2296- }
2297-
2298- @Test
2299- fun `applyMetadata warns when legacy metrics enabled metadata is true` () {
2300- val bundle =
2301- bundleOf(
2302- ManifestMetadataReader .DEBUG to true ,
2303- ManifestMetadataReader .ENABLE_METRICS to true ,
2304- )
2305- val context = fixture.getContext(metaData = bundle)
2306- val client = createSentryClientMock()
2307-
2308- ManifestMetadataReader .applyMetadata(context, fixture.options, fixture.buildInfoProvider)
2309- fixture.options.dsn = " https://key@sentry.io/proj"
2310- val scopes = createTestScopes(fixture.options).also { it.bindClient(client) }
2311- scopes.metrics().count(" metric name" )
2312-
2313- verify(fixture.logger)
2314- .log(
2315- SentryLevel .WARNING ,
2316- " The Android manifest option 'io.sentry.metrics.enabled' is no longer supported. " +
2317- " Manual Sentry.metrics() calls no longer require it." ,
2318- * emptyArray(),
2319- )
2320- verify(client).captureMetric(any(), anyOrNull(), anyOrNull())
2321- }
2322-
2323- @Test
2324- fun `applyMetadata warns when legacy metrics enabled metadata is false` () {
2325- val bundle =
2326- bundleOf(
2327- ManifestMetadataReader .DEBUG to true ,
2328- ManifestMetadataReader .ENABLE_METRICS to false ,
2329- )
2330- val context = fixture.getContext(metaData = bundle)
2331- val client = createSentryClientMock()
2332-
2333- ManifestMetadataReader .applyMetadata(context, fixture.options, fixture.buildInfoProvider)
2334- fixture.options.dsn = " https://key@sentry.io/proj"
2335- val scopes = createTestScopes(fixture.options).also { it.bindClient(client) }
2336- scopes.metrics().count(" metric name" )
2337-
2338- verify(fixture.logger)
2339- .log(
2340- SentryLevel .WARNING ,
2341- " The Android manifest option 'io.sentry.metrics.enabled' no longer disables manual " +
2342- " Sentry.metrics() calls." ,
2343- * emptyArray(),
2344- )
2345- verify(client).captureMetric(any(), anyOrNull(), anyOrNull())
2346- }
2347-
23482227 @Test
23492228 fun `applyMetadata reads feedback name required and keep default value if not found` () {
23502229 // Arrange
0 commit comments