fix liblinphone tester

This commit is contained in:
Jehan Monnier 2013-10-07 14:16:59 +02:00
parent 018c96e20e
commit 7c7719677f
9 changed files with 46 additions and 43 deletions

View file

@ -259,7 +259,7 @@ $(TOPDIR)/res/raw/rootca.pem:
prepare-liblinphone_tester: $(TOPDIR)/submodules/linphone/tester/*_lrc $(TOPDIR)/submodules/linphone/tester/*_rc $(TOPDIR)/submodules/linphone/tester/tester_hosts $(TOPDIR)/submodules/linphone/tester/certificates/* $(TOPDIR)/res/raw/rootca.pem prepare-liblinphone_tester: $(TOPDIR)/submodules/linphone/tester/*_lrc $(TOPDIR)/submodules/linphone/tester/*_rc $(TOPDIR)/submodules/linphone/tester/tester_hosts $(TOPDIR)/submodules/linphone/tester/certificates/* $(TOPDIR)/res/raw/rootca.pem
for file in $^; do \ for file in $^; do \
cp -f $$file $(TOPDIR)/liblinphone_tester/res/raw/. \ cp -f $$file $(TOPDIR)/liblinphone_tester/assets/rc_files/. \
;done ;done
#SQLite3 #SQLite3

View file

@ -1,10 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="linphone/j2se"/>
<classpathentry kind="src" path="linphone/impl"/>
<classpathentry kind="src" path="linphone/common"/>
<classpathentry kind="src" path="gen"/> <classpathentry kind="src" path="gen"/>
<classpathentry excluding="org/linphone/mediastream/MediastreamerActivity.java" kind="src" path="mediastreamer2"/> <classpathentry excluding="org/linphone/mediastream/MediastreamerActivity.java" kind="src" path="mediastreamer2"/>
<classpathentry kind="lib" path="libs/android-support-v4.jar"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/> <classpathentry kind="output" path="bin/classes"/>
</classpath> </classpath>

View file

@ -16,3 +16,5 @@ obj/
# Local configuration file (sdk path, etc) # Local configuration file (sdk path, etc)
local.properties local.properties
assets

View file

@ -31,6 +31,11 @@
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
</natures> </natures>
<linkedResources> <linkedResources>
<link>
<name>linphone</name>
<type>2</type>
<locationURI>PARENT-1-PROJECT_LOCATION/submodules/linphone/java</locationURI>
</link>
<link> <link>
<name>mediastreamer2</name> <name>mediastreamer2</name>
<type>2</type> <type>2</type>

View file

@ -1,12 +0,0 @@
agent.pem
cacert.pem
empty_rc
laure_rc
marie_early_rc
marie_no_sdp_rc
marie_rc
multi_account_lrc
pauline_rc
rootca.pem
tester_hosts
upnp_rc

View file

@ -7,7 +7,9 @@ import java.io.InputStream;
import android.os.Bundle; import android.os.Bundle;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.AssetManager;
import android.view.Gravity; import android.view.Gravity;
import android.view.Menu; import android.view.Menu;
import android.view.View; import android.view.View;
@ -16,34 +18,9 @@ import android.widget.LinearLayout;
public class MainActivity extends Activity { public class MainActivity extends Activity {
private void copyFromPackage(int ressourceId,String target) throws IOException{
FileOutputStream lOutputStream = openFileOutput (target, 0);
InputStream lInputStream = getResources().openRawResource(ressourceId);
int readByte;
byte[] buff = new byte[8048];
while (( readByte = lInputStream.read(buff)) != -1) {
lOutputStream.write(buff,0, readByte);
}
lOutputStream.flush();
lOutputStream.close();
lInputStream.close();
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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());
copyFromPackage(R.raw.marie_early_rc, new File("marie_early_rc").getName());
copyFromPackage(R.raw.multi_account_lrc, new File("multi_account_lrc").getName());
copyFromPackage(R.raw.pauline_rc, new File("pauline_rc").getName());
copyFromPackage(R.raw.rootca, new File("rootca.pem").getName());
copyFromPackage(R.raw.cacert, new File("cacert.pem").getName());
copyFromPackage(R.raw.tester_hosts, new File("tester_hosts").getName());
} catch (IOException e) {
e.printStackTrace();
}
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);

View file

@ -1,5 +1,7 @@
package org.linphone.tester; package org.linphone.tester;
import java.io.IOException;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import android.os.Bundle; import android.os.Bundle;
import android.test.InstrumentationTestRunner; import android.test.InstrumentationTestRunner;
@ -13,6 +15,7 @@ public class TestRunner extends InstrumentationTestRunner {
public void onCreate(Bundle arguments) { public void onCreate(Bundle arguments) {
mSuite = arguments.getString("suite"); mSuite = arguments.getString("suite");
mTest = arguments.getString("test"); mTest = arguments.getString("test");
super.onCreate(arguments); super.onCreate(arguments);
} }

View file

@ -1,25 +1,49 @@
package org.linphone.tester; package org.linphone.tester;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import junit.framework.Assert; import junit.framework.Assert;
import android.content.Context;
import android.test.AndroidTestCase; import android.test.AndroidTestCase;
public class TestUnit extends AndroidTestCase { public class TestUnit extends AndroidTestCase {
private String mSuite; private String mSuite;
private String mTest; private String mTest;
static Boolean isAssetCopied=false;
public TestUnit(String suite, String test) { public TestUnit(String suite, String test) {
mSuite = suite; mSuite = suite;
mTest = test; mTest = test;
setName(suite + "/" + test); setName(suite + "/" + test);
} }
private void copyAssetsFromPackage() throws IOException {
Context ctx= getContext();
for (String file :ctx.getAssets().list("rc_files")) {
FileOutputStream lOutputStream = ctx.openFileOutput (new File(file).getName(), 0);
InputStream lInputStream = ctx.getAssets().open("rc_files/"+file);
int readByte;
byte[] buff = new byte[8048];
while (( readByte = lInputStream.read(buff)) != -1) {
lOutputStream.write(buff,0, readByte);
}
lOutputStream.flush();
lOutputStream.close();
lInputStream.close();
}
}
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
if (isAssetCopied ==false) {
copyAssetsFromPackage();
isAssetCopied=true;
}
} }
@Override @Override
@ -29,7 +53,7 @@ public class TestUnit extends AndroidTestCase {
@Override @Override
protected void runTest() { protected void runTest() {
String path = getContext().getFilesDir().getAbsolutePath(); String path = getContext().getFilesDir().getPath();
Tester tester = new Tester(); Tester tester = new Tester();
List<String> list = new LinkedList<String>(Arrays.asList(new String[]{"tester", "--verbose", "--config", path, "--suite", mSuite, "--test", mTest})); List<String> list = new LinkedList<String>(Arrays.asList(new String[]{"tester", "--verbose", "--config", path, "--suite", mSuite, "--test", mTest}));
String[] array = list.toArray(new String[list.size()]); String[] array = list.toArray(new String[list.size()]);

View file

@ -24,6 +24,7 @@ public class Tester {
} }
static { static {
LinphoneCoreFactory.instance(); LinphoneCoreFactory.instance();
System.loadLibrary("cunit"); System.loadLibrary("cunit");