Add suites and tests in liblinphone_tester
This commit is contained in:
parent
e24ec45fc6
commit
feef30b595
14 changed files with 293 additions and 88 deletions
|
@ -8,16 +8,16 @@
|
|||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="17" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:debuggable="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme"
|
||||
android:debuggable="true">
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name="org.linphone.tester.MainActivity"
|
||||
android:label="@string/app_name" >
|
||||
|
@ -27,6 +27,14 @@
|
|||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.linphone.tester.LogsActivity"
|
||||
android:label="@string/title_activity_logs" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.linphone.tester.SuitesActivity"
|
||||
android:label="@string/title_activity_suites" >
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
12
liblinphone_tester/res/layout/activity_logs.xml
Normal file
12
liblinphone_tester/res/layout/activity_logs.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical"
|
||||
tools:context=".LogsActivity">
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
</ScrollView>
|
|
@ -1,34 +1,15 @@
|
|||
<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"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity" >
|
||||
tools:context=".SuitesActivity" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:id="@+id/suites_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="18dp"
|
||||
android:text="@string/start"
|
||||
android:onClick="onBtnClicked" />
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical" >
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:scrollbars="vertical"
|
||||
android:visibility="visible"
|
||||
android:padding="10dp"
|
||||
android:layout_above="@+id/button1">
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
</ScrollView>
|
||||
</RelativeLayout>
|
||||
</ScrollView>
|
15
liblinphone_tester/res/layout/activity_suites.xml
Normal file
15
liblinphone_tester/res/layout/activity_suites.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".SuitesActivity" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/tests_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
9
liblinphone_tester/res/menu/activity_logs.xml
Normal file
9
liblinphone_tester/res/menu/activity_logs.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/menu_settings"/>
|
||||
|
||||
</menu>
|
9
liblinphone_tester/res/menu/activity_suites.xml
Normal file
9
liblinphone_tester/res/menu/activity_suites.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/menu_settings"/>
|
||||
|
||||
</menu>
|
|
@ -2,7 +2,9 @@
|
|||
<resources>
|
||||
|
||||
<string name="app_name">liblinphone tester</string>
|
||||
<string name="start">Start</string>
|
||||
<string name="all">All</string>
|
||||
<string name="menu_settings">Settings</string>
|
||||
<string name="title_activity_logs">LogsActivity</string>
|
||||
<string name="title_activity_suites">SuitesActivity</string>
|
||||
|
||||
</resources>
|
79
liblinphone_tester/src/org/linphone/tester/LogsActivity.java
Normal file
79
liblinphone_tester/src/org/linphone/tester/LogsActivity.java
Normal file
|
@ -0,0 +1,79 @@
|
|||
package org.linphone.tester;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.view.Menu;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class LogsActivity extends Activity {
|
||||
private String mLogs = "";
|
||||
private LogsThread mLogsThread;
|
||||
private class LogsThread extends Thread {
|
||||
LogsActivity mLogsActivity;
|
||||
String mArgs[];
|
||||
TesterLogger tester;
|
||||
public LogsThread(LogsActivity logsActivity, String[] args) {
|
||||
mLogsActivity = logsActivity;
|
||||
mArgs = args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String path = mLogsActivity.getFilesDir().getAbsolutePath();
|
||||
tester = new TesterLogger(mLogsActivity);
|
||||
List<String> list = new LinkedList<String>(Arrays.asList(new String[]{"tester", "--config", path}));
|
||||
list.addAll(Arrays.asList(mArgs));
|
||||
String[] array = list.toArray(new String[list.size()]);
|
||||
tester.run(array);
|
||||
mLogsActivity.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
mLogsActivity.done();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_logs);
|
||||
((TextView)findViewById(R.id.textView1)).setText(mLogs);
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (extras != null) {
|
||||
String[] values = extras.getStringArray("args");
|
||||
if(values != null) {
|
||||
if(mLogsThread == null || !mLogsThread.isAlive()) {
|
||||
mLogs = "";
|
||||
((TextView)findViewById(R.id.textView1)).setText(mLogs);
|
||||
mLogsThread = new LogsThread(this, values);
|
||||
mLogsThread.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.activity_logs, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addLog(int level, String message) {
|
||||
mLogs += message;
|
||||
((TextView)findViewById(R.id.textView1)).append(message);
|
||||
}
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if(mLogsThread == null || !mLogsThread.isAlive()) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public void done() {
|
||||
}
|
||||
}
|
|
@ -7,34 +7,15 @@ import java.io.InputStream;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.tester.Tester;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
static public MainActivity instance = null;
|
||||
static public Tester tester = new Tester();
|
||||
String mLogs = "";
|
||||
MainThread mThread;
|
||||
|
||||
private class MainThread extends Thread {
|
||||
MainActivity mActivity;
|
||||
public MainThread(MainActivity activity) {
|
||||
mActivity = activity;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
String path = mActivity.getFilesDir().getAbsolutePath();
|
||||
tester.run(new String[]{"tester", "--verbose", "--config", path});
|
||||
mActivity.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
mActivity.done();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void copyFromPackage(int ressourceId,String target) throws IOException{
|
||||
FileOutputStream lOutputStream = openFileOutput (target, 0);
|
||||
|
@ -51,6 +32,7 @@ public class MainActivity extends Activity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
try {
|
||||
copyFromPackage(R.raw.laure_rc, new File("laure_rc").getName());
|
||||
copyFromPackage(R.raw.marie_rc, new File("marie_rc").getName());
|
||||
|
@ -60,16 +42,40 @@ public class MainActivity extends Activity {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
instance = this;
|
||||
setContentView(R.layout.activity_main);
|
||||
((TextView)findViewById(R.id.textView1)).setText(mLogs);
|
||||
if(mThread == null || !mThread.isAlive()) {
|
||||
findViewById(R.id.button1).setEnabled(true);
|
||||
} else {
|
||||
findViewById(R.id.button1).setEnabled(true);
|
||||
|
||||
TesterList suitesTest = new TesterList();
|
||||
suitesTest.run(new String[]{"tester", "--list-suites"});
|
||||
LinearLayout layout = ((LinearLayout)findViewById(R.id.suites_list));
|
||||
layout.removeAllViewsInLayout();
|
||||
addButton(layout, "All", null);
|
||||
for(String str: suitesTest.getList()) {
|
||||
str = str.trim();
|
||||
addButton(layout, str, str);
|
||||
}
|
||||
}
|
||||
private void addButton(LinearLayout layout, String text, String data) {
|
||||
Button button = new Button(this);
|
||||
button.setText(text);
|
||||
button.setTag(data);
|
||||
button.setGravity(Gravity.CENTER);
|
||||
button.setOnClickListener(new Button.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Button button = (Button) v;
|
||||
String data = (String)button.getTag();
|
||||
if(data == null) {
|
||||
Intent intent = new Intent(getBaseContext(), LogsActivity.class);
|
||||
intent.putExtra("args", new String[]{});
|
||||
startActivity(intent);
|
||||
} else {
|
||||
Intent intent = new Intent(getBaseContext(), SuitesActivity.class);
|
||||
intent.putExtra("suite", data);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
layout.addView(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
@ -77,21 +83,4 @@ public class MainActivity extends Activity {
|
|||
getMenuInflater().inflate(R.menu.activity_main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onBtnClicked(View v) {
|
||||
mLogs = "";
|
||||
((TextView)findViewById(R.id.textView1)).setText(mLogs);
|
||||
findViewById(R.id.button1).setEnabled(false);
|
||||
mThread = new MainThread(this);
|
||||
mThread.start();
|
||||
}
|
||||
|
||||
public void addLog(int level, String message) {
|
||||
mLogs += message;
|
||||
((TextView)findViewById(R.id.textView1)).append(message);
|
||||
}
|
||||
|
||||
public void done() {
|
||||
findViewById(R.id.button1).setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package org.linphone.tester;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
public class SuitesActivity extends Activity {
|
||||
String mSuite;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_suites);
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (extras != null) {
|
||||
mSuite = extras.getString("suite");
|
||||
if(mSuite != null) {
|
||||
TesterList suitesTest = new TesterList();
|
||||
suitesTest.run(new String[]{"tester", "--list-tests", mSuite});
|
||||
LinearLayout layout = ((LinearLayout)findViewById(R.id.tests_list));
|
||||
layout.removeAllViewsInLayout();
|
||||
addButton(layout, "All", null);
|
||||
for(String str: suitesTest.getList()) {
|
||||
str = str.trim();
|
||||
addButton(layout, str, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void addButton(LinearLayout layout, String text, String data) {
|
||||
Button button = new Button(this);
|
||||
button.setText(text);
|
||||
button.setTag(data);
|
||||
button.setGravity(Gravity.CENTER);
|
||||
button.setOnClickListener(new Button.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Button button = (Button) v;
|
||||
String data = (String)button.getTag();
|
||||
if(mSuite != null) {
|
||||
if(data == null) {
|
||||
Intent intent = new Intent(getBaseContext(), LogsActivity.class);
|
||||
intent.putExtra("args", new String[]{"--suite", mSuite});
|
||||
startActivity(intent);
|
||||
} else {
|
||||
Intent intent = new Intent(getBaseContext(), LogsActivity.class);
|
||||
intent.putExtra("args", new String[]{"--suite", mSuite, "--test", data});
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
layout.addView(button);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.activity_suites, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -89,11 +89,6 @@ public class Tester {
|
|||
public native int run(String args[]);
|
||||
|
||||
public void printLog(final int level, final String message) {
|
||||
MainActivity.instance.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
MainActivity.instance.addLog(level, message);
|
||||
}
|
||||
});
|
||||
switch(level) {
|
||||
case 0:
|
||||
android.util.Log.i(TAG, message);
|
||||
|
|
16
liblinphone_tester/src/org/linphone/tester/TesterList.java
Normal file
16
liblinphone_tester/src/org/linphone/tester/TesterList.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package org.linphone.tester;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class TesterList extends Tester {
|
||||
private List<String> list = new LinkedList<String>();
|
||||
public void printLog(final int level, final String message) {
|
||||
super.printLog(level, message);
|
||||
list.add(message);
|
||||
}
|
||||
|
||||
public List<String> getList() {
|
||||
return list;
|
||||
}
|
||||
}
|
16
liblinphone_tester/src/org/linphone/tester/TesterLogger.java
Normal file
16
liblinphone_tester/src/org/linphone/tester/TesterLogger.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package org.linphone.tester;
|
||||
|
||||
public class TesterLogger extends Tester {
|
||||
private LogsActivity mLogsActivity;
|
||||
TesterLogger(LogsActivity logsActivity) {
|
||||
mLogsActivity = logsActivity;
|
||||
}
|
||||
public void printLog(final int level, final String message) {
|
||||
super.printLog(level, message);
|
||||
mLogsActivity.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
mLogsActivity.addLog(level, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
5
submodules/externals/build/cunit/Android.mk
vendored
5
submodules/externals/build/cunit/Android.mk
vendored
|
@ -14,9 +14,14 @@ LOCAL_SRC_FILES := \
|
|||
LOCAL_C_INCLUDES := \
|
||||
$(LOCAL_PATH)/CUnit/Headers/ \
|
||||
|
||||
LOCAL_CFLAGS := \
|
||||
-DHAVE_CU_GET_SUITE \
|
||||
|
||||
LOCAL_EXPORT_C_INCLUDES := \
|
||||
$(BUILD_PATH) \
|
||||
|
||||
LOCAL_EXPORT_CFLAGS := $(LOCAL_CFLAGS)
|
||||
|
||||
LOCAL_MODULE := cunit
|
||||
LOCAL_LDLIBS := -llog
|
||||
|
||||
|
|
Loading…
Reference in a new issue