aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/AsymmetricOperationTests.java25
-rw-r--r--OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/matcher/CustomMatchers.java30
2 files changed, 37 insertions, 18 deletions
diff --git a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/AsymmetricOperationTests.java b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/AsymmetricOperationTests.java
index 778406d2a..246e2dd52 100644
--- a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/AsymmetricOperationTests.java
+++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/AsymmetricOperationTests.java
@@ -38,11 +38,13 @@ import static android.support.test.espresso.Espresso.onView;
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.doesNotExist;
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.hasDescendant;
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;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.CoreMatchers.allOf;
@@ -51,11 +53,13 @@ import static org.sufficientlysecure.keychain.TestHelpers.importKeysFromResource
import static org.sufficientlysecure.keychain.TestHelpers.randomString;
import static org.sufficientlysecure.keychain.actions.CustomActions.tokenEncryptViewAddToken;
import static org.sufficientlysecure.keychain.matcher.CustomMatchers.isRecyclerItemView;
+import static org.sufficientlysecure.keychain.matcher.CustomMatchers.withDisplayedChild;
import static org.sufficientlysecure.keychain.matcher.CustomMatchers.withEncryptionStatus;
import static org.sufficientlysecure.keychain.matcher.CustomMatchers.withKeyItemId;
import static org.sufficientlysecure.keychain.matcher.CustomMatchers.withSignatureMyKey;
import static org.sufficientlysecure.keychain.matcher.CustomMatchers.withSignatureNone;
+
@RunWith(AndroidJUnit4.class)
@LargeTest
public class AsymmetricOperationTests {
@@ -95,7 +99,9 @@ public class AsymmetricOperationTests {
{ // encrypt
// the EncryptKeyCompletionView is tested individually
+ onView(withId(R.id.result_encryption_icon)).check(matches(withDisplayedChild(0)));
onView(withId(R.id.recipient_list)).perform(tokenEncryptViewAddToken(0x9D604D2F310716A3L));
+ onView(withId(R.id.result_encryption_icon)).check(matches(withDisplayedChild(1)));
onView(withId(R.id.encrypt_text_text)).perform(typeText(cleartext));
@@ -133,6 +139,9 @@ public class AsymmetricOperationTests {
.perform(click());
onView(withId(R.id.view_key_action_encrypt_text)).perform(click());
+ // make sure the encrypt is correctly set
+ onView(withId(R.id.result_encryption_icon)).check(matches(withDisplayedChild(1)));
+
onView(withId(R.id.encrypt_text_text)).perform(typeText(cleartext));
onView(withId(R.id.encrypt_copy)).perform(click());
@@ -185,11 +194,12 @@ public class AsymmetricOperationTests {
onView(withId(R.id.encrypt_copy)).perform(click());
checkSnackbar(Style.ERROR, R.string.error_empty_text);
- // navigate to edit key dialog
+ onView(withId(R.id.result_signature_icon)).check(matches(withDisplayedChild(0)));
onView(withId(R.id.sign)).perform(click());
onData(withKeyItemId(0x9D604D2F310716A3L))
.inAdapterView(isAssignableFrom(AdapterView.class))
.perform(click());
+ onView(withId(R.id.result_signature_icon)).check(matches(withDisplayedChild(1)));
onView(withId(R.id.encrypt_text_text)).perform(typeText(cleartext));
@@ -213,6 +223,19 @@ public class AsymmetricOperationTests {
hasDescendant(withText(R.string.filename_unknown))))
.check(matches(allOf(withEncryptionStatus(false), withSignatureMyKey())));
+ // open context menu
+ onView(allOf(isDescendantOfA(isRecyclerItemView(R.id.decrypted_files_list,
+ hasDescendant(withText(R.string.filename_unknown)))),
+ withId(R.id.context_menu))).perform(click());
+
+ // "delete file" shouldn't be there
+ onView(withText(R.string.btn_delete_original)).check(doesNotExist());
+
+ // check if log looks ok
+ onView(withText(R.string.view_log)).perform(click());
+ onView(withText(R.string.msg_dc_clear_signature_ok)).check(matches(isDisplayed()));
+ pressBack();
+
}
}
diff --git a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/matcher/CustomMatchers.java b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/matcher/CustomMatchers.java
index abfe4d04d..6713cd237 100644
--- a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/matcher/CustomMatchers.java
+++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/matcher/CustomMatchers.java
@@ -19,43 +19,26 @@
package org.sufficientlysecure.keychain.matcher;
-import java.util.EnumSet;
-
import android.support.annotation.ColorRes;
import android.support.annotation.IdRes;
-import android.support.test.espresso.Espresso;
-import android.support.test.espresso.ViewInteraction;
-import android.support.test.espresso.assertion.ViewAssertions;
import android.support.test.espresso.matcher.BoundedMatcher;
-import android.support.test.espresso.matcher.ViewMatchers;
-import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ViewAnimator;
import com.nispok.snackbar.Snackbar;
-import org.hamcrest.CoreMatchers;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
-import org.sufficientlysecure.keychain.EncryptKeyCompletionViewTest;
import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.ui.DecryptListFragment;
-import org.sufficientlysecure.keychain.ui.DecryptListFragment.ViewHolder;
import org.sufficientlysecure.keychain.ui.adapter.KeyAdapter.KeyItem;
-import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.ui.widget.EncryptKeyCompletionView;
-import static android.support.test.espresso.Espresso.onView;
-import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant;
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;
-import static android.support.test.espresso.matcher.ViewMatchers.withChild;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
-import static android.support.test.internal.util.Checks.checkNotNull;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.not;
import static org.sufficientlysecure.keychain.matcher.DrawableMatcher.withDrawable;
@@ -63,6 +46,19 @@ import static org.sufficientlysecure.keychain.matcher.DrawableMatcher.withDrawab
public abstract class CustomMatchers {
+ public static Matcher<View> withDisplayedChild(final int child) {
+ return new BoundedMatcher<View, ViewAnimator>(ViewAnimator.class) {
+ public void describeTo(Description description) {
+ description.appendText("with displayed child: " + child);
+ }
+
+ @Override
+ public boolean matchesSafely(ViewAnimator viewAnimator) {
+ return viewAnimator.getDisplayedChild() == child;
+ }
+ };
+ }
+
public static Matcher<View> withSnackbarLineColor(@ColorRes final int colorRes) {
return new BoundedMatcher<View, Snackbar>(Snackbar.class) {
public void describeTo(Description description) {