mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
instrument: update asymmetric tests
This commit is contained in:
parent
d472e30b4e
commit
752204d3cc
@ -25,7 +25,6 @@ import android.support.test.runner.AndroidJUnit4;
|
|||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
|
||||||
import org.hamcrest.CoreMatchers;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -41,19 +40,21 @@ import static android.support.test.espresso.action.ViewActions.click;
|
|||||||
import static android.support.test.espresso.action.ViewActions.typeText;
|
import static android.support.test.espresso.action.ViewActions.typeText;
|
||||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||||
import static android.support.test.espresso.contrib.DrawerActions.openDrawer;
|
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.isAssignableFrom;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.isDescendantOfA;
|
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.withId;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||||
import static org.hamcrest.CoreMatchers.allOf;
|
import static org.hamcrest.CoreMatchers.allOf;
|
||||||
import static org.hamcrest.CoreMatchers.not;
|
|
||||||
import static org.sufficientlysecure.keychain.TestHelpers.checkSnackbar;
|
import static org.sufficientlysecure.keychain.TestHelpers.checkSnackbar;
|
||||||
import static org.sufficientlysecure.keychain.TestHelpers.importKeysFromResource;
|
import static org.sufficientlysecure.keychain.TestHelpers.importKeysFromResource;
|
||||||
import static org.sufficientlysecure.keychain.TestHelpers.randomString;
|
import static org.sufficientlysecure.keychain.TestHelpers.randomString;
|
||||||
import static org.sufficientlysecure.keychain.actions.CustomActions.tokenEncryptViewAddToken;
|
import static org.sufficientlysecure.keychain.actions.CustomActions.tokenEncryptViewAddToken;
|
||||||
|
import static org.sufficientlysecure.keychain.matcher.CustomMatchers.isRecyclerItemView;
|
||||||
|
import static org.sufficientlysecure.keychain.matcher.CustomMatchers.withEncryptionStatus;
|
||||||
import static org.sufficientlysecure.keychain.matcher.CustomMatchers.withKeyItemId;
|
import static org.sufficientlysecure.keychain.matcher.CustomMatchers.withKeyItemId;
|
||||||
import static org.sufficientlysecure.keychain.matcher.DrawableMatcher.withDrawable;
|
import static org.sufficientlysecure.keychain.matcher.CustomMatchers.withSignatureMyKey;
|
||||||
|
import static org.sufficientlysecure.keychain.matcher.CustomMatchers.withSignatureNone;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
@ -109,20 +110,11 @@ public class AsymmetricOperationTests {
|
|||||||
onView(withId(R.id.passphrase_passphrase)).perform(typeText("x"));
|
onView(withId(R.id.passphrase_passphrase)).perform(typeText("x"));
|
||||||
onView(withText(R.string.btn_unlock)).perform(click());
|
onView(withText(R.string.btn_unlock)).perform(click());
|
||||||
|
|
||||||
onView(withId(R.id.decrypt_text_plaintext)).check(matches(
|
|
||||||
withText(cleartext)));
|
|
||||||
|
|
||||||
onView(withId(R.id.result_encryption_text)).check(matches(
|
onView(isRecyclerItemView(R.id.decrypted_files_list,
|
||||||
withText(R.string.decrypt_result_encrypted)));
|
hasDescendant(withText(R.string.filename_unknown_text))))
|
||||||
onView(withId(R.id.result_signature_text)).check(matches(
|
.check(matches(allOf(withEncryptionStatus(true), withSignatureNone())));
|
||||||
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)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -159,20 +151,9 @@ public class AsymmetricOperationTests {
|
|||||||
onView(withId(R.id.passphrase_passphrase)).perform(typeText("x"));
|
onView(withId(R.id.passphrase_passphrase)).perform(typeText("x"));
|
||||||
onView(withText(R.string.btn_unlock)).perform(click());
|
onView(withText(R.string.btn_unlock)).perform(click());
|
||||||
|
|
||||||
onView(withId(R.id.decrypt_text_plaintext)).check(matches(
|
onView(isRecyclerItemView(R.id.decrypted_files_list,
|
||||||
withText(cleartext)));
|
hasDescendant(withText(R.string.filename_unknown_text))))
|
||||||
|
.check(matches(allOf(withEncryptionStatus(true), withSignatureNone())));
|
||||||
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)));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,20 +162,9 @@ public class AsymmetricOperationTests {
|
|||||||
|
|
||||||
{ // decrypt again, passphrase should be cached
|
{ // decrypt again, passphrase should be cached
|
||||||
|
|
||||||
onView(withId(R.id.decrypt_text_plaintext)).check(matches(
|
onView(isRecyclerItemView(R.id.decrypted_files_list,
|
||||||
withText(cleartext)));
|
hasDescendant(withText(R.string.filename_unknown_text))))
|
||||||
|
.check(matches(allOf(withEncryptionStatus(true), withSignatureNone())));
|
||||||
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)));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,21 +209,9 @@ public class AsymmetricOperationTests {
|
|||||||
|
|
||||||
{ // decrypt
|
{ // decrypt
|
||||||
|
|
||||||
onView(withId(R.id.decrypt_text_plaintext)).check(matches(
|
onView(isRecyclerItemView(R.id.decrypted_files_list,
|
||||||
// startsWith because there may be extra newlines
|
hasDescendant(withText(R.string.filename_unknown))))
|
||||||
withText(CoreMatchers.startsWith(cleartext))));
|
.check(matches(allOf(withEncryptionStatus(false), withSignatureMyKey())));
|
||||||
|
|
||||||
onView(withId(R.id.result_encryption_text)).check(matches(
|
|
||||||
withText(R.string.decrypt_result_not_encrypted)));
|
|
||||||
onView(withId(R.id.result_signature_text)).check(matches(
|
|
||||||
withText(R.string.decrypt_result_signature_secret)));
|
|
||||||
onView(withId(R.id.result_signature_layout)).check(matches(
|
|
||||||
isDisplayed()));
|
|
||||||
|
|
||||||
onView(withId(R.id.result_encryption_icon)).check(matches(
|
|
||||||
withDrawable(R.drawable.status_lock_open_24dp)));
|
|
||||||
onView(withId(R.id.result_signature_icon)).check(matches(
|
|
||||||
withDrawable(R.drawable.status_signature_verified_cutout_24dp)));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ public abstract class CustomMatchers {
|
|||||||
} else {
|
} else {
|
||||||
return allOf(
|
return allOf(
|
||||||
hasDescendant(allOf(
|
hasDescendant(allOf(
|
||||||
withId(R.id.result_encryption_text), withText(R.string.decrypt_result_encrypted))),
|
withId(R.id.result_encryption_text), withText(R.string.decrypt_result_not_encrypted))),
|
||||||
hasDescendant(allOf(
|
hasDescendant(allOf(
|
||||||
withId(R.id.result_encryption_icon), withDrawable(R.drawable.status_lock_open_24dp, true)))
|
withId(R.id.result_encryption_icon), withDrawable(R.drawable.status_lock_open_24dp, true)))
|
||||||
);
|
);
|
||||||
@ -152,7 +152,7 @@ public abstract class CustomMatchers {
|
|||||||
|
|
||||||
return allOf(
|
return allOf(
|
||||||
hasDescendant(allOf(
|
hasDescendant(allOf(
|
||||||
withId(R.id.result_signature_text), withText(R.string.decrypt_result_signature_secret))),
|
withId(R.id.result_signature_text), withText(R.string.decrypt_result_signature_certified))),
|
||||||
hasDescendant(allOf(
|
hasDescendant(allOf(
|
||||||
withId(R.id.result_signature_icon), withDrawable(R.drawable.status_signature_verified_cutout_24dp, true))),
|
withId(R.id.result_signature_icon), withDrawable(R.drawable.status_signature_verified_cutout_24dp, true))),
|
||||||
hasDescendant(allOf(
|
hasDescendant(allOf(
|
||||||
|
Loading…
Reference in New Issue
Block a user