# 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.
import("//build/config/android/rules.gni")
import("//chrome/android/features/android_library_factory_tmpl.gni")
# Generates java file with arbitrary class name.
template("generate_dummy_java") {
jinja_template(target_name) {
testonly = true
input = "junit/src/org/chromium/chrome/browser/android_library_factory/Dummy.java.jinja2"
output = "$target_gen_dir/junit/src/org/chromium/chrome/browser/android_library_factory/${invoker.class_name}.java"
variables = [ "class_name=${invoker.class_name}" ]
}
}
template("generate_dummy_android_library") {
# No underscores to avoid crbug.com/908819.
_generate_java_source_target_name = "${target_name}generatejavasource"
generate_dummy_java(_generate_java_source_target_name) {
class_name = invoker.class_name
}
android_library(target_name) {
forward_variables_from(invoker, "*")
if (!defined(invoker.deps)) {
deps = []
}
sources = get_target_outputs(":${_generate_java_source_target_name}")
deps += [ ":${_generate_java_source_target_name}" ]
}
}
# Check that "implementation" takes precedence in classpath over "factory java" regardless of
# the lexographic order of the target names.
generate_dummy_java("factory1") {
class_name = "Factory1"
}
android_library("a_impl_factory1_java") {
testonly = true
sources = get_target_outputs(":factory1")
deps = [ ":factory1" ]
}
android_library_factory("z_factory1_java") {
testonly = true
sources = get_target_outputs(":factory1")
generator_deps = [ ":factory1" ]
}
generate_dummy_java("factory2") {
class_name = "Factory2"
}
android_library("z_impl_factory2_java") {
testonly = true
sources = get_target_outputs(":factory2")
deps = [ ":factory2" ]
}
android_library_factory("a_factory2_java") {
testonly = true
sources = get_target_outputs(":factory2")
generator_deps = [ ":factory2" ]
}
robolectric_library("junit_tests") {
sources = [ "junit/src/org/chromium/chrome/browser/android_library_factory/AndroidLibraryFactoryTest.java" ]
deps = [
":a_factory2_java",
":a_impl_factory1_java",
":z_factory1_java",
":z_impl_factory2_java",
"//testing/android/junit:junit_test_support",
"//third_party/androidx:androidx_test_runner_java",
"//third_party/junit",
]
}