blob: c6f2f4d2e6e0e9651d32017ad72fdadaf68afa74 [file] [log] [blame]
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +00001# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
2#
3# Use of this source code is governed by a BSD-style license
4# that can be found in the LICENSE file in the root of the source
5# tree. An additional intellectual property rights grant can be found
6# in the file PATENTS. All contributing project authors may
7# be found in the AUTHORS file in the root of the source tree.
8
ehmaldonado38a21322016-09-02 04:10:34 -07009import("../build/webrtc.gni")
kjellander0f380d82016-06-01 04:48:26 -070010import("//build/config/ui.gni")
kjellander0f380d82016-06-01 04:48:26 -070011if (is_android) {
12 import("//build/config/android/rules.gni")
13}
ehmaldonadoed8c8ed2016-11-23 12:58:35 -080014if (rtc_use_memcheck) {
15 import("//tools/valgrind-webrtc/valgrind-webrtc.gni")
16}
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +000017
kjellanderb62dbbe2016-09-23 00:38:52 -070018group("test") {
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +000019 testonly = true
20
21 deps = [
22 ":field_trial",
kjellander0f380d82016-06-01 04:48:26 -070023 ":rtp_test_utils",
24 ":test_common",
25 ":test_renderer",
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +000026 ":test_support",
27 ":test_support_main",
kjellander0f380d82016-06-01 04:48:26 -070028 ":test_support_unittests",
29 ":video_test_common",
30 ]
31}
32
ehmaldonado38a21322016-09-02 04:10:34 -070033rtc_source_set("video_test_common") {
kjellander0f380d82016-06-01 04:48:26 -070034 testonly = true
35 sources = [
36 "fake_texture_frame.cc",
37 "fake_texture_frame.h",
38 "frame_generator.cc",
39 "frame_generator.h",
40 "frame_utils.cc",
41 "frame_utils.h",
42 ]
43
kjellandere40a7ee2016-10-16 23:56:12 -070044 if (!build_with_chromium && is_clang) {
45 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
ehmaldonado38a21322016-09-02 04:10:34 -070046 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
kjellander0f380d82016-06-01 04:48:26 -070047 }
48
49 deps = [
50 "../common_video",
51 ]
52}
53
ehmaldonado38a21322016-09-02 04:10:34 -070054rtc_source_set("rtp_test_utils") {
kjellander0f380d82016-06-01 04:48:26 -070055 testonly = true
56 sources = [
57 "rtcp_packet_parser.cc",
58 "rtcp_packet_parser.h",
59 "rtp_file_reader.cc",
60 "rtp_file_reader.h",
61 "rtp_file_writer.cc",
62 "rtp_file_writer.h",
63 ]
64
kjellandere40a7ee2016-10-16 23:56:12 -070065 if (!build_with_chromium && is_clang) {
66 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
ehmaldonado38a21322016-09-02 04:10:34 -070067 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
kjellander0f380d82016-06-01 04:48:26 -070068 }
69
70 deps = [
71 "..:webrtc_common",
72 "../modules/rtp_rtcp",
73 "//testing/gtest",
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +000074 ]
75}
76
ehmaldonado38a21322016-09-02 04:10:34 -070077rtc_source_set("field_trial") {
kjellander0f380d82016-06-01 04:48:26 -070078 testonly = true
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +000079 sources = [
80 "field_trial.cc",
81 "field_trial.h",
82 ]
83
84 deps = [
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +000085 "..:webrtc_common",
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +000086 "../system_wrappers",
phoglund37ebcf02016-01-08 05:04:57 -080087 "../system_wrappers:field_trial_default",
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +000088 ]
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +000089}
90
ehmaldonado38a21322016-09-02 04:10:34 -070091rtc_source_set("test_main") {
kjellander0f380d82016-06-01 04:48:26 -070092 testonly = true
93 sources = [
94 "test_main.cc",
95 ]
96
97 deps = [
98 ":field_trial",
99 ":test_support",
100 "../system_wrappers:metrics_default",
101 "//testing/gtest",
102 "//third_party/gflags",
103 ]
kjellander0f380d82016-06-01 04:48:26 -0700104}
105
ehmaldonado38a21322016-09-02 04:10:34 -0700106rtc_source_set("test_support") {
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000107 testonly = true
108
109 sources = [
kwiberg77eab702016-09-28 17:42:01 -0700110 "gmock.h",
111 "gtest.h",
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000112 "testsupport/fileutils.cc",
113 "testsupport/fileutils.h",
114 "testsupport/frame_reader.cc",
115 "testsupport/frame_reader.h",
116 "testsupport/frame_writer.cc",
117 "testsupport/frame_writer.h",
kjellander95177d12016-04-07 00:13:58 -0700118 "testsupport/iosfileutils.mm",
Peter Boström02083222016-06-14 12:52:54 +0200119 "testsupport/metrics/video_metrics.cc",
120 "testsupport/metrics/video_metrics.h",
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000121 "testsupport/mock/mock_frame_reader.h",
122 "testsupport/mock/mock_frame_writer.h",
123 "testsupport/packet_reader.cc",
124 "testsupport/packet_reader.h",
125 "testsupport/perf_test.cc",
126 "testsupport/perf_test.h",
127 "testsupport/trace_to_stderr.cc",
128 "testsupport/trace_to_stderr.h",
129 ]
130
131 deps = [
nisse115bd152016-09-30 04:14:07 -0700132 ":video_test_common",
kjellander988d31e2016-02-05 00:23:50 -0800133 "../base:gtest_prod",
kwiberg77eab702016-09-28 17:42:01 -0700134 "../base:rtc_base_approved",
Peter Boström02083222016-06-14 12:52:54 +0200135 "../common_video",
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000136 "../system_wrappers",
Peter Boström62e9bda2015-11-23 15:12:06 +0100137 "//testing/gmock",
138 "//testing/gtest",
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000139 ]
140
kjellandere40a7ee2016-10-16 23:56:12 -0700141 if (!build_with_chromium && is_clang) {
142 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
ehmaldonado38a21322016-09-02 04:10:34 -0700143 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
Peter Boström02083222016-06-14 12:52:54 +0200144 }
145
kjellander95177d12016-04-07 00:13:58 -0700146 if (is_ios) {
kjellander0f380d82016-06-01 04:48:26 -0700147 configs += [ "//build/config/compiler:enable_arc" ]
148 }
149
150 if (use_x11) {
151 deps += [ "//tools/xdisplaycheck" ]
kjellander95177d12016-04-07 00:13:58 -0700152 }
153
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000154 if (is_android) {
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000155 deps += [ "//base:base" ]
kjellander847f6892016-11-28 02:04:38 -0800156 data = [
157 "../build/android/test_runner.py",
158 ]
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000159 }
ehmaldonadoed8c8ed2016-11-23 12:58:35 -0800160
161 if (rtc_use_memcheck) {
162 data = valgrind_webrtc_dependencies
163 }
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000164}
165
kjellander0f380d82016-06-01 04:48:26 -0700166# Depend on this target when you want to have test_support but also the
167# main method needed for gtest to execute!
ehmaldonado38a21322016-09-02 04:10:34 -0700168rtc_source_set("test_support_main") {
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000169 testonly = true
170
171 sources = [
172 "run_all_unittests.cc",
173 "test_suite.cc",
174 "test_suite.h",
175 ]
176
177 deps = [
178 ":field_trial",
179 ":test_support",
asapersson01d70a32016-05-20 06:29:46 -0700180 "../system_wrappers:metrics_default",
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000181 "//testing/gmock",
182 "//testing/gtest",
183 "//third_party/gflags",
184 ]
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000185}
kjellander0f380d82016-06-01 04:48:26 -0700186
187# Depend on this target when you want to have test_support and a special
188# main for mac which will run your test on a worker thread and consume
189# events on the main thread. Useful if you want to access a webcam.
190# This main will provide all the scaffolding and objective-c black magic
191# for you. All you need to do is to implement a function in the
192# run_threaded_main_mac.h file (ImplementThisToRunYourTest).
ehmaldonado38a21322016-09-02 04:10:34 -0700193rtc_source_set("test_support_main_threaded_mac") {
kjellander0f380d82016-06-01 04:48:26 -0700194 testonly = true
195
196 sources = [
197 "testsupport/mac/run_threaded_main_mac.h",
198 "testsupport/mac/run_threaded_main_mac.mm",
199 ]
200
kjellander0f380d82016-06-01 04:48:26 -0700201 deps = [
202 ":test_support",
203 ]
204}
205
kjellandera3cac052016-10-24 01:52:39 -0700206rtc_source_set("run_test") {
207 testonly = true
208 sources = [
209 "run_test.h",
210 ]
211 if (is_mac) {
212 sources += [ "mac/run_test.mm" ]
213 } else {
214 sources += [ "run_test.cc" ]
215 }
216}
217
ehmaldonado3a7f35b2016-09-14 05:10:01 -0700218test_support_unittests_resources = [
219 "//resources/foreman_cif_short.yuv",
220 "//resources/video_coding/frame-ethernet-ii.pcap",
221 "//resources/video_coding/frame-loopback.pcap",
222 "//resources/video_coding/pltype103.rtp",
223 "//resources/video_coding/pltype103_header_only.rtp",
224 "//resources/video_coding/ssrcs-2.pcap",
225 "//resources/video_coding/ssrcs-3.pcap",
226]
kjellander32c4a202016-08-30 02:53:49 -0700227
228if (is_ios) {
229 bundle_data("test_support_unittests_bundle_data") {
230 testonly = true
231 sources = test_support_unittests_resources
232 outputs = [
233 "{{bundle_resources_dir}}/{{source_file_part}}",
234 ]
235 }
236}
237
ehmaldonado38a21322016-09-02 04:10:34 -0700238rtc_test("test_support_unittests") {
kjellander0f380d82016-06-01 04:48:26 -0700239 deps = []
240 sources = [
kjellander0f380d82016-06-01 04:48:26 -0700241 "fake_network_pipe_unittest.cc",
242 "frame_generator_unittest.cc",
243 "rtp_file_reader_unittest.cc",
244 "rtp_file_writer_unittest.cc",
245 "testsupport/always_passing_unittest.cc",
246 "testsupport/fileutils_unittest.cc",
247 "testsupport/frame_reader_unittest.cc",
248 "testsupport/frame_writer_unittest.cc",
Peter Boström02083222016-06-14 12:52:54 +0200249 "testsupport/metrics/video_metrics_unittest.cc",
kjellander0f380d82016-06-01 04:48:26 -0700250 "testsupport/packet_reader_unittest.cc",
251 "testsupport/perf_test_unittest.cc",
252 "testsupport/unittest_utils.h",
253 ]
254
kjellander8f4419b2016-06-02 02:09:52 -0700255 # TODO(jschuh): Bug 1348: fix this warning.
256 configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
257
kjellander0f380d82016-06-01 04:48:26 -0700258 if (is_win) {
kjellander8f4419b2016-06-02 02:09:52 -0700259 cflags = [ "/wd4373" ] # virtual override w/different const/volatile signature.
kjellander0f380d82016-06-01 04:48:26 -0700260 }
261
kjellandere40a7ee2016-10-16 23:56:12 -0700262 if (!build_with_chromium && is_clang) {
263 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
ehmaldonado38a21322016-09-02 04:10:34 -0700264 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
kjellander0f380d82016-06-01 04:48:26 -0700265 }
266
ehmaldonado3a7f35b2016-09-14 05:10:01 -0700267 data = test_support_unittests_resources
kjellander0f380d82016-06-01 04:48:26 -0700268 if (is_android) {
269 deps += [ "//testing/android/native_test:native_test_support" ]
kjellander28a0ffd2016-08-24 07:48:42 -0700270 shard_timeout = 900
271 }
kjellander0f380d82016-06-01 04:48:26 -0700272
kjellander32c4a202016-08-30 02:53:49 -0700273 if (is_ios) {
274 deps += [ ":test_support_unittests_bundle_data" ]
kjellander0f380d82016-06-01 04:48:26 -0700275 }
kjellander28a0ffd2016-08-24 07:48:42 -0700276
kjellander0f380d82016-06-01 04:48:26 -0700277 deps += [
kjellander0f380d82016-06-01 04:48:26 -0700278 ":test_common",
279 ":test_support_main",
280 "../modules/video_capture",
281 "//testing/gmock",
282 "//testing/gtest",
283 ]
284}
285
ehmaldonado38a21322016-09-02 04:10:34 -0700286rtc_source_set("test_common") {
kjellander0f380d82016-06-01 04:48:26 -0700287 testonly = true
288 sources = [
289 "call_test.cc",
290 "call_test.h",
291 "configurable_frame_size_encoder.cc",
292 "configurable_frame_size_encoder.h",
293 "constants.cc",
294 "constants.h",
295 "direct_transport.cc",
296 "direct_transport.h",
297 "drifting_clock.cc",
298 "drifting_clock.h",
299 "encoder_settings.cc",
300 "encoder_settings.h",
301 "fake_audio_device.cc",
302 "fake_audio_device.h",
303 "fake_decoder.cc",
304 "fake_decoder.h",
305 "fake_encoder.cc",
306 "fake_encoder.h",
307 "fake_network_pipe.cc",
308 "fake_network_pipe.h",
sakal55d932b2016-09-30 06:19:08 -0700309 "fake_videorenderer.h",
kjellander0f380d82016-06-01 04:48:26 -0700310 "frame_generator_capturer.cc",
311 "frame_generator_capturer.h",
312 "layer_filtering_transport.cc",
313 "layer_filtering_transport.h",
314 "mock_transport.h",
315 "mock_voe_channel_proxy.h",
316 "mock_voice_engine.h",
317 "null_transport.cc",
318 "null_transport.h",
319 "rtp_rtcp_observer.h",
320 "statistics.cc",
321 "statistics.h",
322 "vcm_capturer.cc",
323 "vcm_capturer.h",
kjellander0f380d82016-06-01 04:48:26 -0700324 "video_capturer.h",
325 "win/run_loop_win.cc",
326 ]
327 if (!is_win) {
328 sources += [
329 "run_loop.cc",
330 "run_loop.h",
331 ]
332 }
333
kjellandere40a7ee2016-10-16 23:56:12 -0700334 if (!build_with_chromium && is_clang) {
335 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
ehmaldonado38a21322016-09-02 04:10:34 -0700336 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
kjellander0f380d82016-06-01 04:48:26 -0700337 }
338
339 deps = [
340 ":rtp_test_utils",
341 ":test_support",
kjellander0f380d82016-06-01 04:48:26 -0700342 "..:webrtc_common",
aleloia8eb7562016-11-28 07:02:13 -0800343 "../api:transport_api",
kjellander94cee312016-06-10 01:56:57 -0700344 "../audio",
kjellander0f380d82016-06-01 04:48:26 -0700345 "../base:rtc_base_approved",
kjellander94cee312016-06-10 01:56:57 -0700346 "../call",
aleloidd310712016-11-17 06:28:59 -0800347 "../modules/audio_device:mock_audio_device",
aleloi10111bc2016-11-17 06:48:48 -0800348 "../modules/audio_mixer:audio_mixer_impl",
aleloidd310712016-11-17 06:28:59 -0800349 "../modules/audio_processing",
kjellander0f380d82016-06-01 04:48:26 -0700350 "../modules/media_file",
kjellandera3cac052016-10-24 01:52:39 -0700351 "../modules/video_capture:video_capture_module",
kjellander94cee312016-06-10 01:56:57 -0700352 "../video",
kjellander0f380d82016-06-01 04:48:26 -0700353 "//testing/gmock",
354 "//testing/gtest",
kjellander0f380d82016-06-01 04:48:26 -0700355 ]
356}
357
358config("test_renderer_exported_config") {
359 if (is_win && is_clang) {
360 # GN orders flags on a target before flags from configs. The default config
361 # adds -Wall, and this flag have to be after -Wall -- so they need to
362 # come from a config and cannot be on the target directly.
ehmaldonado4bc4d272016-08-25 04:15:40 -0700363 cflags = [
kjellander0f380d82016-06-01 04:48:26 -0700364 "-Wno-bool-conversion",
365 "-Wno-comment",
366 "-Wno-delete-non-virtual-dtor",
367 ]
368 }
369}
370
ehmaldonado38a21322016-09-02 04:10:34 -0700371rtc_source_set("test_renderer") {
kjellander0f380d82016-06-01 04:48:26 -0700372 testonly = true
373 libs = []
374 sources = [
375 "linux/glx_renderer.cc",
376 "linux/glx_renderer.h",
377 "linux/video_renderer_linux.cc",
378 "mac/video_renderer_mac.h",
379 "mac/video_renderer_mac.mm",
380 "video_renderer.cc",
381 "video_renderer.h",
382 "win/d3d_renderer.cc",
383 "win/d3d_renderer.h",
384 ]
385 if (!is_linux && !is_mac && !is_win) {
386 sources += [ "null_platform_renderer.cc" ]
387 }
388 if (is_linux || is_mac) {
389 sources += [
390 "gl/gl_renderer.cc",
391 "gl/gl_renderer.h",
392 ]
393 }
394
395 if (is_linux) {
396 libs += [
397 "Xext",
398 "X11",
399 "GL",
400 ]
401 }
402 if (is_android) {
403 libs += [
404 "GLESv2",
405 "log",
406 ]
407 }
408 if (is_mac) {
409 libs = [
410 "Cocoa.framework",
411 "OpenGL.framework",
412 "CoreVideo.framework",
413 ]
414 }
415
ehmaldonadoe9cc6862016-09-05 06:10:18 -0700416 public_configs = [ ":test_renderer_exported_config" ]
kjellander0f380d82016-06-01 04:48:26 -0700417
kjellandere40a7ee2016-10-16 23:56:12 -0700418 if (!build_with_chromium && is_clang) {
419 # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
ehmaldonado38a21322016-09-02 04:10:34 -0700420 suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
kjellander0f380d82016-06-01 04:48:26 -0700421 }
422
423 deps = [
424 ":test_support",
425 ":video_test_common",
426 "../modules/media_file",
427 "//testing/gtest",
428 ]
429}