Add unittest demo for android platform
This commit is contained in:
parent
3d5990500b
commit
9a33512564
22
Makefile
22
Makefile
@ -108,8 +108,14 @@ gtest-bootstrap:
|
||||
svn co https://googletest.googlecode.com/svn/trunk/ gtest
|
||||
|
||||
ifeq ($(HAVE_GTEST),Yes)
|
||||
|
||||
test: codec_unittest$(EXEEXT)
|
||||
ifeq (android, $(OS))
|
||||
|
||||
else
|
||||
|
||||
./codec_unittest
|
||||
endif
|
||||
else
|
||||
test:
|
||||
@echo "./gtest : No such file or directory."
|
||||
@ -163,11 +169,27 @@ include test/api/targets.mk
|
||||
include test/decoder/targets.mk
|
||||
include test/encoder/targets.mk
|
||||
include test/processing/targets.mk
|
||||
|
||||
|
||||
LIBRARIES +=$(LIBPREFIX)ut.$(SHAREDLIBSUFFIX)
|
||||
$(LIBPREFIX)ut.$(SHAREDLIBSUFFIX): $(DECODER_UNITTEST_OBJS) $(ENCODER_UNITTEST_OBJS) $(PROCESSING_UNITTEST_OBJS) $(API_TEST_OBJS) $(CODEC_UNITTEST_DEPS)
|
||||
$(QUIET)rm -f $@
|
||||
$(QUIET_CXX)$(CXX) $(SHARED) $(LDFLAGS) $(CXX_LINK_O) $+ $(CODEC_UNITTEST_LDFLAGS)
|
||||
|
||||
binaries: codec_unittest$(EXEEXT)
|
||||
BINARIES += codec_unittest$(EXEEXT)
|
||||
|
||||
ifeq (android,$(OS))
|
||||
|
||||
|
||||
codec_unittest$(EXEEXT):$(LIBPREFIX)ut.$(SHAREDLIBSUFFIX)
|
||||
cd ./test/build/android && $(NDKROOT)/ndk-build -B APP_ABI=$(APP_ABI) && android update project -t $(TARGET) -p . && ant debug
|
||||
|
||||
else
|
||||
codec_unittest$(EXEEXT): $(DECODER_UNITTEST_OBJS) $(ENCODER_UNITTEST_OBJS) $(PROCESSING_UNITTEST_OBJS) $(API_TEST_OBJS) $(CODEC_UNITTEST_DEPS)
|
||||
$(QUIET)rm -f $@
|
||||
$(QUIET_CXX)$(CXX) $(CXX_LINK_O) $+ $(CODEC_UNITTEST_LDFLAGS) $(LDFLAGS)
|
||||
endif
|
||||
else
|
||||
binaries:
|
||||
@:
|
||||
|
2009
loggtest.txt
Normal file
2009
loggtest.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,22 @@
|
||||
#include <gtest/gtest.h>
|
||||
#if defined (ANDROID_NDK)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(ANDROID_NDK)
|
||||
int CodecUtMain(int argc , char** argv ) {
|
||||
#else
|
||||
int main (int argc, char** argv) {
|
||||
testing::InitGoogleTest (&argc, argv);
|
||||
#endif
|
||||
|
||||
#if defined(ANDROID_NDK)
|
||||
char xmlPath[1024] = "";
|
||||
sprintf(xmlPath,"xml:%s",argv[1]);
|
||||
::testing::GTEST_FLAG(output) = xmlPath;
|
||||
#endif
|
||||
::testing::InitGoogleTest (&argc, argv);
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
30
test/build/android/AndroidManifest.xml
Normal file
30
test/build/android/AndroidManifest.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.cisco.codec.unittest"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="12"
|
||||
android:targetSdkVersion="19" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name=".Codec_Unittest"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
40
test/build/android/jni/Android.mk
Normal file
40
test/build/android/jni/Android.mk
Normal file
@ -0,0 +1,40 @@
|
||||
# Generate the libwelsdecdemo.so file
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libUT
|
||||
LOCAL_SRC_FILES := ../../../../libut.so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
#
|
||||
# Module Settings
|
||||
#
|
||||
LOCAL_MODULE := utDemo
|
||||
|
||||
#
|
||||
# Source Files
|
||||
#
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
codec_unittest.cpp
|
||||
#
|
||||
# Header Includes
|
||||
#
|
||||
LOCAL_C_INCLUDES := \
|
||||
#
|
||||
# Compile Flags and Link Libraries
|
||||
#
|
||||
LOCAL_CFLAGS := -O3 -DANDROID_NDK
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
LOCAL_ARM_MODE := arm
|
||||
endif
|
||||
|
||||
LOCAL_LDLIBS := -llog
|
||||
LOCAL_SHARED_LIBRARIES := libUT
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
44
test/build/android/jni/Android.mk.264SO
Normal file
44
test/build/android/jni/Android.mk.264SO
Normal file
@ -0,0 +1,44 @@
|
||||
# Generate the libwelsdecdemo.so file
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libUT
|
||||
LOCAL_SRC_FILES := libut.so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := wels
|
||||
LOCAL_SRC_FILES := libopenh264.so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
#
|
||||
# Module Settings
|
||||
#
|
||||
LOCAL_MODULE := UTdemo
|
||||
|
||||
#
|
||||
# Source Files
|
||||
#
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
codec_unittest.cpp
|
||||
#
|
||||
# Header Includes
|
||||
#
|
||||
LOCAL_C_INCLUDES := \
|
||||
#
|
||||
# Compile Flags and Link Libraries
|
||||
#
|
||||
LOCAL_CFLAGS := -O3 -DANDROID_NDK
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
LOCAL_ARM_MODE := arm
|
||||
endif
|
||||
|
||||
LOCAL_LDLIBS := -llog
|
||||
LOCAL_SHARED_LIBRARIES := libUT wels
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
20
test/build/android/jni/Application.mk
Normal file
20
test/build/android/jni/Application.mk
Normal file
@ -0,0 +1,20 @@
|
||||
# debug/release, default is release
|
||||
ifeq ($(OPTIM_debug),true)
|
||||
APP_OPTIM := debug
|
||||
else
|
||||
APP_OPTIM := release
|
||||
endif
|
||||
|
||||
# x86/armeabi-v7a/armeabi, default is armeabi-v7a
|
||||
ifeq ($(ABI_x86),true)
|
||||
APP_ABI := x86
|
||||
else
|
||||
ifeq ($(ABI_armeabi),true)
|
||||
APP_ABI := armeabi
|
||||
else
|
||||
APP_ABI := armeabi-v7a
|
||||
endif
|
||||
endif
|
||||
|
||||
APP_STL := stlport_shared
|
||||
APP_PLATFORM := android-12
|
26
test/build/android/jni/codec_unittest.cpp
Normal file
26
test/build/android/jni/codec_unittest.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <jni.h>
|
||||
#include <android/log.h>
|
||||
|
||||
#define LOG_TAG "codec_unittest"
|
||||
#define LOGI(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
|
||||
|
||||
int CodecUtMain(int argc, char** argv);
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL Java_com_cisco_codec_unittest_MainActivity_DoUnittest
|
||||
(JNIEnv* env, jobject thiz,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));
|
||||
LOGI ("PATH:",+argv[1]);
|
||||
LOGI ("Start to run JNI module!+++");
|
||||
CodecUtMain(argc,argv);
|
||||
LOGI ("End to run JNI module!+++");
|
||||
}
|
||||
|
||||
|
26
test/build/android/jni/codec_unittest.cpp.dec
Normal file
26
test/build/android/jni/codec_unittest.cpp.dec
Normal file
@ -0,0 +1,26 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <jni.h>
|
||||
#include <android/log.h>
|
||||
|
||||
#define LOG_TAG "welsdec"
|
||||
#define LOGI(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
|
||||
|
||||
int CodecUtMain(int argc, char** argv);
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL JNICALL Java_com_cisco_codec_unittest_MainActivity_DoUnittest
|
||||
(JNIEnv* env, jobject thiz,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));
|
||||
LOGI ("PATH:\n",argv[1]);
|
||||
LOGI ("Start to run JNI module!+++");
|
||||
CodecUtMain(argc,argv);
|
||||
LOGI ("End to run JNI module!+++");
|
||||
}
|
||||
|
||||
|
BIN
test/build/android/res/drawable-hdpi/ic_launcher.png
Normal file
BIN
test/build/android/res/drawable-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
BIN
test/build/android/res/drawable-mdpi/ic_launcher.png
Normal file
BIN
test/build/android/res/drawable-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
test/build/android/res/drawable-xhdpi/ic_launcher.png
Normal file
BIN
test/build/android/res/drawable-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
test/build/android/res/drawable-xxhdpi/ic_launcher.png
Normal file
BIN
test/build/android/res/drawable-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
19
test/build/android/res/layout/activity_main.xml
Normal file
19
test/build/android/res/layout/activity_main.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context="com.cisco.codec.unittest.MainActivity" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/status_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:text="@string/hello_world" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
10
test/build/android/res/menu/main.xml
Normal file
10
test/build/android/res/menu/main.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_settings"
|
||||
android:showAsAction="never"/>
|
||||
|
||||
</menu>
|
11
test/build/android/res/values-v11/styles.xml
Normal file
11
test/build/android/res/values-v11/styles.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme for API 11+. This theme completely replaces
|
||||
AppBaseTheme from res/values/styles.xml on API 11+ devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Light">
|
||||
<!-- API 11 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
12
test/build/android/res/values-v14/styles.xml
Normal file
12
test/build/android/res/values-v14/styles.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme for API 14+. This theme completely replaces
|
||||
AppBaseTheme from BOTH res/values/styles.xml and
|
||||
res/values-v11/styles.xml on API 14+ devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- API 14 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
10
test/build/android/res/values-w820dp/dimens.xml
Normal file
10
test/build/android/res/values-w820dp/dimens.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
|
||||
-->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
|
||||
</resources>
|
7
test/build/android/res/values/dimens.xml
Normal file
7
test/build/android/res/values/dimens.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<resources>
|
||||
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
|
||||
</resources>
|
8
test/build/android/res/values/strings.xml
Normal file
8
test/build/android/res/values/strings.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Codec_Unittest</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
|
||||
</resources>
|
20
test/build/android/res/values/styles.xml
Normal file
20
test/build/android/res/values/styles.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme, dependent on API level. This theme is replaced
|
||||
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Light">
|
||||
<!--
|
||||
Theme customizations available in newer API levels can go in
|
||||
res/values-vXX/styles.xml, while customizations related to
|
||||
backward-compatibility can go here.
|
||||
-->
|
||||
</style>
|
||||
|
||||
<!-- Application theme. -->
|
||||
<style name="AppTheme" parent="AppBaseTheme">
|
||||
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
@ -0,0 +1,81 @@
|
||||
package com.cisco.codec.unittest;
|
||||
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
import android.os.Build;
|
||||
import android.os.Process;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
|
||||
private TextView mStatusView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
mStatusView = (TextView)findViewById(R.id.status_view);
|
||||
|
||||
runUnitTest();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy()
|
||||
{
|
||||
Process.killProcess(Process.myPid());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void runUnitTest()
|
||||
{
|
||||
Thread thread = new Thread() {
|
||||
|
||||
public void run()
|
||||
{
|
||||
Log.i("codec_unittest","codec unittest begin");
|
||||
CharSequence text = "Running...";
|
||||
if(mStatusView !=null)
|
||||
{
|
||||
mStatusView.setText(text);
|
||||
}
|
||||
|
||||
// String path = getIntent().getStringExtra("path");
|
||||
// if (path.length() <=0)
|
||||
// {
|
||||
// path = "/sdcard/codec_unittest.xml";
|
||||
// }
|
||||
String path = "/sdcard/codec_unittest.xml";
|
||||
Log.i("codec_unittest","codec unittest runing @"+path);
|
||||
DoUnittest(path);
|
||||
Log.i("codec_unittest","codec unittest end");
|
||||
Process.killProcess(Process.myPid());
|
||||
finish();
|
||||
}
|
||||
|
||||
};
|
||||
thread.start();
|
||||
}
|
||||
|
||||
static{
|
||||
try{
|
||||
System.loadLibrary("stlport_shared");
|
||||
//System.loadLibrary("openh264");
|
||||
System.loadLibrary("ut");
|
||||
System.loadLibrary("utDemo");
|
||||
|
||||
|
||||
}
|
||||
catch(Exception e){Log.v("codec_unittest","Load library failed");}
|
||||
|
||||
}
|
||||
|
||||
public native void DoUnittest(String path);
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user