aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/matcher
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-06-15 04:05:07 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-06-17 18:52:59 +0200
commit71ea52119898f2e9552b542b2bcc40ad430ae8a3 (patch)
tree3320bfb28b11782feca7e4065e7fd65f0e3bab3c /OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/matcher
parentb8305d43dcae87b441e48eb8f47e471e0b0c2781 (diff)
downloadopen-keychain-71ea52119898f2e9552b542b2bcc40ad430ae8a3.tar.gz
open-keychain-71ea52119898f2e9552b542b2bcc40ad430ae8a3.tar.bz2
open-keychain-71ea52119898f2e9552b542b2bcc40ad430ae8a3.zip
clean up helper code, add withKeyItemId matcher for KeyListAdapter
Diffstat (limited to 'OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/matcher')
-rw-r--r--OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/matcher/CustomMatchers.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/matcher/CustomMatchers.java b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/matcher/CustomMatchers.java
new file mode 100644
index 000000000..c023f6411
--- /dev/null
+++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/matcher/CustomMatchers.java
@@ -0,0 +1,48 @@
+package org.sufficientlysecure.keychain.matcher;
+
+
+import android.support.annotation.ColorRes;
+import android.support.test.espresso.matcher.BoundedMatcher;
+import android.support.test.internal.util.Checks;
+import android.view.View;
+
+import com.nispok.snackbar.Snackbar;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.Matchers;
+import org.sufficientlysecure.keychain.ui.KeyListFragment.KeyListAdapter;
+import org.sufficientlysecure.keychain.ui.adapter.KeyAdapter.KeyItem;
+
+import static android.support.test.internal.util.Checks.checkNotNull;
+
+
+public abstract class CustomMatchers {
+
+ public static Matcher<View> withSnackbarLineColor(@ColorRes final int colorRes) {
+ return new BoundedMatcher<View, Snackbar>(Snackbar.class) {
+ public void describeTo(Description description) {
+ description.appendText("with color resource id: " + colorRes);
+ }
+
+ @Override
+ public boolean matchesSafely(Snackbar snackbar) {
+ return snackbar.getResources().getColor(colorRes) == snackbar.getLineColor();
+ }
+ };
+ }
+
+ public static Matcher<Object> withKeyItemId(final long keyId) {
+ return new BoundedMatcher<Object, KeyItem>(KeyItem.class) {
+ @Override
+ public boolean matchesSafely(KeyItem item) {
+ return item.mKeyId == keyId;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("with key id: " + keyId);
+ }
+ };
+ }
+
+}