chromium/components/messages/android/BUILD.gn

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

import("//build/config/android/rules.gni")
import("//chrome/android/features/android_library_factory_tmpl.gni")
import("//third_party/jni_zero/jni_zero.gni")

android_library("java") {
  sources = [
    "java/src/org/chromium/components/messages/MessageAutodismissDurationProvider.java",
    "java/src/org/chromium/components/messages/MessageBannerProperties.java",
    "java/src/org/chromium/components/messages/MessageContainer.java",
    "java/src/org/chromium/components/messages/MessageDispatcher.java",
    "java/src/org/chromium/components/messages/MessageDispatcherBridge.java",
    "java/src/org/chromium/components/messages/MessageDispatcherProvider.java",
    "java/src/org/chromium/components/messages/MessageFeatureList.java",
    "java/src/org/chromium/components/messages/MessageFeatureMap.java",
    "java/src/org/chromium/components/messages/MessageSecondaryMenuItems.java",
    "java/src/org/chromium/components/messages/MessageWrapper.java",
    "java/src/org/chromium/components/messages/MessagesMetrics.java",
  ]
  resources_package = "org.chromium.components.messages"

  deps = [
    ":feature_flags_jni_headers_java",
    ":java_resources",
    ":jni_headers_java",
    "//base:base_java",
    "//build/android:build_java",
    "//components/browser_ui/banners/android:java",
    "//components/browser_ui/widget/android:java",
    "//content/public/android:content_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
    "//third_party/androidx:androidx_appcompat_appcompat_resources_java",
    "//third_party/androidx:androidx_core_core_java",
    "//third_party/jni_zero:jni_zero_java",
    "//ui/android:ui_java",
  ]

  srcjar_deps = [ ":message_enums_java" ]
}

android_library("unit_device_javatests") {
  testonly = true
  sources =
      [ "java/src/org/chromium/components/messages/MessageContainerTest.java" ]
  deps = [
    ":java",
    ":java_resources",
    "//base:base_java",
    "//base:base_java_test_support",
    "//content/public/test/android:content_java_test_support",
    "//third_party/androidx:androidx_core_core_java",
    "//third_party/androidx:androidx_test_runner_java",
    "//third_party/junit:junit",
    "//third_party/mockito:mockito_java",
    "//ui/android:ui_java_test_support",
  ]
}

android_resources("java_resources") {
  sources = [ "java/res/values/dimens.xml" ]
  deps = [
    "//components/browser_ui/strings/android:browser_ui_strings_grd",
    "//components/browser_ui/styles/android:java_resources",
    "//ui/android:ui_java_resources",
  ]
}

generate_jni("jni_headers") {
  sources = [
    "java/src/org/chromium/components/messages/MessageDispatcherBridge.java",
    "java/src/org/chromium/components/messages/MessageWrapper.java",
  ]
}

generate_jni("feature_flags_jni_headers") {
  sources =
      [ "java/src/org/chromium/components/messages/MessageFeatureMap.java" ]
}

static_library("android") {
  sources = [
    "message_dispatcher_bridge.cc",
    "message_dispatcher_bridge.h",
    "message_enums.h",
    "message_wrapper.cc",
    "message_wrapper.h",
    "throttler/domain_session_throttler.cc",
    "throttler/domain_session_throttler.h",
  ]
  deps = [
    ":jni_headers",
    "//content/public/browser",
    "//ui/android:android",
  ]

  public_deps = [
    "//base",
    "//skia",
  ]
}

static_library("test_support") {
  testonly = true
  sources = [
    "mock_message_dispatcher_bridge.cc",
    "mock_message_dispatcher_bridge.h",
  ]

  deps = [
    ":android",
    "//testing/gmock",
  ]
}

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

  deps = [
    ":android",
    "//base",
    "//testing/gtest",
  ]
}

java_cpp_enum("message_enums_java") {
  sources = [ "message_enums.h" ]
}

# Build target for Messages manager code, that owns and initializes
# MessageDispatcher.
android_library("manager_java") {
  sources = [
    "java/src/org/chromium/components/messages/ManagedMessageDispatcher.java",
    "java/src/org/chromium/components/messages/MessageQueueDelegate.java",
  ]
  deps = [ ":java" ]
}

android_library_factory("factory_java") {
  sources = [
    "internal/java/src/org/chromium/components/messages/MessagesFactory.java",
  ]

  deps = [
    ":java",
    ":manager_java",
    "//base:base_java",
    "//ui/android:ui_full_java",
  ]
}

static_library("feature_flags") {
  sources = [
    "messages_feature.cc",
    "messages_feature.h",
  ]
  deps = [
    "//base",
    "//components/messages/android:feature_flags_jni_headers",
  ]
}

robolectric_library("junit") {
  sources =
      [ "java/src/org/chromium/components/messages/MessageWrapperTest.java" ]
  deps = [
    ":java",
    "//base:base_java",
    "//base:base_java_test_support",
    "//base:base_junit_test_support",
    "//components/browser_ui/widget/android:java",
    "//third_party/androidx:androidx_test_runner_java",
    "//third_party/hamcrest:hamcrest_core_java",
    "//third_party/hamcrest:hamcrest_library_java",
    "//third_party/jni_zero:jni_zero_java",
    "//third_party/junit",
    "//third_party/mockito:mockito_java",
    "//ui/android:ui_java",
  ]
}