diff options
author | Michal Klocek <michal.klocek@qt.io> | 2016-11-10 14:06:09 +0100 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2016-11-16 13:45:02 +0000 |
commit | 777da810b25f517d54dc4b7771e42a4ea38c355b (patch) | |
tree | 675d9f4b67f68441adffb9a01e3075d8d12c0fb2 /chromium/mojo | |
parent | 2eb1e44ebb98208ec9bd0acb0c410e95e8f253b9 (diff) | |
download | qtwebengine-chromium-777da810b25f517d54dc4b7771e42a4ea38c355b.tar.gz |
Add all gn, gni, typemap, mojom files
These file are required to gn be able to parse
source tree.
Change-Id: I9cb4a0b3897c1e99dd6e39832a8c55764fb6e1c6
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/mojo')
39 files changed, 2085 insertions, 0 deletions
diff --git a/chromium/mojo/edk/js/test/BUILD.gn b/chromium/mojo/edk/js/test/BUILD.gn new file mode 100644 index 00000000000..c5a78c35056 --- /dev/null +++ b/chromium/mojo/edk/js/test/BUILD.gn @@ -0,0 +1,46 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//testing/test.gni") + +test("js_unittests") { + output_name = "mojo_js_unittests" + + deps = [ + "//base", + "//gin:gin_test", + "//mojo/edk/js", + "//mojo/edk/test:run_all_unittests", + "//mojo/edk/test:test_support", + "//mojo/public/cpp/system", + "//mojo/public/interfaces/bindings/tests:test_interfaces", + "//mojo/public/interfaces/bindings/tests:test_interfaces_experimental", + "//mojo/public/js:tests", + ] + + sources = [ + "//mojo/edk/js/handle_unittest.cc", + "run_js_tests.cc", + ] +} + +test("js_integration_tests") { + output_name = "mojo_js_integration_tests" + + deps = [ + "//base", + "//gin:gin_test", + "//mojo/edk/js", + "//mojo/edk/js/tests:js_to_cpp_tests", + "//mojo/edk/test:run_all_unittests", + "//mojo/edk/test:test_support", + "//mojo/public/cpp/bindings", + "//mojo/public/interfaces/bindings/tests:test_interfaces", + "//mojo/public/js:bindings", + ] + + sources = [ + "run_js_integration_tests.cc", + ] +} diff --git a/chromium/mojo/edk/js/tests/BUILD.gn b/chromium/mojo/edk/js/tests/BUILD.gn new file mode 100644 index 00000000000..b21cdbc40b8 --- /dev/null +++ b/chromium/mojo/edk/js/tests/BUILD.gn @@ -0,0 +1,39 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("../../../../mojo/public/tools/bindings/mojom.gni") + +source_set("js_to_cpp_tests") { + testonly = true + + deps = [ + ":js_to_cpp_bindings", + "//gin:gin_test", + "//mojo/common", + "//mojo/edk/js", + "//mojo/edk/test:test_support", + "//mojo/public/cpp/bindings", + "//mojo/public/cpp/system", + "//mojo/public/interfaces/bindings/tests:test_interfaces", + "//mojo/public/interfaces/bindings/tests:test_interfaces_experimental", + ] + + sources = [ + "js_to_cpp_tests.cc", + ] + + data = [ + "connection_tests.js", + "js_to_cpp_tests.js", + "sample_service_tests.js", + ] + + configs += [ "//v8:external_startup_data" ] +} + +mojom("js_to_cpp_bindings") { + sources = [ + "js_to_cpp.mojom", + ] +} diff --git a/chromium/mojo/edk/js/tests/js_to_cpp.mojom b/chromium/mojo/edk/js/tests/js_to_cpp.mojom new file mode 100644 index 00000000000..688b22b3dea --- /dev/null +++ b/chromium/mojo/edk/js/tests/js_to_cpp.mojom @@ -0,0 +1,54 @@ +module js_to_cpp; + +// This struct encompasses all of the basic types, so that they +// may be sent from C++ to JS and back for validation. +struct EchoArgs { + int64 si64; + int32 si32; + int16 si16; + int8 si8; + uint64 ui64; + uint32 ui32; + uint16 ui16; + uint8 ui8; + float float_val; + float float_inf; + float float_nan; + double double_val; + double double_inf; + double double_nan; + string? name; + array<string>? string_array; + handle<message_pipe>? message_handle; + handle<data_pipe_consumer>? data_handle; +}; + +struct EchoArgsList { + EchoArgsList? next; + EchoArgs? item; +}; + +// Note: For messages which control test flow, pick numbers that are unlikely +// to be hit as a result of our deliberate corruption of response messages. +interface CppSide { + // Sent for all tests to notify that the JS side is now ready. + StartTest@88888888(); + + // Indicates end for echo, bit-flip, and back-pointer tests. + TestFinished@99999999(); + + // Responses from specific tests. + PingResponse(); + EchoResponse(EchoArgsList list); + BitFlipResponse(EchoArgsList arg); + BackPointerResponse(EchoArgsList arg); +}; + +interface JsSide { + SetCppSide(CppSide cpp); + + Ping(); + Echo(int32 numIterations, EchoArgs arg); + BitFlip(EchoArgs arg); + BackPointer(EchoArgs arg); +}; diff --git a/chromium/mojo/edk/test/BUILD.gn b/chromium/mojo/edk/test/BUILD.gn new file mode 100644 index 00000000000..cd56fb8e398 --- /dev/null +++ b/chromium/mojo/edk/test/BUILD.gn @@ -0,0 +1,133 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//testing/test.gni") + +source_set("test_support") { + testonly = true + sources = [ + "mojo_test_base.cc", + "mojo_test_base.h", + "scoped_ipc_support.cc", + "scoped_ipc_support.h", + "test_utils.h", + "test_utils_posix.cc", + "test_utils_win.cc", + ] + + if (!is_ios) { + sources += [ + "multiprocess_test_helper.cc", + "multiprocess_test_helper.h", + ] + } + + deps = [ + "//base", + "//base/test:test_support", + "//mojo/edk/system", + "//mojo/public/cpp/system", + "//testing/gtest", + ] +} + +source_set("run_all_unittests") { + testonly = true + sources = [ + "run_all_unittests.cc", + ] + + deps = [ + ":test_support", + ":test_support_impl", + "//base", + "//base/test:test_support", + "//mojo/edk/system", + "//mojo/public/c/test_support", + "//testing/gtest", + ] + + if (is_linux && !is_component_build) { + public_configs = [ "//build/config/gcc:rpath_for_built_shared_libraries" ] + } +} + +source_set("run_all_perftests") { + testonly = true + deps = [ + ":test_support_impl", + "//base", + "//base/test:test_support", + "//mojo/edk/system", + "//mojo/edk/test:test_support", + "//mojo/public/c/test_support", + ] + + sources = [ + "run_all_perftests.cc", + ] + + if (is_linux && !is_component_build) { + public_configs = [ "//build/config/gcc:rpath_for_built_shared_libraries" ] + } +} + +source_set("test_support_impl") { + testonly = true + deps = [ + "//base", + "//base/test:test_support", + "//mojo/public/c/test_support", + "//mojo/public/cpp/system", + ] + + sources = [ + "test_support_impl.cc", + "test_support_impl.h", + ] +} + +# Public SDK test targets follow. These targets are not defined within the +# public SDK itself as running the unittests requires the EDK. +# TODO(vtl): These don't really belong here. (They should be converted to +# apptests, but even apart from that these targets belong somewhere else.) + +group("public_tests") { + testonly = true + deps = [ + ":mojo_public_bindings_unittests", + ":mojo_public_system_perftests", + ":mojo_public_system_unittests", + ] +} + +test("mojo_public_bindings_perftests") { + deps = [ + ":run_all_perftests", + "//mojo/edk/test:test_support", + "//mojo/public/cpp/bindings/tests:perftests", + ] +} + +test("mojo_public_bindings_unittests") { + deps = [ + ":run_all_unittests", + "//mojo/edk/test:test_support", + "//mojo/public/cpp/bindings/tests", + ] +} + +test("mojo_public_system_perftests") { + deps = [ + ":run_all_perftests", + "//mojo/public/c/system/tests:perftests", + ] +} + +test("mojo_public_system_unittests") { + deps = [ + ":run_all_unittests", + "//mojo/public/cpp/system/tests", + ] +} diff --git a/chromium/mojo/public/c/system/tests/BUILD.gn b/chromium/mojo/public/c/system/tests/BUILD.gn new file mode 100644 index 00000000000..0dd70529cef --- /dev/null +++ b/chromium/mojo/public/c/system/tests/BUILD.gn @@ -0,0 +1,37 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +source_set("tests") { + testonly = true + + visibility = [ + "//mojo/public/cpp/system/tests:mojo_public_system_unittests", + "//mojo/public/cpp/system/tests:tests", + ] + + sources = [ + "core_unittest.cc", + "core_unittest_pure_c.c", + "macros_unittest.cc", + ] + + deps = [ + "//mojo/public/c/system", + "//testing/gtest", + ] +} + +source_set("perftests") { + testonly = true + + sources = [ + "core_perftest.cc", + ] + + deps = [ + "//mojo/public/cpp/system", + "//mojo/public/cpp/test_support:test_utils", + "//testing/gtest", + ] +} diff --git a/chromium/mojo/public/cpp/bindings/tests/BUILD.gn b/chromium/mojo/public/cpp/bindings/tests/BUILD.gn new file mode 100644 index 00000000000..4e38f15032a --- /dev/null +++ b/chromium/mojo/public/cpp/bindings/tests/BUILD.gn @@ -0,0 +1,144 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("../../../mojo_application.gni") + +source_set("tests") { + testonly = true + + sources = [ + "array_common_test.h", + "array_unittest.cc", + "associated_interface_unittest.cc", + "bind_task_runner_unittest.cc", + "binding_callback_unittest.cc", + "binding_unittest.cc", + "buffer_unittest.cc", + "connector_unittest.cc", + "constant_unittest.cc", + "container_test_util.cc", + "container_test_util.h", + "equals_unittest.cc", + "handle_passing_unittest.cc", + "interface_ptr_unittest.cc", + "map_common_test.h", + "map_unittest.cc", + "message_queue.cc", + "message_queue.h", + "multiplex_router_unittest.cc", + "request_response_unittest.cc", + "router_test_util.cc", + "router_test_util.h", + "router_unittest.cc", + "sample_service_unittest.cc", + "serialization_warning_unittest.cc", + "stl_converters_unittest.cc", + "string_unittest.cc", + "struct_unittest.cc", + "sync_method_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", + "//mojo/public/cpp/bindings", + "//mojo/public/cpp/system", + "//mojo/public/cpp/test_support:test_utils", + "//mojo/public/interfaces/bindings/tests:test_associated_interfaces", + "//mojo/public/interfaces/bindings/tests:test_interfaces", + "//mojo/public/interfaces/bindings/tests:test_interfaces_experimental", + "//mojo/public/interfaces/bindings/tests:test_struct_traits_interfaces", + "//testing/gtest", + ] + + data = [ + "//mojo/public/interfaces/bindings/tests/data/validation/", + ] + + if (is_ios) { + assert_no_deps = [ "//third_party/WebKit/*" ] + } else { + sources += [ + "pickle_unittest.cc", + "struct_traits_unittest.cc", + ] + + deps += [ "//mojo/public/interfaces/bindings/tests:test_interfaces_blink" ] + } +} + +if (!is_ios) { + source_set("for_blink_tests") { + testonly = true + + sources = [ + "array_common_test.h", + "container_test_util.cc", + "container_test_util.h", + "map_common_test.h", + "variant_test_util.h", + "wtf_array_unittest.cc", + "wtf_map_unittest.cc", + "wtf_types_unittest.cc", + ] + + deps = [ + "//mojo/public/cpp/bindings", + "//mojo/public/cpp/system", + "//mojo/public/interfaces/bindings/tests:test_interfaces", + "//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", + ] +} + +source_set("perftests") { + testonly = true + + sources = [ + "bindings_perftest.cc", + ] + + if (!is_ios) { + sources += [ "e2e_perftest.cc" ] + } + + deps = [ + "//base/test:test_support", + "//mojo/edk/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 = [ + "//mojo/public/c/system", + ] +} diff --git a/chromium/mojo/public/cpp/bindings/tests/blink_typemaps.gni b/chromium/mojo/public/cpp/bindings/tests/blink_typemaps.gni new file mode 100644 index 00000000000..b71dcf8d469 --- /dev/null +++ b/chromium/mojo/public/cpp/bindings/tests/blink_typemaps.gni @@ -0,0 +1,8 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +typemaps = [ + "//mojo/public/cpp/bindings/tests/rect_blink.typemap", + "//mojo/public/cpp/bindings/tests/test_native_types_blink.typemap", +] diff --git a/chromium/mojo/public/cpp/bindings/tests/chromium_typemaps.gni b/chromium/mojo/public/cpp/bindings/tests/chromium_typemaps.gni new file mode 100644 index 00000000000..1da7cbfa3ef --- /dev/null +++ b/chromium/mojo/public/cpp/bindings/tests/chromium_typemaps.gni @@ -0,0 +1,9 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +typemaps = [ + "//mojo/public/cpp/bindings/tests/rect_chromium.typemap", + "//mojo/public/cpp/bindings/tests/struct_with_traits.typemap", + "//mojo/public/cpp/bindings/tests/test_native_types_chromium.typemap", +] diff --git a/chromium/mojo/public/cpp/bindings/tests/rect_blink.typemap b/chromium/mojo/public/cpp/bindings/tests/rect_blink.typemap new file mode 100644 index 00000000000..37ee409edf1 --- /dev/null +++ b/chromium/mojo/public/cpp/bindings/tests/rect_blink.typemap @@ -0,0 +1,9 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +mojom = "//mojo/public/interfaces/bindings/tests/rect.mojom" +public_headers = [ "//mojo/public/cpp/bindings/tests/rect_blink.h" ] +traits_headers = [ "//mojo/public/cpp/bindings/tests/rect_blink_traits.h" ] + +type_mappings = [ "mojo.test.TypemappedRect=mojo::test::RectBlink" ] diff --git a/chromium/mojo/public/cpp/bindings/tests/rect_chromium.typemap b/chromium/mojo/public/cpp/bindings/tests/rect_chromium.typemap new file mode 100644 index 00000000000..0da40211a49 --- /dev/null +++ b/chromium/mojo/public/cpp/bindings/tests/rect_chromium.typemap @@ -0,0 +1,9 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +mojom = "//mojo/public/interfaces/bindings/tests/rect.mojom" +public_headers = [ "//mojo/public/cpp/bindings/tests/rect_chromium.h" ] +traits_headers = [ "//mojo/public/cpp/bindings/tests/rect_chromium_traits.h" ] + +type_mappings = [ "mojo.test.TypemappedRect=mojo::test::RectChromium" ] diff --git a/chromium/mojo/public/cpp/bindings/tests/struct_with_traits.typemap b/chromium/mojo/public/cpp/bindings/tests/struct_with_traits.typemap new file mode 100644 index 00000000000..fb9d01d38a1 --- /dev/null +++ b/chromium/mojo/public/cpp/bindings/tests/struct_with_traits.typemap @@ -0,0 +1,24 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +mojom = "//mojo/public/interfaces/bindings/tests/struct_with_traits.mojom" +public_headers = + [ "//mojo/public/cpp/bindings/tests/struct_with_traits_impl.h" ] +traits_headers = + [ "//mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h" ] +sources = [ + "//mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc", +] +deps = [ + "//mojo/public/cpp/bindings/tests:struct_with_traits_impl", + "//mojo/public/cpp/system:system", +] + +type_mappings = [ + "mojo.test.EnumWithTraits=mojo::test::EnumWithTraitsImpl", + "mojo.test.StructWithTraits=mojo::test::StructWithTraitsImpl", + "mojo.test.NestedStructWithTraits=mojo::test::NestedStructWithTraitsImpl", + "mojo.test.PassByValueStructWithTraits=mojo::test::PassByValueStructWithTraitsImpl[pass_by_value]", + "mojo.test.StructWithTraitsForUniquePtrTest=std::unique_ptr<int>[pass_by_value]", +] diff --git a/chromium/mojo/public/cpp/bindings/tests/test_native_types_blink.typemap b/chromium/mojo/public/cpp/bindings/tests/test_native_types_blink.typemap new file mode 100644 index 00000000000..258acd570fd --- /dev/null +++ b/chromium/mojo/public/cpp/bindings/tests/test_native_types_blink.typemap @@ -0,0 +1,17 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +mojom = "//mojo/public/interfaces/bindings/tests/test_native_types.mojom" +public_headers = [ "//mojo/public/cpp/bindings/tests/pickled_types_blink.h" ] +sources = [ + "//mojo/public/cpp/bindings/tests/pickled_types_blink.cc", +] +deps = [ + "//ipc", +] + +type_mappings = [ + "mojo.test.PickledEnum=mojo::test::PickledEnumBlink", + "mojo.test.PickledStruct=mojo::test::PickledStructBlink" +] diff --git a/chromium/mojo/public/cpp/bindings/tests/test_native_types_chromium.typemap b/chromium/mojo/public/cpp/bindings/tests/test_native_types_chromium.typemap new file mode 100644 index 00000000000..a4c0f5ac4ac --- /dev/null +++ b/chromium/mojo/public/cpp/bindings/tests/test_native_types_chromium.typemap @@ -0,0 +1,18 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +mojom = "//mojo/public/interfaces/bindings/tests/test_native_types.mojom" +public_headers = + [ "//mojo/public/cpp/bindings/tests/pickled_types_chromium.h" ] +sources = [ + "//mojo/public/cpp/bindings/tests/pickled_types_chromium.cc", +] +deps = [ + "//ipc", +] + +type_mappings = [ + "mojo.test.PickledEnum=mojo::test::PickledEnumChromium", + "mojo.test.PickledStruct=mojo::test::PickledStructChromium" +] diff --git a/chromium/mojo/public/cpp/system/tests/BUILD.gn b/chromium/mojo/public/cpp/system/tests/BUILD.gn new file mode 100644 index 00000000000..8f98b921a0e --- /dev/null +++ b/chromium/mojo/public/cpp/system/tests/BUILD.gn @@ -0,0 +1,20 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +source_set("tests") { + testonly = true + + sources = [ + "core_unittest.cc", + "watcher_unittest.cc", + ] + + deps = [ + "//base", + "//mojo/public/c/system/tests", + "//mojo/public/cpp/system", + "//mojo/public/cpp/test_support:test_utils", + "//testing/gtest", + ] +} diff --git a/chromium/mojo/public/interfaces/bindings/tests/BUILD.gn b/chromium/mojo/public/interfaces/bindings/tests/BUILD.gn new file mode 100644 index 00000000000..635b615f70e --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/BUILD.gn @@ -0,0 +1,116 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("../../../tools/bindings/mojom.gni") + +mojom("test_interfaces") { + testonly = true + sources = [ + "math_calculator.mojom", + "no_module.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_constants.mojom", + "test_native_types.mojom", + "test_structs.mojom", + "test_sync_methods.mojom", + "validation_test_interfaces.mojom", + ] + public_deps = [ + ":test_mojom_import", + ":test_mojom_import2", + ] +} + +mojom("test_mojom_import") { + testonly = true + sources = [ + "sample_import.mojom", + ] +} + +mojom("test_mojom_import_wrapper") { + testonly = true + public_deps = [ + ":test_mojom_import", + ] +} + +mojom("test_mojom_import_wrapper_wrapper") { + testonly = true + public_deps = [ + ":test_mojom_import_wrapper", + ] +} + +mojom("test_mojom_import2") { + testonly = 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", + ] +} + +mojom("test_interfaces_experimental") { + testonly = true + sources = [ + "test_unions.mojom", + ] +} + +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", + ] +} + +mojom("versioning_test_service_interfaces") { + testonly = true + sources = [ + "versioning_test_service.mojom", + ] +} + +mojom("versioning_test_client_interfaces") { + testonly = true + sources = [ + "versioning_test_client.mojom", + ] +} + +mojom("test_wtf_types") { + testonly = true + + sources = [ + "test_wtf_types.mojom", + ] +} + +mojom("test_no_sources") { + testonly = true + + public_deps = [ + ":test_interfaces", + ] +} diff --git a/chromium/mojo/public/interfaces/bindings/tests/math_calculator.mojom b/chromium/mojo/public/interfaces/bindings/tests/math_calculator.mojom new file mode 100644 index 00000000000..7d1b171e1a9 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/math_calculator.mojom @@ -0,0 +1,12 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +[JavaPackage="org.chromium.mojo.bindings.test.mojom.math"] +module math; + +interface Calculator { + Clear@0() => (double value@0); + Add@1(double value@0) => (double value@0); + Multiply@2(double value@0) => (double value@0); +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/no_module.mojom b/chromium/mojo/public/interfaces/bindings/tests/no_module.mojom new file mode 100644 index 00000000000..f3800112904 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/no_module.mojom @@ -0,0 +1,9 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Entities without module + +enum EnumWithoutModule { + A +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/ping_service.mojom b/chromium/mojo/public/interfaces/bindings/tests/ping_service.mojom new file mode 100644 index 00000000000..ba6ad3d66a4 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/ping_service.mojom @@ -0,0 +1,14 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +[JavaPackage="org.chromium.mojo.bindings.test.mojom.ping"] +module mojo.test; + +interface PingService { + Ping() => (); +}; + +interface EchoService { + Echo(string test_data) => (string echo_data); +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/rect.mojom b/chromium/mojo/public/interfaces/bindings/tests/rect.mojom new file mode 100644 index 00000000000..833c76bb2a4 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/rect.mojom @@ -0,0 +1,22 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +[JavaPackage="org.chromium.mojo.bindings.test.mojom.test_structs"] +module mojo.test; + +struct Rect { + int32 x; + int32 y; + int32 width; + int32 height; +}; + +// A copy of Rect that can be typemapped. Arrays of Rect are currently used, +// which do not support typemapping. +struct TypemappedRect { + int32 x; + int32 y; + int32 width; + int32 height; +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/regression_tests.mojom b/chromium/mojo/public/interfaces/bindings/tests/regression_tests.mojom new file mode 100644 index 00000000000..d87a3ad65f3 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/regression_tests.mojom @@ -0,0 +1,76 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Module containing entities for regression tests of the generator. Entities +// must never be modified, instead new entity must be added to add new tests. +[JavaPackage="org.chromium.mojo.bindings.test.mojom.regression_tests"] +module regression_tests; + +interface CheckMethodWithEmptyResponse { +WithouParameterAndEmptyResponse() => (); +WithParameterAndEmptyResponse(bool b) => (); +}; + +interface CheckNameCollision { +WithNameCollision(bool message, bool response) => (bool message, bool response); +}; + +enum EnumWithReference { + k_STEREO_AND_KEYBOARD_MIC = 30, + k_MAX = k_STEREO_AND_KEYBOARD_MIC +}; + +enum EnumWithLowercase { + PlanarF16, + PlanarF32 +}; + +enum EnumWithNumbers { + k_2_1 = 4 +}; + +enum EnumWithK { + K = 0 +}; + +struct Edge { + Vertex? v; +}; + +struct Vertex { + EmptyStruct? e; +}; + +struct EmptyStruct { +}; + +struct A { + B? b; +}; + +struct B { + A? a; +}; + +// Previously, a field or parameter called |handles| would be shadowed by a +// method parameter in generated C++ bindings code. +struct HandlesNameCollisionStruct { + EmptyStruct handles; +}; + +struct HandlesHandleNameCollisionStruct { + handle handles; +}; + +union HandlesNameCollisionUnion { + int32 handles; +}; + +struct HandlesUnionNameCollisionStruct { + HandlesNameCollisionUnion handles; +}; + +interface HandlesNameCollisionInterface { + Method(EmptyStruct handles) => (handle handles); +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/sample_factory.mojom b/chromium/mojo/public/interfaces/bindings/tests/sample_factory.mojom new file mode 100644 index 00000000000..ade3bf37d65 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/sample_factory.mojom @@ -0,0 +1,41 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +[JavaPackage="org.chromium.mojo.bindings.test.mojom.sample"] +module sample; + +import "sample_import.mojom"; + +// This sample shows how handles to MessagePipes can be sent as both parameters +// to methods as well as fields on structs. + +struct Request { + int32 x; + handle<message_pipe>? pipe; + array<handle<message_pipe>>? more_pipes; + + // Interfaces can be used as members. + imported.ImportedInterface? obj; +}; + +struct Response { + int32 x; + handle<message_pipe>? pipe; +}; + +interface NamedObject { + SetName(string name); + GetName() => (string name); +}; + +interface Factory { + DoStuff(Request request, handle<message_pipe>? pipe) => + (Response response, string text); + DoStuff2(handle<data_pipe_consumer> pipe) => (string text); + CreateNamedObject(NamedObject& obj); + RequestImportedInterface( + imported.ImportedInterface& obj) => (imported.ImportedInterface& obj); + TakeImportedInterface( + imported.ImportedInterface obj) => (imported.ImportedInterface obj); +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/sample_import.mojom b/chromium/mojo/public/interfaces/bindings/tests/sample_import.mojom new file mode 100644 index 00000000000..d28cb7b4db8 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/sample_import.mojom @@ -0,0 +1,38 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +[JavaPackage="org.chromium.mojo.bindings.test.mojom.imported"] +module imported; + +// This sample just defines some types that are imported into +// sample_service.mojom, to show how import works. + +enum Shape { + RECTANGLE = 1, + CIRCLE, + TRIANGLE, + LAST = TRIANGLE, +}; + +// These enum values should not interfere with those of Shape above. +enum AnotherShape { + RECTANGLE = 10, + CIRCLE, + TRIANGLE, +}; + +enum YetAnotherShape { + RECTANGLE = 20, + CIRCLE, + TRIANGLE, +}; + +struct Point { + int32 x; + int32 y; +}; + +interface ImportedInterface { + DoSomething(); +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/sample_import2.mojom b/chromium/mojo/public/interfaces/bindings/tests/sample_import2.mojom new file mode 100644 index 00000000000..ca4e81c0bb6 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/sample_import2.mojom @@ -0,0 +1,28 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +[JavaPackage="org.chromium.mojo.bindings.test.mojom.imported"] +module imported; + +import "sample_import.mojom"; + +// This sample adds more types and constants to the "imported" namespace, +// to test a bug with importing multiple modules with the same namespace. + +enum Color { + RED, + BLACK, +}; + +struct Size { + int32 width; + int32 height; +}; + +struct Thing { + imported.Shape shape = RECTANGLE; + imported.Color color = Color.BLACK; + Point location; + Size size; +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/sample_interfaces.mojom b/chromium/mojo/public/interfaces/bindings/tests/sample_interfaces.mojom new file mode 100644 index 00000000000..5960d756657 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/sample_interfaces.mojom @@ -0,0 +1,32 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +[JavaPackage="org.chromium.mojo.bindings.test.mojom.sample", + JavaConstantsClassName="InterfaceConstants", + Foo = "hello world"] +module sample; + +const uint64 kLong = 4405; + +enum Enum { + VALUE +}; + +interface PingTest { + Ping() => (); +}; + +interface Provider { + EchoString(string a) => (string a); + EchoStrings(string a, string b) => (string a, string b); + EchoMessagePipeHandle(handle<message_pipe> a) => (handle<message_pipe> a); + EchoEnum(Enum a) => (Enum a); + EchoInt(int32 a) => (int32 a); +}; + +interface IntegerAccessor { + GetInteger() => (int64 data, [MinVersion=2] Enum type); + [MinVersion=1] + SetInteger(int64 data, [MinVersion=3] Enum type); +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/sample_service.mojom b/chromium/mojo/public/interfaces/bindings/tests/sample_service.mojom new file mode 100644 index 00000000000..761cb91a9b5 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/sample_service.mojom @@ -0,0 +1,112 @@ + +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +[JavaPackage="org.chromium.mojo.bindings.test.mojom.sample"] +module sample; + +import "sample_import.mojom"; +import "sample_import2.mojom"; + +const uint8 kTwelve = 12; + +struct Bar { + enum Type { + VERTICAL = 1, + HORIZONTAL, + BOTH, + INVALID + }; + uint8 alpha@0 = 0xff; + uint8 beta@1; + uint8 gamma@2; + Type type@3 = sample.Bar.Type.VERTICAL; +}; + +struct Foo { + const string kFooby = "Fooby"; + string name@8 = kFooby; + int32 x@0; + int32 y@1; + bool a@2 = true; + bool b@3; + bool c@4; + Bar? bar@5; + array<Bar>? extra_bars@7; + array<uint8>? data@6; + handle<message_pipe>? source@9; + array<handle<data_pipe_consumer>>? input_streams@10; + array<handle<data_pipe_producer>>? output_streams@11; + array<array<bool>>? array_of_array_of_bools@12; + array<array<array<string>>>? multi_array_of_strings@13; + array<bool>? array_of_bools@14; +}; + +struct DefaultsTest { + int8 a0@0 = -12; + uint8 a1@1 = sample.kTwelve; + int16 a2@2 = 1234; + uint16 a3@3 = 34567; + int32 a4@4 = 123456; + uint32 a5@5 = 3456789012; + int64 a6@6 = -111111111111; + uint64 a7@7 = 9999999999999999999; + int32 a8@8 = 0x12345; + int32 a9@9 = -0x12345; + int32 a10@10 = +1234; + bool a11@11 = true; + bool a12@12 = false; + float a13@13 = 123.25; + double a14@14 = 1234567890.123; + double a15@15 = 1E10; + double a16@16 = -1.2E+20; + double a17@17 = +1.23E-20; + + // TODO(vtl): Add tests for default vs null when those are implemented (for + // structs, arrays, and strings). + array<uint8> a18@18; + string a19@19; + + Bar.Type a20@20 = BOTH; + imported.Point a21@21; + imported.Thing a22@22 = default; + + uint64 a23@23 = 0xFFFFFFFFFFFFFFFF; + int64 a24@24 = 0x123456789; + int64 a25@25 = -0x123456789; + + double a26@26 = double.INFINITY; + double a27@27 = double.NEGATIVE_INFINITY; + double a28@28 = double.NAN; + float a29@29 = float.INFINITY; + float a30@30 = float.NEGATIVE_INFINITY; + float a31@31 = float.NAN; +}; + +struct StructWithHoleV1 { + int32 v1 = 1; + int64 v2 = 2; +}; + +struct StructWithHoleV2 { + int32 v1 = 1; + int64 v2 = 2; + int32 v3 = 3; +}; + +interface Service { + enum BazOptions { + REGULAR = 0, + EXTRA + }; + const uint8 kFavoriteBaz = 1; + Frobinate@0(Foo? foo@0, BazOptions baz@1, Port? port@2) => (int32 result@0); + GetPort@1(Port& port @0); +}; + +// This interface is referenced above where it is defined. It also refers to +// itself from a method. +interface Port { + PostMessageToPort@0(string message_text@0, Port port@1); +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/scoping.mojom b/chromium/mojo/public/interfaces/bindings/tests/scoping.mojom new file mode 100644 index 00000000000..2e9edb10b4e --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/scoping.mojom @@ -0,0 +1,17 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module mojo.test; + +interface A { + GetB(B& b); +}; + +interface B { + GetC(C& c); +}; + +interface C { + D(); +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/serialization_test_structs.mojom b/chromium/mojo/public/interfaces/bindings/tests/serialization_test_structs.mojom new file mode 100644 index 00000000000..1239e163cb8 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/serialization_test_structs.mojom @@ -0,0 +1,36 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +[JavaPackage="org.chromium.mojo.bindings.test.mojom.mojo"] +module mojo.test; + +struct Struct1 { + uint8 i; +}; + +struct Struct2 { + handle hdl; +}; + +struct Struct3 { + Struct1 struct_1; +}; + +struct Struct4 { + array<Struct1> data; +}; + +struct Struct5 { + array<Struct1, 2> pair; +}; + +struct Struct6 { + string str; +}; + +struct StructOfNullables { + handle? hdl; + Struct1? struct_1; + string? str; +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/struct_with_traits.mojom b/chromium/mojo/public/interfaces/bindings/tests/struct_with_traits.mojom new file mode 100644 index 00000000000..b1b7437e89c --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/struct_with_traits.mojom @@ -0,0 +1,60 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module mojo.test; + +// TODO(yzshen): Rename *WithTraits* types to something more readable. + +struct NestedStructWithTraits { + int32 value; +}; + +enum EnumWithTraits { + VALUE_0, + VALUE_1 +}; + +struct StructWithTraits { + EnumWithTraits f_enum; + bool f_bool; + uint32 f_uint32; + uint64 f_uint64; + string f_string; + string f_string2; + array<string> f_string_array; + NestedStructWithTraits f_struct; + array<NestedStructWithTraits> f_struct_array; + map<string, NestedStructWithTraits> f_struct_map; +}; + +// Test that this container can be cloned. +struct StructWithTraitsContainer { + StructWithTraits f_struct; +}; + +struct PassByValueStructWithTraits { + handle f_handle; +}; + +// The custom type for PassByValueStructWithTraits is not clonable. Test that +// this container can compile as long as Clone() is not used. +struct PassByValueStructWithTraitsContainer { + PassByValueStructWithTraits f_struct; +}; + +struct StructWithTraitsForUniquePtrTest { + int32 f_int32; +}; + +interface TraitsTestService { + EchoStructWithTraits(StructWithTraits s) => (StructWithTraits passed); + + EchoPassByValueStructWithTraits(PassByValueStructWithTraits s) => + (PassByValueStructWithTraits passed); + + EchoEnumWithTraits(EnumWithTraits e) => (EnumWithTraits passed); + + EchoStructWithTraitsForUniquePtrTest(StructWithTraitsForUniquePtrTest e) => ( + StructWithTraitsForUniquePtrTest passed); +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/test_associated_interfaces.mojom b/chromium/mojo/public/interfaces/bindings/tests/test_associated_interfaces.mojom new file mode 100644 index 00000000000..534cfd8d81e --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/test_associated_interfaces.mojom @@ -0,0 +1,44 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module mojo.test; + +interface FooInterface {}; + +struct StructContainsAssociated { + associated FooInterface? foo_interface; + associated FooInterface& foo_request; + array<associated FooInterface> foo_interfaces; + array<associated FooInterface&> foo_requests; +}; + +union UnionContainsAssociated { + associated FooInterface foo_interface; + associated FooInterface& foo_request; + array<associated FooInterface> foo_interfaces; + array<associated FooInterface&> foo_requests; +}; + +interface InterfacePassesAssociated { + PassFoo(associated FooInterface foo_interface, + associated FooInterface& foo_request) => + (associated FooInterface foo_interface, + associated FooInterface& foo_request); + + PassStruct(StructContainsAssociated foo_struct) => + (StructContainsAssociated foo_struct); + + PassUnion(UnionContainsAssociated foo_union) => + (UnionContainsAssociated foo_union); +}; + +interface IntegerSender { + Echo(int32 value) => (int32 value); + Send(int32 value); +}; + +interface IntegerSenderConnection { + GetSender(associated IntegerSender& sender); + AsyncGetSender() => (associated IntegerSender sender); +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/test_constants.mojom b/chromium/mojo/public/interfaces/bindings/tests/test_constants.mojom new file mode 100644 index 00000000000..462d5126a5a --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/test_constants.mojom @@ -0,0 +1,53 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +[JavaPackage="org.chromium.mojo.bindings.test.mojom.test_constants"] +module mojo.test; + +// Integral types. +const bool kBoolValue = true; + +const int8 kInt8Value = -2; + +// In the range of (MAX_INT8, MAX_UINT8]. +const uint8 kUint8Value = 128; + +// In the range of [MIN_INT16, MIN_INT8). +const int16 kInt16Value = -233; + +// In the range of (MAX_INT16, MAX_UINT16]. +const uint16 kUint16Value = 44204; + +// In the range of [MIN_INT32, MIN_INT16). +const int32 kInt32Value = -44204; + +// In the range of (MAX_INT32, MAX_UINT32]. +const uint32 kUint32Value = 4294967295; + +// In the range of [MIN_INT64, MIN_INT32). +const int64 kInt64Value = -9223372036854775807; + +// In the range of (MAX_INT64, MAX_UINT64]. +const uint64 kUint64Value = 9999999999999999999; + +// Floating point types. +const double kDoubleValue = 3.14159; +const double kDoubleInfinity = double.INFINITY; +const double kDoubleNegativeInfinity = double.NEGATIVE_INFINITY; +const double kDoubleNaN = double.NAN; + +const float kFloatValue = 2.71828; +const float kFloatInfinity = float.INFINITY; +const float kFloatNegativeInfinity = float.NEGATIVE_INFINITY; +const float kFloatNaN = float.NAN; + +struct StructWithConstants { + const int8 kInt8Value = 5; + const float kFloatValue = 765.432; +}; + +interface InterfaceWithConstants { + const uint32 kUint32Value = 20100722; + const double kDoubleValue = 12.34567; +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/test_native_types.mojom b/chromium/mojo/public/interfaces/bindings/tests/test_native_types.mojom new file mode 100644 index 00000000000..46c6f694ce0 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/test_native_types.mojom @@ -0,0 +1,37 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module mojo.test; + +import "mojo/public/interfaces/bindings/tests/rect.mojom"; + +// Used to verify that structs can be declared with no body in mojom. + +[Native] +struct PickledStruct; + +[Native] +enum PickledEnum; + +struct PickleContainer { + PickledStruct f_struct; + PickledEnum f_enum; +}; + +interface PicklePasser { + PassPickledStruct(PickledStruct pickle) => (PickledStruct passed); + PassPickledEnum(PickledEnum pickle) => (PickledEnum passed); + PassPickleContainer(PickleContainer container) => (PickleContainer passed); + PassPickles(array<PickledStruct> pickles) => (array<PickledStruct> passed); + PassPickleArrays(array<array<PickledStruct>> pickle_arrays) + => (array<array<PickledStruct>> passed); +}; + +// Used to verify support for native serialization of mojom-defined structs +// using StrucTraits with different variants of the Rect type from rect.mojom. + +interface RectService { + AddRect(TypemappedRect r); + GetLargestRect() => (TypemappedRect largest); +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/test_structs.mojom b/chromium/mojo/public/interfaces/bindings/tests/test_structs.mojom new file mode 100644 index 00000000000..2709d4923ff --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/test_structs.mojom @@ -0,0 +1,382 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +[JavaPackage="org.chromium.mojo.bindings.test.mojom.test_structs"] +module mojo.test; + +import "mojo/public/interfaces/bindings/tests/rect.mojom"; + +struct NamedRegion { + string? name; + array<Rect>? rects; +}; + +struct RectPair { + Rect? first; + Rect? second; +}; + +struct EmptyStruct { +}; + +[Native] +struct UnmappedNativeStruct; + +// Used to verify that struct fields which don't specify a default are +// initialized to: false for bool, 0 for numbers, and null for strings, +// handles, and structs. The "?" nullable suffix shouldn't have any +// impact on initial field values. + +struct NoDefaultFieldValues { + bool f0; + int8 f1; + uint8 f2; + int16 f3; + uint16 f4; + int32 f5; + uint32 f6; + int64 f7; + uint64 f8; + float f9; + double f10; + string f11; + string? f12; + handle<message_pipe> f13; + handle<data_pipe_consumer> f14; + handle<data_pipe_producer> f15; + handle<message_pipe>? f16; + handle<data_pipe_consumer>? f17; + handle<data_pipe_producer>? f18; + handle f19; + handle? f20; + handle<shared_buffer> f21; + handle<shared_buffer>? f22; + array<string> f23; + array<string?> f24; + array<string>? f25; + array<string?>? f26; + EmptyStruct f27; + EmptyStruct? f28; +}; + +// Used to verify that struct fields with an explicit default value +// are initialized correctly. The "?" nullable suffix shouldn't have any +// impact on initial field values. + +struct DefaultFieldValues { + const string kFoo = "foo"; + bool f0 = true; + int8 f1 = 100; + uint8 f2 = 100; + int16 f3 = 100; + uint16 f4 = 100; + int32 f5 = 100; + uint32 f6 = 100; + int64 f7 = 100; + uint64 f8 = 100; + float f9 = 100; + float f10 = 100.0; + double f11 = 100; + double f12 = 100.0; + string f13 = kFoo; + string? f14 = kFoo; + Rect f15 = default; + Rect? f16 = default; +}; + +// Used to verify that the code generated for enum and const values defined +// within a struct is correct. Assuming that a constant's value can be a literal +// or another constant and that enum values can either be an integer constant or +// another value from the same enum type. + +struct ScopedConstants { + const int32 TEN = 10; + const int32 ALSO_TEN = TEN; + enum EType { + E0, + E1, + E2 = 10, + E3 = E2, + E4, + }; + EType f0 = E0; // 0 + EType f1 = E1; // 1 + EType f2 = E2; // 10 + EType f3 = E3; // 10 + EType f4 = E4; // 11 + int32 f5 = TEN; + int32 f6 = ALSO_TEN; +}; + +// Used to verify that all possible Map key field types can be encoded and +// decoded successfully. + +struct MapKeyTypes { + // TODO(yzshen): WTF::HashMap doesn't support bool as key. + // map<bool, bool> f0; + map<int8, int8> f1; + map<uint8, uint8> f2; + map<int16, int16> f3; + map<uint16, uint16> f4; + map<int32, int32> f5; + map<uint32, uint32> f6; + map<int64, int64> f7; + map<uint64, uint64> f8; + map<float, float> f9; + map<double, double> f10; + map<string, string> f11; +}; + +// Used to verify that various map value types can be encoded and decoded +// successfully. + +struct MapValueTypes { + map<string, array<string>> f0; + map<string, array<string>?> f1; + map<string, array<string?>> f2; + map<string, array<string, 2>> f3; + map<string, array<array<string, 2>?>> f4; + map<string, array<array<string, 2>, 1>> f5; + map<string, Rect?> f6; + map<string, map<string, string>> f7; + map<string, array<map<string, string>>> f8; + map<string, handle> f9; + map<string, array<handle>> f10; + map<string, map<string, handle>> f11; +}; + +// Used to verify that various array types can be encoded and decoded +// successfully. + +struct ArrayValueTypes { + array<int8> f0; + array<int16> f1; + array<int32> f2; + array<int64> f3; + array<float> f4; + array<double> f5; + array<SomeInterface> f6; + array<SomeInterface&> f7; +}; + +// Used to verify that various float and double values can be encoded and +// decoded correctly. + +struct FloatNumberValues { + const double V0 = double.INFINITY; + const double V1 = double.NEGATIVE_INFINITY; + const double V2 = double.NAN; + const float V3 = float.INFINITY; + const float V4 = float.NEGATIVE_INFINITY; + const float V5 = float.NAN; + const float V6 = 0; + const double V7 = 1234567890.123; + const double V8 = 1.2E+20; + const double V9 = -1.2E+20; + + double f0 = V0; + double f1 = V1; + double f2 = V2; + float f3 = V3; + float f4 = V4; + float f5 = V5; + float f6 = V6; + double f7 = V7; + double f8 = V8; + double f9 = V9; +}; + +// Used to verify that various signed integer values can be encoded and +// decoded correctly. + +struct IntegerNumberValues { + const int8 V0 = -128; // Minimum + const int8 V1 = -1; // -1 + const int8 V2 = 0; // 0 + const int8 V3 = 42; // An arbitrary valid value. + const int8 V4 = 127; // Maximum + + const int16 V5 = -32768; // ... + const int16 V6 = -1; + const int16 V7 = 0; + const int16 V8 = 12345; + const int16 V9 = 32767; + + const int32 V10 = -2147483648; + const int32 V11 = -1; + const int32 V12 = 0; + const int32 V13 = 1234567890; + const int32 V14 = 2147483647; + + // The limits for JavaScript integers are +/- (2^53 - 1). + const int64 V15 = -9007199254740991; // Number.MIN_SAFE_INTEGER + const int64 V16 = -1; + const int64 V17 = 0; + const int64 V18 = 1234567890123456; + const int64 V19 = 9007199254740991; // Number.MAX_SAFE_INTEGER + + int8 f0 = V0; + int8 f1 = V1; + int8 f2 = V2; + int8 f3 = V3; + int8 f4 = V4; + + int16 f5 = V5; + int16 f6 = V6; + int16 f7 = V7; + int16 f8 = V8; + int16 f9 = V9; + + int32 f10 = V10; + int32 f11 = V11; + int32 f12 = V12; + int32 f13 = V13; + int32 f14 = V14; + + int64 f15 = V15; + int64 f16 = V16; + int64 f17 = V17; + int64 f18 = V18; + int64 f19 = V19; +}; + +// Used to verify that various unsigned integer values can be encoded and +// decoded correctly. + +struct UnsignedNumberValues { + const uint8 V0 = 0; // Minimum = 0. + const uint8 V1 = 42; // An arbitrary valid value. + const uint8 V2 = 0xFF; // Maximum + + const uint16 V3 = 0; // ... + const uint16 V4 = 12345; + const uint16 V5 = 0xFFFF; + + const uint32 V6 = 0; + const uint32 V7 = 1234567890; + const uint32 V8 = 0xFFFFFFFF; + + // The limits for JavaScript integers are +/- (2^53 - 1). + const uint64 V9 = 0; + const uint64 V10 = 1234567890123456; + const uint64 V11 = 9007199254740991; // Number.MAX_SAFE_INTEGER + + uint8 f0 = V0; + uint8 f1 = V1; + uint8 f2 = V2; + + uint16 f3 = V3; + uint16 f4 = V4; + uint16 f5 = V5; + + uint32 f6 = V6; + uint32 f7 = V7; + uint32 f8 = V8; + + uint64 f9 = V9; + uint64 f10 = V10; + uint64 f11 = V11; +}; + +// Used to verify that various (packed) boolean array values can be encoded +// and decoded correctly. + +struct BitArrayValues { + array<bool, 1> f0; + array<bool, 7> f1; + array<bool, 9> f2; + array<bool> f3; + array<array<bool>> f4; + array<array<bool>?> f5; + array<array<bool, 2>?> f6; +}; + +// Used to verify that different versions can be decoded correctly. + +struct MultiVersionStruct { + [MinVersion=0] + int32 f_int32; + [MinVersion=1] + Rect? f_rect; + [MinVersion=3] + string? f_string; + [MinVersion=5] + array<int8>? f_array; + [MinVersion=7] + handle<message_pipe>? f_message_pipe; + [MinVersion=7] + bool f_bool; + [MinVersion=9] + int16 f_int16; +}; + +struct MultiVersionStructV0 { + [MinVersion=0] + int32 f_int32; +}; + +struct MultiVersionStructV1 { + [MinVersion=0] + int32 f_int32; + [MinVersion=1] + Rect? f_rect; +}; + +struct MultiVersionStructV3 { + [MinVersion=0] + int32 f_int32; + [MinVersion=1] + Rect? f_rect; + [MinVersion=3] + string? f_string; +}; + +struct MultiVersionStructV5 { + [MinVersion=0] + int32 f_int32; + [MinVersion=1] + Rect? f_rect; + [MinVersion=3] + string? f_string; + [MinVersion=5] + array<int8>? f_array; +}; + +struct MultiVersionStructV7 { + [MinVersion=0] + int32 f_int32; + [MinVersion=1] + Rect? f_rect; + [MinVersion=3] + string? f_string; + [MinVersion=5] + array<int8>? f_array; + [MinVersion=7] + handle<message_pipe>? f_message_pipe; + [MinVersion=7] + bool f_bool; +}; + +// Used to verify that interfaces that are struct members can be defined in the +// same file. + +interface SomeInterface { + SomeMethod(RectPair pair) => (RectPair other_pair); +}; + +struct ContainsInterface { + SomeInterface some_interface; +}; + +// Verify that a field can be called |other|. + +struct ContainsOther { + int32 other; +}; + +// Used to verify that structs can contain interface requests. + +struct ContainsInterfaceRequest { + SomeInterface& request; +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/test_sync_methods.mojom b/chromium/mojo/public/interfaces/bindings/tests/test_sync_methods.mojom new file mode 100644 index 00000000000..3b8cfe63882 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/test_sync_methods.mojom @@ -0,0 +1,44 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module mojo.test; + +interface TestSyncCodeGeneration { + [Sync] + NoInput() => (int32 result); + + [Sync] + NoOutput(int32 value) => (); + + [Sync] + NoInOut() => (); + + [Sync] + HaveInOut(int32 value1, int32 value2) => (int32 result1, int32 result2); +}; + +interface TestSync { + [Sync] + Ping() => (); + + [Sync] + Echo(int32 value) => (int32 result); + + AsyncEcho(int32 value) => (int32 result); +}; + +// Test sync method support with associated interfaces. +interface TestSyncMaster { + [Sync] + Ping() => (); + + [Sync] + Echo(int32 value) => (int32 result); + + AsyncEcho(int32 value) => (int32 result); + + SendInterface(associated TestSync ptr); + + SendRequest(associated TestSync& request); +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/test_unions.mojom b/chromium/mojo/public/interfaces/bindings/tests/test_unions.mojom new file mode 100644 index 00000000000..41e1ed6ace0 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/test_unions.mojom @@ -0,0 +1,105 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module mojo.test; + +enum AnEnum { + FIRST, SECOND +}; + +[Extensible] +enum AnExtensibleEnum { + FIRST, SECOND, THIRD +}; + +union PodUnion { + int8 f_int8; + int8 f_int8_other; + uint8 f_uint8; + int16 f_int16; + uint16 f_uint16; + int32 f_int32; + uint32 f_uint32; + int64 f_int64; + uint64 f_uint64; + float f_float; + double f_double; + bool f_bool; + AnEnum f_enum; + AnExtensibleEnum f_extensible_enum; +}; + +union ObjectUnion { + int8 f_int8; + string f_string; + DummyStruct f_dummy; + DummyStruct? f_nullable; + array<int8> f_array_int8; + map<string, int8> f_map_int8; + PodUnion f_pod_union; + // Test that Clone() is defined after SmallStruct is declared. + array<SmallStruct> f_small_structs; +}; + +union HandleUnion { + handle f_handle; + handle<message_pipe> f_message_pipe; + handle<data_pipe_consumer> f_data_pipe_consumer; + handle<data_pipe_producer> f_data_pipe_producer; + handle<shared_buffer> f_shared_buffer; + SmallCache f_small_cache; + SmallCache& f_small_cache_request; +}; + +struct WrapperStruct { + ObjectUnion? object_union; + PodUnion? pod_union; + HandleUnion? handle_union; +}; + +struct DummyStruct { + int8 f_int8; +}; + +struct SmallStruct { + DummyStruct? dummy_struct; + PodUnion? pod_union; + array<PodUnion>? pod_union_array; + array<PodUnion?>? nullable_pod_union_array; + array<DummyStruct>? s_array; + map<string, PodUnion>? pod_union_map; + map<string, PodUnion?>? nullable_pod_union_map; +}; + +struct SmallStructNonNullableUnion { + PodUnion pod_union; +}; + +struct SmallObjStruct { + ObjectUnion obj_union; + int8 f_int8; +}; + +interface SmallCache { + SetIntValue(int64 int_value); + GetIntValue() => (int64 int_value); +}; + +interface UnionInterface { + Echo(PodUnion in_val) => (PodUnion out_val); +}; + +struct TryNonNullStruct { + DummyStruct? nullable; + DummyStruct non_nullable; +}; + +union OldUnion { + int8 f_int8; +}; + +union NewUnion { + int8 f_int8; + int16 f_int16; +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/test_wtf_types.mojom b/chromium/mojo/public/interfaces/bindings/tests/test_wtf_types.mojom new file mode 100644 index 00000000000..2fdbea80b66 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/test_wtf_types.mojom @@ -0,0 +1,37 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module mojo.test; + +struct TestWTFCodeGeneration { + string str; + string? nullable_str; + array<string> strs; + array<string?> nullable_strs; + array<array<int32>> arrays; + array<bool> bools; + array<handle<message_pipe>> handles; + map<string, string?> str_map; + map<int32, array<int32>> array_map; + map<int32, handle<message_pipe>> handle_map; + array<map<string, string?>> str_maps; +}; + +union TestWTFCodeGeneration2 { + string str; + array<string> strs; + map<string, string?> str_map; +}; + +struct TestWTFStruct { + string str; + int32 integer; +}; + +interface TestWTF { + EchoString(string? str) => (string? str); + EchoStringArray(array<string?>? arr) => (array<string?>? arr); + EchoStringMap(map<string, string?>? str_map) + => (map<string, string?>? str_map); +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/validation_test_associated_interfaces.mojom b/chromium/mojo/public/interfaces/bindings/tests/validation_test_associated_interfaces.mojom new file mode 100644 index 00000000000..2fa77ffc9d4 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/validation_test_associated_interfaces.mojom @@ -0,0 +1,18 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module mojo.test; + +// Associated interfaces are not supported by all language bindings yet. +// Eventually these definitions should live in validation_test_interfaces.mojom. + +interface InterfaceX {}; + +interface AssociatedConformanceTestInterface { + Method0(associated InterfaceX param0); + Method1(associated InterfaceX& param0); + Method2(associated InterfaceX? param0); + Method3(array<associated InterfaceX> param0); +}; + diff --git a/chromium/mojo/public/interfaces/bindings/tests/validation_test_interfaces.mojom b/chromium/mojo/public/interfaces/bindings/tests/validation_test_interfaces.mojom new file mode 100644 index 00000000000..c46c0a5a403 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/validation_test_interfaces.mojom @@ -0,0 +1,113 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +[JavaPackage="org.chromium.mojo.bindings.test.mojom.mojo"] +module mojo.test; + +struct StructA { + uint64 i; +}; + +struct StructB { + StructA struct_a; +}; + +struct StructC { + array<uint8> data; +}; + +struct StructD { + array<handle<message_pipe>> message_pipes; +}; + +struct StructE { + StructD struct_d; + handle<data_pipe_consumer> data_pipe_consumer; +}; + +struct StructF { + array<uint8, 3> fixed_size_array; +}; + +struct StructG { + int32 i; + [MinVersion=1] + StructA? struct_a; + [MinVersion=3] + string? str; + [MinVersion=3] + bool b; +}; + +interface InterfaceA { +}; + +enum EnumA { + ENUM_A_0, + ENUM_A_1 +}; + +[Extensible] +enum EnumB { + ENUM_B_0, + ENUM_B_1, + ENUM_B_2 +}; + +// This interface is used for testing bounds-checking in the mojom +// binding code. If you add a method please update the files +// ./data/validation/boundscheck_*. If you add a response please update +// ./data/validation/resp_boundscheck_*. +interface BoundsCheckTestInterface { + Method0(uint8 param0) => (uint8 param0); + Method1(uint8 param0); +}; + +interface ConformanceTestInterface { + Method0(float param0); + Method1(StructA param0); + Method2(StructB param0, StructA param1); + Method3(array<bool> param0); + Method4(StructC param0, array<uint8> param1); + Method5(StructE param0, handle<data_pipe_producer> param1); + Method6(array<array<uint8>> param0); + Method7(StructF param0, array<array<uint8, 3>?, 2> param1); + Method8(array<array<string>?> param0); + Method9(array<array<handle?>>? param0); + Method10(map<string, uint8> param0); + Method11(StructG param0); + Method12(float param0) => (float param0); + Method13(InterfaceA? param0, uint32 param1, InterfaceA? param2); + Method14(EnumA param0, EnumB param1); + Method15(array<EnumA>? param0, array<EnumB>? param1); + Method16(map<EnumA, EnumA>? param0); + Method17(array<InterfaceA> param0); +}; + +struct BasicStruct { + int32 a; +}; + +interface IntegrationTestInterface { + Method0(BasicStruct param0) => (array<uint8> param0); +}; + +// An enum generates a enum-value validation function, so we want to test it. +// E.g., valid enum values for this enum should be: -3, 0, 1, 10 +enum BasicEnum { + A, + B, + C = A, + D = -3, + E = 0xA +}; + +// The enum validation function should be generated within the scope of this +// struct. +struct StructWithEnum { + enum EnumWithin { + A, B, C, D + }; +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/versioning_test_client.mojom b/chromium/mojo/public/interfaces/bindings/tests/versioning_test_client.mojom new file mode 100644 index 00000000000..f0136db9b54 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/versioning_test_client.mojom @@ -0,0 +1,34 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module mojo.test.versioning; + +// versioning_test_service.mojom and versioning_test_client.mojom contain +// different versions of Mojom definitions for a fictitious human resource +// management system. They are used to test the versioning mechanism. + +enum Department { + SALES, + DEV +}; + +struct Employee { + uint64 employee_id; + string name; + Department department; +}; + +interface HumanResourceDatabase { + AddEmployee(Employee employee) => (bool success); + + QueryEmployee(uint64 id, [MinVersion=1] bool retrieve_finger_print) + => (Employee? employee, [MinVersion=1] array<uint8>? finger_print); + + [MinVersion=1] + AttachFingerPrint(uint64 id, array<uint8> finger_print) + => (bool success); + + [MinVersion=2] + ListEmployeeIds() => (array<uint64>? ids); +}; diff --git a/chromium/mojo/public/interfaces/bindings/tests/versioning_test_service.mojom b/chromium/mojo/public/interfaces/bindings/tests/versioning_test_service.mojom new file mode 100644 index 00000000000..59b38324a69 --- /dev/null +++ b/chromium/mojo/public/interfaces/bindings/tests/versioning_test_service.mojom @@ -0,0 +1,38 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module mojo.test.versioning; + +// versioning_test_service.mojom and versioning_test_client.mojom contain +// different versions of Mojom definitions for a fictitious human resource +// management system. They are used to test the versioning mechanism. + +enum Department { + SALES, + DEV +}; + +struct Date { + uint16 year; + uint8 month; + uint8 day; +}; + +struct Employee { + uint64 employee_id; + string name; + Department department; + [MinVersion=1] Date? birthday; +}; + +interface HumanResourceDatabase { + AddEmployee(Employee employee) => (bool success); + + QueryEmployee(uint64 id, [MinVersion=1] bool retrieve_finger_print) + => (Employee? employee, [MinVersion=1] array<uint8>? finger_print); + + [MinVersion=1] + AttachFingerPrint(uint64 id, array<uint8> finger_print) + => (bool success); +}; |