Skip to content

Commit d1f1ad2

Browse files
runningcodeclaude
andcommitted
test(android): Make the DISCONNECTED test mock a disconnected network
`When network is active but not connected with permission, return DISCONNECTED` mocked an active network reporting isConnected=false alongside NetworkCapabilities describing a validated WiFi link. Those describe opposite worlds. It passes today only because the empty connection cache reads as fresh for the first two minutes of every boot (JAVA-717), which forces the legacy activeNetworkInfo path where the capability mocks are never consulted. buildInfo reports API 24, so once that bug is fixed the provider reads capabilities and the test would fail for a reason that has nothing to do with what it is named after. Fixing the mocks first keeps that failure from being buried in the commit that fixes the cache. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 440f5c6 commit d1f1ad2

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎sentry-android-core/src/test/java/io/sentry/android/core/internal/util/AndroidConnectionStatusProviderTest.kt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ class AndroidConnectionStatusProviderTest {
144144
@Test
145145
fun `When network is active but not connected with permission, return DISCONNECTED for isConnected`() {
146146
whenever(networkInfo.isConnected).thenReturn(false)
147+
// buildInfo reports API 24, so the provider reads NetworkCapabilities rather than the legacy
148+
// activeNetworkInfo. The active network has to report it cannot reach the internet too.
149+
whenever(networkCapabilities.hasCapability(NET_CAPABILITY_INTERNET)).thenReturn(false)
150+
whenever(networkCapabilities.hasCapability(NET_CAPABILITY_VALIDATED)).thenReturn(false)
147151

148152
assertEquals(
149153
IConnectionStatusProvider.ConnectionStatus.DISCONNECTED,

0 commit comments

Comments
 (0)