# 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("//build/config/python.gni")
import("//mojo/public/interfaces/bindings/tests/validation_data_files.gni")
import("../../../tools/bindings/mojom.gni")
if (is_ios) {
import("//build/config/ios/bundle_data_from_filelist.gni")
}
group("test_data_deps") {
testonly = true
data_deps = [
":test_associated_interfaces_js_data_deps",
":test_interfaces_js_data_deps",
":validation_test_data",
":validation_test_data_list",
]
}
if (is_ios) {
bundle_data_from_filelist("validation_unittest_bundle_data") {
testonly = true
filelist_name = "validation_unittest_bundle_data.filelist"
}
}
copy("validation_test_data") {
testonly = true
sources = mojo_public_interfaces_bindings_test_validation_data_files
outputs = [ "$root_gen_dir/layout_test_data/{{source_root_relative_dir}}/{{source_file_part}}" ]
}
action_foreach("validation_test_data_list") {
testonly = true
script = "//mojo/public/tools/bindings/gen_data_files_list.py"
inputs = mojom_generator_sources
sources = [ "data/validation" ]
outputs = [ "$root_gen_dir/layout_test_data/{{source_root_relative_dir}}/{{source_file_part}}_index.txt" ]
args = [
"-d",
rebase_path(sources[0], root_build_dir),
"-o",
rebase_path(outputs[0], root_build_dir),
]
}
mojom("test_deserializer_interface") {
testonly = true
generate_java = true
generate_rust = true
sources = [ "deserializer.test-mojom" ]
js_generate_struct_deserializers = true
}
mojom("test_interfaces") {
testonly = true
generate_java = true
generate_rust = true
sources = [
"math_calculator.mojom",
"no_module.mojom",
"nullable_value_types.mojom",
"ping_service.mojom",
"rect.mojom",
"regression_tests.mojom",
"sample_factory.mojom",
"sample_interfaces.mojom",
"sample_service.mojom",
"scoping.mojom",
"serialization_test_structs.mojom",
"test_bad_messages.mojom",
"test_constants.mojom",
"test_data_view.mojom",
"test_name_generator.mojom",
"test_native_types.mojom",
"test_structs.mojom",
"test_sync_methods.mojom",
"test_unions.mojom",
"validation_test_interfaces.mojom",
]
public_deps = [
":echo",
":test_deserializer_interface",
":test_mojom_import",
":test_mojom_import2",
"//mojo/public/mojom/base",
]
cpp_typemaps = [
{
types = [
{
mojom = "mojo.test.nullable_value_types.mojom.TypemappedEnum"
cpp = "::mojo::test::nullable_value_types::TypemappedEnum"
},
]
traits_headers = [
"//mojo/public/cpp/bindings/tests/nullable_value_types_mojom_traits.h",
]
traits_deps = [ "//mojo/public/cpp/bindings/tests:test_types" ]
},
{
types = [
{
mojom = "mojo.test.TypemappedRect"
cpp = "::mojo::test::RectChromium"
hashable = true
},
{
mojom = "mojo.test.SharedTypemappedRect"
cpp = "::mojo::test::SharedRect"
},
]
traits_headers = [
"//mojo/public/cpp/bindings/tests/rect_chromium_traits.h",
"//mojo/public/cpp/bindings/tests/shared_rect_traits.h",
]
},
{
types = [
{
mojom = "mojo.test.PickledEnum"
cpp = "::mojo::test::PickledEnumChromium"
},
{
mojom = "mojo.test.PickledStruct"
cpp = "::mojo::test::PickledStructChromium"
move_only = true
},
{
mojom = "mojo.test.TestNativeStructMojom"
cpp = "::mojo::test::TestNativeStruct"
},
{
mojom = "mojo.test.TestNativeStructWithAttachmentsMojom"
cpp = "::mojo::test::TestNativeStructWithAttachments"
move_only = true
},
]
traits_sources = [
"//mojo/public/cpp/bindings/tests/pickled_types_chromium.cc",
"//mojo/public/cpp/bindings/tests/test_native_types.cc",
]
traits_headers = [
"//mojo/public/cpp/bindings/tests/pickled_types_chromium.h",
"//mojo/public/cpp/bindings/tests/test_native_types.h",
]
traits_deps = [ "//ipc" ]
},
]
blink_cpp_typemaps = [
{
types = [
{
mojom = "mojo.test.TypemappedRect"
cpp = "::mojo::test::RectBlink"
hashable = true
},
{
mojom = "mojo.test.SharedTypemappedRect"
cpp = "::mojo::test::SharedRect"
},
]
traits_headers = [
"//mojo/public/cpp/bindings/tests/rect_blink_traits.h",
"//mojo/public/cpp/bindings/tests/shared_rect_traits.h",
]
},
{
types = [
{
mojom = "mojo.test.PickledEnum"
cpp = "::mojo::test::PickledEnumBlink"
},
{
mojom = "mojo.test.PickledStruct"
cpp = "::mojo::test::PickledStructBlink"
move_only = true
},
]
traits_sources =
[ "//mojo/public/cpp/bindings/tests/pickled_types_blink.cc" ]
traits_headers =
[ "//mojo/public/cpp/bindings/tests/pickled_types_blink.h" ]
traits_deps = [ "//ipc" ]
},
]
# Validation tests require precise message content matching, so we avoid
# scrambling message IDs for test interfaces.
scramble_message_ids = false
}
mojom("test_interfaces_for_containers_of_optionals") {
testonly = true
generate_java = false
sources = [ "containers_of_nullable_types.mojom" ]
cpp_typemaps = [
{
types = [
{
mojom =
"mojo.test.containers_of_nullable_types.mojom.TypemappedStruct"
cpp = "::mojo::test::containers_of_nullable_types::NativeStruct"
},
]
traits_headers = [ "//mojo/public/cpp/bindings/tests/containers_of_nullable_types_mojom_traits.h" ]
traits_sources = [ "//mojo/public/cpp/bindings/tests/containers_of_nullable_types_mojom_traits.cc" ]
},
]
}
component("test_export_component") {
testonly = true
deps = [ ":test_export" ]
}
if (use_blink) {
component("test_export_blink_component") {
testonly = true
public_deps = [ ":test_export_blink" ]
}
}
mojom("test_export") {
testonly = true
sources = [ "test_export.mojom" ]
export_class_attribute = "MOJO_TEST_EXPORT"
export_define = "MOJO_TEST_IMPLEMENTATION=1"
export_header = "mojo/public/cpp/bindings/tests/mojo_test_export.h"
if (use_blink) {
export_class_attribute_blink = "MOJO_TEST_BLINK_EXPORT"
export_define_blink = "MOJO_TEST_BLINK_IMPLEMENTATION=1"
export_header_blink =
"mojo/public/cpp/bindings/tests/mojo_test_blink_export.h"
}
visibility = [ ":test_export_component" ]
if (use_blink) {
visibility_blink = [ ":test_export_blink_component" ]
}
}
mojom("test_exported_import") {
testonly = true
sources = [ "test_import.mojom" ]
public_deps = [ ":test_export" ]
overridden_deps = [ ":test_export" ]
component_deps = [ ":test_export_component" ]
if (use_blink) {
overridden_deps_blink = [ ":test_export" ]
component_deps_blink = [ ":test_export_blink_component" ]
}
}
# Used to test that it is okay to call mojom::Foo::Serialize()/Deserialize()
# even if the mojom target is linked into another component.
#
# We don't use |test_export_component| for this test because
# //mojo/public/cpp/bindings/tests depends on both |test_export_component| and
# |test_exported_import| and therefore actually get the shared cpp sources of
# test_export.mojom from |test_exported_import|.
component("test_export_component2") {
testonly = true
public_deps = [ ":test_export2" ]
}
mojom("test_export2") {
testonly = true
sources = [ "test_export2.mojom" ]
export_class_attribute = "MOJO_TEST_EXPORT"
export_define = "MOJO_TEST_IMPLEMENTATION=1"
export_header = "mojo/public/cpp/bindings/tests/mojo_test_export.h"
visibility = [ ":test_export_component2" ]
}
mojom("test_mojom_import") {
testonly = true
generate_java = true
generate_rust = true
sources = [ "sample_import.mojom" ]
}
mojom("test_mojom_import_wrapper") {
testonly = true
generate_java = true
generate_rust = true
public_deps = [ ":test_mojom_import" ]
}
mojom("test_mojom_import_wrapper_wrapper") {
testonly = true
generate_java = true
generate_rust = true
public_deps = [ ":test_mojom_import_wrapper" ]
}
mojom("test_mojom_import2") {
testonly = true
generate_java = true
generate_rust = true
sources = [ "sample_import2.mojom" ]
public_deps = [
":test_mojom_import",
":test_mojom_import_wrapper_wrapper",
]
}
mojom("test_struct_traits_interfaces") {
testonly = true
sources = [ "struct_with_traits.mojom" ]
cpp_typemaps = [
{
types = [
{
mojom = "mojo.test.EnumWithTraits"
cpp = "::mojo::test::EnumWithTraitsImpl"
},
{
mojom = "mojo.test.StructWithTraits"
cpp = "::mojo::test::StructWithTraitsImpl"
},
{
mojom = "mojo.test.StructWithUnreachableTraits"
cpp = "::mojo::test::StructWithUnreachableTraitsImpl"
},
{
mojom = "mojo.test.NestedStructWithTraits"
cpp = "::mojo::test::NestedStructWithTraitsImpl"
},
{
mojom = "mojo.test.TrivialStructWithTraits"
cpp = "::mojo::test::TrivialStructWithTraitsImpl"
copyable_pass_by_value = true
},
{
mojom = "mojo.test.MoveOnlyStructWithTraits"
cpp = "::mojo::test::MoveOnlyStructWithTraitsImpl"
move_only = true
},
{
mojom = "mojo.test.StructWithTraitsForUniquePtr"
cpp = "::std::unique_ptr<int>"
move_only = true
nullable_is_same_type = true
},
{
mojom = "mojo.test.UnionWithTraits"
cpp = "::std::unique_ptr<::mojo::test::UnionWithTraitsBase>"
move_only = true
nullable_is_same_type = true
},
{
mojom = "mojo.test.StructForceSerialize"
cpp = "::mojo::test::StructForceSerializeImpl"
force_serialize = true
},
{
mojom = "mojo.test.StructNestedForceSerialize"
cpp = "::mojo::test::StructNestedForceSerializeImpl"
},
]
traits_sources = [
"//mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc",
]
traits_headers = [
"//mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h",
]
traits_public_deps =
[ "//mojo/public/cpp/bindings/tests:struct_with_traits_impl" ]
},
]
}
mojom("test_associated_interfaces") {
# These files are not included in the test_interfaces target because
# associated interfaces are not supported by all bindings languages yet.
testonly = true
sources = [
"test_associated_interfaces.mojom",
"validation_test_associated_interfaces.mojom",
]
public_deps = [ ":test_interfaces" ]
# Validation tests require precise message content matching, so we avoid
# scrambling message IDs for test interfaces.
scramble_message_ids = false
}
mojom("test_wtf_types") {
testonly = true
sources = [ "test_wtf_types.mojom" ]
}
mojom("test_no_sources") {
testonly = true
public_deps = [ ":test_interfaces" ]
}
mojom("echo") {
testonly = true
generate_java = true
generate_rust = true
sources = [
"echo.mojom",
"echo_import/echo_import.mojom",
]
}
# These could probably be merged with "test_interfaces" at some point.
mojom("other_test_interfaces") {
testonly = true
generate_java = true
sources = [ "new_endpoint_types.test-mojom" ]
}
# Ensure that some target forces JS and Java bindings generation when all
# targets are built. This provides a basic generation smoke test for new
# endpoint types in mojom.
group("test_generation") {
testonly = true
deps = [
":other_test_interfaces",
":other_test_interfaces_js",
]
if (is_android) {
deps += [ ":other_test_interfaces_java" ]
}
}