chromium/components/webapps/browser/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/config.gni")
import("//build/config/android/rules.gni")
import("//build/config/locales.gni")
import("//third_party/jni_zero/jni_zero.gni")
import("//tools/grit/grit_rule.gni")

android_library("java") {
  resources_package = "org.chromium.components.webapps"
  sources = [
    "java/src/org/chromium/components/webapps/AddToHomescreenCoordinator.java",
    "java/src/org/chromium/components/webapps/AddToHomescreenDialogView.java",
    "java/src/org/chromium/components/webapps/AddToHomescreenInstaller.java",
    "java/src/org/chromium/components/webapps/AddToHomescreenMediator.java",
    "java/src/org/chromium/components/webapps/AddToHomescreenProperties.java",
    "java/src/org/chromium/components/webapps/AddToHomescreenViewBinder.java",
    "java/src/org/chromium/components/webapps/AddToHomescreenViewDelegate.java",
    "java/src/org/chromium/components/webapps/AppBannerManager.java",
    "java/src/org/chromium/components/webapps/AppData.java",
    "java/src/org/chromium/components/webapps/AppDetailsDelegate.java",
    "java/src/org/chromium/components/webapps/WebappsIconUtils.java",
    "java/src/org/chromium/components/webapps/WebappsUtils.java",
    "java/src/org/chromium/components/webapps/bottomsheet/AddToHomescreenBottomSheetViewBinder.java",
    "java/src/org/chromium/components/webapps/bottomsheet/ImageZoomView.java",
    "java/src/org/chromium/components/webapps/bottomsheet/PwaBottomSheetController.java",
    "java/src/org/chromium/components/webapps/bottomsheet/PwaBottomSheetControllerFactory.java",
    "java/src/org/chromium/components/webapps/bottomsheet/PwaBottomSheetControllerProvider.java",
    "java/src/org/chromium/components/webapps/bottomsheet/PwaInstallBottomSheetContent.java",
    "java/src/org/chromium/components/webapps/bottomsheet/PwaInstallBottomSheetView.java",
    "java/src/org/chromium/components/webapps/pwa_restore_ui/PwaRestoreBottomSheetContent.java",
    "java/src/org/chromium/components/webapps/pwa_restore_ui/PwaRestoreBottomSheetCoordinator.java",
    "java/src/org/chromium/components/webapps/pwa_restore_ui/PwaRestoreBottomSheetMediator.java",
    "java/src/org/chromium/components/webapps/pwa_restore_ui/PwaRestoreBottomSheetView.java",
    "java/src/org/chromium/components/webapps/pwa_restore_ui/PwaRestoreBottomSheetViewBinder.java",
    "java/src/org/chromium/components/webapps/pwa_restore_ui/PwaRestoreProperties.java",
    "java/src/org/chromium/components/webapps/pwa_universal_install/PwaUniversalInstallBottomSheetContent.java",
    "java/src/org/chromium/components/webapps/pwa_universal_install/PwaUniversalInstallBottomSheetCoordinator.java",
    "java/src/org/chromium/components/webapps/pwa_universal_install/PwaUniversalInstallBottomSheetMediator.java",
    "java/src/org/chromium/components/webapps/pwa_universal_install/PwaUniversalInstallBottomSheetView.java",
    "java/src/org/chromium/components/webapps/pwa_universal_install/PwaUniversalInstallBottomSheetViewBinder.java",
    "java/src/org/chromium/components/webapps/pwa_universal_install/PwaUniversalInstallProperties.java",
  ]
  deps = [
    ":java_resources",
    ":pwa_restore_bottom_sheet_mediator_jni_headers_java",
    ":webapps_jni_headers_java",
    "//base:base_java",
    "//build/android:build_java",
    "//chrome/browser/android/webapk/proto:proto_java",
    "//components/browser_ui/bottomsheet/android:java",
    "//components/browser_ui/widget/android:java",
    "//components/webapk/android/libs/client:java",
    "//content/public/android:content_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
    "//third_party/androidx:androidx_core_core_java",
    "//third_party/androidx:androidx_recyclerview_recyclerview_java",
    "//third_party/jni_zero:jni_zero_java",
    "//ui/android:ui_no_recycler_view_java",
    "//ui/android:ui_utils_java",
    "//url:gurl_java",
  ]
  srcjar_deps = [
    ":webapps_java_enums_srcjar",
    "//components/webapps/browser/android/webapk:enums_srcjar",
  ]
}

generate_jni("webapps_jni_headers") {
  sources = [
    "java/src/org/chromium/components/webapps/AddToHomescreenCoordinator.java",
    "java/src/org/chromium/components/webapps/AddToHomescreenInstaller.java",
    "java/src/org/chromium/components/webapps/AddToHomescreenMediator.java",
    "java/src/org/chromium/components/webapps/AppBannerManager.java",
    "java/src/org/chromium/components/webapps/WebappsIconUtils.java",
    "java/src/org/chromium/components/webapps/WebappsUtils.java",
    "java/src/org/chromium/components/webapps/bottomsheet/PwaBottomSheetController.java",
    "java/src/org/chromium/components/webapps/bottomsheet/PwaBottomSheetControllerProvider.java",
    "java/src/org/chromium/components/webapps/pwa_universal_install/PwaUniversalInstallBottomSheetCoordinator.java",
  ]
}

generate_jni("pwa_restore_bottom_sheet_mediator_jni_headers") {
  sources = [ "java/src/org/chromium/components/webapps/pwa_restore_ui/PwaRestoreBottomSheetMediator.java" ]
}

java_cpp_enum("webapps_java_enums_srcjar") {
  sources = [
    "//components/webapps/browser/android/ambient_badge_manager.h",
    "//components/webapps/browser/banners/app_banner_manager.h",
    "//components/webapps/browser/banners/app_banner_settings_helper.h",
    "//components/webapps/browser/installable/installable_metrics.h",
    "add_to_homescreen_params.h",
    "shortcut_info.h",
  ]
}

android_resources("java_resources") {
  sources = [
    "java/res/drawable-hdpi/google_play.png",
    "java/res/drawable-hdpi/star_gray.png",
    "java/res/drawable-hdpi/star_green.png",
    "java/res/drawable-mdpi/google_play.png",
    "java/res/drawable-mdpi/star_gray.png",
    "java/res/drawable-mdpi/star_green.png",
    "java/res/drawable-xhdpi/google_play.png",
    "java/res/drawable-xhdpi/star_gray.png",
    "java/res/drawable-xhdpi/star_green.png",
    "java/res/drawable-xxhdpi/google_play.png",
    "java/res/drawable-xxhdpi/star_gray.png",
    "java/res/drawable-xxhdpi/star_green.png",
    "java/res/drawable-xxxhdpi/google_play.png",
    "java/res/drawable-xxxhdpi/star_gray.png",
    "java/res/drawable-xxxhdpi/star_green.png",
    "java/res/drawable/pwa_restore_app_item_background_bottom.xml",
    "java/res/drawable/pwa_restore_app_item_background_middle.xml",
    "java/res/drawable/pwa_restore_app_item_background_single.xml",
    "java/res/drawable/pwa_restore_app_item_background_top.xml",
    "java/res/drawable/pwa_restore_icon.xml",
    "java/res/drawable/rating_bar.xml",
    "java/res/layout/add_to_homescreen_dialog.xml",
    "java/res/layout/image_zoom_view.xml",
    "java/res/layout/pwa_install_bottom_sheet_content.xml",
    "java/res/layout/pwa_restore_bottom_sheet_content.xml",
    "java/res/layout/pwa_restore_bottom_sheet_dialog.xml",
    "java/res/layout/pwa_restore_bottom_sheet_preview.xml",
    "java/res/layout/pwa_restore_list_item_app.xml",
    "java/res/layout/pwa_restore_list_item_label.xml",
    "java/res/layout/pwa_universal_install_bottom_sheet_content.xml",
    "java/res/mipmap-hdpi/shortcut_icon_shadow.png",
    "java/res/mipmap-mdpi/shortcut_icon_shadow.png",
    "java/res/mipmap-xhdpi/shortcut_icon_shadow.png",
    "java/res/mipmap-xxhdpi/shortcut_icon_shadow.png",
    "java/res/mipmap-xxxhdpi/shortcut_icon_shadow.png",
    "java/res/values-night/colors.xml",
    "java/res/values/colors.xml",
    "java/res/values/dimens.xml",
    "java/res/values/styles.xml",
  ]
  deps = [
    ":webapps_strings_grd",
    "//components/browser_ui/strings/android:browser_ui_strings_grd",
    "//components/browser_ui/styles/android:java_resources",
    "//components/webapk/android/libs/common:splash_resources",
    "//third_party/androidx:androidx_constraintlayout_constraintlayout_java",
  ]
}

java_strings_grd("webapps_strings_grd") {
  grd_file = "android_webapps_strings.grd"
  outputs = [ "values/android_webapps_strings.xml" ] +
            process_file_template(
                android_bundle_locales_as_resources,
                [ "values-{{source_name_part}}/android_webapps_strings.xml" ])
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "add_to_homescreen_data_fetcher_unittest.cc",
    "install_prompt_prefs_unittest.cc",
    "shortcut_info_unittest.cc",
    "webapk/webapk_icons_hasher_unittest.cc",
    "webapk/webapk_proto_builder_unittest.cc",
    "webapk/webapk_single_icon_hasher_unittest.cc",
    "webapp_icon_unittest.cc",
    "webapps_utils_unittest.cc",
  ]
  deps = [
    "//base",
    "//build:android_buildflags",
    "//components/favicon/content",
    "//components/favicon_base",
    "//components/prefs:test_support",
    "//components/webapk:proto",
    "//components/webapps/browser",
    "//components/webapps/common:mojo_bindings",
    "//content/public/browser",
    "//content/test:test_support",
    "//net:test_support",
    "//services/network:test_support",
    "//testing/gtest",
    "//third_party/blink/public/common:common",
    "//third_party/blink/public/mojom:mojom_platform",
    "//ui/gfx:test_support",
    "//url",
  ]

  data = [
    "//components/test/data/webapps/nostore.html",
    "//components/test/data/webapps/simple.html",
    "//components/test/data/webapps/title1.html",
  ]
}

robolectric_library("junit") {
  resources_package = "org.chromium.components.webapps"
  sources = [
    "java/src/org/chromium/components/webapps/AddToHomescreenDialogViewTest.java",
    "java/src/org/chromium/components/webapps/AddToHomescreenMediatorTest.java",
    "java/src/org/chromium/components/webapps/AddToHomescreenViewBinderTest.java",
    "java/src/org/chromium/components/webapps/pwa_restore_ui/PwaRestoreBottomSheetContentTest.java",
    "java/src/org/chromium/components/webapps/pwa_restore_ui/PwaRestoreBottomSheetCoordinatorTest.java",
    "java/src/org/chromium/components/webapps/pwa_universal_install/PwaUniversalInstallBottomSheetContentTest.java",
    "java/src/org/chromium/components/webapps/pwa_universal_install/PwaUniversalInstallBottomSheetCoordinatorTest.java",
  ]
  deps = [
    ":java",
    ":java_resources",
    "//base:base_java_test_support",
    "//base:base_junit_test_support",
    "//base:tasks_java",
    "//base/test:test_support_java",
    "//chrome/browser/profiles/android:java",
    "//chrome/test/android:chrome_java_unit_test_support",
    "//components/browser_ui/bottomsheet/android:java",
    "//components/browser_ui/share/android:java",
    "//components/feature_engagement/public:public_java",
    "//content/public/android:content_java",
    "//content/public/test/android:content_java_test_support",
    "//third_party/androidx:androidx_core_core_java",
    "//third_party/androidx:androidx_test_runner_java",
    "//third_party/jni_zero:jni_zero_java",
    "//third_party/junit",
    "//third_party/mockito:mockito_java",
    "//ui/android:ui_java_test_support",
    "//ui/android:ui_junit_test_support",
    "//ui/android:ui_no_recycler_view_java",
    "//url:url_java",
  ]
}

android_library("unit_device_javatests") {
  testonly = true
  resources_package = "org.chromium.components.webapps"

  sources = [ "java/src/org/chromium/components/webapps/pwa_restore_ui/PwaRestoreBottomSheetViewRenderTest.java" ]
  deps = [
    ":java",
    "//base:base_java_test_support",
    "//base:tasks_java",
    "//chrome/android:chrome_java",
    "//chrome/test/android:chrome_java_integration_test_support",
    "//components/browser_ui/bottomsheet/android:java",
    "//components/browser_ui/widget/android:unit_device_javatests",
    "//content/public/test/android:content_java_test_support",
    "//third_party/androidx:androidx_test_runner_java",
    "//third_party/jni_zero:jni_zero_java",
    "//third_party/junit:junit",
    "//third_party/mockito:mockito_java",
    "//ui/android:ui_java",
    "//ui/android:ui_java_test_support",
  ]
}