Index: chrome/test/BUILD.gn |
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn |
index 0d0e9646f9c8686f18691e808a87abc70b30bfd8..e1fa372514fd9e4cdf8f1eb330e5183354ea0389 100644 |
--- a/chrome/test/BUILD.gn |
+++ b/chrome/test/BUILD.gn |
@@ -505,7 +505,9 @@ if (!is_android) { |
} |
} |
- template("js2webui") { |
+ template("js2gtest") { |
+ assert(defined(invoker.test_type) && |
+ (invoker.test_type == "webui" || invoker.test_type == "unit")) |
action_name = target_name + "_action" |
source_set_name = target_name |
@@ -531,14 +533,14 @@ if (!is_android) { |
outputs = [ |
"$target_gen_dir/{{source_name_part}}-gen.cc", |
- "$root_out_dir/test_data/chrome/{{source_root_relative_dir}}/{{source_file_part}}", |
+ "$root_out_dir/test_data/{{source_root_relative_dir}}/{{source_file_part}}", |
] |
args = [ |
# Need "./" for script to find binary (cur dir is not on path). |
"./" + rebase_path(d8_path, root_build_dir), |
] |
- args += rebase_path(input_js, root_build_dir) + [ "webui" ] |
+ args += rebase_path(input_js, root_build_dir) + [ invoker.test_type ] |
if (v8_use_external_startup_data) { |
args += [ "--external=y" ] |
} else { |
@@ -555,13 +557,25 @@ if (!is_android) { |
] |
} |
+ if (defined(invoker.extra_js_files)) { |
+ copy_target_name = target_name + "_copy" |
+ copy(copy_target_name) { |
+ visibility = [ ":$source_set_name" ] |
+ sources = invoker.extra_js_files |
+ outputs = [ |
+ "$root_out_dir/test_data/{{source_root_relative_dir}}/{{source_file_part}}", |
+ ] |
+ } |
+ } |
source_set(source_set_name) { |
testonly = true |
if (defined(invoker.visibility)) { |
visibility = invoker.visibility |
} |
sources = get_target_outputs(":$action_name") |
- defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] |
+ if (defined(invoker.defines)) { |
+ defines = invoker.defines |
+ } |
deps = [ |
":$action_name", |
@@ -573,10 +587,14 @@ if (!is_android) { |
if (defined(invoker.deps)) { |
deps += invoker.deps |
} |
+ if (defined(invoker.extra_js_files)) { |
+ data_deps = [ ":$copy_target_name" ] |
+ } |
} |
} |
- js2webui("browser_tests_js_webui") { |
+ js2gtest("browser_tests_js_webui") { |
+ test_type = "webui" |
sources = rebase_path( |
chrome_tests_gypi_values.chrome_browser_tests_webui_js_sources, |
".", |
@@ -599,6 +617,7 @@ if (!is_android) { |
"//chrome/browser/ui", |
"//skia", |
] |
+ defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] |
} |
test("browser_tests") { |
@@ -1196,6 +1215,26 @@ if (!is_android) { |
"scope", |
[ "../chrome_tests_unit.gypi" ]) |
+ js2gtest("unit_tests_js") { |
+ test_type = "unit" |
+ sources = rebase_path(unit_gypi_values.chrome_unit_tests_gtestjs_sources, |
+ ".", |
+ "//chrome") |
+ extra_js_files = rebase_path(unit_gypi_values.chrome_unit_tests_js_sources, |
+ ".", |
+ "//chrome") |
+ if (is_chromeos) { |
+ sources += rebase_path( |
+ unit_gypi_values.chrome_unit_tests_chromeos_gtestjs_sources, |
+ ".", |
+ "//chrome") |
+ extra_js_files += |
+ rebase_path(unit_gypi_values.chrome_unit_tests_chromeos_js_sources, |
+ ".", |
+ "//chrome") |
+ } |
+ } |
+ |
test("unit_tests") { |
sources = |
rebase_path(unit_gypi_values.chrome_unit_tests_sources, ".", "//chrome") |
@@ -1250,6 +1289,7 @@ if (!is_android) { |
if (!is_ios) { |
deps += [ |
+ ":unit_tests_js", |
"//components/audio_modem:audio_modem_test_support", |
"//components/autofill/content/browser:test_support", |
"//components/metrics/proto", |