# Copyright 2016 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/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import(
"//chrome/browser/resources/chromeos/accessibility/tools/run_jsbundler.gni")
import("//chrome/common/features.gni")
import("//chrome/test/base/ash/js2gtest.gni")
import("//testing/test.gni")
import("//tools/typescript/ts_library.gni")
assert(is_chromeos_ash)
group("build") {
deps = [ ":copied_files" ]
}
select_to_speak_out_dir =
"$root_out_dir/resources/chromeos/accessibility/select_to_speak"
# Directory where typescript build will occur.
ts_build_staging_dir = "$target_gen_dir/ts_build_staging"
tsc_out_dir = "$target_gen_dir/tsc"
common_tsc_dir =
"$root_gen_dir/chrome/browser/resources/chromeos/accessibility/common/tsc"
# Add typescript files to compile here.
ts_modules = [
"select_to_speak_main.ts",
"metrics_utils.ts",
"select_to_speak_constants.ts",
"tts_manager.ts",
"input_handler.ts",
"ui_manager.ts",
"prefs_manager.ts",
"select_to_speak.ts",
]
# Root dir must be the parent directory so it can reach common.
ts_library("ts_build") {
root_dir = "$ts_build_staging_dir"
out_dir = tsc_out_dir
composite = true
deps = [ "../common:ts_build" ]
extra_deps = [ ":stage_ts_build" ]
path_mappings =
[ "/common/*|" + rebase_path("$common_tsc_dir/*", target_gen_dir) ]
definitions = [
"../definitions/accessibility_private_mv2.d.ts",
"../definitions/automation.d.ts",
"../definitions/clipboard_mv2.d.ts",
"../definitions/extensions.d.ts",
"../definitions/extension_types.d.ts",
"../definitions/i18n.d.ts",
"../definitions/runtime.d.ts",
"../definitions/settings_private_mv2.d.ts",
"../definitions/storage_mv2.d.ts",
"../definitions/tabs.d.ts",
"../definitions/tts.d.ts",
"../definitions/windows.d.ts",
"//tools/typescript/definitions/chrome_event.d.ts",
"//tools/typescript/definitions/context_menus.d.ts",
"//tools/typescript/definitions/metrics_private.d.ts",
]
in_files = ts_modules
tsconfig_base = "../tsconfig.base.json"
}
# Instead of setting up one copy target for each subdirectory, use a script
# to copy all files.
run_jsbundler("copied_files") {
mode = "copy"
dest_dir = select_to_speak_out_dir
clear_dest_dirs = [ "." ]
deps = [
":ts_build",
"../common:copied_files",
]
sources = [
"background.html",
"checked.png",
"earcons/null_selection.ogg",
"select_to_speak-2x.svg",
"sts-icon-128.png",
"sts-icon-16.png",
"sts-icon-48.png",
"unchecked.png",
]
sources += filter_include(get_target_outputs(":ts_build"), [ "*.js" ])
rewrite_rules = [
rebase_path("$tsc_out_dir", root_build_dir) + ":",
rebase_path(".", root_build_dir) + ":",
rebase_path(closure_library_dir, root_build_dir) + ":closure",
]
}
# Copy all JS and TS sources to a staging folder. All generated TS/JS files
# will also be copied into this folder, which will allow us to support a TS
# build that uses both checked-in and generated files.
copy("stage_ts_build") {
sources = ts_modules
outputs = [ "$ts_build_staging_dir/{{source_target_relative}}" ]
}
source_set("browser_tests") {
testonly = true
assert(enable_extensions)
deps = [ ":select_to_speak_extjs_tests" ]
# TODO(jamescook): Figure out which of these are really necessary.
data = [
"$root_out_dir/chrome_100_percent.pak",
"$root_out_dir/chrome_200_percent.pak",
"$root_out_dir/locales/en-US.pak",
"$root_out_dir/resources.pak",
"$root_out_dir/resources/chromeos/accessibility/select_to_speak/",
"$root_out_dir/test_data/chrome/browser/resources/chromeos/accessibility/select_to_speak/",
# The test uses data from the original location, not the copied one.
"//chrome/browser/resources/chromeos/accessibility/common/",
"//chrome/browser/resources/chromeos/accessibility/select_to_speak/",
]
data += js2gtest_js_libraries
}
js2gtest("select_to_speak_extjs_tests") {
test_type = "extension"
sources = [
# These are end-to-end tests.
"select_to_speak_context_menu_tests.js",
"select_to_speak_enhanced_voices_test.js",
"select_to_speak_keystroke_selection_test.js",
"select_to_speak_mouse_selection_test.js",
"select_to_speak_navigation_control_test.js",
"select_to_speak_prefs_test.js",
]
# These are unit tests run under an extension environment to get ES6 module support.
sources += [
"select_to_speak_unittest.js",
"tts_manager_unittest.js",
"ui_manager_unittest.js",
]
gen_include_files = [
"../common/testing/accessibility_test_base.js",
"../common/testing/callback_helper.js",
"../common/testing/e2e_test_base.js",
"../common/testing/fake_chrome_event.js",
"../common/testing/fake_settings_private.js",
"../common/testing/mock_storage.js",
"../common/testing/mock_tts.js",
"select_to_speak_e2e_test_base.js",
"pipe.jpg",
]
# The test base classes generate C++ code with these deps.
deps = [
"//ash",
"//ash/keyboard/ui",
"//base",
"//chrome/browser/ash/accessibility",
"//chrome/browser/ash/crosapi",
"//chrome/browser/ash/system_web_apps",
"//chrome/common",
]
defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
}