chromium/chrome/test/data/webui/chromeos/BUILD.gn

# Copyright 2020 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("//chrome/test/base/ash/js2gtest.gni")
import("//chrome/test/include_js_tests.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//third_party/closure_compiler/compile_js.gni")
import("//tools/typescript/webui_ts_library.gni")
import("//ui/webui/resources/tools/generate_grd.gni")

assert(is_chromeos_ash)

if (include_js2gtest_tests) {
  js2gtest("interactive_ui_tests_js_webui") {
    test_type = "webui"

    sources = [ "cr_focus_row_behavior_interactive_test.js" ]

    gen_include_files = [
      "polymer_browser_test_base.js",
      "polymer_interactive_ui_test.js",
    ]

    deps = [ "//chrome/browser/ui" ]
    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
  }

  js2gtest("browser_tests_js_webui") {
    test_type = "webui"

    # Javascript sources. These are combined with the .cc files in the GYP
    # build and are handled by a rule, but in the GN build they're in a
    # separate action so need to be separated out.
    sources = [
      "../../../../browser/ui/webui/ash/certificate_manager_dialog_browsertest.js",
      "../cr_components/chromeos/cr_components_chromeos_v3_browsertest.js",
      "account_manager/account_manager_browsertest.js",
      "arc_account_picker/arc_account_picker_browsertest.js",
      "ash_common/i18n_process_test.js",
      "ash_common/post_message_api/post_message_api_browsertest.js",
      "assertions.js",
      "async_gen.js",
      "borealis_installer/borealis_installer_browsertest.js",
      "cloud_upload/cloud_upload_dialog_browsertest.js",
      "cloud_upload/connect_onedrive_browsertest.js",
      "cloud_upload/file_handler_page_browsertest.js",
      "cloud_upload/move_confirmation_page_browsertest.js",
      "emoji_picker/emoji_picker_browsertest.js",
      "gaia_action_buttons/gaia_action_buttons_browsertest.js",
      "internet_config_dialog_browsertest.js",
      "internet_detail_dialog_browsertest.js",
      "js2gtest_browsertest.js",
      "network_browsertest.js",
      "office_fallback/office_fallback_browsertest.js",
      "set_time_dialog/set_time_dialog_browsertest.js",
      "sys_internals/sys_internals_browsertest.js",
    ]

    gen_include_files = [ "polymer_browser_test_base.js" ]

    deps = [
      "//build:branding_buildflags",
      "//build/config/coverage:buildflags",
      "//chrome/browser/ui",
      "//crypto:buildflags",
      "//services/network/public/cpp",
      "//skia",
    ]

    data = [ "//ui/webui/resources/js/load_time_data_deprecated.js" ]

    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
  }

  js2gtest("browser_tests_js_mojo_lite_webui") {
    test_type = "mojo_lite_webui"

    deps = [ "//chrome/browser/ui" ]

    sources = [
      "crostini_installer_browsertest.js",
      "crostini_upgrader_browsertest.js",
    ]

    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
  }

  js2gtest("browser_tests_js_mojo_webui") {
    test_type = "mojo_webui"
    sources = [
      "../nearby_share/nearby_browsertest.js",
      "../nearby_share/shared/nearby_shared_v3_browsertest.js",
      "manage_mirrorsync/manage_mirrorsync_browsertest.js",
    ]
    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
  }
}

js_type_check("closure_compile_local") {
  is_polymer3 = true
  closure_flags = default_closure_args + mojom_js_args + [
                    "js_module_root=" + rebase_path("//chrome/test/data/webui/",
                                                    root_build_dir),
                    "js_module_root=./gen/chrome/test/data/webui/",
                  ]
  deps = [
    ":chai_assert",
    ":fake_network_config_mojom",
    ":mock_controller.m",
    ":test_browser_proxy",
    ":test_util",
  ]
}

js_library("chai_assert") {
  externs_list = [ "//third_party/closure_compiler/externs/chai-3.5.js" ]
}

js_library("fake_network_config_mojom") {
  deps = [
    "//ash/webui/common/resources:assert",
    "//ash/webui/common/resources:promise_resolver",
    "//ash/webui/common/resources/network:onc_mojo",
  ]
}

js_library("mock_controller.m") {
}

js_library("test_browser_proxy") {
  deps = [ "//ash/webui/common/resources:promise_resolver" ]
}

js_library("test_util") {
  deps = [ "//ash/webui/common/resources:event_target" ]
}

group("closure_compile") {
  public_deps = [
    ":closure_compile_local",
    "account_manager:closure_compile",
    "arc_account_picker:closure_compile",
    "ash_common:closure_compile",
    "gaia_action_buttons:closure_compile",
  ]
}

webui_ts_library("build_ts") {
  root_dir = "."
  out_dir = "$target_gen_dir/tsc"
  composite = true
  tsconfig_base = "../tsconfig_base.json"
  in_files = [
    "chai_assert.js",
    "cr_focus_row_behavior_test.ts",
    "crostini_installer_app_test.js",
    "crostini_upgrader_app_test.js",
    "fake_network_config_mojom.js",
    "fake_passpoint_service_mojom.ts",
    "internet_config_dialog_test.ts",
    "internet_detail_dialog_test.ts",
    "mock_controller.js",
    "mock_controller.m.js",
    "mojo_webui_test_support.js",
    "test_browser_proxy.js",
    "test_util.js",

    # Subfolder files. Move these files to their dedicated ts_library()
    # subfolder targets when migrated to TS.
    "account_manager/account_migration_welcome_test.js",
    "account_manager/test_account_manager_browser_proxy.js",
    "arc_account_picker/arc_account_picker_test.js",
    "arc_account_picker/test_util.js",
    "gaia_action_buttons/gaia_action_buttons_test.js",
    "set_time_dialog/set_time_dialog_test.js",
    "set_time_dialog/test_set_time_browser_proxy.js",
    "sys_internals/all_tests.js",
    "sys_internals/api_test.js",
    "sys_internals/line_chart/data_series_test.js",
    "sys_internals/line_chart/line_chart_test.js",
    "sys_internals/line_chart/menu_test.js",
    "sys_internals/line_chart/scrollbar_test.js",
    "sys_internals/line_chart/sub_chart_test.js",
    "sys_internals/line_chart/unit_label_test.js",
    "sys_internals/page_drawer_test.js",
    "sys_internals/page_infopage_test.js",
    "sys_internals/page_switch_test.js",
    "sys_internals/page_unit_test.js",
    "sys_internals/test_util.js",
  ]

  definitions = [
    "//chrome/browser/resources/chromeos/arc_account_picker/arc_account_picker_app.d.ts",
    "//chrome/browser/resources/chromeos/arc_account_picker/arc_account_picker_browser_proxy.d.ts",
    "//chrome/test/data/webui/chromeos/arc_account_picker/test_util.d.ts",
  ]

  path_mappings = [
    "chrome://chrome-signin/arc_account_picker/*|" +
        rebase_path("//chrome/browser/resources/chromeos/arc_account_picker/*",
                    target_gen_dir),
    "chrome://internet-detail-dialog/*|" + rebase_path(
            "${root_gen_dir}/chrome/browser/resources/chromeos/internet_detail_dialog/tsc/*",
            target_gen_dir),
    "chrome://internet-config-dialog/*|" + rebase_path(
            "${root_gen_dir}/chrome/browser/resources/chromeos/internet_config_dialog/tsc/*",
            target_gen_dir),
    "chrome://webui-test/*|" +
        rebase_path("$root_gen_dir/chrome/test/data/webui/tsc/*",
                    target_gen_dir),
  ]

  deps = [
    "//ash/webui/common/resources:build_ts",
    "//ash/webui/common/resources/cr_elements:build_ts",
    "//chrome/browser/resources/chromeos/internet_config_dialog:build_ts",
    "//chrome/browser/resources/chromeos/internet_detail_dialog:build_ts",
    "//chrome/test/data/webui:build_ts",
    "//third_party/polymer/v3_0:library",
    "//ui/webui/resources/js:build_ts",
    "//ui/webui/resources/mojo:build_ts",
  ]
  extra_deps = [ "//ash/webui/common/resources:generate_definitions" ]
}

mojom("web_ui_test_bindings") {
  sources = [ "web_ui_test.mojom" ]
  webui_module_path = "/"

  # Used by legacy MojoWebUIBrowserTest.
  generate_webui_js_bindings = true
}

generate_grd("build_web_ui_test_mojo_grdp") {
  testonly = true
  grd_prefix = "webui_chromeos_test"
  out_grd = "$target_gen_dir/web_ui_test_mojo_resources.grdp"
  input_files_base_dir =
      rebase_path("$root_gen_dir/mojom-webui/chrome/test/data/webui/chromeos/",
                  root_build_dir)
  input_files = [ "web_ui_test.mojom-webui.js" ]
  deps = [ ":web_ui_test_bindings_js__generator" ]
  resource_path_prefix = "chromeos"
}

generate_grd("build_web_ui_test_mojo_lite_grdp") {
  testonly = true
  grd_prefix = "webui_chromeos_test"
  out_grd = "$target_gen_dir/web_ui_test_mojo_lite_resources.grdp"
  input_files_base_dir = rebase_path(target_gen_dir, root_build_dir)
  input_files = [ "web_ui_test.mojom-lite.js" ]
  deps = [ ":web_ui_test_bindings_js__generator" ]
  resource_path_prefix = "chromeos"
}

generate_grd("build_grdp") {
  testonly = true
  grd_prefix = "webui_test_chromeos"
  out_grd = "$target_gen_dir/resources.grdp"

  deps = [ ":build_ts" ]

  manifest_files =
      filter_include(get_target_outputs(":build_ts"), [ "*_manifest.json" ])
  resource_path_prefix = "chromeos"
}