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