tools: first LOC Phase-1 slices (dead APIs, shared test fake, redundant configs)
- Commit
e12df9d1754668c45139b319f2ccce5c6221c18b- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 15:41 UTC (4 days ago)
- Parents
3dc6ef7
Lever E, verified dead in production (scoped src/main grep): GameHubClient.registerAchievementsLegacy (test-only caller) and library/map RegionLevel/RegionMask (test-only; the live native mask path is separate and kept). 55 production lines out; the audit's ~500 for this item did not hold and is not claimed. Lever A small items: redundant @Config(sdk=[34]) stripped in 9 test files where the shared robolectric.properties already defaults sdk=34; FakeAndroidKeyStore unified into one shared superset in build-logic/shared-test (already on every unit-test source set), migrating biometric, library and notes copies (-136 net, 12 copies remain for follow-up); astronomy's deadline-poll await helpers delegate to DeterministicAwait (-25). Net -244 counted lines on this change. Verified per module (sdk:games, library:map, library, library:biometric, notes, logicgate, education tests+lint green); office/astronomy have one pre-existing unrelated test failure each (untouched classes, evidence in the agent report) and lint errors from other agents' untracked detectors on untouched main files.
Diff
astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelLocationTest.kt
diff --git a/astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelLocationTest.kt b/astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelLocationTest.ktindex 3b14023e7a..9578fc827f 100644--- a/astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelLocationTest.kt+++ b/astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelLocationTest.kt@@ -6,6 +6,7 @@ import android.location.Location import android.location.LocationManager import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4+import com.vayunmathur.testsupport.awaitWithMainIdle import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.resetMain@@ -17,7 +18,6 @@ import org.junit.runner.RunWith import org.robolectric.Shadows.shadowOf import kotlin.test.assertEquals import kotlin.test.assertNotNull-import kotlin.test.assertTrue /** * Location-refresh tests for [AstronomyViewModel]: with a granted@@ -40,14 +40,7 @@ class AstronomyViewModelLocationTest { Dispatchers.resetMain() } - private fun await(desc: String, cond: () -> Boolean) {- val deadline = System.currentTimeMillis() + 20_000- while (System.currentTimeMillis() < deadline) {- if (cond()) return- Thread.sleep(50)- }- assertTrue(cond(), "timed out: $desc")- }+ private fun await(desc: String, cond: () -> Boolean) = awaitWithMainIdle(desc) { cond() } @Test fun `refresh location adopts the last-known fix`() {
astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelTest.kt
diff --git a/astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelTest.kt b/astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelTest.ktindex 972c8908fd..324da48502 100644--- a/astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelTest.kt+++ b/astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelTest.kt@@ -3,6 +3,7 @@ package com.vayunmathur.astronomy.platform import android.app.Application import androidx.test.core.app.ApplicationProvider import com.vayunmathur.astronomy.domain.engine.RaDec+import com.vayunmathur.testsupport.awaitWithMainIdle import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking@@ -26,14 +27,7 @@ class AstronomyViewModelTest { @BeforeTest fun setUp() { Dispatchers.setMain(Dispatchers.Unconfined) } @AfterTest fun tearDown() { Dispatchers.resetMain() } - private fun await(desc: String, cond: () -> Boolean) {- val deadline = System.currentTimeMillis() + 20_000- while (System.currentTimeMillis() < deadline) {- if (cond()) return- Thread.sleep(50)- }- assertTrue(cond(), "timed out: $desc")- }+ private fun await(desc: String, cond: () -> Boolean) = awaitWithMainIdle(desc) { cond() } @Test fun `catalog loads and visible sky computes for a manual location`() { val vm = AstronomyViewModel(app)
astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.kt
diff --git a/astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.kt b/astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.ktindex dc44ad11a1..1a6d7fa280 100644--- a/astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.kt+++ b/astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.kt@@ -9,6 +9,7 @@ import com.vayunmathur.astronomy.Route import com.vayunmathur.astronomy.platform.AstronomyViewModel import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.library.util.rememberNavBackStack+import com.vayunmathur.testsupport.awaitWithMainIdle import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.resetMain@@ -33,14 +34,7 @@ class AstronomyPagesTest { @Composable private fun stack(): NavBackStack<Route> = rememberNavBackStack(Route.SkyMap) - private fun await(desc: String, cond: () -> Boolean) {- val deadline = System.currentTimeMillis() + 20_000- while (System.currentTimeMillis() < deadline) {- if (cond()) return- Thread.sleep(50)- }- assertTrue(cond(), "timed out: $desc")- }+ private fun await(desc: String, cond: () -> Boolean) = awaitWithMainIdle(desc) { cond() } @Test fun `object detail page renders the sun`() { val vm = AstronomyViewModel(app)
astronomy/src/test/java/com/vayunmathur/astronomy/ui/ObjectDetailPagesTest.kt
diff --git a/astronomy/src/test/java/com/vayunmathur/astronomy/ui/ObjectDetailPagesTest.kt b/astronomy/src/test/java/com/vayunmathur/astronomy/ui/ObjectDetailPagesTest.ktindex cfbc9bbf52..220c517458 100644--- a/astronomy/src/test/java/com/vayunmathur/astronomy/ui/ObjectDetailPagesTest.kt+++ b/astronomy/src/test/java/com/vayunmathur/astronomy/ui/ObjectDetailPagesTest.kt@@ -13,6 +13,7 @@ import com.vayunmathur.astronomy.Route import com.vayunmathur.astronomy.platform.AstronomyViewModel import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.library.util.rememberNavBackStack+import com.vayunmathur.testsupport.awaitWithMainIdle import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.resetMain@@ -54,14 +55,7 @@ class ObjectDetailPagesTest { @Composable private fun stack(): NavBackStack<Route> = rememberNavBackStack(Route.SkyMap) - private fun await(desc: String, cond: () -> Boolean) {- val deadline = System.currentTimeMillis() + 20_000- while (System.currentTimeMillis() < deadline) {- if (cond()) return- Thread.sleep(50)- }- assertTrue(cond(), "timed out: $desc")- }+ private fun await(desc: String, cond: () -> Boolean) = awaitWithMainIdle(desc) { cond() } private fun viewModel(): AstronomyViewModel { val vm = AstronomyViewModel(app)
build-logic/shared-test/java/com/vayunmathur/testsupport/FakeAndroidKeyStore.kt
diff --git a/library/biometric/src/test/java/com/vayunmathur/library/biometric/FakeAndroidKeyStore.kt b/build-logic/shared-test/java/com/vayunmathur/testsupport/FakeAndroidKeyStore.ktsimilarity index 56%rename from library/biometric/src/test/java/com/vayunmathur/library/biometric/FakeAndroidKeyStore.ktrename to build-logic/shared-test/java/com/vayunmathur/testsupport/FakeAndroidKeyStore.ktindex 62eb0f38fd..1669f27547 100644--- a/library/biometric/src/test/java/com/vayunmathur/library/biometric/FakeAndroidKeyStore.kt+++ b/build-logic/shared-test/java/com/vayunmathur/testsupport/FakeAndroidKeyStore.kt@@ -1,10 +1,9 @@-package com.vayunmathur.library.biometric+package com.vayunmathur.testsupport import android.security.keystore.KeyGenParameterSpec import java.io.InputStream import java.io.OutputStream import java.security.Key-import java.security.KeyStore import java.security.KeyStoreSpi import java.security.Provider import java.security.SecureRandom@@ -19,29 +18,43 @@ import javax.crypto.SecretKey import javax.crypto.spec.SecretKeySpec /**- * Robolectric has no AndroidKeyStore provider, which otherwise blocks every- * code path that opens the SQLCipher vault (PasswordRepository,- * DatabaseHelper, KdbxPasswordHelper). Installing this JCA provider gives- * tests a plain in-memory AES keystore with the same alias semantics; keys- * never leave the test process.+ * Shared in-memory AndroidKeyStore provider for Robolectric (which has none).+ *+ * This is the repo's one shared copy, in `build-logic/shared-test/java`, which+ * both convention plugins (`common-conventions-app` and+ * `common-conventions-library`) add to every module's unit-test source set โ+ * the same mechanism that shares [DeterministicAwait]. It is a superset of+ * the per-module copies it replaces:+ * - alias helpers ([put]/[get]/[remove]/[contains]/[aliases]/[clear]) used by+ * tests that inspect or reset the store directly;+ * - [generator] for tests that obtain a generator through JCA;+ * - [failGeneration] so a test can simulate key generation failing with no+ * way to authenticate the user (the biometric unlock path);+ * - byte-array key entries are stored (as an AES [SecretKeySpec]), matching+ * the copies whose `engineSetKeyEntry(ByteArray)` stored the key.+ *+ * Keys never leave the test process. Install once per test class with+ * [install]; installing twice is a no-op once any AndroidKeyStore provider+ * (real or fake) is present. */ object FakeAndroidKeyStore {- private val keys = mutableMapOf<String, SecretKey>()+ private val keys = Collections.synchronizedMap(HashMap<String, Key>()) + /** When true, the next key generation fails as it does with no way to authenticate the user. */+ var failGeneration: Boolean = false++ @Synchronized fun install() { if (Security.getProvider("AndroidKeyStore") == null) { Security.addProvider(FakeProvider()) } } - /** When true, the next key generation fails as it does with no way to authenticate the user. */- var failGeneration: Boolean = false-- fun put(alias: String, key: SecretKey) {+ fun put(alias: String, key: Key) { keys[alias] = key } - fun get(alias: String): SecretKey? = keys[alias]+ fun get(alias: String): SecretKey? = keys[alias] as? SecretKey fun remove(alias: String) { keys.remove(alias)@@ -49,7 +62,12 @@ object FakeAndroidKeyStore { fun contains(alias: String): Boolean = keys.containsKey(alias) - fun aliases(): List<String> = keys.keys.toList()+ fun aliases(): List<String> = synchronized(keys) { keys.keys.toList() }++ fun clear() = synchronized(keys) { keys.clear() }++ /** Convenience for tests that obtain a generator through JCA. */+ fun generator(): KeyGenerator = KeyGenerator.getInstance("AES", "AndroidKeyStore") class FakeProvider : Provider("AndroidKeyStore", 1.0, "in-memory test keystore") { init {@@ -60,23 +78,32 @@ object FakeAndroidKeyStore { class FakeKeyStoreSpi : KeyStoreSpi() { override fun engineLoad(stream: InputStream?, password: CharArray?) = Unit- override fun engineContainsAlias(alias: String) = contains(alias)- override fun engineDeleteEntry(alias: String) = remove(alias)- override fun engineGetKey(alias: String, password: CharArray?): Key? = get(alias)- override fun engineIsKeyEntry(alias: String) = contains(alias)+ override fun engineStore(stream: OutputStream?, password: CharArray?) = Unit+ override fun engineGetKey(alias: String, password: CharArray?): Key? = keys[alias]+ override fun engineContainsAlias(alias: String): Boolean = keys.containsKey(alias)+ override fun engineDeleteEntry(alias: String) {+ keys.remove(alias)+ } override fun engineAliases(): Enumeration<String> = Collections.enumeration(aliases())- override fun engineSize() = aliases().size+ override fun engineSize(): Int = keys.size+ override fun engineIsKeyEntry(alias: String): Boolean = keys.containsKey(alias)+ override fun engineIsCertificateEntry(alias: String): Boolean = false override fun engineGetCertificate(alias: String): Certificate? = null- override fun engineGetCertificateAlias(cert: Certificate) = null override fun engineGetCertificateChain(alias: String): Array<Certificate>? = null- override fun engineGetCreationDate(alias: String) = Date()- override fun engineIsCertificateEntry(alias: String) = false- override fun engineSetCertificateEntry(alias: String, cert: Certificate) = Unit- override fun engineStore(stream: OutputStream?, password: CharArray?) = Unit- override fun engineSetKeyEntry(alias: String, key: Key, password: CharArray?, chain: Array<out Certificate>?) {- if (key is SecretKey) put(alias, key)+ override fun engineGetCertificateAlias(cert: Certificate): String? = null+ override fun engineGetCreationDate(alias: String): Date = Date()+ override fun engineSetKeyEntry(+ alias: String,+ key: Key,+ password: CharArray?,+ chain: Array<out Certificate>?,+ ) {+ keys[alias] = key+ }+ override fun engineSetKeyEntry(alias: String, key: ByteArray, chain: Array<out Certificate>?) {+ keys[alias] = SecretKeySpec(key, "AES") }- override fun engineSetKeyEntry(alias: String, key: ByteArray, chain: Array<out Certificate>?) = Unit+ override fun engineSetCertificateEntry(alias: String, cert: Certificate) = Unit } class FakeKeyGeneratorSpi : KeyGeneratorSpi() {@@ -95,7 +122,4 @@ object FakeAndroidKeyStore { return SecretKeySpec(bytes, "AES").also { put(alias, it) } } }-- /** Convenience for tests that obtain a generator through JCA. */- fun generator(): KeyGenerator = KeyGenerator.getInstance("AES", "AndroidKeyStore") }
education/src/test/java/com/vayunmathur/education/ui/EducationHomeCourseTest.kt
diff --git a/education/src/test/java/com/vayunmathur/education/ui/EducationHomeCourseTest.kt b/education/src/test/java/com/vayunmathur/education/ui/EducationHomeCourseTest.ktindex c96223ac43..897f6accb0 100644--- a/education/src/test/java/com/vayunmathur/education/ui/EducationHomeCourseTest.kt+++ b/education/src/test/java/com/vayunmathur/education/ui/EducationHomeCourseTest.kt@@ -23,11 +23,9 @@ import kotlin.test.assertTrue import org.junit.Rule import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner-import org.robolectric.annotation.Config /** Scholar home (sections/deadlines) and course (units/challenge) screens. */ @RunWith(RobolectricTestRunner::class)-@Config(sdk = [34]) class EducationHomeCourseTest { @get:Rule
education/src/test/java/com/vayunmathur/education/ui/EducationQuizTest.kt
diff --git a/education/src/test/java/com/vayunmathur/education/ui/EducationQuizTest.kt b/education/src/test/java/com/vayunmathur/education/ui/EducationQuizTest.ktindex 2f66cb9e8f..75fb5bd72c 100644--- a/education/src/test/java/com/vayunmathur/education/ui/EducationQuizTest.kt+++ b/education/src/test/java/com/vayunmathur/education/ui/EducationQuizTest.kt@@ -35,11 +35,9 @@ import kotlin.test.assertTrue import org.junit.Rule import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner-import org.robolectric.annotation.Config /** Grading for every question type plus the quiz screen flow. */ @RunWith(RobolectricTestRunner::class)-@Config(sdk = [34]) class EducationQuizTest { @get:Rule
games/logicgate/src/test/java/com/vayunmathur/games/logicgate/ui/LogicCanvasW6Test.kt
diff --git a/games/logicgate/src/test/java/com/vayunmathur/games/logicgate/ui/LogicCanvasW6Test.kt b/games/logicgate/src/test/java/com/vayunmathur/games/logicgate/ui/LogicCanvasW6Test.ktindex f92ad01956..f3d2d743de 100644--- a/games/logicgate/src/test/java/com/vayunmathur/games/logicgate/ui/LogicCanvasW6Test.kt+++ b/games/logicgate/src/test/java/com/vayunmathur/games/logicgate/ui/LogicCanvasW6Test.kt@@ -31,7 +31,6 @@ import kotlin.test.assertTrue import org.junit.Rule import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner-import org.robolectric.annotation.Config /** * W6: renders the real canvas (every gate shape, bus wires with live values,@@ -39,7 +38,6 @@ import org.robolectric.annotation.Config * the painter and sheet branches no JVM test reached before. */ @RunWith(RobolectricTestRunner::class)-@Config(sdk = [34]) @org.robolectric.annotation.GraphicsMode(org.robolectric.annotation.GraphicsMode.Mode.NATIVE) class LogicCanvasW6Test {
games/logicgate/src/test/java/com/vayunmathur/games/logicgate/ui/LogicNavigationW6Test.kt
diff --git a/games/logicgate/src/test/java/com/vayunmathur/games/logicgate/ui/LogicNavigationW6Test.kt b/games/logicgate/src/test/java/com/vayunmathur/games/logicgate/ui/LogicNavigationW6Test.ktindex 4cfe1d1271..3ca21ee46b 100644--- a/games/logicgate/src/test/java/com/vayunmathur/games/logicgate/ui/LogicNavigationW6Test.kt+++ b/games/logicgate/src/test/java/com/vayunmathur/games/logicgate/ui/LogicNavigationW6Test.kt@@ -19,11 +19,9 @@ import kotlinx.coroutines.Dispatchers import org.junit.Rule import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner-import org.robolectric.annotation.Config /** W6: the real Navigation shell and its Game/Component pages over a live ViewModel. */ @RunWith(RobolectricTestRunner::class)-@Config(sdk = [34]) class LogicNavigationW6Test { @get:Rule val rule = createComposeRule()
library/biometric/src/test/java/com/vayunmathur/library/biometric/BiometricDatabaseHelperTest.kt
diff --git a/library/biometric/src/test/java/com/vayunmathur/library/biometric/BiometricDatabaseHelperTest.kt b/library/biometric/src/test/java/com/vayunmathur/library/biometric/BiometricDatabaseHelperTest.ktindex 29d98c0554..cffa369e31 100644--- a/library/biometric/src/test/java/com/vayunmathur/library/biometric/BiometricDatabaseHelperTest.kt+++ b/library/biometric/src/test/java/com/vayunmathur/library/biometric/BiometricDatabaseHelperTest.kt@@ -2,6 +2,7 @@ package com.vayunmathur.library.biometric import android.content.Context import androidx.test.core.app.ApplicationProvider+import com.vayunmathur.testsupport.FakeAndroidKeyStore import java.security.KeyStore import org.junit.Before import org.junit.runner.RunWith
library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockBiometricsTest.kt
diff --git a/library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockBiometricsTest.kt b/library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockBiometricsTest.ktindex 29e8ae2ce6..7c2c638de0 100644--- a/library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockBiometricsTest.kt+++ b/library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockBiometricsTest.kt@@ -4,6 +4,7 @@ import android.content.Context import android.os.Looper import androidx.fragment.app.FragmentActivity import androidx.test.core.app.ApplicationProvider+import com.vayunmathur.testsupport.FakeAndroidKeyStore import java.security.KeyStore import org.junit.Before import org.junit.runner.RunWith
library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockCipherDeliveryTest.kt
diff --git a/library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockCipherDeliveryTest.kt b/library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockCipherDeliveryTest.ktindex 58e972209f..a26f89bf66 100644--- a/library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockCipherDeliveryTest.kt+++ b/library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockCipherDeliveryTest.kt@@ -2,6 +2,7 @@ package com.vayunmathur.library.biometric import android.content.Context import androidx.test.core.app.ApplicationProvider+import com.vayunmathur.testsupport.FakeAndroidKeyStore import org.junit.Before import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner
library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockStatusTest.kt
diff --git a/library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockStatusTest.kt b/library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockStatusTest.ktindex 9d04c00f24..6479429cc7 100644--- a/library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockStatusTest.kt+++ b/library/biometric/src/test/java/com/vayunmathur/library/biometric/UnlockStatusTest.kt@@ -3,6 +3,7 @@ package com.vayunmathur.library.biometric import android.hardware.biometrics.BiometricManager import android.os.Looper import androidx.fragment.app.FragmentActivity+import com.vayunmathur.testsupport.FakeAndroidKeyStore import org.junit.Before import org.junit.runner.RunWith import org.robolectric.Robolectric
library/map/AGENTS.md
diff --git a/library/map/AGENTS.md b/library/map/AGENTS.mdindex 4efd977387..11de5d3505 100644--- a/library/map/AGENTS.md+++ b/library/map/AGENTS.md@@ -41,7 +41,6 @@ - com/vayunmathur/library/map/GeoTypes.kt - com/vayunmathur/library/map/Mercator.kt - com/vayunmathur/library/map/Projection.kt-- com/vayunmathur/library/map/RegionLevel.kt - com/vayunmathur/library/map/FrameStatsOverlay.kt ## Verify (this module only)
library/map/src/main/java/com/vayunmathur/library/map/RegionLevel.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/RegionLevel.kt b/library/map/src/main/java/com/vayunmathur/library/map/RegionLevel.ktdeleted file mode 100644index 6805e1ca1a..0000000000--- a/library/map/src/main/java/com/vayunmathur/library/map/RegionLevel.kt+++ /dev/null@@ -1,48 +0,0 @@-package com.vayunmathur.library.map--/**- * Which rung of the administrative stack a region mask meant.- *- * @deprecated The mask is now the label's baked `regionId` passed straight through- * (`Long?` from `regionMaskFor` to `setRegionMask`): the tile's `region_links` table links- * each place label to its outline at build time, so no point/level guess is needed.- * Kept until the follow-up removes it; nothing references it anymore.- *- * A mask used to be asked for by point, because nothing in the archive linked a place label- * to its outline. But a point is contained by every region above it at once โ a city sits- * inside a county inside a state inside a country โ so the point alone could not say which- * outline was meant, and the level band disambiguated. The bands were OSM `admin_level`- * values, matching the names the tiler's boundary schema gives them (`kind_for`): 1-2- * country, 3-4 region, 5-6 county, 7+ locality.- */-// OSM admin_level bands (see the KDoc above): 1-2 country, 3-4 region, 7-12 locality.-// Enum entries cannot reference companion constants in their own constructor calls-// (companion initializes after entries), so the bands stay as literals with the-// documented ranges as the single source of truth.-@Suppress("MagicNumber")-@Deprecated("Baked-id path: pass the label's regionId (Long?) straight through instead.")-enum class RegionLevel(val min: Int, val max: Int) {- /** A country. */- COUNTRY(1, 2),-- /** A state, province or other first-level division. */- REGION(3, 4),-- /** A city, town or neighbourhood.- *- * Deliberately starts above the county band. A city and the county sharing its name are- * near enough the same shape that preferring the smaller one picks between them by- * accident, and the same tap could resolve differently twice running.- */- LOCALITY(7, 12),-}--/**- * A request to dim everything outside one administrative region.- *- * @deprecated The mask is now a baked `regionId` (`Long?`): `[position]` + `[level]` travelled- * together because neither identified a region on its own, and the id does. Kept until the- * follow-up removes it; nothing references it anymore.- */-@Deprecated("Baked-id path: pass the label's regionId (Long?) straight through instead.")-data class RegionMask(val position: GeoPoint, val level: RegionLevel)
library/map/src/test/java/com/vayunmathur/library/map/MapAttachTest.kt
diff --git a/library/map/src/test/java/com/vayunmathur/library/map/MapAttachTest.kt b/library/map/src/test/java/com/vayunmathur/library/map/MapAttachTest.ktindex f48d3e35bf..122353db4c 100644--- a/library/map/src/test/java/com/vayunmathur/library/map/MapAttachTest.kt+++ b/library/map/src/test/java/com/vayunmathur/library/map/MapAttachTest.kt@@ -20,11 +20,9 @@ import kotlin.test.assertTrue import org.junit.Rule import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner-import org.robolectric.annotation.Config /** Surface attach (native unavailable under Robolectric), image overlay, taps, bounds, saver. */ @RunWith(RobolectricTestRunner::class)-@Config(sdk = [34]) class MapAttachTest { @get:Rule val rule = createComposeRule()
library/map/src/test/java/com/vayunmathur/library/map/MapComposeTest.kt
diff --git a/library/map/src/test/java/com/vayunmathur/library/map/MapComposeTest.kt b/library/map/src/test/java/com/vayunmathur/library/map/MapComposeTest.ktindex a63cb697e8..9087768d7f 100644--- a/library/map/src/test/java/com/vayunmathur/library/map/MapComposeTest.kt+++ b/library/map/src/test/java/com/vayunmathur/library/map/MapComposeTest.kt@@ -16,11 +16,9 @@ import kotlin.test.Test import org.junit.Rule import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner-import org.robolectric.annotation.Config /** Compose surfaces without a GPU: stats overlay rows and MapScope marker placement. */ @RunWith(RobolectricTestRunner::class)-@Config(sdk = [34]) class MapComposeTest { @get:Rule val rule = createComposeRule()
library/map/src/test/java/com/vayunmathur/library/map/MapGesturesTest.kt
diff --git a/library/map/src/test/java/com/vayunmathur/library/map/MapGesturesTest.kt b/library/map/src/test/java/com/vayunmathur/library/map/MapGesturesTest.ktindex d3ee2ba69c..8db209b2b0 100644--- a/library/map/src/test/java/com/vayunmathur/library/map/MapGesturesTest.kt+++ b/library/map/src/test/java/com/vayunmathur/library/map/MapGesturesTest.kt@@ -15,11 +15,9 @@ import kotlin.test.assertTrue import org.junit.Rule import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner-import org.robolectric.annotation.Config /** Gesture modifier: tap reports geo, drag pans, viewport is measured from layout. */ @RunWith(RobolectricTestRunner::class)-@Config(sdk = [34]) class MapGesturesTest { @get:Rule val rule = createComposeRule()
library/map/src/test/java/com/vayunmathur/library/map/MapOptionsTest.kt
diff --git a/library/map/src/test/java/com/vayunmathur/library/map/MapOptionsTest.kt b/library/map/src/test/java/com/vayunmathur/library/map/MapOptionsTest.ktindex a0c5fc2335..36d36aec42 100644--- a/library/map/src/test/java/com/vayunmathur/library/map/MapOptionsTest.kt+++ b/library/map/src/test/java/com/vayunmathur/library/map/MapOptionsTest.kt@@ -6,7 +6,7 @@ import kotlin.test.assertFalse import kotlin.test.assertNotEquals import kotlin.test.assertTrue -/** Value types: defaults, presets, content equality, level bands. */+/** Value types: defaults, presets, content equality. */ class MapOptionsTest { @Test fun geoPointAndBounds_equality() {@@ -46,12 +46,6 @@ class MapOptionsTest { assertFalse(a.isEmpty()) } - @Test fun regionLevel_bands() {- assertEquals(1, RegionLevel.COUNTRY.min); assertEquals(2, RegionLevel.COUNTRY.max)- assertEquals(3, RegionLevel.REGION.min); assertEquals(4, RegionLevel.REGION.max)- assertEquals(7, RegionLevel.LOCALITY.min); assertEquals(12, RegionLevel.LOCALITY.max)- }- @Test fun overlayValues_roundTripFields() { val seg = RouteSegment(points = listOf(GeoPoint(0.0, 0.0), GeoPoint(1.0, 1.0)), color = androidx.compose.ui.graphics.Color.Red) val route = RouteOverlay(segments = listOf(seg))
library/map/src/test/java/com/vayunmathur/library/map/RenderHotPathTest.kt
diff --git a/library/map/src/test/java/com/vayunmathur/library/map/RenderHotPathTest.kt b/library/map/src/test/java/com/vayunmathur/library/map/RenderHotPathTest.ktindex 188a8f2ebd..b3db92552a 100644--- a/library/map/src/test/java/com/vayunmathur/library/map/RenderHotPathTest.kt+++ b/library/map/src/test/java/com/vayunmathur/library/map/RenderHotPathTest.kt@@ -14,14 +14,12 @@ import kotlin.test.assertSame import org.junit.Rule import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner-import org.robolectric.annotation.Config /** * Pins for the render hot-path optimisations: identical output, less work. * Host (Robolectric) timings only -- no device claims. */ @RunWith(RobolectricTestRunner::class)-@Config(sdk = [34]) class RenderHotPathTest { @get:Rule val rule = createComposeRule()
library/src/test/java/com/vayunmathur/library/util/DatabaseHelperCryptoTest.kt
diff --git a/library/src/test/java/com/vayunmathur/library/util/DatabaseHelperCryptoTest.kt b/library/src/test/java/com/vayunmathur/library/util/DatabaseHelperCryptoTest.ktindex e4259f12c4..826c17e412 100644--- a/library/src/test/java/com/vayunmathur/library/util/DatabaseHelperCryptoTest.kt+++ b/library/src/test/java/com/vayunmathur/library/util/DatabaseHelperCryptoTest.kt@@ -2,6 +2,7 @@ package com.vayunmathur.library.util import android.content.Context import androidx.test.core.app.ApplicationProvider+import com.vayunmathur.testsupport.FakeAndroidKeyStore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse
library/src/test/java/com/vayunmathur/library/util/FakeAndroidKeyStore.kt
diff --git a/library/src/test/java/com/vayunmathur/library/util/FakeAndroidKeyStore.kt b/library/src/test/java/com/vayunmathur/library/util/FakeAndroidKeyStore.ktdeleted file mode 100644index 8cd005b023..0000000000--- a/library/src/test/java/com/vayunmathur/library/util/FakeAndroidKeyStore.kt+++ /dev/null@@ -1,93 +0,0 @@-package com.vayunmathur.library.util--import android.security.keystore.KeyGenParameterSpec-import java.io.InputStream-import java.io.OutputStream-import java.security.Key-import java.security.KeyStoreSpi-import java.security.Provider-import java.security.SecureRandom-import java.security.Security-import java.security.cert.Certificate-import java.util.Collections-import java.util.Date-import java.util.Enumeration-import javax.crypto.KeyGeneratorSpi-import javax.crypto.SecretKey-import javax.crypto.spec.SecretKeySpec--/**- * In-memory stand-in for the AndroidKeyStore JCE provider, which Robolectric- * does not ship. Lets [DatabaseHelper] generate/store its passphrase key on- * the JVM (same pattern as uniflix's test fake).- */-object FakeAndroidKeyStore {- private val keys = Collections.synchronizedMap(HashMap<String, Key>())-- fun install() {- if (Security.getProvider("AndroidKeyStore") == null) {- Security.addProvider(FakeProvider())- }- }-- internal fun put(alias: String, key: Key) {- keys[alias] = key- }-- internal fun get(alias: String): Key? = keys[alias]- internal fun remove(alias: String) {- keys.remove(alias)- }-- internal fun contains(alias: String): Boolean = keys.containsKey(alias)- internal fun aliases(): List<String> = synchronized(keys) { keys.keys.toList() }-}--class FakeProvider : Provider("AndroidKeyStore", 1.0, "fake for tests") {- init {- put("KeyStore.AndroidKeyStore", FakeKeyStoreSpi::class.java.name)- put("KeyGenerator.AES", FakeKeyGeneratorSpi::class.java.name)- }-}--class FakeKeyStoreSpi : KeyStoreSpi() {- override fun engineLoad(stream: InputStream?, password: CharArray?) = Unit- override fun engineStore(stream: OutputStream?, password: CharArray?) = Unit- override fun engineGetKey(alias: String, password: CharArray?): Key? = FakeAndroidKeyStore.get(alias)- override fun engineContainsAlias(alias: String): Boolean = FakeAndroidKeyStore.contains(alias)- override fun engineDeleteEntry(alias: String) = FakeAndroidKeyStore.remove(alias)- override fun engineAliases(): Enumeration<String> =- Collections.enumeration(FakeAndroidKeyStore.aliases())- override fun engineSize(): Int = FakeAndroidKeyStore.aliases().size- override fun engineIsKeyEntry(alias: String): Boolean = FakeAndroidKeyStore.contains(alias)- override fun engineIsCertificateEntry(alias: String): Boolean = false- override fun engineGetCertificate(alias: String): Certificate? = null- override fun engineGetCertificateChain(alias: String): Array<Certificate>? = null- override fun engineGetCertificateAlias(cert: Certificate): String? = null- override fun engineGetCreationDate(alias: String): Date = Date(0)- override fun engineSetKeyEntry(alias: String, key: Key, password: CharArray?, chain: Array<out Certificate>?) {- FakeAndroidKeyStore.put(alias, key)- }- override fun engineSetKeyEntry(alias: String, key: ByteArray, chain: Array<out Certificate>?) {- FakeAndroidKeyStore.put(alias, SecretKeySpec(key, "AES"))- }- override fun engineSetCertificateEntry(alias: String, cert: Certificate) = Unit-}--class FakeKeyGeneratorSpi : KeyGeneratorSpi() {- private var alias: String = "db_no_auth_key"-- override fun engineInit(random: SecureRandom?) = Unit- override fun engineInit(params: java.security.spec.AlgorithmParameterSpec?, random: SecureRandom?) {- if (params is KeyGenParameterSpec) alias = params.keystoreAlias- }- override fun engineInit(keysize: Int, random: SecureRandom?) = Unit-- override fun engineGenerateKey(): SecretKey {- val bytes = ByteArray(32)- SecureRandom().nextBytes(bytes)- val key = SecretKeySpec(bytes, "AES")- FakeAndroidKeyStore.put(alias, key)- return key- }-}
notes/src/test/java/com/vayunmathur/notes/FakeAndroidKeyStore.kt
diff --git a/notes/src/test/java/com/vayunmathur/notes/FakeAndroidKeyStore.kt b/notes/src/test/java/com/vayunmathur/notes/FakeAndroidKeyStore.ktdeleted file mode 100644index abf7d938ca..0000000000--- a/notes/src/test/java/com/vayunmathur/notes/FakeAndroidKeyStore.kt+++ /dev/null@@ -1,75 +0,0 @@-package com.vayunmathur.notes--import android.security.keystore.KeyGenParameterSpec-import java.io.InputStream-import java.io.OutputStream-import java.security.Key-import java.security.KeyStoreSpi-import java.security.Provider-import java.security.SecureRandom-import java.security.Security-import java.security.cert.Certificate-import java.util.Collections-import java.util.Date-import java.util.Enumeration-import javax.crypto.KeyGenerator-import javax.crypto.KeyGeneratorSpi-import javax.crypto.SecretKey-import javax.crypto.spec.SecretKeySpec--/** Robolectric has no AndroidKeyStore; in-memory AES keystore for tests (same pattern as passwords). */-object FakeAndroidKeyStore {- private val keys = mutableMapOf<String, SecretKey>()- fun install() {- if (Security.getProvider("AndroidKeyStore") == null) Security.addProvider(FakeProvider())- }- fun put(alias: String, key: SecretKey) { keys[alias] = key }- fun get(alias: String): SecretKey? = keys[alias]- fun remove(alias: String) { keys.remove(alias) }- fun contains(alias: String): Boolean = keys.containsKey(alias)- fun aliases(): List<String> = keys.keys.toList()-- class FakeProvider : Provider("AndroidKeyStore", 1.0, "in-memory test keystore") {- init {- put("KeyStore.AndroidKeyStore", FakeKeyStoreSpi::class.java.name)- put("KeyGenerator.AES", FakeKeyGeneratorSpi::class.java.name)- }- }-- class FakeKeyStoreSpi : KeyStoreSpi() {- override fun engineLoad(stream: InputStream?, password: CharArray?) = Unit- override fun engineContainsAlias(alias: String) = contains(alias)- override fun engineDeleteEntry(alias: String) = remove(alias)- override fun engineGetKey(alias: String, password: CharArray?): Key? = get(alias)- override fun engineIsKeyEntry(alias: String) = contains(alias)- override fun engineAliases(): Enumeration<String> = Collections.enumeration(aliases())- override fun engineSize() = aliases().size- override fun engineGetCertificate(alias: String): Certificate? = null- override fun engineGetCertificateAlias(cert: Certificate) = null- override fun engineGetCertificateChain(alias: String): Array<Certificate>? = null- override fun engineGetCreationDate(alias: String) = Date()- override fun engineIsCertificateEntry(alias: String) = false- override fun engineSetCertificateEntry(alias: String, cert: Certificate) = Unit- override fun engineStore(stream: OutputStream?, password: CharArray?) = Unit- override fun engineSetKeyEntry(alias: String, key: Key, password: CharArray?, chain: Array<out Certificate>?) {- if (key is SecretKey) put(alias, key)- }- override fun engineSetKeyEntry(alias: String, key: ByteArray, chain: Array<out Certificate>?) = Unit- }-- class FakeKeyGeneratorSpi : KeyGeneratorSpi() {- private var alias: String = "test-key"- override fun engineInit(random: SecureRandom) = Unit- override fun engineInit(keysize: Int, random: SecureRandom) = Unit- override fun engineInit(params: java.security.spec.AlgorithmParameterSpec?, random: SecureRandom) {- if (params is KeyGenParameterSpec) alias = params.keystoreAlias- }- override fun engineGenerateKey(): SecretKey {- val bytes = ByteArray(32)- SecureRandom().nextBytes(bytes)- return SecretKeySpec(bytes, "AES").also { put(alias, it) }- }- }-- fun generator(): KeyGenerator = KeyGenerator.getInstance("AES", "AndroidKeyStore")-}
notes/src/test/java/com/vayunmathur/notes/IntentsAndRouteTest.kt
diff --git a/notes/src/test/java/com/vayunmathur/notes/IntentsAndRouteTest.kt b/notes/src/test/java/com/vayunmathur/notes/IntentsAndRouteTest.ktindex f10f62536c..7b8c46662e 100644--- a/notes/src/test/java/com/vayunmathur/notes/IntentsAndRouteTest.kt+++ b/notes/src/test/java/com/vayunmathur/notes/IntentsAndRouteTest.kt@@ -10,6 +10,7 @@ import android.os.ResultReceiver import androidx.test.core.app.ApplicationProvider import com.vayunmathur.library.intents.notes.NoteData import com.vayunmathur.notes.data.Note+import com.vayunmathur.testsupport.FakeAndroidKeyStore import kotlinx.coroutines.runBlocking import kotlinx.serialization.builtins.serializer import kotlinx.serialization.json.Json
notes/src/test/java/com/vayunmathur/notes/platform/NotesShareCoverageTest.kt
diff --git a/notes/src/test/java/com/vayunmathur/notes/platform/NotesShareCoverageTest.kt b/notes/src/test/java/com/vayunmathur/notes/platform/NotesShareCoverageTest.ktindex 1764abfc1b..18122e5ab1 100644--- a/notes/src/test/java/com/vayunmathur/notes/platform/NotesShareCoverageTest.kt+++ b/notes/src/test/java/com/vayunmathur/notes/platform/NotesShareCoverageTest.kt@@ -5,6 +5,7 @@ import androidx.test.core.app.ApplicationProvider import com.vayunmathur.notes.data.Note import com.vayunmathur.notes.data.withBody import com.vayunmathur.notes.seedNotesDb+import com.vayunmathur.testsupport.FakeAndroidKeyStore import kotlinx.coroutines.runBlocking import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner@@ -21,7 +22,7 @@ class NotesShareCoverageTest { private fun vm() = NotesViewModel(app, repo) @BeforeTest fun purge() {- com.vayunmathur.notes.FakeAndroidKeyStore.install()+ com.vayunmathur.testsupport.FakeAndroidKeyStore.install() runCatching { com.vayunmathur.library.util.DatabaseHelper(app).storePassphrase("test-passphrase") } runBlocking { repo.purge(); repo.deleteAllSnapshots() } }
notes/src/test/java/com/vayunmathur/notes/ui/InkEditorAndEditableNoteTest.kt
diff --git a/notes/src/test/java/com/vayunmathur/notes/ui/InkEditorAndEditableNoteTest.kt b/notes/src/test/java/com/vayunmathur/notes/ui/InkEditorAndEditableNoteTest.ktindex 1d8ca04560..72a191029b 100644--- a/notes/src/test/java/com/vayunmathur/notes/ui/InkEditorAndEditableNoteTest.kt+++ b/notes/src/test/java/com/vayunmathur/notes/ui/InkEditorAndEditableNoteTest.kt@@ -8,7 +8,7 @@ import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.performClick import androidx.test.core.app.ApplicationProvider-import com.vayunmathur.notes.FakeAndroidKeyStore+import com.vayunmathur.testsupport.FakeAndroidKeyStore import com.vayunmathur.notes.data.Note import com.vayunmathur.notes.platform.NotesViewModel import com.vayunmathur.notes.seedNotesDb
notes/src/test/java/com/vayunmathur/notes/ui/NotePageBlocksCoverageTest.kt
diff --git a/notes/src/test/java/com/vayunmathur/notes/ui/NotePageBlocksCoverageTest.kt b/notes/src/test/java/com/vayunmathur/notes/ui/NotePageBlocksCoverageTest.ktindex 7559a4b5b1..ceb3162270 100644--- a/notes/src/test/java/com/vayunmathur/notes/ui/NotePageBlocksCoverageTest.kt+++ b/notes/src/test/java/com/vayunmathur/notes/ui/NotePageBlocksCoverageTest.kt@@ -16,7 +16,7 @@ import androidx.compose.ui.test.performTextReplacement import androidx.compose.ui.test.performTouchInput import androidx.test.core.app.ApplicationProvider import com.vayunmathur.library.util.NavBackStack-import com.vayunmathur.notes.FakeAndroidKeyStore+import com.vayunmathur.testsupport.FakeAndroidKeyStore import com.vayunmathur.notes.Route import com.vayunmathur.notes.data.Note import com.vayunmathur.notes.data.NoteBlock
notes/src/test/java/com/vayunmathur/notes/ui/NotesPagesTest.kt
diff --git a/notes/src/test/java/com/vayunmathur/notes/ui/NotesPagesTest.kt b/notes/src/test/java/com/vayunmathur/notes/ui/NotesPagesTest.ktindex 67b036d9d0..d0fe6bc93c 100644--- a/notes/src/test/java/com/vayunmathur/notes/ui/NotesPagesTest.kt+++ b/notes/src/test/java/com/vayunmathur/notes/ui/NotesPagesTest.kt@@ -21,6 +21,7 @@ import com.vayunmathur.notes.data.Note import com.vayunmathur.notes.data.withBody import com.vayunmathur.notes.platform.NotesViewModel import com.vayunmathur.notes.seedNotesDb+import com.vayunmathur.testsupport.FakeAndroidKeyStore import kotlinx.coroutines.runBlocking import org.junit.Rule import org.junit.runner.RunWith@@ -40,7 +41,7 @@ class NotesPagesTest { private fun vm() = NotesViewModel(app, repo) @BeforeTest fun purge() {- com.vayunmathur.notes.FakeAndroidKeyStore.install()+ com.vayunmathur.testsupport.FakeAndroidKeyStore.install() runCatching { com.vayunmathur.library.util.DatabaseHelper(app).storePassphrase("test-passphrase") } runBlocking { repo.purge(); repo.deleteAllSnapshots() } }
office/src/test/java/com/vayunmathur/office/data/odf/AtomicDocumentWriteTest.kt
diff --git a/office/src/test/java/com/vayunmathur/office/data/odf/AtomicDocumentWriteTest.kt b/office/src/test/java/com/vayunmathur/office/data/odf/AtomicDocumentWriteTest.ktindex 1cfcabde21..180d76e6f7 100644--- a/office/src/test/java/com/vayunmathur/office/data/odf/AtomicDocumentWriteTest.kt+++ b/office/src/test/java/com/vayunmathur/office/data/odf/AtomicDocumentWriteTest.kt@@ -15,7 +15,6 @@ import kotlin.test.assertFalse import kotlin.test.assertTrue import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner-import org.robolectric.annotation.Config /** * Atomic document replace: a save must never truncate the only copy.@@ -23,7 +22,6 @@ import org.robolectric.annotation.Config * renamed over the original; any failure leaves the original intact. */ @RunWith(RobolectricTestRunner::class)-@Config(sdk = [34]) class AtomicDocumentWriteTest { private val context get() = ApplicationProvider.getApplicationContext<android.content.Context>()
sdk/games/src/main/java/com/vayunmathur/sdk/games/GameHubClient.kt
diff --git a/sdk/games/src/main/java/com/vayunmathur/sdk/games/GameHubClient.kt b/sdk/games/src/main/java/com/vayunmathur/sdk/games/GameHubClient.ktindex 8d4028283c..54492e8e6c 100644--- a/sdk/games/src/main/java/com/vayunmathur/sdk/games/GameHubClient.kt+++ b/sdk/games/src/main/java/com/vayunmathur/sdk/games/GameHubClient.kt@@ -202,13 +202,6 @@ class GameHubClient( try { resolver.insert(uri, values) != null } catch (_: Exception) { false } } - @Deprecated("Use registerAchievements with AchievementDefinition")- suspend fun registerAchievementsLegacy(achievements: List<Achievement>) {- val defs = achievements.map {- AchievementDefinition(it.id, it.name, it.description, iconResName = it.iconResName)- }- registerAchievements(defs)- } @Deprecated("Leaderboards removed - no-op") suspend fun reportScore( @Suppress("UNUSED_PARAMETER") category: String,
sdk/games/src/test/java/com/vayunmathur/sdk/games/GameHubClientTest.kt
diff --git a/sdk/games/src/test/java/com/vayunmathur/sdk/games/GameHubClientTest.kt b/sdk/games/src/test/java/com/vayunmathur/sdk/games/GameHubClientTest.ktindex 4851adba48..a41a746247 100644--- a/sdk/games/src/test/java/com/vayunmathur/sdk/games/GameHubClientTest.kt+++ b/sdk/games/src/test/java/com/vayunmathur/sdk/games/GameHubClientTest.kt@@ -208,12 +208,9 @@ class GameHubClientTest { @Test @Suppress("DEPRECATION")- fun legacyRegistrationAndScoreNoOps() = runTest {+ fun scoreNoOp() = runTest { installHub()- client.registerAchievementsLegacy(listOf(Achievement("a1", "First", "win", iconResName = "ic")))- assertEquals(1, FakeHubProvider.inserts.size)- assertEquals(25, FakeHubProvider.inserts[0].values[GameHubContract.AchievementDefs.XP_REWARD]) client.reportScore("blitz", 100L) // no-op, must not reach the provider- assertEquals(1, FakeHubProvider.inserts.size)+ assertEquals(0, FakeHubProvider.inserts.size) } }