chromium/chromecast/net/BUILD.gn

# Copyright 2015 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//chromecast/chromecast.gni")
import("//testing/test.gni")

cast_source_set("net") {
  sources = [
    "net_util_cast.cc",
    "net_util_cast.h",
  ]

  if (is_linux || is_chromeos) {
    sources += [
      "network_change_notifier_factory_cast.cc",
      "network_change_notifier_factory_cast.h",
    ]
  }

  deps = [
    ":net_switches",
    "//base",
    "//chromecast/base:cast_sys_info_util",
    "//chromecast/public",
    "//net",
  ]

  if (is_fuchsia) {
    sources += [
      "network_change_notifier_factory_fuchsia.cc",
      "network_change_notifier_factory_fuchsia.h",
    ]

    deps += [ "//chromecast/base:chromecast_switches" ]
  }
}

cast_source_set("net_switches") {
  sources = [
    "net_switches.cc",
    "net_switches.h",
  ]
}

cast_source_set("time_sync_tracker") {
  sources = [
    "time_sync_tracker.cc",
    "time_sync_tracker.h",
  ]
  deps = [ "//base" ]

  if (is_fuchsia) {
    sources += [
      "time_sync_tracker_fuchsia.cc",
      "time_sync_tracker_fuchsia.h",
    ]
  }
}

cast_source_set("connectivity_checker") {
  sources = [
    "connectivity_checker.cc",
    "connectivity_checker.h",
    "connectivity_checker_impl.cc",
    "connectivity_checker_impl.h",
    "fake_connectivity_checker.cc",
    "fake_connectivity_checker.h",
  ]
  deps = [
    ":net_switches",
    ":time_sync_tracker",
    "//base",
    "//chromecast:chromecast_buildflags",
    "//chromecast/base/metrics",
    "//services/network/public/cpp",
    "//services/network/public/mojom",
  ]
}

cast_source_set("socket_util") {
  sources = [
    "socket_util.cc",
    "socket_util.h",
  ]

  deps = [
    "//base",
    "//net",
  ]
}

cast_source_set("io_buffer_pool") {
  sources = [
    "io_buffer_pool.cc",
    "io_buffer_pool.h",
  ]

  deps = [
    "//base",
    "//net",
  ]
}

cast_source_set("small_message_socket") {
  sources = [
    "small_message_socket.cc",
    "small_message_socket.h",
  ]
  public_deps = [ "//net" ]

  deps = [
    ":io_buffer_pool",
    "//base",
  ]
}

cast_source_set("test_support") {
  testonly = true

  sources = [
    "fake_shared_url_loader_factory.cc",
    "fake_shared_url_loader_factory.h",
    "fake_stream_socket.cc",
    "fake_stream_socket.h",
    "mock_stream_socket.cc",
    "mock_stream_socket.h",
  ]

  public_deps = [ "//testing/gmock" ]

  deps = [
    "//base",
    "//mojo/public/cpp/bindings",
    "//net",
    "//services/network:test_support",
    "//services/network/public/cpp",
    "//services/network/public/mojom",
  ]
}

test("cast_net_unittests") {
  sources = [
    "connectivity_checker_impl_unittest.cc",
    "fake_stream_socket_unittest.cc",
    "io_buffer_pool_unittest.cc",
    "small_message_socket_unittest.cc",
  ]

  deps = [
    ":connectivity_checker",
    ":io_buffer_pool",
    ":small_message_socket",
    ":test_support",
    "//base",
    "//chromecast/base/metrics:test_support",
    "//chromecast/mojo/test:run_all_unittests",
    "//net",
    "//net:test_support",
    "//services/network:test_support",
    "//services/network/public/cpp",
    "//services/network/public/mojom",
    "//testing/gmock",
    "//testing/gtest",
  ]
}