Browse Source

first approach to ui for testing

JNI-44
huss 9 years ago
parent
commit
94b8c27867
  1. 1
      androidTests/app/build.gradle
  2. 66
      androidTests/app/src/main/java/com/pep/k9/MainActivity.java
  3. 96
      androidTests/app/src/main/res/layout/activity_main.xml

1
androidTests/app/build.gradle

@ -28,4 +28,5 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.0'
compile project(':pEpJNIAdapter')
compile 'com.jakewharton:butterknife:7.0.1'
}

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

@ -2,22 +2,24 @@ package com.pep.k9;
import android.content.Context;
import android.content.res.AssetManager;
import android.support.v7.app.AppCompatActivity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import org.pEp.jniadapter.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Vector;
import java.util.Date;
import java.util.Vector;
public class MainActivity extends AppCompatActivity {
@ -25,13 +27,18 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
Context c = getApplicationContext();
Log.d("PEPTEST", "Helper Setup");
AndroidHelper.setup(c);
}
@Bind(R.id.bRunGenKey) Button runGenKey;
@OnClick(R.id.bRunGenKey) public void runGenKey() {
new RunTestTask().execute();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
@ -45,19 +52,23 @@ public class MainActivity extends AppCompatActivity {
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
new RunTestTask().execute();
return true;
}
return super.onOptionsItemSelected(item);
}
private void runTest() {
try {
//testPEpTypes();
testPEpAliceBobJohn();
//testPEpAliceBobJohn();
//testKeyserverLookup();
//testKeyGen();
testKeyGen();
}
catch (Exception ex) {
Log.e("PEPTEST", "##################### TEST Exception ####################", ex);
}
return true;
}
return super.onOptionsItemSelected(item);
}
private byte[] LoadAssetAsBuffer(String fname) throws IOException {
@ -618,4 +629,35 @@ public class MainActivity extends AppCompatActivity {
e.close();
}
private class RunTestTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
runTest();
return null;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
Log.i("RunTestTask", "onPreExecute " + "Starting test");
runGenKey.setText("Running");
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
Log.i("RunTestTask", "onPostExecute " + "Ended test");
runGenKey.setText("Done");
}
@Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
}
}

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

@ -5,7 +5,99 @@
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<!--//testPEpTypes();-->
<!--//testPEpAliceBobJohn();-->
<!--//testKeyserverLookup();-->
<!--testKeyGen();-->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="pEp Types"
android:layout_weight="1"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Run"
android:id="@+id/bRunTypes"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="pEp Alice Bob John"
android:layout_weight="1"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Run"
android:id="@+id/bRunAliceBob"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Server Lookup"
android:layout_weight="1"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Run"
android:id="@+id/bRunServerLookup"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="KeyGen"
android:layout_weight="1"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Run"
android:id="@+id/bRunGenKey"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

Loading…
Cancel
Save