fix cpim tester crashes

This commit is contained in:
Jehan Monnier 2018-05-30 15:55:58 +02:00
parent 807bf7bbcd
commit 0868eb9839
2 changed files with 6 additions and 30 deletions

View file

@ -23,7 +23,7 @@ public class LogsActivity extends Activity {
@Override
public void run() {
String res_path = mLogsActivity.getFilesDir().getAbsolutePath()+"/config_files";
String res_path = mLogsActivity.getFilesDir().getAbsolutePath();
String write_path = mLogsActivity.getCacheDir().getPath();
tester = new TesterLogger(mLogsActivity);
List<String> list = new LinkedList<String>(Arrays.asList(new String[]{"tester", "--verbose", "--resource-dir", res_path, "--writable-dir", write_path}));

View file

@ -32,37 +32,13 @@ public class TestUnit extends AndroidTestCase {
}
static public void copyAssetsFromPackage(Context ctx) throws IOException {
copyAssetsFromPackage(ctx,"config_files");
//copy sdk assets
org.linphone.core.tools.AndroidPlatformHelper.copyAssetsFromPackage(ctx,"org.linphone.core",".");
//copy tester assets
org.linphone.core.tools.AndroidPlatformHelper.copyAssetsFromPackage(ctx,"config_files",".");
}
public static void copyAssetsFromPackage(Context ctx,String fromPath) throws IOException {
new File(ctx.getFilesDir().getPath()+"/"+fromPath).mkdir();
for (String f :ctx.getAssets().list(fromPath)) {
String current_name=fromPath+"/"+f;
InputStream lInputStream;
try {
lInputStream = ctx.getAssets().open(current_name);
} catch (IOException e) {
//probably a dir
new File(ctx.getFilesDir().getPath()+"/"+current_name).mkdir();
copyAssetsFromPackage(ctx,current_name);
continue;
}
FileOutputStream lOutputStream = new FileOutputStream(new File(ctx.getFilesDir().getPath()+"/"+current_name));//ctx.openFileOutput (fromPath+"/"+f, 0);
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
protected void setUp() throws Exception {
super.setUp();
@ -80,7 +56,7 @@ public class TestUnit extends AndroidTestCase {
@Override
protected void runTest() {
String res_path = getContext().getFilesDir().getPath()+"/config_files";
String res_path = getContext().getFilesDir().getPath();
String write_path = getContext().getCacheDir().getPath();
Tester tester = new Tester();