Home | History | Annotate | Download | only in test
      1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import("//build/config/ui.gni")
      6 import("//build/config/nacl/config.gni")
      7 
      8 if (is_android) {
      9   import("//build/config/android/rules.gni")
     10 }
     11 
     12 source_set("test_config") {
     13   # TODO http://crbug.com/412064 enable this flag all the time.
     14   testonly = !is_component_build
     15   sources = [
     16     "test_switches.cc",
     17     "test_switches.h",
     18     "test_timeouts.cc",
     19     "test_timeouts.h",
     20   ]
     21   deps = [
     22     "//base",
     23   ]
     24 }
     25 
     26 # GYP: //base/base.gyp:test_support_base
     27 source_set("test_support") {
     28   # TODO http://crbug.com/412064 enable this flag all the time.
     29   testonly = !is_component_build
     30   sources = [
     31     "gtest_util.cc",
     32     "gtest_util.h",
     33     "gtest_xml_unittest_result_printer.cc",
     34     "gtest_xml_unittest_result_printer.h",
     35     "gtest_xml_util.cc",
     36     "gtest_xml_util.h",
     37     "histogram_tester.cc",
     38     "histogram_tester.h",
     39     "ios/wait_util.h",
     40     "ios/wait_util.mm",
     41     "launcher/test_result.cc",
     42     "launcher/test_result.h",
     43     "launcher/test_results_tracker.h",
     44     "launcher/unit_test_launcher.h",
     45     "mock_chrome_application_mac.h",
     46     "mock_chrome_application_mac.mm",
     47     "mock_devices_changed_observer.cc",
     48     "mock_devices_changed_observer.h",
     49     "mock_entropy_provider.cc",
     50     "mock_entropy_provider.h",
     51     "mock_log.cc",
     52     "mock_log.h",
     53     "multiprocess_test.h",
     54     "null_task_runner.cc",
     55     "null_task_runner.h",
     56     "opaque_ref_counted.cc",
     57     "opaque_ref_counted.h",
     58     "perf_log.cc",
     59     "perf_log.h",
     60     "perf_test_suite.cc",
     61     "perf_test_suite.h",
     62     "perf_time_logger.cc",
     63     "perf_time_logger.h",
     64     "power_monitor_test_base.cc",
     65     "power_monitor_test_base.h",
     66     "scoped_locale.cc",
     67     "scoped_locale.h",
     68     "scoped_path_override.cc",
     69     "scoped_path_override.h",
     70     "sequenced_task_runner_test_template.cc",
     71     "sequenced_task_runner_test_template.h",
     72     "sequenced_worker_pool_owner.cc",
     73     "sequenced_worker_pool_owner.h",
     74     "simple_test_clock.cc",
     75     "simple_test_clock.h",
     76     "simple_test_tick_clock.cc",
     77     "simple_test_tick_clock.h",
     78     "task_runner_test_template.cc",
     79     "task_runner_test_template.h",
     80     "test_discardable_memory_allocator.cc",
     81     "test_discardable_memory_allocator.h",
     82     "test_file_util.cc",
     83     "test_file_util.h",
     84     "test_file_util_android.cc",
     85     "test_file_util_linux.cc",
     86     "test_file_util_mac.cc",
     87     "test_file_util_posix.cc",
     88     "test_file_util_win.cc",
     89     "test_io_thread.cc",
     90     "test_io_thread.h",
     91     "test_listener_ios.h",
     92     "test_listener_ios.mm",
     93     "test_mock_time_task_runner.cc",
     94     "test_mock_time_task_runner.h",
     95     "test_pending_task.cc",
     96     "test_pending_task.h",
     97     "test_reg_util_win.cc",
     98     "test_reg_util_win.h",
     99     "test_shortcut_win.cc",
    100     "test_shortcut_win.h",
    101     "test_simple_task_runner.cc",
    102     "test_simple_task_runner.h",
    103     "test_suite.cc",
    104     "test_suite.h",
    105     "test_support_android.cc",
    106     "test_support_android.h",
    107     "test_support_ios.h",
    108     "test_support_ios.mm",
    109     "test_ui_thread_android.cc",
    110     "test_ui_thread_android.h",
    111     "thread_test_helper.cc",
    112     "thread_test_helper.h",
    113     "trace_event_analyzer.cc",
    114     "trace_event_analyzer.h",
    115     "trace_to_file.cc",
    116     "trace_to_file.h",
    117     "user_action_tester.cc",
    118     "user_action_tester.h",
    119     "values_test_util.cc",
    120     "values_test_util.h",
    121   ]
    122 
    123   if (is_ios) {
    124     sources += [ "launcher/unit_test_launcher_ios.cc" ]
    125   } else if (!is_nacl_nonsfi) {
    126     sources += [
    127       "launcher/test_launcher.cc",
    128       "launcher/test_launcher.h",
    129       "launcher/test_results_tracker.cc",
    130       "launcher/unit_test_launcher.cc",
    131       "multiprocess_test.cc",
    132       "multiprocess_test_android.cc",
    133     ]
    134   }
    135 
    136   configs += [ "//build/config:precompiled_headers" ]
    137 
    138   data = [
    139     # The isolate needs this script for setting up the test. It's not actually
    140     # needed to run this target locally.
    141     "//testing/test_env.py",
    142   ]
    143 
    144   public_deps = [
    145     ":test_config",
    146     "//base",
    147     "//base:base_static",
    148     "//base:i18n",
    149   ]
    150   deps = [
    151     "//base/third_party/dynamic_annotations",
    152     "//testing/gmock",
    153     "//testing/gtest",
    154     "//third_party/icu:icuuc",
    155     "//third_party/libxml",
    156   ]
    157 
    158   if (!is_posix) {
    159     sources -= [
    160       "scoped_locale.cc",
    161       "scoped_locale.h",
    162     ]
    163   }
    164 
    165   if (is_ios) {
    166     set_sources_assignment_filter([])
    167     sources += [ "test_file_util_mac.cc" ]
    168     set_sources_assignment_filter(sources_assignment_filter)
    169   }
    170 
    171   if (is_android) {
    172     deps += [ ":base_unittests_jni_headers" ]
    173   }
    174 
    175   if (is_nacl_nonsfi) {
    176     sources += [
    177       "launcher/test_launcher.h",
    178       "launcher/test_result.h",
    179       "launcher/unit_test_launcher.h",
    180       "launcher/unit_test_launcher_nacl_nonsfi.cc",
    181     ]
    182     sources -= [
    183       "gtest_xml_util.cc",
    184       "gtest_xml_util.h",
    185       "perf_test_suite.cc",
    186       "perf_test_suite.h",
    187       "scoped_path_override.cc",
    188       "scoped_path_override.h",
    189       "test_discardable_memory_allocator.cc",
    190       "test_discardable_memory_allocator.h",
    191       "test_file_util.cc",
    192       "test_file_util.h",
    193       "test_file_util_posix.cc",
    194       "test_suite.cc",
    195       "test_suite.h",
    196       "trace_to_file.cc",
    197       "trace_to_file.h",
    198     ]
    199     public_deps -= [ "//base:i18n" ]
    200     deps -= [
    201       "//third_party/icu:icuuc",
    202       "//third_party/libxml",
    203     ]
    204   }
    205 }
    206 
    207 config("perf_test_config") {
    208   defines = [ "PERF_TEST" ]
    209 }
    210 
    211 source_set("test_support_perf") {
    212   testonly = true
    213   sources = [
    214     "run_all_perftests.cc",
    215   ]
    216   deps = [
    217     ":test_support",
    218     "//base",
    219     "//testing/gtest",
    220   ]
    221 
    222   public_configs = [ ":perf_test_config" ]
    223 }
    224 
    225 source_set("test_launcher_nacl_nonsfi") {
    226   testonly = true
    227   sources = [
    228     "launcher/test_launcher_nacl_nonsfi.cc",
    229     "launcher/test_launcher_nacl_nonsfi.h",
    230   ]
    231   deps = [
    232     ":test_support",
    233   ]
    234 }
    235 
    236 source_set("run_all_unittests") {
    237   testonly = true
    238   sources = [
    239     "run_all_unittests.cc",
    240   ]
    241   deps = [
    242     ":test_support",
    243   ]
    244 }
    245 
    246 if (is_linux) {
    247   shared_library("malloc_wrapper") {
    248     testonly = true
    249     sources = [
    250       "malloc_wrapper.cc",
    251     ]
    252     deps = [
    253       "//base",
    254       "//build/config/sanitizers:deps",
    255     ]
    256   }
    257 }
    258 
    259 if (is_android) {
    260   generate_jni("base_unittests_jni_headers") {
    261     sources = [
    262       "android/java/src/org/chromium/base/ContentUriTestUtils.java",
    263       "android/java/src/org/chromium/base/TestUiThread.java",
    264     ]
    265     jni_package = "base"
    266   }
    267 }
    268