diff --git a/webrtc/test/BUILD.gn b/webrtc/test/BUILD.gn index 5951693a50..631645e99a 100644 --- a/webrtc/test/BUILD.gn +++ b/webrtc/test/BUILD.gn @@ -6,19 +6,143 @@ # in the file PATENTS. All contributing project authors may # be found in the AUTHORS file in the root of the source tree. -# TODO(kjellander): Convert the rest of the test.gyp targets and put here. +import("//build/config/ui.gni") +import("//testing/test.gni") +if (is_android) { + import("//build/config/android/rules.gni") +} source_set("test") { testonly = true deps = [ + ":channel_transport", ":field_trial", + ":rtp_test_utils", + ":test_common", + ":test_renderer", ":test_support", ":test_support_main", + ":test_support_unittests", + ":video_test_common", + ] +} + +config("channel_transport_warnings_config") { + if (is_win) { + cflags = [ "/wd4302" ] # cast truncation + + if (is_clang) { + # GN orders flags on a target before flags from configs. The default config + # adds -Wall, and this flag have to be after -Wall -- so they need to + # come from a config and cannot be on the target directly. + cflags += [ + "-Wno-parentheses-equality", + "-Wno-reorder", + "-Wno-tautological-constant-out-of-range-compare", + "-Wno-unused-private-field", + ] + } + } +} + +source_set("channel_transport") { + testonly = true + sources = [ + "channel_transport/channel_transport.cc", + "channel_transport/channel_transport.h", + "channel_transport/traffic_control_win.cc", + "channel_transport/traffic_control_win.h", + "channel_transport/udp_socket2_manager_win.cc", + "channel_transport/udp_socket2_manager_win.h", + "channel_transport/udp_socket2_win.cc", + "channel_transport/udp_socket2_win.h", + "channel_transport/udp_socket_manager_posix.cc", + "channel_transport/udp_socket_manager_posix.h", + "channel_transport/udp_socket_manager_wrapper.cc", + "channel_transport/udp_socket_manager_wrapper.h", + "channel_transport/udp_socket_posix.cc", + "channel_transport/udp_socket_posix.h", + "channel_transport/udp_socket_wrapper.cc", + "channel_transport/udp_socket_wrapper.h", + "channel_transport/udp_transport.h", + "channel_transport/udp_transport_impl.cc", + "channel_transport/udp_transport_impl.h", + ] + + configs += [ + "..:common_config", + ":channel_transport_warnings_config", + ] + public_configs = [ "..:common_inherited_config" ] + + if (is_clang && !is_nacl) { + # Suppress warnings from the Chromium Clang plugin. + # See http://code.google.com/p/webrtc/issues/detail?id=163 for details. + configs -= [ "//build/config/clang:find_bad_constructs" ] + } + + deps = [ + "..:webrtc_common", + "../system_wrappers", + "//testing/gtest", + ] +} + +source_set("video_test_common") { + testonly = true + sources = [ + "fake_texture_frame.cc", + "fake_texture_frame.h", + "frame_generator.cc", + "frame_generator.h", + "frame_utils.cc", + "frame_utils.h", + ] + + configs += [ "..:common_config" ] + public_configs = [ "..:common_inherited_config" ] + + if (is_clang && !is_nacl) { + # Suppress warnings from the Chromium Clang plugin. + # See http://code.google.com/p/webrtc/issues/detail?id=163 for details. + configs -= [ "//build/config/clang:find_bad_constructs" ] + } + + deps = [ + "../common_video", + ] +} + +source_set("rtp_test_utils") { + testonly = true + sources = [ + "rtcp_packet_parser.cc", + "rtcp_packet_parser.h", + "rtp_file_reader.cc", + "rtp_file_reader.h", + "rtp_file_writer.cc", + "rtp_file_writer.h", + ] + + configs += [ "..:common_config" ] + public_configs = [ "..:common_inherited_config" ] + + if (is_clang && !is_nacl) { + # Suppress warnings from the Chromium Clang plugin. + # See http://code.google.com/p/webrtc/issues/detail?id=163 for details. + configs -= [ "//build/config/clang:find_bad_constructs" ] + } + + deps = [ + "..:webrtc_common", + "../modules/rtp_rtcp", + "//testing/gtest", ] } source_set("field_trial") { + testonly = true sources = [ "field_trial.cc", "field_trial.h", @@ -34,6 +158,24 @@ source_set("field_trial") { public_configs = [ "..:common_inherited_config" ] } +source_set("test_main") { + testonly = true + sources = [ + "test_main.cc", + ] + + deps = [ + ":field_trial", + ":test_support", + "../system_wrappers:metrics_default", + "//testing/gtest", + "//third_party/gflags", + ] + + configs += [ "..:common_config" ] + public_configs = [ "..:common_inherited_config" ] +} + source_set("test_support") { testonly = true @@ -63,7 +205,11 @@ source_set("test_support") { ] if (is_ios) { - cflags = [ "-fobjc-arc" ] # CLANG_ENABLE_OBJC_ARC = YES. + configs += [ "//build/config/compiler:enable_arc" ] + } + + if (use_x11) { + deps += [ "//tools/xdisplaycheck" ] } if (is_android) { @@ -74,6 +220,8 @@ source_set("test_support") { public_configs = [ "..:common_inherited_config" ] } +# Depend on this target when you want to have test_support but also the +# main method needed for gtest to execute! source_set("test_support_main") { testonly = true @@ -95,3 +243,234 @@ source_set("test_support_main") { configs += [ "..:common_config" ] public_configs = [ "..:common_inherited_config" ] } + +# Depend on this target when you want to have test_support and a special +# main for mac which will run your test on a worker thread and consume +# events on the main thread. Useful if you want to access a webcam. +# This main will provide all the scaffolding and objective-c black magic +# for you. All you need to do is to implement a function in the +# run_threaded_main_mac.h file (ImplementThisToRunYourTest). +source_set("test_support_main_threaded_mac") { + testonly = true + + sources = [ + "testsupport/mac/run_threaded_main_mac.h", + "testsupport/mac/run_threaded_main_mac.mm", + ] + + configs += [ "..:common_config" ] + public_configs = [ "..:common_inherited_config" ] + + deps = [ + ":test_support", + ] +} + +test("test_support_unittests") { + deps = [] + sources = [ + "channel_transport/udp_socket_manager_unittest.cc", + "channel_transport/udp_socket_wrapper_unittest.cc", + "channel_transport/udp_transport_unittest.cc", + "fake_network_pipe_unittest.cc", + "frame_generator_unittest.cc", + "rtp_file_reader_unittest.cc", + "rtp_file_writer_unittest.cc", + "testsupport/always_passing_unittest.cc", + "testsupport/fileutils_unittest.cc", + "testsupport/frame_reader_unittest.cc", + "testsupport/frame_writer_unittest.cc", + "testsupport/packet_reader_unittest.cc", + "testsupport/perf_test_unittest.cc", + "testsupport/unittest_utils.h", + ] + + configs += [ "..:common_config" ] + public_configs = [ "..:common_inherited_config" ] + + if (is_win) { + cflags = [ + # TODO(jschuh): Bug 1348: fix this warning. + "/wd4267", # size_t to int truncations + "/wd4373", # virtual override w/different const/volatile signature. + ] + } + + if (is_clang) { + # Suppress warnings from the Chromium Clang plugin. + # See http://code.google.com/p/webrtc/issues/detail?id=163 for details. + configs -= [ "//build/config/clang:find_bad_constructs" ] + } + + if (is_android) { + deps += [ "//testing/android/native_test:native_test_support" ] + + # This needs to be kept in sync with the test_support_unittests.isolate file. + # TODO(kjellander); Move this to android_assets targets instead. + data = [ + "//resources/video_coding/frame-ethernet-ii.pcap", + "//resources/video_coding/frame-loopback.pcap", + "//resources/video_coding/pltype103.rtp", + "//resources/video_coding/pltype103_header_only.rtp", + "//resources/video_coding/ssrcs-2.pcap", + "//resources/video_coding/ssrcs-3.pcap", + ] + } + deps += [ + ":channel_transport", + ":test_common", + ":test_support_main", + "../modules/video_capture", + "//testing/gmock", + "//testing/gtest", + ] +} + +source_set("test_common") { + testonly = true + sources = [ + "call_test.cc", + "call_test.h", + "configurable_frame_size_encoder.cc", + "configurable_frame_size_encoder.h", + "constants.cc", + "constants.h", + "direct_transport.cc", + "direct_transport.h", + "drifting_clock.cc", + "drifting_clock.h", + "encoder_settings.cc", + "encoder_settings.h", + "fake_audio_device.cc", + "fake_audio_device.h", + "fake_decoder.cc", + "fake_decoder.h", + "fake_encoder.cc", + "fake_encoder.h", + "fake_network_pipe.cc", + "fake_network_pipe.h", + "frame_generator_capturer.cc", + "frame_generator_capturer.h", + "layer_filtering_transport.cc", + "layer_filtering_transport.h", + "mock_transport.h", + "mock_voe_channel_proxy.h", + "mock_voice_engine.h", + "null_transport.cc", + "null_transport.h", + "rtp_rtcp_observer.h", + "statistics.cc", + "statistics.h", + "vcm_capturer.cc", + "vcm_capturer.h", + "video_capturer.cc", + "video_capturer.h", + "win/run_loop_win.cc", + ] + if (!is_win) { + sources += [ + "run_loop.cc", + "run_loop.h", + ] + } + + configs += [ "..:common_config" ] + public_configs = [ "..:common_inherited_config" ] + + if (is_clang && !is_nacl) { + # Suppress warnings from the Chromium Clang plugin. + # See http://code.google.com/p/webrtc/issues/detail?id=163 for details. + configs -= [ "//build/config/clang:find_bad_constructs" ] + } + + deps = [ + ":rtp_test_utils", + ":test_support", + ":video_test_common", + "..:webrtc", + "..:webrtc_common", + "../base:rtc_base_approved", + "../modules/media_file", + "//testing/gmock", + "//testing/gtest", + "//third_party/gflags", + ] +} + +config("test_renderer_exported_config") { + if (is_win && is_clang) { + # GN orders flags on a target before flags from configs. The default config + # adds -Wall, and this flag have to be after -Wall -- so they need to + # come from a config and cannot be on the target directly. + cflags += [ + "-Wno-bool-conversion", + "-Wno-comment", + "-Wno-delete-non-virtual-dtor", + ] + } +} + +source_set("test_renderer") { + testonly = true + libs = [] + sources = [ + "linux/glx_renderer.cc", + "linux/glx_renderer.h", + "linux/video_renderer_linux.cc", + "mac/video_renderer_mac.h", + "mac/video_renderer_mac.mm", + "video_renderer.cc", + "video_renderer.h", + "win/d3d_renderer.cc", + "win/d3d_renderer.h", + ] + if (!is_linux && !is_mac && !is_win) { + sources += [ "null_platform_renderer.cc" ] + } + if (is_linux || is_mac) { + sources += [ + "gl/gl_renderer.cc", + "gl/gl_renderer.h", + ] + } + + if (is_linux) { + libs += [ + "Xext", + "X11", + "GL", + ] + } + if (is_android) { + libs += [ + "GLESv2", + "log", + ] + } + if (is_mac) { + libs = [ + "Cocoa.framework", + "OpenGL.framework", + "CoreVideo.framework", + ] + } + + configs += [ "..:common_config" ] + public_configs = [ + "..:common_inherited_config", + ":test_renderer_exported_config", + ] + + if (is_clang && !is_nacl) { + # Suppress warnings from the Chromium Clang plugin. + # See http://code.google.com/p/webrtc/issues/detail?id=163 for details. + configs -= [ "//build/config/clang:find_bad_constructs" ] + } + + deps = [ + ":test_support", + ":video_test_common", + "../modules/media_file", + "//testing/gtest", + ] +} diff --git a/webrtc/test/test.gyp b/webrtc/test/test.gyp index 28b5783cd3..b7beffb1b4 100644 --- a/webrtc/test/test.gyp +++ b/webrtc/test/test.gyp @@ -268,8 +268,6 @@ 'null_transport.cc', 'null_transport.h', 'rtp_rtcp_observer.h', - 'run_loop.cc', - 'run_loop.h', 'statistics.cc', 'statistics.h', 'vcm_capturer.cc', @@ -279,9 +277,10 @@ 'win/run_loop_win.cc', ], 'conditions': [ - ['OS=="win"', { - 'sources!': [ - 'run_loop.cc', + ['OS!="win"', { + 'sources': [ + 'run_loop.h', + 'run_loop.cc', ], }], ], @@ -302,40 +301,29 @@ 'target_name': 'test_renderer', 'type': 'static_library', 'sources': [ - 'gl/gl_renderer.cc', - 'gl/gl_renderer.h', 'linux/glx_renderer.cc', 'linux/glx_renderer.h', 'linux/video_renderer_linux.cc', 'mac/video_renderer_mac.h', 'mac/video_renderer_mac.mm', - 'null_platform_renderer.cc', 'video_renderer.cc', 'video_renderer.h', 'win/d3d_renderer.cc', 'win/d3d_renderer.h', ], 'conditions': [ - ['OS=="linux"', { - 'sources!': [ + ['OS!="linux" and OS!="mac" and OS!="win"', { + 'sources': [ 'null_platform_renderer.cc', ], }], - ['OS=="mac"', { - 'sources!': [ - 'null_platform_renderer.cc', - ], - }], - ['OS!="linux" and OS!="mac"', { - 'sources!' : [ + ['OS=="linux" or OS=="mac"', { + 'sources' : [ 'gl/gl_renderer.cc', 'gl/gl_renderer.h', ], }], ['OS=="win"', { - 'sources!': [ - 'null_platform_renderer.cc', - ], 'include_dirs': [ '<(directx_sdk_path)/Include', ],