chromium/mojo/public/cpp/bindings/tests/BUILD.gn

# Copyright 2014 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/features.gni")
import("//mojo/public/tools/bindings/mojom.gni")

source_set("tests") {
  testonly = true

  sources = [
    "associated_interface_unittest.cc",
    "bind_task_runner_unittest.cc",
    "binder_map_unittest.cc",
    "bindings_test_base.cc",
    "bindings_test_base.h",
    "callback_helpers_unittest.cc",
    "connection_group_unittest.cc",
    "connector_unittest.cc",
    "constant_unittest.cc",
    "container_test_util.cc",
    "container_test_util.h",
    "containers_of_nullable_types_unittest.cc",
    "data_view_unittest.cc",
    "default_construct_unittest.cc",
    "direct_receiver_unittest.cc",
    "enum_default_unittest.cc",
    "enum_headers_unittest.cc",
    "equals_unittest.cc",
    "extra_cpp_template_unittest.cc",
    "feature_unittest.cc",
    "flush_async_unittest.cc",
    "handle_passing_unittest.cc",
    "hash_unittest.cc",
    "idle_tracking_unittest.cc",
    "interface_unittest.cc",
    "map_unittest.cc",
    "message_queue.cc",
    "message_queue.h",
    "message_unittest.cc",
    "multiplex_router_unittest.cc",
    "native_struct_unittest.cc",
    "new_endpoint_types_unittest.cc",
    "nullable_value_types_unittest.cc",
    "receiver_callback_unittest.cc",
    "receiver_set_unittest.cc",
    "receiver_unittest.cc",
    "remote_unittest.cc",
    "report_bad_message_unittest.cc",
    "request_response_unittest.cc",
    "router_test_util.cc",
    "router_test_util.h",
    "sample_service_unittest.cc",
    "serialization_warning_unittest.cc",
    "service_factory_unittest.cc",
    "struct_headers_unittest.cc",
    "struct_unittest.cc",
    "supports_urgent_attribute_unittest.cc",
    "sync_handle_registry_unittest.cc",
    "sync_method_unittest.cc",
    "test_helpers_unittest.cc",
    "type_conversion_unittest.cc",
    "union_unittest.cc",
    "validation_context_unittest.cc",
    "validation_unittest.cc",
    "variant_test_util.h",
  ]

  deps = [
    ":mojo_public_bindings_test_utils",
    ":test_extra_cpp_template_mojom",
    ":test_mojom",
    ":test_mojom__generate_message_ids",
    ":test_types",
    "//base/test:test_support",
    "//build:blink_buildflags",
    "//mojo/core/test:test_support",
    "//mojo/public/cpp/bindings",
    "//mojo/public/cpp/system",
    "//mojo/public/cpp/test_support:test_utils",
    "//mojo/public/interfaces/bindings/tests:other_test_interfaces",
    "//mojo/public/interfaces/bindings/tests:test_associated_interfaces",
    "//mojo/public/interfaces/bindings/tests:test_export_component",
    "//mojo/public/interfaces/bindings/tests:test_export_component2",
    "//mojo/public/interfaces/bindings/tests:test_exported_import",
    "//mojo/public/interfaces/bindings/tests:test_interfaces",
    "//mojo/public/interfaces/bindings/tests:test_interfaces_for_containers_of_optionals",
    "//mojo/public/interfaces/bindings/tests:test_struct_traits_interfaces",
    "//testing/gtest",
    "//third_party/ipcz/src:ipcz_test_support_chromium",
  ]

  if (is_ios) {
    deps += [
      "//mojo/public/interfaces/bindings/tests:validation_unittest_bundle_data",
    ]
  } else {
    data = [ "//mojo/public/interfaces/bindings/tests/data/validation/" ]
  }

  if (!use_blink) {
    assert_no_deps = [ "//third_party/blink/*" ]
  } else {
    sources += [
      "pickle_unittest.cc",
      "struct_traits_unittest.cc",
    ]

    deps += [
      ":struct_with_traits_impl",
      "//mojo/public/interfaces/bindings/tests:test_interfaces_blink",
    ]
  }
}

source_set("test_types") {
  sources = [ "nullable_value_types_enums.h" ]
  testonly = true
}

if (use_blink) {
  source_set("for_blink_tests") {
    testonly = true

    sources = [
      "container_test_util.cc",
      "container_test_util.h",
      "variant_test_util.h",
      "wtf_hash_unittest.cc",
      "wtf_map_unittest.cc",
      "wtf_types_unittest.cc",
    ]

    deps = [
      "//base/test:test_support",
      "//mojo/public/cpp/bindings",
      "//mojo/public/cpp/system",
      "//mojo/public/interfaces/bindings/tests:test_export_blink_component",
      "//mojo/public/interfaces/bindings/tests:test_exported_import_blink",
      "//mojo/public/interfaces/bindings/tests:test_interfaces",
      "//mojo/public/interfaces/bindings/tests:test_interfaces_blink",
      "//mojo/public/interfaces/bindings/tests:test_wtf_types",
      "//mojo/public/interfaces/bindings/tests:test_wtf_types_blink",
      "//testing/gtest",
    ]
  }
}

source_set("struct_with_traits_impl") {
  sources = [
    "struct_with_traits_impl.cc",
    "struct_with_traits_impl.h",
  ]

  deps = [
    "//base",
    "//mojo/public/cpp/system:system",
  ]
}

mojom("test_extra_cpp_template_mojom") {
  testonly = true
  sources = [ "extra_cpp_template_unittest.test-mojom" ]

  extra_cpp_template_paths = [ "extra_cpp_template_unittest.h.tmpl" ]
  public_deps = [ "//mojo/public/mojom/base" ]
}

mojom("test_mojom") {
  testonly = true
  sources = [
    "associated_interface_unittest.test-mojom",
    "binder_map_unittest.test-mojom",
    "connection_group_unittest.test-mojom",
    "default_construct_unittest.test-mojom",
    "direct_receiver_unittest.test-mojom",
    "enum_default_unittest.test-mojom",
    "enum_headers_unittest.test-mojom",
    "feature_unittest.test-mojom",
    "feature_unittest_other.test-mojom",
    "flush_async_unittest.test-mojom",
    "idle_tracking_unittest.test-mojom",
    "interface_unittest.test-mojom",
    "receiver_unittest.test-mojom",
    "remote_unittest.test-mojom",
    "service_factory_unittest.test-mojom",
    "struct_headers_unittest.test-mojom",
    "supports_urgent_attribute_unittest.test-mojom",
    "sync_method_unittest.test-mojom",
    "union_unittest.test-mojom",
  ]

  public_deps = [
    # NOTE: This is a kind of test in itself, to verify that mojom() rules can
    # operate on generated mojom files and produce compilable outputs.
    ":generated_test_mojom",
    "//mojo/public/mojom/base",
  ]

  cpp_typemaps = [
    {
      types = [
        {
          mojom = "mojo.test.default_construct.mojom.TestStruct"
          cpp = "::mojo::test::default_construct::TestStruct"
          default_constructible = false
        },
      ]
      traits_headers = [ "default_construct_unittest_mojom_traits.h" ]
    },
  ]
}

source_set("perftests") {
  testonly = true

  sources = [ "bindings_perftest.cc" ]

  if (!is_ios) {
    sources += [ "e2e_perftest.cc" ]
  }

  deps = [
    "//base/test:test_support",
    "//mojo/core/embedder",
    "//mojo/core/test:test_support",
    "//mojo/public/cpp/bindings",
    "//mojo/public/cpp/system",
    "//mojo/public/cpp/test_support:test_utils",
    "//mojo/public/interfaces/bindings/tests:test_interfaces",
    "//testing/gtest",
  ]
}

source_set("mojo_public_bindings_test_utils") {
  sources = [
    "validation_test_input_parser.cc",
    "validation_test_input_parser.h",
  ]

  deps = [
    "//base",
    "//mojo/public/c/system",
  ]
}

action("generate_test_mojom") {
  script = "generate_test_mojom.py"
  outputs = [ "$target_gen_dir/generated.test-mojom" ]
  args = [ rebase_path("$target_gen_dir/generated.test-mojom", root_build_dir) ]
}

mojom("generated_test_mojom") {
  testonly = true
  sources = [ "$target_gen_dir/generated.test-mojom" ]
  parser_deps = [ ":generate_test_mojom" ]
}