test: add junit+robolectric to buildfiles and stub test file
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package org.sufficientlysecure.keychain;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.Robolectric;
|
||||
|
||||
import org.sufficientlysecure.keychain.pgp.*;
|
||||
import org.spongycastle.openpgp.*;
|
||||
|
||||
@RunWith(RobolectricGradleTestRunner.class)
|
||||
public class PgpKeyOperationTest {
|
||||
|
||||
PGPSecretKey key;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
/* Input */
|
||||
int algorithm = Id.choice.algorithm.dsa;
|
||||
String passphrase = "swag";
|
||||
int keysize = 2048;
|
||||
boolean masterKey = true;
|
||||
|
||||
/* Operation */
|
||||
PgpKeyOperation keyOperations = new PgpKeyOperation(null);
|
||||
key = keyOperations.createKey(algorithm, keysize, passphrase, masterKey);
|
||||
|
||||
System.err.println("initialized, test key: " + PgpKeyHelper.convertKeyIdToHex(key.getKeyID()));
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void certifyKey() {
|
||||
System.err.println("swag");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.sufficientlysecure.keychain;
|
||||
|
||||
import org.junit.runners.model.InitializationError;
|
||||
import org.robolectric.AndroidManifest;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.res.Fs;
|
||||
import org.robolectric.res.FsFile;
|
||||
|
||||
import org.sufficientlysecure.keychain.KeychainApplication;
|
||||
|
||||
public class RobolectricGradleTestRunner extends RobolectricTestRunner {
|
||||
public RobolectricGradleTestRunner(Class<?> testClass) throws InitializationError {
|
||||
super(testClass);
|
||||
}
|
||||
|
||||
@Override protected AndroidManifest getAppManifest(Config config) {
|
||||
String myAppPath = KeychainApplication.class.getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
String manifestPath = myAppPath + "../../../src/main/AndroidManifest.xml";
|
||||
return createAppManifest(Fs.fileFromPath(manifestPath));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user