# Copyright 2021 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")
}
source_set("public") {
sources = [
"config.cc",
"config.h",
"constants.cc",
"constants.h",
"database_client.cc",
"database_client.h",
"features.cc",
"features.h",
"field_trial_register.h",
"input_context.cc",
"input_context.h",
"input_delegate.cc",
"input_delegate.h",
"local_state_helper.h",
"model_provider.cc",
"model_provider.h",
"prediction_options.cc",
"prediction_options.h",
"result.cc",
"result.h",
"segment_selection_result.cc",
"segment_selection_result.h",
"segmentation_platform_service.cc",
"segmentation_platform_service.h",
"service_proxy.cc",
"service_proxy.h",
"trigger.h",
"types/processed_value.cc",
"types/processed_value.h",
]
public_deps = [ "//components/segmentation_platform/public/proto" ]
deps = [
"//base",
"//base:i18n",
"//components/keyed_service/core",
"//services/metrics/public/cpp:metrics_cpp",
"//url",
]
if (is_android) {
sources += [
"android/input_context_android.cc",
"android/input_context_android.h",
"android/prediction_options_android.cc",
"android/prediction_options_android.h",
"android/segmentation_platform_conversion_bridge.cc",
"android/segmentation_platform_conversion_bridge.h",
]
deps += [ ":jni_headers" ]
}
}
source_set("unit_tests") {
testonly = true
# IMPORTANT NOTE: When adding new tests, also remember to update the list of
# tests in //components/segmentation_platform/components_unittests.filter
sources = []
deps = [
":public",
"//testing/gtest",
]
if (is_android) {
sources += [ "android/input_context_android_unittest.cc" ]
deps += [
"//base:base",
"//url:url",
]
}
}
source_set("test_support") {
testonly = true
sources = [
"testing/mock_database_client.h",
"testing/mock_device_switcher_result_dispatcher.h",
"testing/mock_field_trial_register.h",
"testing/mock_segmentation_platform_service.h",
]
deps = [
":public",
"//base",
"//components/segmentation_platform/embedder/default_model",
"//testing/gmock",
"//testing/gtest",
]
}
if (is_android) {
android_library("public_java") {
sources = [
"android/java/src/org/chromium/components/segmentation_platform/ClassificationResult.java",
"android/java/src/org/chromium/components/segmentation_platform/Constants.java",
"android/java/src/org/chromium/components/segmentation_platform/InputContext.java",
"android/java/src/org/chromium/components/segmentation_platform/PredictionOptions.java",
"android/java/src/org/chromium/components/segmentation_platform/ProcessedValue.java",
"android/java/src/org/chromium/components/segmentation_platform/SegmentSelectionResult.java",
"android/java/src/org/chromium/components/segmentation_platform/SegmentationPlatformConversionBridge.java",
"android/java/src/org/chromium/components/segmentation_platform/SegmentationPlatformService.java",
]
deps = [
"//base:base_java",
"//build/android:build_java",
"//third_party/androidx:androidx_annotation_annotation_java",
"//third_party/androidx:androidx_annotation_annotation_jvm_java",
"//third_party/jni_zero:jni_zero_java",
"//url:gurl_java",
]
srcjar_deps = [
":execution_status_enums_java",
":jni_headers",
":processed_value_enums_java",
]
public_deps = [ "//components/segmentation_platform/public/proto:segmentation_platform_proto_java" ]
}
robolectric_library("junit") {
sources = [
"android/java/src/org/chromium/components/segmentation_platform/InputContextTest.java",
"android/java/src/org/chromium/components/segmentation_platform/PredictionOptionsTest.java",
]
deps = [
":public_java",
"//base:base_java",
"//base:base_java_test_support",
"//base:base_java_test_support_uncommon",
"//base:base_junit_test_support",
"//content/public/android:content_full_java",
"//third_party/jni_zero:jni_zero_java",
"//third_party/junit",
"//third_party/mockito:mockito_java",
"//ui/android:ui_no_recycler_view_java",
"//url:gurl_java",
"//url:gurl_junit_test_support",
]
}
generate_jni("jni_headers") {
visibility = [ ":*" ]
sources = [
"android/java/src/org/chromium/components/segmentation_platform/InputContext.java",
"android/java/src/org/chromium/components/segmentation_platform/PredictionOptions.java",
"android/java/src/org/chromium/components/segmentation_platform/SegmentationPlatformConversionBridge.java",
]
}
java_cpp_enum("execution_status_enums_java") {
sources = [ "result.h" ]
}
java_cpp_enum("processed_value_enums_java") {
sources = [ "types/processed_value.h" ]
}
}