diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-06-14 20:21:13 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-06-17 18:52:20 +0200 |
commit | db0266c0aeefb5f788625f6ee2a7be733cace454 (patch) | |
tree | 2ddbf9be5e7f94cd5c7f3aee15c0ed46cc0e4b77 /OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/actions | |
parent | 908545e5212fc62cb2c1cb7b3dcac2311e43524a (diff) | |
download | open-keychain-db0266c0aeefb5f788625f6ee2a7be733cace454.tar.gz open-keychain-db0266c0aeefb5f788625f6ee2a7be733cace454.tar.bz2 open-keychain-db0266c0aeefb5f788625f6ee2a7be733cace454.zip |
instrument: work on instrumentation tests
Diffstat (limited to 'OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/actions')
-rw-r--r-- | OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/actions/CustomActions.java | 48 |
1 files changed, 48 insertions, 0 deletions
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 13c092b85..ff9384247 100644 --- a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/actions/CustomActions.java +++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/actions/CustomActions.java @@ -8,11 +8,59 @@ import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.view.View; +import com.tokenautocomplete.TokenCompleteTextView; import org.hamcrest.Matcher; +import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.ui.adapter.KeyAdapter; + +import static android.support.test.InstrumentationRegistry.getTargetContext; public abstract class CustomActions { + public static ViewAction tokenEncryptViewAddToken(long keyId) throws Exception { + CanonicalizedPublicKeyRing ring = + new ProviderHelper(getTargetContext()).getCanonicalizedPublicKeyRing(keyId); + final Object item = new KeyAdapter.KeyItem(ring); + + return new ViewAction() { + @Override + public Matcher<View> getConstraints() { + return ViewMatchers.isAssignableFrom(TokenCompleteTextView.class); + } + + @Override + public String getDescription() { + return "add completion token"; + } + + @Override + public void perform(UiController uiController, View view) { + ((TokenCompleteTextView) view).addObject(item); + } + }; + } + + public static ViewAction tokenViewAddToken(final Object item) { + return new ViewAction() { + @Override + public Matcher<View> getConstraints() { + return ViewMatchers.isAssignableFrom(TokenCompleteTextView.class); + } + + @Override + public String getDescription() { + return "add completion token"; + } + + @Override + public void perform(UiController uiController, View view) { + ((TokenCompleteTextView) view).addObject(item); + } + }; + } + public static ViewAction actionOpenDrawer() { return new ViewAction() { @Override |