diff options
-rw-r--r-- | base/base.gyp | 47 | ||||
-rw-r--r-- | build/apk_test.gypi | 55 | ||||
-rw-r--r-- | content/content_tests.gypi | 32 | ||||
-rw-r--r-- | ipc/ipc.gyp | 43 | ||||
-rw-r--r-- | net/net.gyp | 34 | ||||
-rwxr-xr-x | testing/android/generate_native_test.py | 10 | ||||
-rw-r--r-- | ui/ui_unittests.gypi | 43 |
7 files changed, 155 insertions, 109 deletions
diff --git a/base/base.gyp b/base/base.gyp index 99c826c..60fa8ab 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -312,7 +312,7 @@ 'android/jni_generator/jni_generator.gyp:jni_generator_tests', ], 'conditions': [ - ['"<(gtest_target_type)"=="shared_library"', { + ['gtest_target_type == "shared_library"', { 'dependencies': [ '../testing/android/native_test.gyp:native_test_native_code', ], @@ -643,54 +643,27 @@ }, ], }], - # Special target to wrap a <(gtest_target_type)==shared_library + # Special target to wrap a gtest_target_type == shared_library # base_unittests into an android apk for execution. # TODO(jrg): lib.target comes from _InstallableTargetInstallPath() # in the gyp make generator. What is the correct way to extract # this path from gyp and into 'raw' for input to antfiles? # Hard-coding in the gypfile seems a poor choice. - # TODO(jrg): there has to be a shorter way to do all this. Try - # and convert this entire target cluster into ~5 lines that can be - # trivially copied to other projects with only a deps change, such - # as with a new gtest_target_type called - # 'shared_library_apk_wrapper' that does a lot of this magically. - ['OS=="android" and "<(gtest_target_type)"=="shared_library"', { + ['OS == "android" and gtest_target_type == "shared_library"', { 'targets': [ { 'target_name': 'base_unittests_apk', 'type': 'none', 'dependencies': [ - 'base', # So that android/java/java.gyp:base_java is built + 'base_java', 'base_unittests', ], - 'actions': [ - { - # Generate apk files (including source and antfile) from - # a template, and builds them. - 'action_name': 'generate_and_build', - 'inputs': [ - '../testing/android/AndroidManifest.xml', - '../testing/android/generate_native_test.py', - '<(PRODUCT_DIR)/lib.target/libbase_unittests.so', - '<(PRODUCT_DIR)/lib.java/chromium_base.jar' - ], - 'outputs': [ - '<(PRODUCT_DIR)/base_unittests_apk/base_unittests-debug.apk', - ], - 'action': [ - '../testing/android/generate_native_test.py', - '--native_library', - '<(PRODUCT_DIR)/lib.target/libbase_unittests.so', - '--jar', - '<(PRODUCT_DIR)/lib.java/chromium_base.jar', - '--output', - '<(PRODUCT_DIR)/base_unittests_apk', - '--ant-args', - '-DPRODUCT_DIR=<(PRODUCT_DIR)', - '--ant-compile' - ], - }, - ] + 'variables': { + 'test_suite_name': 'base_unittests', + 'input_shlib_path': '<(PRODUCT_DIR)/lib.target/<(SHARED_LIB_PREFIX)base_unittests<(SHARED_LIB_SUFFIX)', + 'input_jars_paths': ['<(PRODUCT_DIR)/lib.java/chromium_base.jar',], + }, + 'includes': [ '../build/apk_test.gypi' ], }], }], ], diff --git a/build/apk_test.gypi b/build/apk_test.gypi new file mode 100644 index 0000000..e982bdd --- /dev/null +++ b/build/apk_test.gypi @@ -0,0 +1,55 @@ +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This file is meant to be included into a target to provide a rule +# to build APK based test suites. +# +# To use this, create a gyp target with the following form: +# { +# 'target_name': 'test_suite_name_apk', +# 'type': 'none', +# 'variables': { +# 'test_suite_name': 'test_suite_name', # string +# 'input_shlib_path' : '/path/to/test_suite.so', # string +# 'input_jars_paths': ['/path/to/test_suite.jar', ... ], # list +# }, +# 'includes': ['path/to/this/gypi/file'], +# } +# + +{ + 'target_conditions': [ + ['_toolset == "target"', { + 'conditions': [ + ['OS == "android" and gtest_target_type == "shared_library"', { + 'actions': [{ + 'action_name': 'apk_<(test_suite_name)', + 'message': 'Building <(test_suite_name) test apk.', + 'inputs': [ + '<(DEPTH)/testing/android/AndroidManifest.xml', + '<(DEPTH)/testing/android/generate_native_test.py', + '<(input_shlib_path)', + '<@(input_jars_paths)', + ], + 'outputs': [ + '<(PRODUCT_DIR)/<(test_suite_name)_apk/<(test_suite_name)-debug.apk', + ], + 'action': [ + '<(DEPTH)/testing/android/generate_native_test.py', + '--native_library', + '<(input_shlib_path)', + '--jars', + '"<@(input_jars_paths)"', + '--output', + '<(PRODUCT_DIR)/<(test_suite_name)_apk', + '--ant-args', + '-DPRODUCT_DIR=<(PRODUCT_DIR)', + '--ant-compile' + ], + }], + }], # 'OS == "android" and gtest_target_type == "shared_library" + ], # conditions + }], + ], # target_conditions +} diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 224c4f4..00619a4 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -162,7 +162,7 @@ }, { 'target_name': 'content_unittests', - 'type': 'executable', + 'type': '<(gtest_target_type)', 'defines!': ['CONTENT_IMPLEMENTATION'], 'dependencies': [ 'content_browser', @@ -400,6 +400,11 @@ 'browser/geolocation/wifi_data_provider_linux_unittest.cc', ], }], + ['OS == "android" and gtest_target_type == "shared_library"', { + 'dependencies': [ + '../testing/android/native_test.gyp:native_test_native_code', + ] + }], ], }, { @@ -540,5 +545,30 @@ } ], }], + # Special target to wrap a gtest_target_type==shared_library + # content_unittests into an android apk for execution. + # See base.gyp for TODO(jrg)s about this strategy. + ['OS == "android" and gtest_target_type == "shared_library"', { + 'targets': [ + { + 'target_name': 'content_unittests_apk', + 'type': 'none', + 'dependencies': [ + '../base/base.gyp:base_java', + 'content_java', + 'content_unittests', + ], + 'variables': { + 'test_suite_name': 'content_unittests', + 'input_shlib_path': '<(PRODUCT_DIR)/lib.target/<(SHARED_LIB_PREFIX)content_unittests<(SHARED_LIB_SUFFIX)', + 'input_jars_paths': [ + '<(PRODUCT_DIR)/lib.java/chromium_base.jar', + '<(PRODUCT_DIR)/lib.java/chromium_content.jar', + ], + }, + 'includes': [ '../build/apk_test.gypi' ], + }, + ], + }], ], } diff --git a/ipc/ipc.gyp b/ipc/ipc.gyp index 0e72df5..f8bacdd 100644 --- a/ipc/ipc.gyp +++ b/ipc/ipc.gyp @@ -63,7 +63,7 @@ '../build/linux/system.gyp:gtk', ], }], - ['OS=="android" and "<(gtest_target_type)"=="shared_library"', { + ['OS == "android" and gtest_target_type == "shared_library"', { 'dependencies': [ '../testing/android/native_test.gyp:native_test_native_code', ], @@ -93,47 +93,24 @@ }, ], 'conditions': [ - # Special target to wrap a <(gtest_target_type)==shared_library + # Special target to wrap a gtest_target_type==shared_library # ipc_tests into an android apk for execution. # See base.gyp for TODO(jrg)s about this strategy. - ['OS=="android" and "<(gtest_target_type)"=="shared_library"', { + ['OS == "android" and gtest_target_type == "shared_library"', { 'targets': [ { 'target_name': 'ipc_tests_apk', 'type': 'none', 'dependencies': [ + '../base/base.gyp:base_java', 'ipc_tests', ], - 'actions': [ - { - # Generate apk files (including source and antfile) from - # a template, and builds them. - 'action_name': 'generate_and_build', - 'inputs': [ - '../testing/android/AndroidManifest.xml', - '../testing/android/generate_native_test.py', - '<(PRODUCT_DIR)/lib.target/libipc_tests.so', - '<(PRODUCT_DIR)/lib.java/chromium_base.jar' - ], - 'outputs': [ - '<(PRODUCT_DIR)/ipc_tests_apk/ipc_tests-debug.apk', - ], - 'action': [ - '../testing/android/generate_native_test.py', - '--native_library', - '<(PRODUCT_DIR)/lib.target/libipc_tests.so', - # TODO(jrg): find a better way to specify jar - # dependencies. Hard coding seems fragile. - '--jar', - '<(PRODUCT_DIR)/lib.java/chromium_base.jar', - '--output', - '<(PRODUCT_DIR)/ipc_tests_apk', - '--ant-args', - '-DPRODUCT_DIR=<(PRODUCT_DIR)', - '--ant-compile' - ], - }, - ], + 'variables': { + 'test_suite_name': 'ipc_tests', + 'input_shlib_path': '<(PRODUCT_DIR)/lib.target/<(SHARED_LIB_PREFIX)ipc_tests<(SHARED_LIB_SUFFIX)', + 'input_jars_paths': ['<(PRODUCT_DIR)/lib.java/chromium_base.jar',], + }, + 'includes': [ '../build/apk_test.gypi' ], }], }], ], diff --git a/net/net.gyp b/net/net.gyp index ccd8d06..b347646 100644 --- a/net/net.gyp +++ b/net/net.gyp @@ -1032,7 +1032,7 @@ }, { 'target_name': 'net_unittests', - 'type': 'executable', + 'type': '<(gtest_target_type)', 'dependencies': [ 'net', 'net_test_support', @@ -1369,6 +1369,11 @@ ], }, ], + ['OS == "android" and gtest_target_type == "shared_library"', { + 'dependencies': [ + '../testing/android/native_test.gyp:native_test_native_code', + ] + }], [ 'OS != "win" and OS != "mac"', { 'sources!': [ 'base/x509_cert_types_unittest.cc', @@ -1542,7 +1547,7 @@ 'test/local_test_server.cc', 'test/local_test_server.h', 'test/python_utils.cc', - 'test/python_utils.h', + 'test/python_utils.h', 'test/remote_test_server.cc', 'test/remote_test_server.h', 'test/spawner_communicator.cc', @@ -1844,6 +1849,31 @@ }, ], }], + # Special target to wrap a gtest_target_type==shared_library + # net_unittests into an android apk for execution. + # See base.gyp for TODO(jrg)s about this strategy. + ['OS == "android" and gtest_target_type == "shared_library"', { + 'targets': [ + { + 'target_name': 'net_unittests_apk', + 'type': 'none', + 'dependencies': [ + '../base/base.gyp:base_java', + 'net_java', + 'net_unittests', + ], + 'variables': { + 'test_suite_name': 'net_unittests', + 'input_shlib_path': '<(PRODUCT_DIR)/lib.target/<(SHARED_LIB_PREFIX)net_unittests<(SHARED_LIB_SUFFIX)', + 'input_jars_paths': [ + '<(PRODUCT_DIR)/lib.java/chromium_base.jar', + '<(PRODUCT_DIR)/lib.java/chromium_net.jar', + ], + }, + 'includes': [ '../build/apk_test.gypi' ], + }, + ], + }], ['OS=="win"', { 'targets': [ { diff --git a/testing/android/generate_native_test.py b/testing/android/generate_native_test.py index 2062144..bd7c136 100755 --- a/testing/android/generate_native_test.py +++ b/testing/android/generate_native_test.py @@ -168,8 +168,8 @@ def main(argv): help='Be verbose') parser.add_option('--native_library', help='Full name of native shared library test bundle') - parser.add_option('--jar', action='append', - help='Include this jar; can be specified multiple times') + parser.add_option('--jars', + help='Space separated list of jars to be included') parser.add_option('--output', help='Output directory for generated files.') parser.add_option('--ant-compile', action='store_true', @@ -188,8 +188,12 @@ def main(argv): if options.verbose: logging.basicConfig(level=logging.DEBUG, format=' %(message)s') + # Remove all quotes from the jars string + jar_list = [] + if options.jars: + jar_list = options.jars.replace('"', '').split() ntag = NativeTestApkGenerator(native_library=options.native_library, - jars=options.jar, + jars=jar_list, output_directory=options.output) ntag.CreateBundle() if options.ant_compile: diff --git a/ui/ui_unittests.gypi b/ui/ui_unittests.gypi index f9c9c78..038d037 100644 --- a/ui/ui_unittests.gypi +++ b/ui/ui_unittests.gypi @@ -151,7 +151,7 @@ 'gfx/interpolated_transform_unittest.cc', ], }], - ['OS=="android" and "<(gtest_target_type)"=="shared_library"', { + ['OS == "android" and gtest_target_type == "shared_library"', { 'dependencies': [ '../testing/android/native_test.gyp:native_test_native_code', ], @@ -209,47 +209,24 @@ }, ], 'conditions': [ - # Special target to wrap a <(gtest_target_type)==shared_library + # Special target to wrap a gtest_target_type==shared_library # ui_unittests into an android apk for execution. # See base.gyp for TODO(jrg)s about this strategy. - ['OS=="android" and "<(gtest_target_type)"=="shared_library"', { + ['OS == "android" and gtest_target_type == "shared_library"', { 'targets': [ { 'target_name': 'ui_unittests_apk', 'type': 'none', 'dependencies': [ + '../base/base.gyp:base_java', 'ui_unittests', ], - 'actions': [ - { - # Generate apk files (including source and antfile) from - # a template, and builds them. - 'action_name': 'generate_and_build', - 'inputs': [ - '../testing/android/AndroidManifest.xml', - '../testing/android/generate_native_test.py', - '<(PRODUCT_DIR)/lib.target/libui_unittests.so', - '<(PRODUCT_DIR)/lib.java/chromium_base.jar', - ], - 'outputs': [ - '<(PRODUCT_DIR)/ui_unittests_apk/ui_unittests-debug.apk', - ], - 'action': [ - '../testing/android/generate_native_test.py', - '--native_library', - '<(PRODUCT_DIR)/lib.target/libui_unittests.so', - # TODO(jrg): find a better way to specify jar - # dependencies. Hard coding seems fragile. - '--jar', - '<(PRODUCT_DIR)/lib.java/chromium_base.jar', - '--output', - '<(PRODUCT_DIR)/ui_unittests_apk', - '--ant-args', - '-DPRODUCT_DIR=<(PRODUCT_DIR)', - '--ant-compile' - ], - }, - ] + 'variables': { + 'test_suite_name': 'ui_unittests', + 'input_shlib_path': '<(PRODUCT_DIR)/lib.target/<(SHARED_LIB_PREFIX)ui_unittests<(SHARED_LIB_SUFFIX)', + 'input_jars_paths': ['<(PRODUCT_DIR)/lib.java/chromium_base.jar',], + }, + 'includes': [ '../build/apk_test.gypi' ], }, ], }], |