ea9e08358185

test: Pin Autofill picker states (v2.3.54)

time
2026-06-26 14:27 UTC · 4 months ago
machine
koh2
parent
00d727da4137
3 files app/build.gradle+2 −2app/src/main/java/com/peachpasswords/autofill/PeachAutofillService.kt+10 −5app/src/test/java/com/peachpasswords/autofill/AutofillMatchTest.kt+12 −0
app/build.gradle+2 −2
@@ -16,8 +16,8 @@1616         applicationId "com.peachpasswords"1717         minSdk 261818         targetSdk 3519-        versionCode 23530020-        versionName "2.3.53"19+        versionCode 23540020+        versionName "2.3.54"2121 2222         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"2323         vectorDrawables {

view file

app/src/main/java/com/peachpasswords/autofill/PeachAutofillService.kt+10 −5
@@ -71,11 +71,10 @@7171         }7272 7373         // Always offer the branded picker as the last row (search / unlock / no-match).74-        val pickerLabel = when {75-            !vault.isUnlocked.value -> "Unlock Peach"76-            datasetCount == 0 -> "No saved logins for this site"77-            else -> "Search Peach…"78-        }74+        val pickerLabel = autofillPickerLabel(75+            unlocked = vault.isUnlocked.value,76+            datasetCount = datasetCount,77+        )7978         runCatching {8079             response.addDataset(pickerDataset(context, parsed, pickerLabel, inlineSpecs.getOrNull(datasetCount)))8180             datasetCount++@@ -175,4 +174,10 @@175174     private companion object {176175         const val MAX_DATASETS = 6177176     }177+}178+179+internal fun autofillPickerLabel(unlocked: Boolean, datasetCount: Int): String = when {180+    !unlocked -> "Unlock Peach"181+    datasetCount == 0 -> "No saved logins for this site"182+    else -> "Search Peach…"178183 }

view file

app/src/test/java/com/peachpasswords/autofill/AutofillMatchTest.kt+12 −0
@@ -65,6 +65,18 @@6565         assertTrue(autofillPickerEntries(listOf(app), parsed, limit = 12).isEmpty())6666     }6767 68+    @Test fun picker_label_routes_locked_users_to_unlock() {69+        assertEquals("Unlock Peach", autofillPickerLabel(unlocked = false, datasetCount = 3))70+    }71+72+    @Test fun picker_label_names_no_match_state() {73+        assertEquals("No saved logins for this site", autofillPickerLabel(unlocked = true, datasetCount = 0))74+    }75+76+    @Test fun picker_label_keeps_search_affordance_when_matches_exist() {77+        assertEquals("Search Peach…", autofillPickerLabel(unlocked = true, datasetCount = 1))78+    }79+6880     @Test fun null_origin_yields_no_hits_only_fallback() {6981         val a = entry("A", "https://a.com")7082         val b = entry("B", "https://b.com")

view file