Commit 5583f942 authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Move ToolbarSecurityIconTest to unit_tests

In order to migrate java.net.URI to GURL the junit tests that rely on
java.net.URI need to be moved to a test apk that supports the native
library.

This change moves the ToolbarSecurityIconTestunittests from junit to
unit_tests (Android only). These tests should be just as fast as they
were as junit tests (and much faster than chrome_test_apk unit tests).

Bug: 783819
Change-Id: I9e397ff1260cce9fca375af212dbac9e360e31f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1997640
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Reviewed-by: default avatarEric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732491}
parent dfdace44
...@@ -75,9 +75,7 @@ template("create_native_executable_dist") { ...@@ -75,9 +75,7 @@ template("create_native_executable_dist") {
} }
deps += [ ":${_sanitizer_runtimes_target_name}" ] deps += [ ":${_sanitizer_runtimes_target_name}" ]
output_conversion = "json" output_conversion = "json"
outputs = [ outputs = [ _libraries_list ]
_libraries_list,
]
data_keys = [ "shared_libraries" ] data_keys = [ "shared_libraries" ]
walk_keys = [ "shared_libraries_barrier" ] walk_keys = [ "shared_libraries_barrier" ]
rebase = root_build_dir rebase = root_build_dir
...@@ -90,9 +88,7 @@ template("create_native_executable_dist") { ...@@ -90,9 +88,7 @@ template("create_native_executable_dist") {
] ]
dest = invoker.dist_dir dest = invoker.dist_dir
data = [ data = [ "${invoker.dist_dir}/" ]
"${invoker.dist_dir}/",
]
_rebased_libraries_list = rebase_path(_libraries_list, root_build_dir) _rebased_libraries_list = rebase_path(_libraries_list, root_build_dir)
_rebased_binaries_list = rebase_path([ invoker.binary ], root_build_dir) _rebased_binaries_list = rebase_path([ invoker.binary ], root_build_dir)
...@@ -108,9 +104,7 @@ template("create_native_executable_dist") { ...@@ -108,9 +104,7 @@ template("create_native_executable_dist") {
_depfile = "$target_gen_dir/$target_name.d" _depfile = "$target_gen_dir/$target_name.d"
_stamp_file = "$target_gen_dir/$target_name.stamp" _stamp_file = "$target_gen_dir/$target_name.stamp"
outputs = [ outputs = [ _stamp_file ]
_stamp_file,
]
args += [ args += [
"--depfile", "--depfile",
rebase_path(_depfile, root_build_dir), rebase_path(_depfile, root_build_dir),
...@@ -118,9 +112,7 @@ template("create_native_executable_dist") { ...@@ -118,9 +112,7 @@ template("create_native_executable_dist") {
rebase_path(_stamp_file, root_build_dir), rebase_path(_stamp_file, root_build_dir),
] ]
deps = [ deps = [ ":${target_name}__library_list" ]
":${target_name}__library_list",
]
if (defined(invoker.deps)) { if (defined(invoker.deps)) {
deps += invoker.deps deps += invoker.deps
} }
...@@ -333,9 +325,7 @@ if (enable_java_templates) { ...@@ -333,9 +325,7 @@ if (enable_java_templates) {
inputs = [] inputs = []
deps = [] deps = []
_srcjar_output = "$target_gen_dir/$target_name.srcjar" _srcjar_output = "$target_gen_dir/$target_name.srcjar"
outputs = [ outputs = [ _srcjar_output ]
_srcjar_output,
]
depfile = "$target_gen_dir/$target_name.d" depfile = "$target_gen_dir/$target_name.d"
args = [ args = [
...@@ -458,9 +448,7 @@ if (enable_java_templates) { ...@@ -458,9 +448,7 @@ if (enable_java_templates) {
sources = invoker.sources sources = invoker.sources
outputs = [ outputs = [ "$_base_gen_dir/${_package_path}/{{source_name_part}}.java" ]
"$_base_gen_dir/${_package_path}/{{source_name_part}}.java",
]
args = [ args = [
"--depfile", "--depfile",
...@@ -495,9 +483,7 @@ if (enable_java_templates) { ...@@ -495,9 +483,7 @@ if (enable_java_templates) {
inputs = sources inputs = sources
output = "${target_gen_dir}/${target_name}.srcjar" output = "${target_gen_dir}/${target_name}.srcjar"
base_dir = _base_gen_dir base_dir = _base_gen_dir
deps = [ deps = [ ":$_apply_gcc_target_name" ]
":$_apply_gcc_target_name",
]
} }
} }
...@@ -544,9 +530,7 @@ if (enable_java_templates) { ...@@ -544,9 +530,7 @@ if (enable_java_templates) {
rebase_path(depfile, root_build_dir), rebase_path(depfile, root_build_dir),
"--srcjar=$_rebased_srcjar_path", "--srcjar=$_rebased_srcjar_path",
] + _rebased_sources ] + _rebased_sources
outputs = [ outputs = [ _srcjar_path ]
_srcjar_path,
]
} }
} }
...@@ -623,9 +607,7 @@ if (enable_java_templates) { ...@@ -623,9 +607,7 @@ if (enable_java_templates) {
args += _rebased_sources args += _rebased_sources
sources += [ invoker.template ] sources += [ invoker.template ]
outputs = [ outputs = [ _srcjar_path ]
_srcjar_path,
]
} }
} }
...@@ -651,17 +633,13 @@ if (enable_java_templates) { ...@@ -651,17 +633,13 @@ if (enable_java_templates) {
"deps", "deps",
"testonly", "testonly",
]) ])
inputs = [ inputs = [ invoker.input ]
invoker.input,
]
if (defined(invoker.includes)) { if (defined(invoker.includes)) {
inputs += invoker.includes inputs += invoker.includes
} }
script = "//build/android/gyp/jinja_template.py" script = "//build/android/gyp/jinja_template.py"
outputs = [ outputs = [ invoker.output ]
invoker.output,
]
args = [ args = [
"--loader-base-dir", "--loader-base-dir",
...@@ -718,9 +696,7 @@ if (enable_java_templates) { ...@@ -718,9 +696,7 @@ if (enable_java_templates) {
"testonly", "testonly",
]) ])
script = "//build/android/gyp/write_native_libraries_java.py" script = "//build/android/gyp/write_native_libraries_java.py"
outputs = [ outputs = [ _native_libraries_file ]
_native_libraries_file,
]
args = [ args = [
"--output", "--output",
rebase_path(_native_libraries_file, root_build_dir), rebase_path(_native_libraries_file, root_build_dir),
...@@ -733,9 +709,7 @@ if (enable_java_templates) { ...@@ -733,9 +709,7 @@ if (enable_java_templates) {
"--native-libraries-list", "--native-libraries-list",
rebase_path(invoker.native_libraries_list_file, root_build_dir), rebase_path(invoker.native_libraries_list_file, root_build_dir),
] ]
inputs = [ inputs = [ invoker.native_libraries_list_file ]
invoker.native_libraries_list_file,
]
if (defined(invoker.version_number)) { if (defined(invoker.version_number)) {
args += [ args += [
"--version-number", "--version-number",
...@@ -857,9 +831,7 @@ if (enable_java_templates) { ...@@ -857,9 +831,7 @@ if (enable_java_templates) {
inputs = invoker.resources inputs = invoker.resources
script = "//build/android/gyp/jinja_template.py" script = "//build/android/gyp/jinja_template.py"
outputs = [ outputs = [ _resources_zip ]
_resources_zip,
]
_rebased_resources = rebase_path(invoker.resources, root_build_dir) _rebased_resources = rebase_path(invoker.resources, root_build_dir)
args = [ args = [
...@@ -1129,9 +1101,7 @@ if (enable_java_templates) { ...@@ -1129,9 +1101,7 @@ if (enable_java_templates) {
"deps", "deps",
"visibility", "visibility",
]) ])
public_deps = [ public_deps = [ ":$_build_config_target_name" ]
":$_build_config_target_name",
]
} }
} }
...@@ -1214,9 +1184,7 @@ if (enable_java_templates) { ...@@ -1214,9 +1184,7 @@ if (enable_java_templates) {
sources = get_target_outputs(":${_grit_target_name}_grit") sources = get_target_outputs(":${_grit_target_name}_grit")
inputs = sources inputs = sources
output = _resources_zip output = _resources_zip
deps = [ deps = [ ":$_grit_target_name" ]
":$_grit_target_name",
]
} }
android_generated_resources(target_name) { android_generated_resources(target_name) {
...@@ -1613,13 +1581,9 @@ if (enable_java_templates) { ...@@ -1613,13 +1581,9 @@ if (enable_java_templates) {
depfile = "$target_gen_dir/$target_name.d" depfile = "$target_gen_dir/$target_name.d"
deps = _deps deps = _deps
inputs = [ inputs = [ _build_config ]
_build_config,
]
outputs = [ outputs = [ invoker.output ]
invoker.output,
]
args = [ args = [
"--depfile", "--depfile",
...@@ -1774,9 +1738,7 @@ if (enable_java_templates) { ...@@ -1774,9 +1738,7 @@ if (enable_java_templates) {
deps = _deps deps = _deps
script = "//build/android/gyp/dist_aar.py" script = "//build/android/gyp/dist_aar.py"
inputs = [ inputs = [ _build_config ]
_build_config,
]
# Although these will be listed as deps in the depfile, they must also # Although these will be listed as deps in the depfile, they must also
# appear here so that "gn analyze" knows about them. # appear here so that "gn analyze" knows about them.
...@@ -1785,9 +1747,7 @@ if (enable_java_templates) { ...@@ -1785,9 +1747,7 @@ if (enable_java_templates) {
inputs += invoker.proguard_configs inputs += invoker.proguard_configs
} }
outputs = [ outputs = [ invoker.output ]
invoker.output,
]
args = [ args = [
"--depfile", "--depfile",
...@@ -1945,9 +1905,7 @@ if (enable_java_templates) { ...@@ -1945,9 +1905,7 @@ if (enable_java_templates) {
template("generate_build_config_srcjar") { template("generate_build_config_srcjar") {
java_cpp_template(target_name) { java_cpp_template(target_name) {
package_path = "org/chromium/base" package_path = "org/chromium/base"
sources = [ sources = [ "//base/android/java/templates/BuildConfig.template" ]
"//base/android/java/templates/BuildConfig.template",
]
defines = [] defines = []
# TODO(agrieve): These two are not target-specific and should be moved # TODO(agrieve): These two are not target-specific and should be moved
...@@ -2019,9 +1977,7 @@ if (enable_java_templates) { ...@@ -2019,9 +1977,7 @@ if (enable_java_templates) {
} }
package_path = string_replace(invoker.java_package, ".", "/") package_path = string_replace(invoker.java_package, ".", "/")
sources = [ sources = [ "//build/android/java/templates/ProductConfig.template" ]
"//build/android/java/templates/ProductConfig.template",
]
defines += [ "PACKAGE=${invoker.java_package}" ] defines += [ "PACKAGE=${invoker.java_package}" ]
_use_chromium_linker = _use_chromium_linker =
...@@ -2318,9 +2274,7 @@ if (enable_java_templates) { ...@@ -2318,9 +2274,7 @@ if (enable_java_templates) {
"$target_gen_dir/${_template_name}.native_libs" "$target_gen_dir/${_template_name}.native_libs"
generated_file("${_template_name}__shared_library_list") { generated_file("${_template_name}__shared_library_list") {
deps = _native_libs_deps deps = _native_libs_deps
outputs = [ outputs = [ _shared_library_list_file ]
_shared_library_list_file,
]
data_keys = [ "shared_libraries" ] data_keys = [ "shared_libraries" ]
walk_keys = [ "shared_libraries_barrier" ] walk_keys = [ "shared_libraries_barrier" ]
rebase = root_build_dir rebase = root_build_dir
...@@ -2344,9 +2298,7 @@ if (enable_java_templates) { ...@@ -2344,9 +2298,7 @@ if (enable_java_templates) {
"$target_gen_dir/${_template_name}.secondary_abi_native_libs" "$target_gen_dir/${_template_name}.secondary_abi_native_libs"
generated_file("${_template_name}__secondary_abi_shared_library_list") { generated_file("${_template_name}__secondary_abi_shared_library_list") {
deps = _secondary_abi_native_libs_deps deps = _secondary_abi_native_libs_deps
outputs = [ outputs = [ _secondary_abi_shared_library_list_file ]
_secondary_abi_shared_library_list_file,
]
data_keys = [ "shared_libraries" ] data_keys = [ "shared_libraries" ]
walk_keys = [ "shared_libraries_barrier" ] walk_keys = [ "shared_libraries_barrier" ]
rebase = root_build_dir rebase = root_build_dir
...@@ -2623,17 +2575,11 @@ if (enable_java_templates) { ...@@ -2623,17 +2575,11 @@ if (enable_java_templates) {
if (defined(_resource_sizes_arsc_path)) { if (defined(_resource_sizes_arsc_path)) {
_copy_arsc_target = "${_template_name}__copy_arsc" _copy_arsc_target = "${_template_name}__copy_arsc"
copy(_copy_arsc_target) { copy(_copy_arsc_target) {
deps = [ deps = [ ":$_compile_resources_target" ]
":$_compile_resources_target",
]
# resource_sizes.py doesn't care if it gets the optimized .arsc. # resource_sizes.py doesn't care if it gets the optimized .arsc.
sources = [ sources = [ _arsc_resources_path ]
_arsc_resources_path, outputs = [ _resource_sizes_arsc_path ]
]
outputs = [
_resource_sizes_arsc_path,
]
} }
_final_deps += [ ":$_copy_arsc_target" ] _final_deps += [ ":$_copy_arsc_target" ]
} }
...@@ -2647,15 +2593,9 @@ if (enable_java_templates) { ...@@ -2647,15 +2593,9 @@ if (enable_java_templates) {
# file. # file.
_copy_rtxt_target = "${_template_name}__copy_rtxt" _copy_rtxt_target = "${_template_name}__copy_rtxt"
copy(_copy_rtxt_target) { copy(_copy_rtxt_target) {
deps = [ deps = [ ":$_compile_resources_target" ]
":$_compile_resources_target", sources = [ _compile_resources_rtxt_out ]
] outputs = [ _final_rtxt_path ]
sources = [
_compile_resources_rtxt_out,
]
outputs = [
_final_rtxt_path,
]
} }
_final_deps += [ ":$_copy_rtxt_target" ] _final_deps += [ ":$_copy_rtxt_target" ]
...@@ -2663,20 +2603,12 @@ if (enable_java_templates) { ...@@ -2663,20 +2603,12 @@ if (enable_java_templates) {
# Do the same for path map # Do the same for path map
_copy_pathmap_target = "${_template_name}__copy_pathmap" _copy_pathmap_target = "${_template_name}__copy_pathmap"
copy(_copy_pathmap_target) { copy(_copy_pathmap_target) {
deps = [ deps = [ ":$_compile_resources_target" ]
":$_compile_resources_target", sources = [ _resources_path_map_out_path ]
] outputs = [ _final_pathmap_path ]
sources = [
_resources_path_map_out_path,
]
outputs = [
_final_pathmap_path,
]
# The monochrome_apk_checker test needs pathmap when run on swarming. # The monochrome_apk_checker test needs pathmap when run on swarming.
data = [ data = [ _final_pathmap_path ]
_final_pathmap_path,
]
} }
_final_deps += [ ":$_copy_pathmap_target" ] _final_deps += [ ":$_copy_pathmap_target" ]
} }
...@@ -2750,9 +2682,7 @@ if (enable_java_templates) { ...@@ -2750,9 +2682,7 @@ if (enable_java_templates) {
resources_version_variable = resources_version_variable =
"org.chromium.base.R.string.product_version" "org.chromium.base.R.string.product_version"
} }
deps = [ deps = [ ":$_build_config_target" ]
":$_build_config_target",
]
} }
_srcjar_deps += [ ":${_template_name}__build_config_srcjar" ] _srcjar_deps += [ ":${_template_name}__build_config_srcjar" ]
} }
...@@ -2767,9 +2697,7 @@ if (enable_java_templates) { ...@@ -2767,9 +2697,7 @@ if (enable_java_templates) {
java_package = _package java_package = _package
use_chromium_linker = _use_chromium_linker use_chromium_linker = _use_chromium_linker
use_modern_linker = _use_modern_linker use_modern_linker = _use_modern_linker
deps = [ deps = [ ":$_build_config_target" ]
":$_build_config_target",
]
} }
_srcjar_deps += [ ":$_locale_target_name" ] _srcjar_deps += [ ":$_locale_target_name" ]
} }
...@@ -2810,9 +2738,7 @@ if (enable_java_templates) { ...@@ -2810,9 +2738,7 @@ if (enable_java_templates) {
# and thus, this workaround skips looking for one. # and thus, this workaround skips looking for one.
if (defined(invoker.base_module_target)) { if (defined(invoker.base_module_target)) {
group("${_template_name}__group") { group("${_template_name}__group") {
deps = [ deps = [ "${invoker.base_module_target}__java" ]
"${invoker.base_module_target}__java",
]
} }
} }
java_library_impl(_java_target) { java_library_impl(_java_target) {
...@@ -2933,9 +2859,7 @@ if (enable_java_templates) { ...@@ -2933,9 +2859,7 @@ if (enable_java_templates) {
dist_jar("${_template_name}_dist_ijar") { dist_jar("${_template_name}_dist_ijar") {
override_build_config = _build_config override_build_config = _build_config
output = _dist_ijar_path output = _dist_ijar_path
data = [ data = [ _dist_ijar_path ]
_dist_ijar_path,
]
use_interface_jars = true use_interface_jars = true
deps = [ deps = [
":$_build_config_target", ":$_build_config_target",
...@@ -3090,13 +3014,9 @@ if (enable_java_templates) { ...@@ -3090,13 +3014,9 @@ if (enable_java_templates) {
depfile = "$target_gen_dir/$target_name.d" depfile = "$target_gen_dir/$target_name.d"
script = script =
"//build/android/gyp/validate_static_library_dex_references.py" "//build/android/gyp/validate_static_library_dex_references.py"
inputs = [ inputs = [ _build_config ]
_build_config,
]
_stamp = "$target_gen_dir/$target_name.stamp" _stamp = "$target_gen_dir/$target_name.stamp"
outputs = [ outputs = [ _stamp ]
_stamp,
]
deps = [ deps = [
":$_build_config_target", ":$_build_config_target",
":$_static_library_dexsplitter_target", ":$_static_library_dexsplitter_target",
...@@ -3200,9 +3120,7 @@ if (enable_java_templates) { ...@@ -3200,9 +3120,7 @@ if (enable_java_templates) {
_build_config, _build_config,
_arsc_resources_path, _arsc_resources_path,
] ]
outputs = [ outputs = [ _incremental_compiled_resources_path ]
_incremental_compiled_resources_path,
]
args = [ args = [
"--disable-isolated-processes", "--disable-isolated-processes",
...@@ -3295,15 +3213,9 @@ if (enable_java_templates) { ...@@ -3295,15 +3213,9 @@ if (enable_java_templates) {
script = "//build/android/incremental_install/write_installer_json.py" script = "//build/android/incremental_install/write_installer_json.py"
deps = [ ":$_build_config_target" ] + _all_native_libs_deps deps = [ ":$_build_config_target" ] + _all_native_libs_deps
data = [ data = [ _incremental_install_json_path ]
_incremental_install_json_path, inputs = [ _build_config ]
] outputs = [ _incremental_install_json_path ]
inputs = [
_build_config,
]
outputs = [
_incremental_install_json_path,
]
_rebased_incremental_apk_path = _rebased_incremental_apk_path =
rebase_path(_incremental_apk_path, root_build_dir) rebase_path(_incremental_apk_path, root_build_dir)
...@@ -3345,12 +3257,8 @@ if (enable_java_templates) { ...@@ -3345,12 +3257,8 @@ if (enable_java_templates) {
"${target_gen_dir}/${target_name}.install_artifacts" "${target_gen_dir}/${target_name}.install_artifacts"
generated_file(_install_artifacts_target) { generated_file(_install_artifacts_target) {
output_conversion = "json" output_conversion = "json"
deps = [ deps = [ invoker.static_library_provider ]
invoker.static_library_provider, outputs = [ _install_artifacts_json ]
]
outputs = [
_install_artifacts_json,
]
data_keys = [ "install_artifacts" ] data_keys = [ "install_artifacts" ]
rebase = root_build_dir rebase = root_build_dir
} }
...@@ -3359,17 +3267,11 @@ if (enable_java_templates) { ...@@ -3359,17 +3267,11 @@ if (enable_java_templates) {
action_with_pydeps(_apk_operations_target_name) { action_with_pydeps(_apk_operations_target_name) {
_generated_script = "$root_build_dir/bin/${invoker.target_name}" _generated_script = "$root_build_dir/bin/${invoker.target_name}"
script = "//build/android/gyp/create_apk_operations_script.py" script = "//build/android/gyp/create_apk_operations_script.py"
outputs = [ outputs = [ _generated_script ]
_generated_script,
]
if (_proguard_enabled) { if (_proguard_enabled) {
# Required by logcat command. # Required by logcat command.
data_deps = [ data_deps = [ "//build/android/stacktrace:java_deobfuscate" ]
"//build/android/stacktrace:java_deobfuscate", data = [ "$_final_apk_path.mapping" ]
]
data = [
"$_final_apk_path.mapping",
]
} }
args = [ args = [
"--script-output-path", "--script-output-path",
...@@ -3394,9 +3296,7 @@ if (enable_java_templates) { ...@@ -3394,9 +3296,7 @@ if (enable_java_templates) {
] ]
} }
if (_uses_static_library) { if (_uses_static_library) {
deps = [ deps = [ ":$_install_artifacts_target" ]
":$_install_artifacts_target",
]
_rebased_install_artifacts_json = _rebased_install_artifacts_json =
rebase_path(_install_artifacts_json, root_build_dir) rebase_path(_install_artifacts_json, root_build_dir)
_static_library_apk_path = _static_library_apk_path =
...@@ -3844,9 +3744,7 @@ if (enable_java_templates) { ...@@ -3844,9 +3744,7 @@ if (enable_java_templates) {
} else { } else {
_final_apk_path = "$root_build_dir/apks/${apk_name}.apk" _final_apk_path = "$root_build_dir/apks/${apk_name}.apk"
} }
data = [ data = [ "$_final_apk_path.mapping" ]
"$_final_apk_path.mapping",
]
data_deps += [ "//build/android/stacktrace:java_deobfuscate" ] data_deps += [ "//build/android/stacktrace:java_deobfuscate" ]
} }
...@@ -3936,6 +3834,7 @@ if (enable_java_templates) { ...@@ -3936,6 +3834,7 @@ if (enable_java_templates) {
forward_variables_from(invoker, "*") forward_variables_from(invoker, "*")
testonly = true testonly = true
create_apk_script = false create_apk_script = false
enable_native_mocks = true
assert(!defined(invoker.proguard_enabled) || !invoker.proguard_enabled || assert(!defined(invoker.proguard_enabled) || !invoker.proguard_enabled ||
invoker.proguard_configs != []) invoker.proguard_configs != [])
...@@ -4009,9 +3908,7 @@ if (enable_java_templates) { ...@@ -4009,9 +3908,7 @@ if (enable_java_templates) {
inputs = [ _aidl_path ] + _imports inputs = [ _aidl_path ] + _imports
outputs = [ outputs = [ _srcjar_path ]
_srcjar_path,
]
_rebased_imports = rebase_path(_imports, root_build_dir) _rebased_imports = rebase_path(_imports, root_build_dir)
args = [ args = [
"--aidl-path", "--aidl-path",
...@@ -4103,18 +4000,14 @@ if (enable_java_templates) { ...@@ -4103,18 +4000,14 @@ if (enable_java_templates) {
_srcjar_path = "$target_gen_dir/$target_name.srcjar" _srcjar_path = "$target_gen_dir/$target_name.srcjar"
script = "//build/protoc_java.py" script = "//build/protoc_java.py"
deps = [ deps = [ _protoc_dep ]
_protoc_dep,
]
if (defined(invoker.deps)) { if (defined(invoker.deps)) {
deps += invoker.deps deps += invoker.deps
} }
sources = invoker.sources sources = invoker.sources
depfile = "$target_gen_dir/$target_name.d" depfile = "$target_gen_dir/$target_name.d"
outputs = [ outputs = [ _srcjar_path ]
_srcjar_path,
]
args = [ args = [
"--depfile", "--depfile",
rebase_path(depfile, root_build_dir), rebase_path(depfile, root_build_dir),
...@@ -4149,9 +4042,7 @@ if (enable_java_templates) { ...@@ -4149,9 +4042,7 @@ if (enable_java_templates) {
chromium_code = false chromium_code = false
sources = [] sources = []
srcjar_deps = [ ":${_template_name}__protoc_java" ] srcjar_deps = [ ":${_template_name}__protoc_java" ]
deps = [ deps = [ _proto_runtime ]
_proto_runtime,
]
if (defined(invoker.deps)) { if (defined(invoker.deps)) {
deps += invoker.deps deps += invoker.deps
} }
...@@ -4265,9 +4156,7 @@ if (enable_java_templates) { ...@@ -4265,9 +4156,7 @@ if (enable_java_templates) {
if (_strip_resources) { if (_strip_resources) {
args += [ "--ignore-resources" ] args += [ "--ignore-resources" ]
} }
inputs = [ inputs = [ invoker.aar_path ]
invoker.aar_path,
]
outputs = [] outputs = []
if (!_ignore_manifest) { if (!_ignore_manifest) {
outputs += [ "${_output_path}/AndroidManifest.xml" ] outputs += [ "${_output_path}/AndroidManifest.xml" ]
...@@ -4353,9 +4242,7 @@ if (enable_java_templates) { ...@@ -4353,9 +4242,7 @@ if (enable_java_templates) {
_subjar_targets += [ ":$_current_target" ] _subjar_targets += [ ":$_current_target" ]
java_prebuilt(_current_target) { java_prebuilt(_current_target) {
forward_variables_from(invoker, _java_library_vars) forward_variables_from(invoker, _java_library_vars)
deps = [ deps = [ ":$_unpack_target_name" ]
":$_unpack_target_name",
]
if (!defined(requires_android)) { if (!defined(requires_android)) {
requires_android = true requires_android = true
} }
...@@ -4406,9 +4293,7 @@ if (enable_java_templates) { ...@@ -4406,9 +4293,7 @@ if (enable_java_templates) {
"testonly", "testonly",
"visibility", "visibility",
]) ])
public_deps = [ public_deps = [ ":$_unpack_target_name" ]
":$_unpack_target_name",
]
deps = [] deps = []
if (defined(_jar_target_name)) { if (defined(_jar_target_name)) {
deps += [ ":$_jar_target_name" ] deps += [ ":$_jar_target_name" ]
...@@ -4666,9 +4551,7 @@ if (enable_java_templates) { ...@@ -4666,9 +4551,7 @@ if (enable_java_templates) {
deps = _module_java_targets deps = _module_java_targets
} }
group("${_target_name}__compile_resources") { group("${_target_name}__compile_resources") {
deps = [ deps = [ "${invoker.base_module_target}__compile_resources" ]
"${invoker.base_module_target}__compile_resources",
]
} }
_build_config = "$target_gen_dir/${_target_name}.build_config" _build_config = "$target_gen_dir/${_target_name}.build_config"
...@@ -4844,9 +4727,7 @@ if (enable_java_templates) { ...@@ -4844,9 +4727,7 @@ if (enable_java_templates) {
action_with_pydeps(_bundle_target_name) { action_with_pydeps(_bundle_target_name) {
script = "//build/android/gyp/create_app_bundle.py" script = "//build/android/gyp/create_app_bundle.py"
inputs = _all_module_zip_paths + _all_module_build_configs inputs = _all_module_zip_paths + _all_module_build_configs
outputs = [ outputs = [ _bundle_path ]
_bundle_path,
]
deps = _all_create_module_targets + [ ":$_build_config_target" ] deps = _all_create_module_targets + [ ":$_build_config_target" ]
args = [ args = [
"--out-bundle=$_rebased_bundle_path", "--out-bundle=$_rebased_bundle_path",
...@@ -4915,12 +4796,8 @@ if (enable_java_templates) { ...@@ -4915,12 +4796,8 @@ if (enable_java_templates) {
"${target_gen_dir}/${target_name}.install_artifacts" "${target_gen_dir}/${target_name}.install_artifacts"
generated_file(_install_artifacts_target) { generated_file(_install_artifacts_target) {
output_conversion = "json" output_conversion = "json"
deps = [ deps = [ invoker.static_library_provider ]
invoker.static_library_provider, outputs = [ _install_artifacts_json ]
]
outputs = [
_install_artifacts_json,
]
data_keys = [ "install_artifacts" ] data_keys = [ "install_artifacts" ]
rebase = root_build_dir rebase = root_build_dir
} }
...@@ -4935,12 +4812,8 @@ if (enable_java_templates) { ...@@ -4935,12 +4812,8 @@ if (enable_java_templates) {
action_with_pydeps("${_target_name}__wrapper_script") { action_with_pydeps("${_target_name}__wrapper_script") {
script = "//build/android/gyp/create_bundle_wrapper_script.py" script = "//build/android/gyp/create_bundle_wrapper_script.py"
inputs = [ inputs = [ _base_module_build_config ]
_base_module_build_config, outputs = [ _bundle_wrapper_script_path ]
]
outputs = [
_bundle_wrapper_script_path,
]
# Telemetry for bundles uses the wrapper script for installation. # Telemetry for bundles uses the wrapper script for installation.
data = [ data = [
...@@ -4949,13 +4822,9 @@ if (enable_java_templates) { ...@@ -4949,13 +4822,9 @@ if (enable_java_templates) {
_keystore_path, _keystore_path,
_bundle_path, _bundle_path,
] ]
data_deps = [ data_deps = [ "//build/android:bundle_wrapper_script_py" ]
"//build/android:bundle_wrapper_script_py",
]
deps = [ deps = [ _base_module_build_config_target ]
_base_module_build_config_target,
]
args = [ args = [
"--script-output-path", "--script-output-path",
rebase_path(_bundle_wrapper_script_path, root_build_dir), rebase_path(_bundle_wrapper_script_path, root_build_dir),
...@@ -5021,15 +4890,9 @@ if (enable_java_templates) { ...@@ -5021,15 +4890,9 @@ if (enable_java_templates) {
_apks_path = "$root_build_dir/apks/$_bundle_name.apks" _apks_path = "$root_build_dir/apks/$_bundle_name.apks"
action_with_pydeps("${_target_name}_apks") { action_with_pydeps("${_target_name}_apks") {
script = "//build/android/gyp/create_app_bundle_apks.py" script = "//build/android/gyp/create_app_bundle_apks.py"
inputs = [ inputs = [ _bundle_path ]
_bundle_path, outputs = [ _apks_path ]
] data = [ _apks_path ]
outputs = [
_apks_path,
]
data = [
_apks_path,
]
args = [ args = [
"--bundle", "--bundle",
_rebased_bundle_path, _rebased_bundle_path,
...@@ -5044,9 +4907,7 @@ if (enable_java_templates) { ...@@ -5044,9 +4907,7 @@ if (enable_java_templates) {
"--keystore-password", "--keystore-password",
android_keystore_password, android_keystore_password,
] ]
deps = [ deps = [ ":$_bundle_target_name" ]
":$_bundle_target_name",
]
metadata = { metadata = {
install_artifacts = [ _apks_path ] install_artifacts = [ _apks_path ]
} }
...@@ -5081,12 +4942,8 @@ if (enable_java_templates) { ...@@ -5081,12 +4942,8 @@ if (enable_java_templates) {
_dir = get_path_info(invoker.bundle_path, "dir") _dir = get_path_info(invoker.bundle_path, "dir")
_name = get_path_info(invoker.bundle_path, "name") _name = get_path_info(invoker.bundle_path, "name")
_output_path = "$_dir/$_name.minimal.apks" _output_path = "$_dir/$_name.minimal.apks"
outputs = [ outputs = [ _output_path ]
_output_path, inputs = [ invoker.bundle_path ]
]
inputs = [
invoker.bundle_path,
]
args = [ args = [
"--bundle", "--bundle",
rebase_path(invoker.bundle_path, root_build_dir), rebase_path(invoker.bundle_path, root_build_dir),
...@@ -5126,9 +4983,7 @@ template("generate_ui_locale_resources") { ...@@ -5126,9 +4983,7 @@ template("generate_ui_locale_resources") {
action(_generating_target_name) { action(_generating_target_name) {
script = "//build/android/gyp/create_ui_locale_resources.py" script = "//build/android/gyp/create_ui_locale_resources.py"
depfile = _depfile depfile = _depfile
outputs = [ outputs = [ _output_zip ]
_output_zip,
]
args = [ args = [
"--locale-list=$_locales", "--locale-list=$_locales",
"--depfile", "--depfile",
......
...@@ -2846,6 +2846,7 @@ android_library("native_java_unittests_java") { ...@@ -2846,6 +2846,7 @@ android_library("native_java_unittests_java") {
":chrome_test_util_java", ":chrome_test_util_java",
"//base:base_java", "//base:base_java",
"//base:base_java_test_support", "//base:base_java_test_support",
"//base:jni_java",
"//base/test:test_support_java", "//base/test:test_support_java",
"//chrome/android:chrome_java", "//chrome/android:chrome_java",
"//chrome/browser/util:java", "//chrome/browser/util:java",
...@@ -2871,6 +2872,7 @@ android_library("native_java_unittests_java") { ...@@ -2871,6 +2872,7 @@ android_library("native_java_unittests_java") {
"native_java_unittests/src/org/chromium/chrome/browser/payments/AndroidPaymentAppFinderUnitTest.java", "native_java_unittests/src/org/chromium/chrome/browser/payments/AndroidPaymentAppFinderUnitTest.java",
"native_java_unittests/src/org/chromium/chrome/browser/payments/PaymentManifestVerifierTest.java", "native_java_unittests/src/org/chromium/chrome/browser/payments/PaymentManifestVerifierTest.java",
"native_java_unittests/src/org/chromium/chrome/browser/tabmodel/TabPersistentStoreUnitTest.java", "native_java_unittests/src/org/chromium/chrome/browser/tabmodel/TabPersistentStoreUnitTest.java",
"native_java_unittests/src/org/chromium/chrome/browser/toolbar/ToolbarSecurityIconTest.java",
] ]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
...@@ -2888,5 +2890,6 @@ generate_jni("native_j_unittests_jni_headers") { ...@@ -2888,5 +2890,6 @@ generate_jni("native_j_unittests_jni_headers") {
"native_java_unittests/src/org/chromium/chrome/browser/payments/AndroidPaymentAppFinderUnitTest.java", "native_java_unittests/src/org/chromium/chrome/browser/payments/AndroidPaymentAppFinderUnitTest.java",
"native_java_unittests/src/org/chromium/chrome/browser/payments/PaymentManifestVerifierTest.java", "native_java_unittests/src/org/chromium/chrome/browser/payments/PaymentManifestVerifierTest.java",
"native_java_unittests/src/org/chromium/chrome/browser/tabmodel/TabPersistentStoreUnitTest.java", "native_java_unittests/src/org/chromium/chrome/browser/tabmodel/TabPersistentStoreUnitTest.java",
"native_java_unittests/src/org/chromium/chrome/browser/toolbar/ToolbarSecurityIconTest.java",
] ]
} }
...@@ -203,7 +203,6 @@ chrome_junit_test_java_sources = [ ...@@ -203,7 +203,6 @@ chrome_junit_test_java_sources = [
"junit/src/org/chromium/chrome/browser/tabstate/TabStateUnitTest.java", "junit/src/org/chromium/chrome/browser/tabstate/TabStateUnitTest.java",
"junit/src/org/chromium/chrome/browser/tasks/EngagementTimeUtilTest.java", "junit/src/org/chromium/chrome/browser/tasks/EngagementTimeUtilTest.java",
"junit/src/org/chromium/chrome/browser/tasks/JourneyManagerTest.java", "junit/src/org/chromium/chrome/browser/tasks/JourneyManagerTest.java",
"junit/src/org/chromium/chrome/browser/toolbar/ToolbarSecurityIconTest.java",
"junit/src/org/chromium/chrome/browser/usage_stats/EventTrackerTest.java", "junit/src/org/chromium/chrome/browser/usage_stats/EventTrackerTest.java",
"junit/src/org/chromium/chrome/browser/usage_stats/PageViewObserverTest.java", "junit/src/org/chromium/chrome/browser/usage_stats/PageViewObserverTest.java",
"junit/src/org/chromium/chrome/browser/util/BitmapCacheTest.java", "junit/src/org/chromium/chrome/browser/util/BitmapCacheTest.java",
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
package org.chromium.chrome.browser.ssl; package org.chromium.chrome.browser.ssl;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.annotations.NativeMethods; import org.chromium.base.annotations.NativeMethods;
import org.chromium.components.security_state.ConnectionSecurityLevel; import org.chromium.components.security_state.ConnectionSecurityLevel;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
...@@ -39,7 +41,8 @@ public class SecurityStateModel { ...@@ -39,7 +41,8 @@ public class SecurityStateModel {
private SecurityStateModel() {} private SecurityStateModel() {}
@NativeMethods @NativeMethods
interface Natives { @VisibleForTesting
public interface Natives {
int getSecurityLevelForWebContents(WebContents webContents); int getSecurityLevelForWebContents(WebContents webContents);
boolean shouldShowDangerTriangleForWarningLevel(); boolean shouldShowDangerTriangleForWarningLevel();
} }
......
...@@ -4,38 +4,24 @@ ...@@ -4,38 +4,24 @@
package org.chromium.chrome.browser.toolbar; package org.chromium.chrome.browser.toolbar;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.res.Resources;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.Resetter;
import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.base.ContextUtils;
import org.chromium.base.test.util.JniMocker; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.CalledByNativeJavaTest;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.omnibox.LocationBarLayout; import org.chromium.chrome.browser.omnibox.LocationBarLayout;
import org.chromium.chrome.browser.ssl.SecurityStateModel; import org.chromium.chrome.browser.ssl.SecurityStateModel;
import org.chromium.chrome.browser.ssl.SecurityStateModelJni;
import org.chromium.chrome.browser.tab.TabImpl; import org.chromium.chrome.browser.tab.TabImpl;
import org.chromium.components.security_state.ConnectionSecurityLevel; import org.chromium.components.security_state.ConnectionSecurityLevel;
/** /**
* Unit tests for {@link LocationBarLayout} class. * Unit tests for {@link LocationBarLayout} class.
*/ */
@RunWith(BaseRobolectricTestRunner.class)
@Config(manifest = Config.NONE, shadows = {ToolbarSecurityIconTest.ShadowSecurityStateModel.class})
public final class ToolbarSecurityIconTest { public final class ToolbarSecurityIconTest {
private static final boolean IS_SMALL_DEVICE = true; private static final boolean IS_SMALL_DEVICE = true;
private static final boolean IS_OFFLINE_PAGE = true; private static final boolean IS_OFFLINE_PAGE = true;
...@@ -43,58 +29,31 @@ public final class ToolbarSecurityIconTest { ...@@ -43,58 +29,31 @@ public final class ToolbarSecurityIconTest {
private static final int[] SECURITY_LEVELS = new int[] {ConnectionSecurityLevel.NONE, private static final int[] SECURITY_LEVELS = new int[] {ConnectionSecurityLevel.NONE,
ConnectionSecurityLevel.WARNING, ConnectionSecurityLevel.DANGEROUS, ConnectionSecurityLevel.WARNING, ConnectionSecurityLevel.DANGEROUS,
ConnectionSecurityLevel.SECURE, ConnectionSecurityLevel.EV_SECURE}; ConnectionSecurityLevel.SECURE, ConnectionSecurityLevel.EV_SECURE};
private static final long NATIVE_PTR = 1;
@Rule
public JniMocker mocker = new JniMocker();
@Mock @Mock
private TabImpl mTab; private TabImpl mTab;
@Mock @Mock
private Context mContext; SecurityStateModel.Natives mSecurityStateMocks;
@Mock
private Resources mResources;
@Mock
LocationBarModel.Natives mNativeMocks;
private LocationBarModel mLocationBarModel; private LocationBarModel mLocationBarModel;
@Implements(SecurityStateModel.class) @CalledByNative
static class ShadowSecurityStateModel { private ToolbarSecurityIconTest() {}
private static boolean sShouldShowDangerTriangle;
@Resetter
public static void reset() {
sShouldShowDangerTriangle = false;
}
@Implementation
public static boolean shouldShowDangerTriangleForWarningLevel() {
return sShouldShowDangerTriangle;
}
public static void setShouldShowDangerTriangleForWarningLevel(
boolean shouldShowDangerTriangleValue) {
sShouldShowDangerTriangle = shouldShowDangerTriangleValue;
}
}
@Before @CalledByNative
public void setUp() { public void setUp() {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
mocker.mock(LocationBarModelJni.TEST_HOOKS, mNativeMocks); SecurityStateModelJni.TEST_HOOKS.setInstanceForTesting(mSecurityStateMocks);
doReturn(mResources).when(mContext).getResources(); mLocationBarModel = new LocationBarModel(ContextUtils.getApplicationContext());
when(mNativeMocks.init(any())).thenReturn(NATIVE_PTR);
mLocationBarModel = new LocationBarModel(mContext);
mLocationBarModel.initializeWithNative(); mLocationBarModel.initializeWithNative();
} }
@After @CalledByNative
public void tearDown() { public void tearDown() {
ShadowSecurityStateModel.reset(); SecurityStateModelJni.TEST_HOOKS.setInstanceForTesting(null);
} }
@Test @CalledByNativeJavaTest
public void testGetSecurityLevel() { public void testGetSecurityLevel() {
assertEquals(ConnectionSecurityLevel.NONE, assertEquals(ConnectionSecurityLevel.NONE,
LocationBarModel.getSecurityLevel(null, !IS_OFFLINE_PAGE, null)); LocationBarModel.getSecurityLevel(null, !IS_OFFLINE_PAGE, null));
...@@ -123,8 +82,9 @@ public final class ToolbarSecurityIconTest { ...@@ -123,8 +82,9 @@ public final class ToolbarSecurityIconTest {
LocationBarModel.getSecurityLevel(mTab, !IS_OFFLINE_PAGE, null)); LocationBarModel.getSecurityLevel(mTab, !IS_OFFLINE_PAGE, null));
} }
@Test @CalledByNativeJavaTest
public void testGetSecurityIconResource() { public void testGetSecurityIconResource() {
when(mSecurityStateMocks.shouldShowDangerTriangleForWarningLevel()).thenReturn(false);
for (int securityLevel : SECURITY_LEVELS) { for (int securityLevel : SECURITY_LEVELS) {
assertEquals("Wrong phone resource for security level " + securityLevel, assertEquals("Wrong phone resource for security level " + securityLevel,
R.drawable.ic_offline_pin_24dp, R.drawable.ic_offline_pin_24dp,
...@@ -189,8 +149,9 @@ public final class ToolbarSecurityIconTest { ...@@ -189,8 +149,9 @@ public final class ToolbarSecurityIconTest {
!IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); !IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW));
} }
@Test @CalledByNativeJavaTest
public void testGetSecurityIconResourceForMarkHttpAsDangerWarning() { public void testGetSecurityIconResourceForMarkHttpAsDangerWarning() {
when(mSecurityStateMocks.shouldShowDangerTriangleForWarningLevel()).thenReturn(false);
assertEquals(0, assertEquals(0,
mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.NONE, mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.NONE,
IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW));
...@@ -198,7 +159,7 @@ public final class ToolbarSecurityIconTest { ...@@ -198,7 +159,7 @@ public final class ToolbarSecurityIconTest {
mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.NONE, mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.NONE,
!IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); !IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW));
ShadowSecurityStateModel.setShouldShowDangerTriangleForWarningLevel(true); when(mSecurityStateMocks.shouldShowDangerTriangleForWarningLevel()).thenReturn(true);
assertEquals(R.drawable.omnibox_not_secure_warning, assertEquals(R.drawable.omnibox_not_secure_warning,
mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.WARNING, mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.WARNING,
IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW));
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/android/jni_android.h"
#include "chrome/android/native_j_unittests_jni_headers/ToolbarSecurityIconTest_jni.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::android::AttachCurrentThread;
class ToolbarSecurityIconTest : public ::testing::Test {
public:
ToolbarSecurityIconTest()
: j_test_(
Java_ToolbarSecurityIconTest_Constructor(AttachCurrentThread())) {}
void SetUp() override {
Java_ToolbarSecurityIconTest_setUp(AttachCurrentThread(), j_test_);
}
void TearDown() override {
Java_ToolbarSecurityIconTest_tearDown(AttachCurrentThread(), j_test_);
}
const base::android::ScopedJavaGlobalRef<jobject>& j_test() {
return j_test_;
}
private:
base::android::ScopedJavaGlobalRef<jobject> j_test_;
};
JAVA_TESTS(ToolbarSecurityIconTest, j_test())
...@@ -3759,6 +3759,7 @@ test("unit_tests") { ...@@ -3759,6 +3759,7 @@ test("unit_tests") {
"../browser/permissions/permission_request_notification_android_unittest.cc", "../browser/permissions/permission_request_notification_android_unittest.cc",
"../browser/permissions/permission_request_notification_handler_unittest.cc", "../browser/permissions/permission_request_notification_handler_unittest.cc",
"../browser/tabmodel/tab_persistent_store_unittest.cc", "../browser/tabmodel/tab_persistent_store_unittest.cc",
"../browser/toolbar/toolbar_security_icon_unittest.cc",
"../browser/touch_to_fill/touch_to_fill_controller_unittest.cc", "../browser/touch_to_fill/touch_to_fill_controller_unittest.cc",
"../browser/translate/translate_manager_render_view_host_android_unittest.cc", "../browser/translate/translate_manager_render_view_host_android_unittest.cc",
"../browser/updates/update_notification_config_unittest.cc", "../browser/updates/update_notification_config_unittest.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment