shithub: openh264

Download patch

ref: a294cad5c8ada3ada88fdc52220352d4c8a3a8e1
parent: a0c9f8c9a06a63e37a74d20c1ff07e19ef979ba6
author: Martin Storsjö <martin@martin.st>
date: Fri May 30 06:58:19 EDT 2014

Change directory to /sdcard before running the unit tests on android

This allows placing the test files in /sdcard/res before running
the test. Previously, the current directory was /, and writing
data into /res isn't possible on non-rooted phones.

--- a/test/build/android/jni/codec_unittest.cpp
+++ b/test/build/android/jni/codec_unittest.cpp
@@ -2,6 +2,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <jni.h>
+#include <unistd.h>
 #include <android/log.h>
 
 #define LOG_TAG "codec_unittest"
@@ -10,12 +11,13 @@
 int CodecUtMain(int argc, char** argv);
 extern "C"
 JNIEXPORT void JNICALL Java_com_cisco_codec_unittest_MainActivity_DoUnittest
-(JNIEnv* env, jobject thiz,jstring jspath) {
+(JNIEnv* env, jobject thiz, jstring directory, jstring jspath) {
   /**************** Add the native codes/API *****************/
   char* argv[2];
   int  argc = 2;
   argv[0] = (char*) ("codec_unittest.exe");
   argv[1] = (char*) ((*env).GetStringUTFChars (jspath,NULL));
+  chdir((*env).GetStringUTFChars (directory, NULL));
   LOGI ("PATH: %s", argv[1]);
   LOGI ("Start to run JNI module!+++");
  CodecUtMain(argc,argv);
--- a/test/build/android/src/com/cisco/codec/unittest/MainActivity.java
+++ b/test/build/android/src/com/cisco/codec/unittest/MainActivity.java
@@ -53,7 +53,7 @@
 //				}
 				String path = "/sdcard/codec_unittest.xml";
 				Log.i("codec_unittest","codec unittest runing @"+path);
-				DoUnittest(path);
+				DoUnittest("/sdcard", path);
 				Log.i("codec_unittest","codec unittest end");
 				Process.killProcess(Process.myPid());
 				finish();
@@ -76,6 +76,6 @@
 
 	}
 
-	public native void DoUnittest(String path);
+	public native void DoUnittest(String directory, String path);
 
 }