# Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS.  All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.

import("../../webrtc.gni")

rtc_library("column_printer") {
  testonly = true
  sources = [
    "column_printer.cc",
    "column_printer.h",
  ]
  deps = [
    "../../rtc_base:macromagic",
    "../../rtc_base:stringutils",
    "../logging:log_writer",
  ]
}

if (rtc_include_tests && !build_with_chromium) {
  scenario_resources = [
    "../../resources/difficult_photo_1850_1110.yuv",
    "../../resources/photo_1850_1110.yuv",
    "../../resources/presentation_1850_1110.yuv",
    "../../resources/web_screenshot_1850_1110.yuv",
  ]
  scenario_unittest_resources = [ "../../resources/foreman_cif.yuv" ]

  if (is_ios) {
    bundle_data("scenario_resources_bundle_data") {
      testonly = true
      sources = scenario_resources
      outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
    }
    bundle_data("scenario_unittest_resources_bundle_data") {
      testonly = true
      sources = scenario_unittest_resources
      outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
    }
  }

  rtc_library("scenario") {
    testonly = true
    sources = [
      "audio_stream.cc",
      "audio_stream.h",
      "call_client.cc",
      "call_client.h",
      "hardware_codecs.cc",
      "hardware_codecs.h",
      "network_node.cc",
      "network_node.h",
      "performance_stats.cc",
      "performance_stats.h",
      "scenario.cc",
      "scenario.h",
      "scenario_config.cc",
      "scenario_config.h",
      "stats_collection.cc",
      "stats_collection.h",
      "video_frame_matcher.cc",
      "video_frame_matcher.h",
      "video_stream.cc",
      "video_stream.h",
    ]
    deps = [
      ":column_printer",
      "..:frame_generator_capturer",
      "..:test_video_capturer",
      "..:video_test_constants",
      "../:fake_video_codecs",
      "../:fileutils",
      "../:test_common",
      "../:test_support",
      "../:video_test_common",
      "../..//test/network:simulated_network",
      "../../api:array_view",
      "../../api:create_frame_generator",
      "../../api:fec_controller_api",
      "../../api:frame_generator_api",
      "../../api:libjingle_peerconnection_api",
      "../../api:rtc_event_log_output_file",
      "../../api:rtp_parameters",
      "../../api:sequence_checker",
      "../../api:time_controller",
      "../../api:transport_api",
      "../../api/audio:audio_device",
      "../../api/audio_codecs:builtin_audio_decoder_factory",
      "../../api/audio_codecs:builtin_audio_encoder_factory",
      "../../api/environment",
      "../../api/environment:environment_factory",
      "../../api/rtc_event_log",
      "../../api/rtc_event_log:rtc_event_log_factory",
      "../../api/task_queue",
      "../../api/test/network_emulation",
      "../../api/test/video:function_video_factory",
      "../../api/transport:network_control",
      "../../api/units:data_rate",
      "../../api/units:data_size",
      "../../api/units:time_delta",
      "../../api/units:timestamp",
      "../../api/video:builtin_video_bitrate_allocator_factory",
      "../../api/video:video_frame",
      "../../api/video:video_rtp_headers",
      "../../api/video_codecs:scalability_mode",
      "../../api/video_codecs:video_codecs_api",
      "../../audio",
      "../../call",
      "../../call:call_interfaces",
      "../../call:rtp_sender",
      "../../call:video_stream_api",
      "../../common_video",
      "../../media:media_constants",
      "../../media:rtc_audio_video",
      "../../media:rtc_internal_video_codecs",
      "../../modules/audio_device",
      "../../modules/audio_device:mock_audio_device",
      "../../modules/audio_device:test_audio_device_module",
      "../../modules/audio_mixer:audio_mixer_impl",
      "../../modules/audio_processing",
      "../../modules/congestion_controller/goog_cc:test_goog_cc_printer",
      "../../modules/rtp_rtcp",
      "../../modules/rtp_rtcp:mock_rtp_rtcp",
      "../../modules/rtp_rtcp:rtp_rtcp_format",
      "../../modules/video_coding:video_codec_interface",
      "../../modules/video_coding:video_coding_utility",
      "../../modules/video_coding:webrtc_h264",
      "../../modules/video_coding:webrtc_vp8",
      "../../modules/video_coding:webrtc_vp9",
      "../../modules/video_coding/svc:scalability_mode_util",
      "../../rtc_base:checks",
      "../../rtc_base:copy_on_write_buffer",
      "../../rtc_base:macromagic",
      "../../rtc_base:net_helper",
      "../../rtc_base:network_route",
      "../../rtc_base:refcount",
      "../../rtc_base:rtc_base_tests_utils",
      "../../rtc_base:rtc_event",
      "../../rtc_base:rtc_numerics",
      "../../rtc_base:rtc_stats_counters",
      "../../rtc_base:safe_minmax",
      "../../rtc_base:socket_address",
      "../../rtc_base:task_queue_for_test",
      "../../rtc_base:threading",
      "../../rtc_base/synchronization:mutex",
      "../../rtc_base/task_utils:repeating_task",
      "../../system_wrappers",
      "../../video/config:streams_config",
      "../logging:log_writer",
      "../network:emulated_network",
      "../time_controller",
      "//third_party/abseil-cpp/absl/cleanup",
      "//third_party/abseil-cpp/absl/flags:flag",
      "//third_party/abseil-cpp/absl/flags:parse",
      "//third_party/abseil-cpp/absl/functional:any_invocable",
      "//third_party/abseil-cpp/absl/memory",
      "//third_party/abseil-cpp/absl/strings",
      "//third_party/abseil-cpp/absl/strings:string_view",
    ]
    if (is_android) {
      deps += [ "../../modules/video_coding:android_codec_factory_helper" ]
    } else if (is_ios || is_mac) {
      deps += [ "../../modules/video_coding:objc_codec_factory_helper" ]
    }
    if (rtc_enable_protobuf) {
      deps += [ "../../modules/audio_coding:ana_config_proto" ]
    }
    data = scenario_resources
    if (is_ios) {
      deps += [ ":scenario_resources_bundle_data" ]
    }
  }
  rtc_library("scenario_unittests") {
    testonly = true
    sources = [
      "performance_stats_unittest.cc",
      "probing_test.cc",
      "scenario_unittest.cc",
      "stats_collection_unittest.cc",
      "video_stream_unittest.cc",
    ]
    deps = [
      ":scenario",
      "../../api/test/network_emulation",
      "../../api/test/network_emulation:create_cross_traffic",
      "../../logging:mocks",
      "../../rtc_base:checks",
      "../../system_wrappers",
      "../../system_wrappers:field_trial",
      "../../test:field_trial",
      "../../test:test_support",
      "../logging:log_writer",
      "//testing/gmock",
    ]
    data = scenario_unittest_resources
    if (is_ios) {
      deps += [ ":scenario_unittest_resources_bundle_data" ]
    }
  }
}
