How to use Google Test on Android-4.0.3_r1
来源:互联网 发布:java中求字符串的长度 编辑:程序博客网 时间:2024/05/16 17:20
AOSP has Google Test project in extarnal/gtest directory.
I try to use Google Test in my Application.
I uploaded sample project.
https://docs.google.com/open?id=0BwdCdBWuE_7cb2ZzVGt3eHhSOEtEbGVxNnRCSkFJdw
If building success , executable file is created.
I try to use Google Test in my Application.
Create Android.mk for Google Test
I was referring to the existing Android.mk in extarnal/gtest/test.LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)# Gtest depends on STLPort which does not build on host/simulator.ifeq ($(BUILD_WITH_ASTL),true)libgtest_test_includes := \ bionic/libstdc++/include \ external/astl/include \ external/gtest/include \ $(LOCAL_PATH)/../test \ $(LOCAL_PATH)/..libgtest_test_static_lib := libgtest_main libgtest libastllibgtest_test_shared_lib :=libgtest_test_host_static_lib := libgtest_main_host libgtest_host libastl_hostlibgtest_test_host_shared_lib :=else# BUILD_WITH_ASTL could be undefined, force it to false (for the guard# before the test-target call).BUILD_WITH_ASTL := falselibgtest_test_includes := \ bionic \ external/stlport/stlport \ external/gtest/include \ $(LOCAL_PATH)/../test \ $(LOCAL_PATH)/..libgtest_test_static_lib := libgtest_main libgtestlibgtest_test_shared_lib := libstlportlibgtest_test_host_static_lib :=libgtest_test_host_shared_lib :=endifLOCAL_MODULE_TAGS := TestAppGtestLOCAL_C_INCLUDES := $(libgtest_test_includes)LOCAL_SHARED_LIBRARIES := \ libcutils \ libutils \ libandroid_runtime \ $(libgtest_test_shared_lib) \ $(libgtest_test_host_shared_lib)LOCAL_STATIC_LIBRARIES := \ $(libgtest_test_static_lib) \ $(libgtest_test_host_static_lib)# if LOCAL_SRC_FILES is .cc#LOCAL_CPP_EXTENSION := .cc# YOUR Source and Test SourceLOCAL_SRC_FILES := \ sample1.cpp \ sample1_unittest.cppLOCAL_MODULE := gtest_mytestLOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)include $(BUILD_EXECUTABLE)
Building Google Test
I try to build an apllicaion with google test code.I uploaded sample project.
https://docs.google.com/open?id=0BwdCdBWuE_7cb2ZzVGt3eHhSOEtEbGVxNnRCSkFJdw
$ cd "YOUR_BUILD_DIRECTORY"$ . build/envsetup.sh$ lunch "YOUR_BUILD_LUNCH"$ make$ cd packages/apps/$ cd TestApp$ mm -B
If building success , executable file is created.
target thumb C++: gtest_mytest <= packages/apps/TestApp/jni/test/sample1.cpptarget thumb C++: gtest_mytest <= packages/apps/TestApp/jni/test/sample1_unittest.cpptarget Executable: gtest_mytest (out/target/product/maguro/obj/EXECUTABLES/gtest_mytest_intermediates/LINKED/gtest_mytest)target Symbolic: gtest_mytest (out/target/product/maguro/symbols/data/app/gtest_mytest)target Strip: gtest_mytest (out/target/product/maguro/obj/EXECUTABLES/gtest_mytest_intermediates/gtest_mytest)Install: out/target/product/maguro/data/app/gtest_mytest
Running Google Test
I try to run Google Test on Galaxy Nexus. My Galaxy Nexus is flashed Android-4.0.3_r1. Copy to executable file.cd out/target/product/maguro/$ adb push data/app/gtest_mytest /data/app2870 KB/s (48728 bytes in 0.016s)Running test using ADB.
$ adb shellroot@android:/ # cd data/app root@android:/data/app # ./gtest_mytestSuccess to run, The test results are displayed.
root@android:/data/app # ./gtest_mytest Running main() from gtest_main.cc[==========] Running 6 tests from 2 test cases.[----------] Global test environment set-up.[----------] 3 tests from FactorialTest[ RUN ] FactorialTest.Negative[ OK ] FactorialTest.Negative[ RUN ] FactorialTest.Zero[ OK ] FactorialTest.Zero[ RUN ] FactorialTest.Positive[ OK ] FactorialTest.Positive[----------] 3 tests from IsPrimeTest[ RUN ] IsPrimeTest.Negative[ OK ] IsPrimeTest.Negative[ RUN ] IsPrimeTest.Trivial[ OK ] IsPrimeTest.Trivial[ RUN ] IsPrimeTest.Positive[ OK ] IsPrimeTest.Positive[----------] Global test environment tear-down[==========] 6 tests from 2 test cases ran.[ PASSED ] 6 tests.
- How to use Google Test on Android-4.0.3_r1
- How to use OpenID to sign on with Google account
- How to use tcpdump on Android
- How to use unity CreateExternalTexture on Android?
- how to use google
- how to use Google
- How to Use Google AdSense Ads on Responsive Websites
- How To Use Netcat to Establish and Test TCP and UDP Connections on a VPS
- how to use HW accelerated video codec on android
- How to Use Android ADB Command Line Tool on mac
- How to run test cases on android-ndk
- How to use Google to Hack(Googledorks)
- How to use Softether to visit google
- How-to create a Calculator on Google Android: Part I
- How to use "mount.cifs" on ESX
- how to use struct on c++
- How to use vi on linux
- how to use onSearchRequested on Fragment
- 求数组的最长递增子序列的长度
- 查好友ios1.0总结II:开发节奏的把握
- Android 4.0.4 data call fail - 数据激活失败处理机制
- java调试技巧
- 出兵钓鱼岛
- How to use Google Test on Android-4.0.3_r1
- Java中十个常见的违规编码
- 应该记住的*8位java任务
- J2EE打开本地程序
- J2EE性能
- 自動光圈
- MTF(Modulation Transfer Function)
- JNDI
- 超低倍率TELECENTRIC鏡頭