Browse Source

re-commited arturo's changes in one single clean commit, again stripped leftover mess - 'update test app, update hgignore' also, this commit updates adapter's buildToolsVersion to 25.0.0.

JNI-44
Edouard Tisserant 9 years ago
parent
commit
d961a32145
  1. 11
      .hgignore
  2. 4
      android/build.gradle
  3. 7
      androidTests/app/build.gradle
  4. 10
      androidTests/app/src/androidTest/java/com/pep/k9/PEpTest.java
  5. 10
      androidTests/app/src/main/AndroidManifest.xml
  6. 1849
      androidTests/app/src/main/java/com/pep/k9/MainActivity.java
  7. 46
      androidTests/app/src/main/java/com/pep/k9/PEpUnitaryStuff.java
  8. 280
      androidTests/app/src/main/java/com/pep/k9/UnitActivity.java
  9. 417
      androidTests/app/src/main/res/layout/activity_main.xml
  10. 13
      androidTests/app/src/main/res/layout/activity_unit.xml
  11. 4
      androidTests/app/src/main/res/menu/menu_main.xml
  12. 10
      androidTests/app/src/test/java/com/pep/k9/MainActivityTest.java
  13. 49
      androidTests/app/src/test/java/com/pep/k9/UnitaryTest.java
  14. 2
      androidTests/build.gradle

11
.hgignore

@ -51,7 +51,16 @@ androidTests/build
androidTests/.idea androidTests/.idea
androidTests/androidTests.iml androidTests/androidTests.iml
androidTests/app/app.iml androidTests/app/app.iml
.gradle
android/.externalNativeBuild
android/android.iml
android/gradle/wrapper/gradle-wrapper.properties
android/gradlew
android/gradlew.bat
androidTests/gradle/wrapper/gradle-wrapper.properties
androidTests/gradlew
androidTests/gradlew.bat
src/org.tar.gz
syntax: regexp syntax: regexp
android/external/[^.]* android/external/[^.]*

4
android/build.gradle

@ -18,7 +18,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.1.2' classpath 'com.android.tools.build:gradle:2.2.0'
} }
} }
@ -32,7 +32,7 @@ apply plugin: 'com.android.library'
android { android {
compileSdkVersion 21 compileSdkVersion 21
buildToolsVersion '23.0.3' buildToolsVersion '25.0.0'
defaultConfig { defaultConfig {
minSdkVersion 15 minSdkVersion 15

7
androidTests/app/build.gradle

@ -2,11 +2,11 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 23 compileSdkVersion 23
buildToolsVersion "23.0.0" buildToolsVersion '25.0.0'
defaultConfig { defaultConfig {
applicationId "pep.android.k9" applicationId "pep.android.k9"
minSdkVersion 15 minSdkVersion 19
targetSdkVersion 23 targetSdkVersion 23
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
@ -28,5 +28,8 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs') compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.0' compile 'com.android.support:appcompat-v7:23.0.0'
compile project(':pEpJNIAdapter') compile project(':pEpJNIAdapter')
testCompile 'junit:junit:4.12'
compile 'com.jakewharton:butterknife:7.0.1' compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.karumi:dexter:2.3.1'
compile group: 'net.lingala.zip4j', name: 'zip4j', version: '1.3.1'
} }

10
androidTests/app/src/androidTest/java/com/pep/k9/PEpTest.java

@ -0,0 +1,10 @@
package com.pep.k9;
import static org.junit.Assert.*;
/**
* Created by arturo on 15/11/16.
*/
public class PEpTest {
}

10
androidTests/app/src/main/AndroidManifest.xml

@ -1,23 +1,27 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pep.k9" > package="com.pep.k9">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/AppTheme" > android:theme="@style/AppTheme">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:label="@string/app_name" > android:label="@string/app_name">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".UnitActivity"></activity>
</application> </application>
</manifest> </manifest>

1849
androidTests/app/src/main/java/com/pep/k9/MainActivity.java

File diff suppressed because it is too large

46
androidTests/app/src/main/java/com/pep/k9/PEpUnitaryStuff.java

@ -0,0 +1,46 @@
package com.pep.k9;
import org.pEp.jniadapter.Engine;
import org.pEp.jniadapter.Identity;
import org.pEp.jniadapter.Message;
import java.util.Vector;
public class PEpUnitaryStuff {
public static void main (String args[]) {
try {
shouldDoSomeStuff();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void shouldDoSomeStuff() throws Exception {
Engine engine;
engine = new Engine();
Message msg = new Message();
msg.setFrom(new Identity());
Vector<Identity> to = new Vector<>();
to.add(new Identity());
msg.setTo(to);
msg.setShortmsg("hello, world");
String message = "this is a test";
msg.setLongmsg(message);
msg.setDir(Message.Direction.Outgoing);
Vector<Identity> cc = new Vector<>();
cc.add(new Identity());
msg.setCc(cc);
Message encriptedMessage = engine.encrypt_message(msg, null);
Engine.decrypt_message_Return decrypt_message_return = engine.decrypt_message(encriptedMessage);
if (!decrypt_message_return.dst.getLongmsg().equals(message)) {
throw new RuntimeException("FAILED");
}
}
}

280
androidTests/app/src/main/java/com/pep/k9/UnitActivity.java

@ -0,0 +1,280 @@
package com.pep.k9;
import android.content.res.AssetManager;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import org.pEp.jniadapter.Blob;
import org.pEp.jniadapter.Engine;
import org.pEp.jniadapter.Identity;
import org.pEp.jniadapter.Message;
import org.pEp.jniadapter.Pair;
import org.pEp.jniadapter.Rating;
import org.pEp.jniadapter.pEpException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Vector;
public class UnitActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_unit);
try {
messageAfterDecriptionShouldBeTheSame();
messageAfterDecriptionWithoutKeyShouldKeepBreaks();
messageAfterDecriptionShouldKeepBreaks();
} catch (Exception e) {
e.printStackTrace();
}
}
public void messageAfterDecriptionWithoutKeyShouldKeepBreaks() throws Exception {
Engine engine;
engine = new Engine();
Identity alice = loadAliceFromEngine(engine);
Identity bob = loadDummyBobFromEngine(engine);
// message
Message msg = new Message();
msg.setFrom(alice);
Vector<Identity> to = new Vector<>();
to.add(bob);
msg.setTo(to);
msg.setShortmsg("hello, world");
msg.setLongmsg("thisis\nastest");
msg.setDir(Message.Direction.Outgoing);
Vector<Identity> cc = new Vector<>();
cc.add(alice);
msg.setCc(cc);
ArrayList<Pair<String, String>> pairs = new ArrayList<>();
pairs.add(new Pair<>("Received", "in time"));
pairs.add(new Pair<>("X-Foobaz", "of course"));
msg.setOptFields(pairs);
Message encriptedMessage = null;
encriptedMessage = encryptMessageOnEngine(engine, msg);
Vector<Blob> attachments = encriptedMessage.getAttachments();
Engine.decrypt_message_Return result = null;
result = decryptMessageOnEngine(engine, encriptedMessage);
engine.close();
if (!result.dst.getLongmsg().equals(msg.getLongmsg())) {
throw new RuntimeException("FAILED: " +result.dst.getLongmsg()+" not equals to "+msg.getLongmsg());
}
}
public void messageAfterDecriptionShouldKeepBreaks() throws Exception {
Engine engine;
engine = new Engine();
Identity alice = loadAliceFromEngine(engine);
Identity bob = loadBobFromEngine(engine);
// message
Message msg = new Message();
msg.setFrom(alice);
Vector<Identity> to = new Vector<>();
to.add(bob);
msg.setTo(to);
msg.setShortmsg("hello, world");
msg.setLongmsg("thisis\nastest");
msg.setDir(Message.Direction.Outgoing);
Vector<Identity> cc = new Vector<>();
cc.add(alice);
msg.setCc(cc);
ArrayList<Pair<String, String>> pairs = new ArrayList<>();
pairs.add(new Pair<>("Received", "in time"));
pairs.add(new Pair<>("X-Foobaz", "of course"));
msg.setOptFields(pairs);
Message encriptedMessage = null;
encriptedMessage = encryptMessageOnEngine(engine, msg);
Vector<Blob> attachments = encriptedMessage.getAttachments();
Engine.decrypt_message_Return result = null;
result = decryptMessageOnEngine(engine, encriptedMessage);
engine.close();
if (!result.dst.getLongmsg().equals(msg.getLongmsg())) {
throw new RuntimeException("FAILED: " +result.dst.getLongmsg()+" not equals to "+msg.getLongmsg());
}
}
public void messageAfterDecriptionShouldBeTheSame() throws Exception {
Engine engine;
engine = new Engine();
Identity alice = loadAliceFromEngine(engine);
Identity bob = loadBobFromEngine(engine);
// message
Message msg = setupMessage(alice, bob);
ArrayList<Pair<String, String>> pairs = new ArrayList<>();
pairs.add(new Pair<>("Received", "in time"));
pairs.add(new Pair<>("X-Foobaz", "of course"));
msg.setOptFields(pairs);
Message encriptedMessage = null;
encriptedMessage = encryptMessageOnEngine(engine, msg);
Vector<Blob> attachments = encriptedMessage.getAttachments();
Engine.decrypt_message_Return result = null;
result = decryptMessageOnEngine(engine, encriptedMessage);
engine.close();
if (!result.dst.getLongmsg().equals(msg.getLongmsg())) {
throw new RuntimeException("FAILED: " +result.dst.getLongmsg()+" not equals to "+msg.getLongmsg());
}
}
private Message setupMessage(Identity alice, Identity bob) {
Message msg = new Message();
msg.setFrom(alice);
Vector<Identity> to = new Vector<>();
to.add(bob);
msg.setTo(to);
msg.setShortmsg("hello, world");
msg.setLongmsg("this is a test");
msg.setDir(Message.Direction.Outgoing);
Vector<Identity> cc = new Vector<>();
cc.add(alice);
msg.setCc(cc);
return msg;
}
private Engine.decrypt_message_Return decryptMessageOnEngine(Engine engine, Message encriptedMessage) throws pEpException {
long lastTime = System.currentTimeMillis();
Engine.decrypt_message_Return decrypt_message_return = engine.decrypt_message(encriptedMessage);
return decrypt_message_return;
}
private Message encryptMessageOnEngine(Engine engine, Message msg) throws pEpException {
long lastTime = System.currentTimeMillis();
Message message = engine.encrypt_message(msg, null);
return message;
}
private Identity loadBobFromEngine(Engine engine) throws IOException {
//
// Other peers :
// pEp Test Bob (test key, don't use) <pep.test.bob@pep-project.org> 
// C9C2EE39
// 59BFF488C9C2EE39
importKeyFromEngine(engine, "0xC9C2EE39.asc");
Identity bob = new Identity();
bob.username = "bob Test";
bob.address = "pep.test.bob@pep-project.org";
bob.user_id = "112";
bob.fpr = "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39";
updateIdentityOnEngine(engine, bob);
return bob;
}
private Identity loadDummyBobFromEngine(Engine engine) throws IOException {
//
// Other peers :
// pEp Test Bob (test key, don't use) <pep.test.bob@pep-project.org> 
// C9C2EE39
// 59BFF488C9C2EE39
Identity bob = new Identity();
bob.username = "bob Test";
bob.address = "pep.test.bob@pep-project.org";
bob.user_id = "112";
updateIdentityOnEngine(engine, bob);
return bob;
}
private void updateIdentityOnEngine(Engine engine, Identity identity) {
long lastTime = System.currentTimeMillis();
engine.updateIdentity(identity);
}
@NonNull
private Identity loadAliceFromEngine(Engine engine) throws IOException {
// Our test user :
// pEp Test Alice (test key don't use) <pep.test.alice@pep-project.org>
// 6FF00E97
// A9411D176FF00E97
importKeyFromEngine(engine, "6FF00E97_sec.asc");
Identity alice = new Identity();
alice.username = "Alice Test";
alice.address = "pep.test.alice@pep-project.org";
alice.user_id = "pEp_own_userId";
alice.me = true;
alice.fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
long lastTime = System.currentTimeMillis();
myselfInEngine(engine, alice);
return alice;
}
private void importKeyFromEngine(Engine engine, String filename) throws IOException {
long lastTime = System.currentTimeMillis();
engine.importKey(LoadAssetAsString(filename));
}
private String LoadAssetAsString(String fname) throws IOException {
// byte buffer into a string
return new String(LoadAssetAsBuffer(fname));
}
private byte[] LoadAssetAsBuffer(String fname) throws IOException {
AssetManager assetManager = getAssets();
InputStream input;
input = assetManager.open(fname);
int size = input.available();
byte[] buffer = new byte[size];
input.read(buffer);
input.close();
// byte buffer
return buffer;
}
private Identity myselfInEngine(Engine engine, Identity identity) {
Identity myself = engine.myself(identity);
return myself;
}
}

417
androidTests/app/src/main/res/layout/activity_main.xml

@ -1,103 +1,396 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:layout_width="match_parent"
android:paddingRight="@dimen/activity_horizontal_margin" android:layout_height="match_parent">
android:paddingTop="@dimen/activity_vertical_margin" <LinearLayout android:id="@+id/content"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> android:layout_width="match_parent"
android:layout_height="wrap_content"
<!--//testPEpTypes();--> android:orientation="vertical"
<!--//testPEpAliceBobJohn();--> tools:context=".MainActivity">
<!--//testKeyserverLookup();-->
<!--testKeyGen();--> <LinearLayout
<LinearLayout android:layout_width="match_parent"
android:orientation="vertical" android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="KeyGen"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/bRunGenKey"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Run" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"> android:layout_alignParentStart="true"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView <TextView
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" android:layout_weight="1"
android:text="pEp Types" android:text="pEp Types"
android:layout_weight="1"/> android:textAppearance="?android:attr/textAppearanceMedium" />
<Button <Button
android:id="@+id/bRunTypes"
style="?android:attr/buttonStyleSmall" style="?android:attr/buttonStyleSmall"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Run" android:layout_weight="1"
android:id="@+id/bRunTypes" android:text="Run" />
android:layout_weight="1"/> </LinearLayout>
</LinearLayout>
<LinearLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView <TextView
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" android:layout_weight="1"
android:text="pEp Alice Bob John" android:text="Server Lookup"
android:layout_weight="1"/> android:textAppearance="?android:attr/textAppearanceMedium" />
<Button <Button
android:id="@+id/bRunServerLookup"
style="?android:attr/buttonStyleSmall" style="?android:attr/buttonStyleSmall"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Run" android:layout_weight="1"
android:text="Run" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Encrypt and decreypt"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/encrypt_and_decrypt"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Run" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Encrypt and decreypt without key"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/encrypt_and_decrypt_without_key"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Run" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Ratings"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/ratings"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Run" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Integration test"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/bRunAliceBob" android:id="@+id/bRunAliceBob"
android:layout_weight="1"/> style="?android:attr/buttonStyleSmall"
</LinearLayout> android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Run" />
</LinearLayout>
<LinearLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView <TextView
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" android:layout_weight="1"
android:text="Server Lookup" android:text="Add to blacklist + new key"
android:layout_weight="1"/> android:textAppearance="?android:attr/textAppearanceMedium" />
<Button <Button
android:id="@+id/black_list"
style="?android:attr/buttonStyleSmall" style="?android:attr/buttonStyleSmall"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Run" android:layout_weight="1"
android:id="@+id/bRunServerLookup" android:text="Run" />
android:layout_weight="1"/> </LinearLayout>
</LinearLayout>
<LinearLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView <TextView
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" android:layout_weight="1"
android:text="KeyGen" android:text="Blacklist + send"
android:layout_weight="1"/> android:textAppearance="?android:attr/textAppearanceMedium" />
<Button <Button
android:id="@+id/black_list_and_send"
style="?android:attr/buttonStyleSmall" style="?android:attr/buttonStyleSmall"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Run" android:layout_weight="1"
android:id="@+id/bRunGenKey" android:text="Run" />
android:layout_weight="1"/> </LinearLayout>
</LinearLayout>
</LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Blacklist + delete"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout> <Button
android:id="@+id/black_list_and_delete"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Run" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Unencrypt subject"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/unencrypted_subject"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Run" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Passive mode"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/passive_mode"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Run" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="enc + dec message to myself"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/message_me"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Run" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Message from me - green"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/message_from_me_green"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Run" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="outgoing color"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/outgoing_color"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Run" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="identity"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/identity_rating"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Run" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Deblacklist rating"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/deblacklist"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Run" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/times_to_test"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:text="1"
android:inputType="textEmailAddress" />
<Button
android:id="@+id/test_everything"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TEST EVERYTHING" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

13
androidTests/app/src/main/res/layout/activity_unit.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_unit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.pep.k9.UnitActivity">
</RelativeLayout>

4
androidTests/app/src/main/res/menu/menu_main.xml

@ -1,6 +1,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity"> xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item android:id="@+id/action_settings" android:title="@string/action_settings" <item android:id="@+id/action_settings" android:title="Refresh"
android:orderInCategory="100" app:showAsAction="never" />
<item android:id="@+id/action_unitary" android:title="Do More things"
android:orderInCategory="100" app:showAsAction="never" /> android:orderInCategory="100" app:showAsAction="never" />
</menu> </menu>

10
androidTests/app/src/test/java/com/pep/k9/MainActivityTest.java

@ -0,0 +1,10 @@
package com.pep.k9;
import static org.junit.Assert.*;
/**
* Created by arturo on 15/11/16.
*/
public class MainActivityTest {
}

49
androidTests/app/src/test/java/com/pep/k9/UnitaryTest.java

@ -0,0 +1,49 @@
package com.pep.k9;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.pEp.jniadapter.Engine;
import org.pEp.jniadapter.Identity;
import org.pEp.jniadapter.Message;
import java.util.Vector;
/**
* Created by arturo on 15/11/16.
*/
public class UnitaryTest {
@Before
public void setUp() throws Exception {
}
@Test
public void shouldDoSomeStuff() throws Exception {
Engine engine;
engine = new Engine();
Message msg = new Message();
msg.setFrom(new Identity());
Vector<Identity> to = new Vector<>();
to.add(new Identity());
msg.setTo(to);
msg.setShortmsg("hello, world");
String message = "this is a test";
msg.setLongmsg(message);
msg.setDir(Message.Direction.Outgoing);
Vector<Identity> cc = new Vector<>();
cc.add(new Identity());
msg.setCc(cc);
Message encriptedMessage = engine.encrypt_message(msg, null);
Engine.decrypt_message_Return decrypt_message_return = engine.decrypt_message(encriptedMessage);
Assert.assertTrue(decrypt_message_return.dst.getLongmsg().equals(message));
}
}

2
androidTests/build.gradle

@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.1.2' classpath 'com.android.tools.build:gradle:2.3.0-alpha1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files

Loading…
Cancel
Save