aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/androidTest
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-06-16 16:20:09 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-06-17 18:53:05 +0200
commit04e9137b663555c491be90be31de5104495782cc (patch)
tree70d2788855c71a03bce8c4c2917cbcfae5050b2e /OpenKeychain/src/androidTest
parentd2cdfb34fa694886b231b76a3f66e6a18b6a3ed5 (diff)
downloadopen-keychain-04e9137b663555c491be90be31de5104495782cc.tar.gz
open-keychain-04e9137b663555c491be90be31de5104495782cc.tar.bz2
open-keychain-04e9137b663555c491be90be31de5104495782cc.zip
instrument: use contrib drawer methods, respect passphrase cache
Diffstat (limited to 'OpenKeychain/src/androidTest')
-rw-r--r--OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/AsymmetricOperationTests.java35
-rw-r--r--OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/EncryptDecryptSymmetricTests.java4
-rw-r--r--OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/actions/CustomActions.java38
3 files changed, 32 insertions, 45 deletions
diff --git a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/AsymmetricOperationTests.java b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/AsymmetricOperationTests.java
index 59f6dbd79..3a4114fbe 100644
--- a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/AsymmetricOperationTests.java
+++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/AsymmetricOperationTests.java
@@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain;
import android.app.Activity;
import android.content.Intent;
-import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
@@ -31,6 +30,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.sufficientlysecure.keychain.service.PassphraseCacheService;
import org.sufficientlysecure.keychain.ui.MainActivity;
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
@@ -40,6 +40,7 @@ import static android.support.test.espresso.Espresso.pressBack;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.contrib.DrawerActions.openDrawer;
import static android.support.test.espresso.matcher.ViewMatchers.isAssignableFrom;
import static android.support.test.espresso.matcher.ViewMatchers.isDescendantOfA;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
@@ -50,7 +51,6 @@ import static org.hamcrest.CoreMatchers.not;
import static org.sufficientlysecure.keychain.TestHelpers.checkSnackbar;
import static org.sufficientlysecure.keychain.TestHelpers.importKeysFromResource;
import static org.sufficientlysecure.keychain.TestHelpers.randomString;
-import static org.sufficientlysecure.keychain.actions.CustomActions.actionOpenDrawer;
import static org.sufficientlysecure.keychain.actions.CustomActions.tokenEncryptViewAddToken;
import static org.sufficientlysecure.keychain.matcher.CustomMatchers.withKeyItemId;
import static org.sufficientlysecure.keychain.matcher.DrawableMatcher.withDrawable;
@@ -76,13 +76,16 @@ public class AsymmetricOperationTests {
// import these two, make sure they're there
importKeysFromResource(activity, "x.sec.asc");
+
+ // make sure no passphrases are cached
+ PassphraseCacheService.clearCachedPassphrases(activity);
}
@Test
public void testTextEncryptDecryptFromToken() throws Exception {
// navigate to 'encrypt text'
- onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
+ openDrawer(R.id.drawer_layout);
onView(withText(R.string.nav_encrypt_decrypt)).perform(click());
onView(withId(R.id.encrypt_text)).perform(click());
@@ -146,7 +149,7 @@ public class AsymmetricOperationTests {
pressBack();
pressBack();
- onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
+ openDrawer(R.id.drawer_layout);
onView(withText(R.string.nav_encrypt_decrypt)).perform(click());
onView(withId(R.id.decrypt_from_clipboard)).perform(click());
@@ -172,6 +175,28 @@ public class AsymmetricOperationTests {
}
+ pressBack();
+ onView(withId(R.id.decrypt_from_clipboard)).perform(click());
+
+ { // decrypt again, passphrase should be cached
+
+ onView(withId(R.id.decrypt_text_plaintext)).check(matches(
+ withText(cleartext)));
+
+ onView(withId(R.id.result_encryption_text)).check(matches(
+ withText(R.string.decrypt_result_encrypted)));
+ onView(withId(R.id.result_signature_text)).check(matches(
+ withText(R.string.decrypt_result_no_signature)));
+ onView(withId(R.id.result_signature_layout)).check(matches(
+ not(isDisplayed())));
+
+ onView(withId(R.id.result_encryption_icon)).check(matches(
+ withDrawable(R.drawable.status_lock_closed_24dp)));
+ onView(withId(R.id.result_signature_icon)).check(matches(
+ withDrawable(R.drawable.status_signature_unknown_cutout_24dp)));
+
+ }
+
}
@Test
@@ -180,7 +205,7 @@ public class AsymmetricOperationTests {
String cleartext = randomString(10, 30);
// navigate to 'encrypt text'
- onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
+ openDrawer(R.id.drawer_layout);
onView(withText(R.string.nav_encrypt_decrypt)).perform(click());
onView(withId(R.id.encrypt_text)).perform(click());
diff --git a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/EncryptDecryptSymmetricTests.java b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/EncryptDecryptSymmetricTests.java
index 081bef920..919bb710a 100644
--- a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/EncryptDecryptSymmetricTests.java
+++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/EncryptDecryptSymmetricTests.java
@@ -39,13 +39,13 @@ import static android.support.test.espresso.Espresso.pressBack;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.contrib.DrawerActions.openDrawer;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.CoreMatchers.not;
import static org.sufficientlysecure.keychain.TestHelpers.checkSnackbar;
import static org.sufficientlysecure.keychain.TestHelpers.randomString;
-import static org.sufficientlysecure.keychain.actions.CustomActions.actionOpenDrawer;
import static org.sufficientlysecure.keychain.matcher.DrawableMatcher.withDrawable;
@@ -75,7 +75,7 @@ public class EncryptDecryptSymmetricTests {
String text = randomString(10, 30);
// navigate to encrypt/decrypt
- onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
+ openDrawer(R.id.drawer_layout);
onView(ViewMatchers.withText(R.string.nav_encrypt_decrypt)).perform(click());
onView(withId(R.id.encrypt_text)).perform(click());
diff --git a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/actions/CustomActions.java b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/actions/CustomActions.java
index ff9384247..feb95403b 100644
--- a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/actions/CustomActions.java
+++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/actions/CustomActions.java
@@ -61,42 +61,4 @@ public abstract class CustomActions {
};
}
- public static ViewAction actionOpenDrawer() {
- return new ViewAction() {
- @Override
- public Matcher<View> getConstraints() {
- return ViewMatchers.isAssignableFrom(DrawerLayout.class);
- }
-
- @Override
- public String getDescription() {
- return "open drawer";
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- ((DrawerLayout) view).openDrawer(GravityCompat.START);
- }
- };
- }
-
- public static ViewAction actionCloseDrawer() {
- return new ViewAction() {
- @Override
- public Matcher<View> getConstraints() {
- return ViewMatchers.isAssignableFrom(DrawerLayout.class);
- }
-
- @Override
- public String getDescription() {
- return "close drawer";
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- ((DrawerLayout) view).closeDrawer(GravityCompat.START);
- }
- };
- }
-
} \ No newline at end of file