Browse Source

AndroidTest : Added Keyserver Lookup Test. Fixed missing perms and gpg2key binary

JNI-44
Edouard Tisserant 6 years ago
parent
commit
20b6b17876
3 changed files with 36 additions and 8 deletions
  1. +1
    -0
      android/src/org/pEp/jniadapter/AndroidHelper.java
  2. +2
    -0
      androidTests/app/src/main/AndroidManifest.xml
  3. +33
    -8
      androidTests/app/src/main/java/com/pep/k9/MainActivity.java

+ 1
- 0
android/src/org/pEp/jniadapter/AndroidHelper.java View File

@ -117,6 +117,7 @@ public class AndroidHelper {
optDir.mkdirs();
assetPathExtract(c, "lib", optDir);
assetPathExtract(c, "bin", optDir);
assetPathExtract(c, "libexec", optDir);
new File(optDir, "var/cache/gnupg").mkdirs();
new File(optDir, "var/lib/gnupg").mkdirs();
new File(optDir, "var/run/gnupg").mkdirs();


+ 2
- 0
androidTests/app/src/main/AndroidManifest.xml View File

@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pep.k9" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"


+ 33
- 8
androidTests/app/src/main/java/com/pep/k9/MainActivity.java View File

@ -41,9 +41,6 @@ public class MainActivity extends AppCompatActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action b§§ar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
@ -51,6 +48,7 @@ public class MainActivity extends AppCompatActivity {
try {
testPEpTypes();
testPEpAliceBobJohn();
testKeyserverLookup();
}
catch (Exception ex) {
Log.e("PEPTEST", "##################### TEST Exception ####################",ex);
@ -95,11 +93,6 @@ public class MainActivity extends AppCompatActivity {
// TEST : Call getter before call to getter
// BUG : if not already instantiated, enum cannot be mapped
// then getDir and getEncFormat return null.
// Message.Direction _bug1 = Message.Direction.Incoming;
// Message.EncFormat _bug2 = Message.EncFormat.None;
if(!(msg.getDir() == Message.Direction.Incoming)) throw new AssertionError();
if(!(msg.getId()==null)) throw new AssertionError();
if(!(msg.getLongmsg()==null)) throw new AssertionError();
@ -549,4 +542,36 @@ public class MainActivity extends AppCompatActivity {
}
e.close();
}
public void testKeyserverLookup() throws pEpException, IOException, AssertionError, InterruptedException {
Engine e;
Log.d("PEPTEST", "Test loaded");
e = new Engine();
e.startKeyserverLookup();
Identity vb = new Identity();
vb.username = "pEpDontAssert";
vb.address = "vb@ulm.ccc.de";
vb.user_id = "SsI6H9";
e.updateIdentity(vb);
int count = 0;
while (count++ < 5000) {
Thread.sleep(1);
}
String fpr = e.updateIdentity(vb).fpr;
Log.d("PEPTEST", "keyserver test fpr");
Log.d("PEPTEST", fpr != null ? fpr : "NULL");
if(!(fpr != null)) throw new AssertionError();
e.stopKeyserverLookup();
e.close();
}
}

Loading…
Cancel
Save