# Copyright (c) 2017 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")
if (rtc_enable_protobuf) {
  import("//third_party/protobuf/proto_library.gni")
}

if (rtc_enable_protobuf) {
  proto_library("network_tester_config_proto") {
    sources = [ "network_tester_config.proto" ]
    proto_out_dir = "rtc_tools/network_tester"
  }

  proto_library("network_tester_packet_proto") {
    sources = [ "network_tester_packet.proto" ]
    proto_out_dir = "rtc_tools/network_tester"
  }

  rtc_library("network_tester") {
    sources = [
      "config_reader.cc",
      "config_reader.h",
      "packet_logger.cc",
      "packet_logger.h",
      "packet_sender.cc",
      "packet_sender.h",
      "test_controller.cc",
      "test_controller.h",
    ]

    defines = [ "WEBRTC_NETWORK_TESTER_PROTO" ]

    deps = [
      ":network_tester_config_proto",
      ":network_tester_packet_proto",
      "../../api:sequence_checker",
      "../../api/task_queue",
      "../../api/task_queue:default_task_queue_factory",
      "../../api/task_queue:pending_task_safety_flag",
      "../../api/units:timestamp",
      "../../p2p:basic_packet_socket_factory",
      "../../p2p:rtc_p2p",
      "../../rtc_base:async_packet_socket",
      "../../rtc_base:checks",
      "../../rtc_base:ip_address",
      "../../rtc_base:logging",
      "../../rtc_base:macromagic",
      "../../rtc_base:protobuf_utils",
      "../../rtc_base:socket_address",
      "../../rtc_base:socket_server",
      "../../rtc_base:threading",
      "../../rtc_base:timeutils",
      "../../rtc_base/network:received_packet",
      "../../rtc_base/synchronization:mutex",
      "../../rtc_base/system:no_unique_address",
      "//third_party/abseil-cpp/absl/functional:any_invocable",
    ]
  }

  network_tester_unittests_resources = [
    "../../resources/network_tester/client_config.dat",
    "../../resources/network_tester/server_config.dat",
  ]

  if (is_ios) {
    bundle_data("network_tester_unittests_bundle_data") {
      testonly = true
      sources = network_tester_unittests_resources
      outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
    }
  }

  rtc_library("network_tester_unittests") {
    testonly = true

    sources = [ "network_tester_unittest.cc" ]

    deps = [
      ":network_tester",
      "../../rtc_base:gunit_helpers",
      "../../rtc_base:random",
      "../../rtc_base:threading",
      "../../test:fileutils",
      "../../test:test_support",
      "//testing/gtest",
    ]

    if (is_ios) {
      deps += [ ":network_tester_unittests_bundle_data" ]
    }

    defines = [ "WEBRTC_NETWORK_TESTER_TEST_ENABLED" ]

    data = network_tester_unittests_resources
  }

  rtc_executable("network_tester_server") {
    sources = [ "server.cc" ]

    deps = [
      ":network_tester",
      "../../rtc_base:null_socket_server",
      "../../rtc_base:threading",
    ]
  }
}

if (is_android) {
  rtc_android_apk("NetworkTesterMobile") {
    testonly = true
    apk_name = "NetworkTesterMobile"
    android_manifest = "androidapp/AndroidManifest.xml"
    min_sdk_version = 21
    target_sdk_version = 24

    deps = [
      ":NetworkTesterMobile_javalib",
      ":NetworkTesterMobile_resources",
      "../../rtc_base:base_java",
    ]

    shared_libraries = [ "../../rtc_tools/network_tester:network_tester_so" ]
  }

  rtc_android_library("NetworkTesterMobile_javalib") {
    testonly = true
    android_manifest = "androidapp/AndroidManifest.xml"

    sources = [
      "androidapp/src/com/google/media/networktester/MainActivity.java",
      "androidapp/src/com/google/media/networktester/NetworkTester.java",
    ]

    resources_package = "com.google.media.networktester"
    deps = [
      ":NetworkTesterMobile_resources",
      "../../rtc_base:base_java",
    ]
  }

  android_resources("NetworkTesterMobile_resources") {
    testonly = true
    custom_package = "com.google.media.networktester"
    sources = [
      "androidapp/res/layout/activity_main.xml",
      "androidapp/res/mipmap-hdpi/ic_launcher.png",
      "androidapp/res/mipmap-mdpi/ic_launcher.png",
      "androidapp/res/mipmap-xhdpi/ic_launcher.png",
      "androidapp/res/mipmap-xxhdpi/ic_launcher.png",
      "androidapp/res/mipmap-xxxhdpi/ic_launcher.png",
      "androidapp/res/values-v17/styles.xml",
      "androidapp/res/values-w820dp/dimens.xml",
      "androidapp/res/values/colors.xml",
      "androidapp/res/values/dimens.xml",
      "androidapp/res/values/strings.xml",
    ]

    # Needed for Bazel converter.
    resource_dirs = [ "androidapp/res" ]
    assert(resource_dirs != [])  # Mark as used.
  }

  rtc_shared_library("network_tester_so") {
    sources = [ "jni.cc" ]

    deps = [
      ":network_tester",
      "../../rtc_base:logging",
      "../../rtc_base:threading",
    ]

    suppressed_configs += [ "//build/config/android:hide_all_but_jni_onload" ]
    configs += [ "//build/config/android:hide_all_but_jni" ]

    output_extension = "so"
  }
}
