Test live location permission preservation

Split the existing PR change into a smaller reviewable piece.
Original change: fix: do not revoke live location when enabling it
This commit is contained in:
Taksh 2026-10-05 16:10:58 +05:30
parent 40e741221a
commit 577f8f6260

View File

@ -0,0 +1,32 @@
package com.bitchat.android.geohash
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
class LiveLocationPrivacyGateTest {
@Test
fun `enabling location does not fire revocation listeners`() {
var revoked = 0
val listener = { revoked += 1 }
LiveLocationPrivacyGate.addRevocationListener(listener)
try {
LiveLocationPrivacyGate.update(false)
val afterDisable = revoked
assertTrue("disable should revoke", afterDisable >= 1)
LiveLocationPrivacyGate.update(true)
assertEquals(
"enable must not cancel in-flight location work",
afterDisable,
revoked
)
LiveLocationPrivacyGate.update(false)
assertTrue(revoked > afterDisable)
} finally {
LiveLocationPrivacyGate.removeRevocationListener(listener)
LiveLocationPrivacyGate.update(false)
}
}
}