diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2016-02-01 17:32:17 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2016-02-05 16:10:47 +0100 |
commit | 6a7652c0d76f1ac9f3ba989ac2387f14e8853014 (patch) | |
tree | 6b1f4056f2722b5a390f1f116d0eb21fd5cd77ea /OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java | |
parent | b1ea1261425e05d7eaa803e6ea72c1f0bbb5ae32 (diff) | |
download | open-keychain-6a7652c0d76f1ac9f3ba989ac2387f14e8853014.tar.gz open-keychain-6a7652c0d76f1ac9f3ba989ac2387f14e8853014.tar.bz2 open-keychain-6a7652c0d76f1ac9f3ba989ac2387f14e8853014.zip |
performance: fix unit tests
Diffstat (limited to 'OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java')
-rw-r--r-- | OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java index b48c5ac4e..91d819400 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/InteropTest.java @@ -30,6 +30,7 @@ import org.openintents.openpgp.OpenPgpSignatureResult; import org.robolectric.RobolectricGradleTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; +import org.robolectric.shadows.ShadowLog; import org.spongycastle.jce.provider.BouncyCastleProvider; import org.sufficientlysecure.keychain.WorkaroundBuildConfig; import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult; @@ -37,10 +38,12 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.Operat import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing; import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKey; import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing; +import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyOperation; import org.sufficientlysecure.keychain.pgp.UncachedKeyRing; +import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; @@ -64,6 +67,7 @@ public class InteropTest { @BeforeClass public static void setUpOnce() throws Exception { Security.insertProviderAt(new BouncyCastleProvider(), 1); + ShadowLog.stream = System.out; } @Test @@ -243,21 +247,45 @@ public class InteropTest { KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(verify.getMasterKeyId()) : null; ProviderHelper helper = new ProviderHelper(RuntimeEnvironment.application) { - @Override - public CanonicalizedPublicKeyRing getCanonicalizedPublicKeyRing(Uri q) - throws NotFoundException { - Assert.assertEquals(msg + ": query should be for verification key", - q, verifyUri); - return verify; - } - @Override - public CanonicalizedSecretKeyRing getCanonicalizedSecretKeyRing(Uri q) - throws NotFoundException { - Assert.assertEquals(msg + ": query should be for the decryption key", - q, decryptUri); - return decrypt; - } - }; + + @Override + public CachedPublicKeyRing getCachedPublicKeyRing(Uri queryUri) throws PgpKeyNotFoundException { + Assert.assertEquals(msg + ": query should be for the decryption key", queryUri, decryptUri); + return new CachedPublicKeyRing(this, queryUri) { + @Override + public long getMasterKeyId() throws PgpKeyNotFoundException { + return decrypt.getMasterKeyId(); + } + + @Override + public SecretKeyType getSecretKeyType(long keyId) throws NotFoundException { + return decrypt.getSecretKey(keyId).getSecretKeyTypeSuperExpensive(); + } + }; + } + + @Override + public CanonicalizedPublicKeyRing getCanonicalizedPublicKeyRing(Uri q) + throws NotFoundException { + Assert.assertEquals(msg + ": query should be for verification key", q, verifyUri); + return verify; + } + + @Override + public CanonicalizedSecretKeyRing getCanonicalizedSecretKeyRing(Uri q) + throws NotFoundException { + Assert.assertEquals(msg + ": query should be for the decryption key", q, decryptUri); + return decrypt; + } + + @Override + public CanonicalizedSecretKeyRing getCanonicalizedSecretKeyRing(long masterKeyId) + throws NotFoundException { + Assert.assertEquals(msg + ": query should be for the decryption key", + masterKeyId, decrypt.getMasterKeyId()); + return decrypt; + } + }; return new PgpDecryptVerifyOperation(RuntimeEnvironment.application, helper, null) { @Override |