chromium/components/download/network/BUILD.gn

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

if (is_android) {
  import("//build/config/android/config.gni")
  import("//build/config/android/rules.gni")
  import("//third_party/jni_zero/jni_zero.gni")
}

static_library("network") {
  sources = [
    "download_http_utils.cc",
    "download_http_utils.h",
    "network_status_listener.cc",
    "network_status_listener.h",
    "network_status_listener_impl.cc",
    "network_status_listener_impl.h",
  ]

  deps = [
    "//base",
    "//net",
    "//services/network/public/cpp",
  ]

  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  if (is_android) {
    sources += [
      "android/network_status_listener_android.cc",
      "android/network_status_listener_android.h",
    ]

    deps += [ ":jni_headers" ]
  }
}

source_set("unit_tests") {
  testonly = true
  sources = [ "download_http_utils_unittest.cc" ]

  deps = [
    ":network",
    "//net",
    "//testing/gtest",
  ]
}

if (is_android) {
  android_library("network_java") {
    srcjar_deps = [ ":jni_headers" ]
    sources = [
      "android/java/src/org/chromium/components/download/BackgroundNetworkStatusListener.java",
      "android/java/src/org/chromium/components/download/NetworkStatusListenerAndroid.java",
    ]

    deps = [
      "//base:base_java",
      "//build/android:build_java",
      "//net/android:net_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
  }

  generate_jni("jni_headers") {
    visibility = [ ":*" ]
    sources = [ "android/java/src/org/chromium/components/download/NetworkStatusListenerAndroid.java" ]
  }

  robolectric_library("junit") {
    testonly = true

    sources = [ "android/junit/src/org/chromium/components/download/NetworkStatusListenerAndroidTest.java" ]

    deps = [
      ":network_java",
      "//base:base_java",
      "//base:base_java_test_support",
      "//base:base_junit_test_support",
      "//net/android:net_java",
      "//third_party/androidx:androidx_test_runner_java",
      "//third_party/jni_zero:jni_zero_java",
      "//third_party/junit",
      "//third_party/mockito:mockito_java",
    ]
  }
}