diff options
author | Mohamed Zenadi <mohamed@zenadi.com> | 2017-08-02 00:40:36 +0100 |
---|---|---|
committer | Mohamed Zenadi <zeapo@users.noreply.github.com> | 2017-08-10 11:10:29 +0200 |
commit | f80d13a5b32684e12020ece4a1cc9aa2ad0f4f98 (patch) | |
tree | f627265f02f3530072a143b1f4541db7eeadeb2e /app | |
parent | ce44171a0b0dd66f4e8a0cf4e95e62c337a0c40e (diff) |
add copy and clipboard clearing tests
this would have avoided the regression in .66 :)
Diffstat (limited to 'app')
-rw-r--r-- | app/src/androidTest/java/com/zeapo/pwdstore/DecryptTest.kt | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/src/androidTest/java/com/zeapo/pwdstore/DecryptTest.kt b/app/src/androidTest/java/com/zeapo/pwdstore/DecryptTest.kt index eba20e1d..2bf1083e 100644 --- a/app/src/androidTest/java/com/zeapo/pwdstore/DecryptTest.kt +++ b/app/src/androidTest/java/com/zeapo/pwdstore/DecryptTest.kt @@ -1,7 +1,10 @@ package com.zeapo.pwdstore +import android.annotation.SuppressLint +import android.content.ClipboardManager import android.content.Context import android.content.Intent +import android.os.SystemClock import android.support.test.InstrumentationRegistry import android.support.test.filters.LargeTest import android.support.test.rule.ActivityTestRule @@ -74,19 +77,45 @@ class DecryptTest { assertEquals(name, nameView.text) } + @SuppressLint("ApplySharedPref") // we need the preferences right away @Test fun shouldDecrypt() { init() + // Setup the timer to 1 second + // first remember the previous timer to set it back later + val showTime = try { + Integer.parseInt(activity.settings.getString("general_show_time", "45")) + } catch (e: NumberFormatException) { + 45 + } + // second set the new timer + activity.settings.edit().putString("general_show_time", "1").commit() + activity.onBound(null) val clearPass = IOUtils.toString( IOUtils.toByteArray(testContext.assets.open("clear-store/category/sub")), Charsets.UTF_8.name() ) val passEntry = PasswordEntry(clearPass) + + // have we decrypted things correctly? assertEquals(passEntry.password, activity.crypto_password_show.text) assertEquals(passEntry.username, activity.crypto_username_show.text.toString()) assertEquals(passEntry.extraContent, activity.crypto_extra_show.text.toString()) + + // did we copy the password? + val clipboard: ClipboardManager = activity.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + assertEquals(passEntry.password, clipboard.primaryClip.getItemAt(0).text) + + // wait until the clipboard is cleared + SystemClock.sleep(2000) + + // The clipboard should be cleared!! + assertEquals("", clipboard.primaryClip.getItemAt(0).text) + + // set back the timer + activity.settings.edit().putString("general_show_time", showTime.toString()).commit() } companion object { |