summaryrefslogtreecommitdiffstats
path: root/app/src/test/java
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-04 11:22:03 +0100
committerDanilo M. <danix@danix.xyz>2026-11-04 11:22:03 +0100
commitf5a736755a151be6753a2f939c493a7f9ad5bf06 (patch)
tree924944cc98e578cba5d12fa1ff77ac6f909e857c /app/src/test/java
parentd1266d1fbd4588c872bd6af30278b32c33e39eb9 (diff)
downloadHardenedPass-f5a736755a151be6753a2f939c493a7f9ad5bf06.tar.gz
HardenedPass-f5a736755a151be6753a2f939c493a7f9ad5bf06.zip
feat(app): add the autofill picker's row model
autofillRows turns the picker's search results into list rows: the origin identifier, the part that must match the site or app, becomes the row's name, and the account part and the folders above it the subtitle, as the old picker's bold title and subtitle showed them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'app/src/test/java')
-rw-r--r--app/src/test/java/app/passwordstore/ui/autofill/AutofillModelTest.kt73
1 files changed, 73 insertions, 0 deletions
diff --git a/app/src/test/java/app/passwordstore/ui/autofill/AutofillModelTest.kt b/app/src/test/java/app/passwordstore/ui/autofill/AutofillModelTest.kt
new file mode 100644
index 00000000..8907aa54
--- /dev/null
+++ b/app/src/test/java/app/passwordstore/ui/autofill/AutofillModelTest.kt
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+package app.passwordstore.ui.autofill
+
+import app.passwordstore.util.settings.DirectoryStructure
+import java.io.File
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class AutofillModelTest {
+
+ private val root = File("/store")
+
+ private fun rows(structure: DirectoryStructure, vararg paths: String) =
+ autofillRows(paths.map { File(root, it) }, root, structure).map {
+ Triple(it.path, it.label, it.subtitle)
+ }
+
+ @Test
+ fun fileBasedNamesTheIdentifier() {
+ assertEquals(
+ listOf(
+ Triple("/store/work/example.org/john@doe.org.gpg", "example.org", "john@doe.org · work"),
+ Triple("/store/example.org/john.gpg", "example.org", "john"),
+ Triple("/store/example.org.gpg", "example.org", null),
+ ),
+ rows(
+ DirectoryStructure.FileBased,
+ "work/example.org/john@doe.org.gpg",
+ "example.org/john.gpg",
+ "example.org.gpg",
+ ),
+ )
+ }
+
+ @Test
+ fun directoryBasedFallsBackToTheAccountPart() {
+ assertEquals(
+ listOf(
+ Triple(
+ "/store/example.org/john@doe.org/password.gpg",
+ "example.org",
+ "john@doe.org/password",
+ ),
+ Triple("/store/Temporary PIN.gpg", "Temporary PIN", null),
+ ),
+ rows(
+ DirectoryStructure.DirectoryBased,
+ "example.org/john@doe.org/password.gpg",
+ "Temporary PIN.gpg",
+ ),
+ )
+ }
+
+ @Test
+ fun encryptedUsernameShowsTheFolders() {
+ assertEquals(
+ listOf(Triple("/store/work/example.org.gpg", "example.org", "work")),
+ rows(DirectoryStructure.EncryptedUsername, "work/example.org.gpg"),
+ )
+ }
+
+ @Test
+ fun rowsKeepTheRankingOrder() {
+ assertEquals(
+ listOf("b.org", "a.org"),
+ rows(DirectoryStructure.FileBased, "b.org.gpg", "a.org.gpg").map { it.second },
+ )
+ }
+}