aboutsummaryrefslogtreecommitdiff
path: root/app/src/androidTest
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2020-08-27 14:27:55 +0530
committerGitHub <noreply@github.com>2020-08-27 14:27:55 +0530
commit1ce3ef4ea3c55d4a6c4a79f8a6cca58387b240df (patch)
tree6e9fbf27c8528637857d358fa9f4b21e96132ef3 /app/src/androidTest
parent8ec3320df793b58d20f632038b0b2a37f37103e3 (diff)
Expand show hidden folders to also cover files (#1059)
* PasswordItem: only strip .gpg suffixes Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Add preference key and migration for showing all hidden contents Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Allow showing both hidden files and directories Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Add tests for hidden folder setting migration Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Add changelog entry Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Slightly improve migration logic Skip migration if old key is not found and always delete the previous key even if its set to false. Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Tweak wording Suggested-by: Fabian Henneke <fabian@henneke.me> Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Assert previous key's removal in tests Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/androidTest')
-rw-r--r--app/src/androidTest/java/com/zeapo/pwdstore/MigrationsTest.kt26
1 files changed, 24 insertions, 2 deletions
diff --git a/app/src/androidTest/java/com/zeapo/pwdstore/MigrationsTest.kt b/app/src/androidTest/java/com/zeapo/pwdstore/MigrationsTest.kt
index c66bb215..5ba1b307 100644
--- a/app/src/androidTest/java/com/zeapo/pwdstore/MigrationsTest.kt
+++ b/app/src/androidTest/java/com/zeapo/pwdstore/MigrationsTest.kt
@@ -4,6 +4,7 @@
*/
@file:Suppress("DEPRECATION")
+
package com.zeapo.pwdstore
import android.content.Context
@@ -13,10 +14,10 @@ import com.zeapo.pwdstore.git.config.Protocol
import com.zeapo.pwdstore.utils.PreferenceKeys
import com.zeapo.pwdstore.utils.getString
import com.zeapo.pwdstore.utils.sharedPrefs
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNull
import org.junit.Test
-import org.junit.Assert.*
-
class MigrationsTest {
private fun checkOldKeysAreRemoved(context: Context) = with(context.sharedPrefs) {
@@ -84,4 +85,25 @@ class MigrationsTest {
"https://github.com/Android-Password-Store/pass-test"
)
}
+
+ @Test
+ fun verifyHiddenFoldersMigrationIfDisabled() {
+ val context = Application.instance.applicationContext
+ context.sharedPrefs.edit { clear() }
+ runMigrations(context)
+ assertEquals(true, context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, true))
+ assertEquals(false, context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_CONTENTS, false))
+ }
+
+ @Test
+ fun verifyHiddenFoldersMigrationIfEnabled() {
+ val context = Application.instance.applicationContext
+ context.sharedPrefs.edit {
+ clear()
+ putBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, true)
+ }
+ runMigrations(context)
+ assertEquals(false, context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, false))
+ assertEquals(true, context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_CONTENTS, false))
+ }
}