instrument: first couple of tests for OpenPGP API
This commit is contained in:
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user