From 577f8f6260bb37aecf25619d17e1f468efd437d1 Mon Sep 17 00:00:00 2001 From: Taksh Date: Mon, 5 Oct 2026 16:10:58 +0530 Subject: [PATCH] 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 --- .../geohash/LiveLocationPrivacyGateTest.kt | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 app/src/test/java/com/bitchat/android/geohash/LiveLocationPrivacyGateTest.kt diff --git a/app/src/test/java/com/bitchat/android/geohash/LiveLocationPrivacyGateTest.kt b/app/src/test/java/com/bitchat/android/geohash/LiveLocationPrivacyGateTest.kt new file mode 100644 index 000000000..ee4caa900 --- /dev/null +++ b/app/src/test/java/com/bitchat/android/geohash/LiveLocationPrivacyGateTest.kt @@ -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) + } + } +}