ref: 78eed44d1523ec28012b0e96ae209993c312c989
parent: 80fdf09b260a900c9ce6bba59315db832c12de17
parent: 1e4f367a1de656ffc33d8003b4465353eafb7800
author: HaiboZhu <haibozhu@cisco.com>
date: Fri May 30 05:53:02 EDT 2014
Merge pull request #901 from syureyi/androidut Androidut
--- a/Makefile
+++ b/Makefile
@@ -108,8 +108,14 @@
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/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:
@:
--- a/test/api/simple_test.cpp
+++ b/test/api/simple_test.cpp
@@ -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();
}
--- /dev/null
+++ b/test/build/android/AndroidManifest.xml
@@ -1,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=".MainActivity"
+ 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>
--- /dev/null
+++ b/test/build/android/jni/Android.mk
@@ -1,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)
--- /dev/null
+++ b/test/build/android/jni/Application.mk
@@ -1,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
--- /dev/null
+++ b/test/build/android/jni/codec_unittest.cpp
@@ -1,0 +1,25 @@
+#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!+++");
+}
+
+
binary files /dev/null b/test/build/android/res/drawable-hdpi/ic_launcher.png differ
binary files /dev/null b/test/build/android/res/drawable-mdpi/ic_launcher.png differ
binary files /dev/null b/test/build/android/res/drawable-xhdpi/ic_launcher.png differ
binary files /dev/null b/test/build/android/res/drawable-xxhdpi/ic_launcher.png differ
--- /dev/null
+++ b/test/build/android/res/layout/activity_main.xml
@@ -1,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>
+
--- /dev/null
+++ b/test/build/android/res/menu/main.xml
@@ -1,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>
--- /dev/null
+++ b/test/build/android/res/values-v11/styles.xml
@@ -1,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>
--- /dev/null
+++ b/test/build/android/res/values-w820dp/dimens.xml
@@ -1,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>
--- /dev/null
+++ b/test/build/android/res/values/dimens.xml
@@ -1,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>
--- /dev/null
+++ b/test/build/android/res/values/strings.xml
@@ -1,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>
--- /dev/null
+++ b/test/build/android/res/values/styles.xml
@@ -1,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>
--- /dev/null
+++ b/test/build/android/src/com/cisco/codec/unittest/MainActivity.java
@@ -1,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);
+
+}