instrument: first couple of tests for OpenPGP API

This commit is contained in:
Vincent Breitmoser
2015-06-26 01:58:51 +02:00
parent 88c86e1945
commit 51d35c7a83
3 changed files with 188 additions and 1 deletions

View File

@@ -26,7 +26,9 @@ import android.support.annotation.StringRes;
import org.hamcrest.CoreMatchers;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing.IteratorWithIOThrow;
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
import org.sufficientlysecure.keychain.util.ProgressScaler;
@@ -55,7 +57,7 @@ public class TestHelpers {
}
static void importKeysFromResource(Context context, String name) throws Exception {
public static void importKeysFromResource(Context context, String name) throws Exception {
IteratorWithIOThrow<UncachedKeyRing> stream = UncachedKeyRing.fromStream(
getInstrumentation().getContext().getAssets().open(name));
@@ -82,5 +84,16 @@ public class TestHelpers {
return passbuilder.toString();
}
public static void cleanupForTests(Context context) throws Exception {
new KeychainDatabase(context).clearDatabase();
// import these two, make sure they're there
importKeysFromResource(context, "x.sec.asc");
// make sure no passphrases are cached
PassphraseCacheService.clearCachedPassphrases(context);
}
}