chromium/ios/web/public/test/BUILD.gn

# Copyright 2017 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

source_set("test") {
  testonly = true

  public_deps = [
    ":util",
    "//ios/web/public/test/fakes",
    "//testing/gtest",
  ]

  deps = [
    ":test_fixture",
    "//base",
    "//base/test:test_support",
    "//ios/web",
    "//ios/web/js_messaging",
    "//ios/web/js_messaging:java_script_feature",
    "//ios/web/navigation",
    "//ios/web/navigation:wk_navigation_util",
    "//ios/web/public/deprecated",
    "//ios/web/public/session",
    "//ios/web/public/session/proto",
    "//ios/web/public/session/proto:proto_util",
    "//ios/web/test:js_test_util_internal",
    "//ios/web/test:test_support",
    "//ios/web/web_state:web_state_impl_header",
    "//ios/web/web_state/ui:web_controller_header",
    "//ios/web/web_state/ui:wk_web_view_configuration_provider_header",
    "//ui/base",
  ]

  allow_circular_includes_from = [
    ":test_fixture",
    "//ios/web/test:test_support",
  ]

  sources = [
    "scoped_testing_web_client.h",
    "scoped_testing_web_client.mm",
    "test_redirect_observer.h",
    "test_redirect_observer.mm",
    "test_web_thread.h",
    "web_state_test_util.h",
    "web_state_test_util.mm",
    "web_task_environment.h",
  ]
}

source_set("download_test_utils") {
  deps = [
    "//base",
    "//ios/web/public/download",
  ]

  sources = [
    "download_task_test_util.h",
    "download_task_test_util.mm",
  ]

  frameworks = [ "Foundation.framework" ]
}

source_set("javascript_test") {
  testonly = true

  deps = [
    ":util",
    "//base",
    "//base/test:test_support",
    "//net",
    "//testing/gtest",
  ]

  sources = [
    "javascript_test.h",
    "javascript_test.mm",
  ]

  frameworks = [ "WebKit.framework" ]
}

# Those fixtures *must* not be used directly from //ios/chrome code as they
# create web::BrowserState* as the BrowserState which violates one important
# invariant of //ios/chrome code (the invariant that all BrowserStates are of
# a sub-class of ChromeBrowserState). This is why the classes are defined in
# a target that limits its visibility to //ios/web, //components and to the
# targets in //ios/chrome that safely wraps those fixtures.
source_set("test_fixture") {
  testonly = true

  visibility = [
    "//components/*",
    "//ios/components/*",
    "//ios/web/*",
    "//ios/web_view/*",

    # Do not add new targets from //ios/chrome here. If you want to do it,
    # please contact sdefresne@ or rohitrao@ to check with them.
    "//ios/chrome/test:ios_chrome_unit_test_suite",
  ]

  sources = [
    "web_test.h",
    "web_test.mm",
    "web_test_suite.h",
    "web_test_with_web_state.h",
    "web_test_with_web_state.mm",
  ]

  deps = [
    "//base/test:test_support",
    "//ios/web/common:features",
    "//ios/web/js_messaging:java_script_feature",
    "//ios/web/navigation",
    "//ios/web/navigation:core",
    "//ios/web/navigation:wk_navigation_util",
    "//ios/web/public/deprecated",
    "//ios/web/public/test:util",
    "//ios/web/public/test/fakes",
    "//ios/web/test:js_test_util_internal",
    "//ios/web/web_state:web_state_impl_header",
    "//ios/web/web_state/ui:web_controller_header",
    "//ios/web/web_state/ui:wk_web_view_configuration_provider_header",
    "//ui/base",
    "//url",
  ]
}

source_set("element_selector") {
  testonly = true

  sources = [
    "element_selector.h",
    "element_selector.mm",
  ]

  deps = [ "//base" ]
}

source_set("util") {
  testonly = true

  deps = [
    ":element_selector",
    "//base",
    "//base/test:test_support",
    "//ios/net",
    "//ios/web/find_in_page",
    "//ios/web/js_messaging",
    "//ios/web/js_messaging:java_script_feature",
    "//ios/web/js_messaging:web_view_js_utils",
    "//ios/web/public",
    "//ios/web/public/js_messaging",
    "//ios/web/public/js_messaging:web_view_js_utils",
    "//ios/web/test:js_test_util_internal",
    "//ios/web/web_state:web_state_impl_header",
    "//ios/web/web_state/ui",
    "//ios/web/web_state/ui:wk_web_view_configuration_provider_header",
    "//ios/web/web_view:util",
    "//net",
    "//testing/gtest",
  ]

  # TODO(crbug.com/40609912): Remove this once internal targets depend directly
  # on ":element_selector".
  public_deps = [ "//ios/web/public/test:element_selector" ]

  sources = [
    "error_test_util.h",
    "error_test_util.mm",
    "js_test_util.h",
    "js_test_util.mm",
    "navigation_test_util.h",
    "navigation_test_util.mm",
    "task_observer_util.h",
    "task_observer_util.mm",
    "url_test_util.h",
    "web_view_content_test_util.h",
    "web_view_content_test_util.mm",
    "web_view_interaction_test_util.h",
    "web_view_interaction_test_util.mm",
  ]
}

source_set("fuzzer_support") {
  testonly = true
  sources = [
    "fuzzer_env_with_web_state.h",
    "fuzzer_env_with_web_state.mm",
  ]
  deps = [
    ":test",
    "//base",
    "//base/test:test_support",
    "//ios/web/public",
    "//ios/web/public/test/fakes",
  ]
}