| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 19 #include "gin/array_buffer.h" | 19 #include "gin/array_buffer.h" |
| 20 #include "gin/public/isolate_holder.h" | 20 #include "gin/public/isolate_holder.h" |
| 21 #include "gin/v8_initializer.h" | 21 #include "gin/v8_initializer.h" |
| 22 #include "mojo/common/data_pipe_utils.h" | 22 #include "mojo/common/data_pipe_utils.h" |
| 23 #include "mojo/edk/js/mojo_runner_delegate.h" | 23 #include "mojo/edk/js/mojo_runner_delegate.h" |
| 24 #include "mojo/edk/js/tests/js_to_cpp.mojom.h" | 24 #include "mojo/edk/js/tests/js_to_cpp.mojom.h" |
| 25 #include "mojo/public/cpp/bindings/binding.h" | 25 #include "mojo/public/cpp/bindings/binding.h" |
| 26 #include "mojo/public/cpp/bindings/lib/validation_errors.h" | 26 #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
| 27 #include "mojo/public/cpp/system/core.h" | 27 #include "mojo/public/cpp/system/core.h" |
| 28 #include "mojo/public/cpp/system/wait.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 30 |
| 30 namespace mojo { | 31 namespace mojo { |
| 31 namespace edk { | 32 namespace edk { |
| 32 namespace js { | 33 namespace js { |
| 33 | 34 |
| 34 // Global value updated by some checks to prevent compilers from optimizing | 35 // Global value updated by some checks to prevent compilers from optimizing |
| 35 // reads out of existence. | 36 // reads out of existence. |
| 36 uint32_t g_waste_accumulator = 0; | 37 uint32_t g_waste_accumulator = 0; |
| 37 | 38 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 EXPECT_TRUE(result); | 70 EXPECT_TRUE(result); |
| 70 EXPECT_EQ(64u, buffer.size()); | 71 EXPECT_EQ(64u, buffer.size()); |
| 71 for (int i = 0; i < 64; ++i) { | 72 for (int i = 0; i < 64; ++i) { |
| 72 EXPECT_EQ(i, buffer[i]); | 73 EXPECT_EQ(i, buffer[i]); |
| 73 } | 74 } |
| 74 } | 75 } |
| 75 | 76 |
| 76 void CheckMessagePipe(MessagePipeHandle message_pipe_handle) { | 77 void CheckMessagePipe(MessagePipeHandle message_pipe_handle) { |
| 77 unsigned char buffer[100]; | 78 unsigned char buffer[100]; |
| 78 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); | 79 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); |
| 79 MojoResult result = Wait( | 80 MojoResult result = Wait(message_pipe_handle, MOJO_HANDLE_SIGNAL_READABLE); |
| 80 message_pipe_handle, MOJO_HANDLE_SIGNAL_READABLE, | |
| 81 MOJO_DEADLINE_INDEFINITE, nullptr); | |
| 82 EXPECT_EQ(MOJO_RESULT_OK, result); | 81 EXPECT_EQ(MOJO_RESULT_OK, result); |
| 83 result = ReadMessageRaw( | 82 result = ReadMessageRaw( |
| 84 message_pipe_handle, buffer, &buffer_size, 0, 0, 0); | 83 message_pipe_handle, buffer, &buffer_size, 0, 0, 0); |
| 85 EXPECT_EQ(MOJO_RESULT_OK, result); | 84 EXPECT_EQ(MOJO_RESULT_OK, result); |
| 86 EXPECT_EQ(64u, buffer_size); | 85 EXPECT_EQ(64u, buffer_size); |
| 87 for (int i = 0; i < 64; ++i) { | 86 for (int i = 0; i < 64; ++i) { |
| 88 EXPECT_EQ(255 - i, buffer[i]); | 87 EXPECT_EQ(255 - i, buffer[i]); |
| 89 } | 88 } |
| 90 } | 89 } |
| 91 | 90 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 mojo::internal::ScopedSuppressValidationErrorLoggingForTests log_suppression; | 446 mojo::internal::ScopedSuppressValidationErrorLoggingForTests log_suppression; |
| 448 | 447 |
| 449 BackPointerCppSideConnection cpp_side_connection; | 448 BackPointerCppSideConnection cpp_side_connection; |
| 450 RunTest("mojo/edk/js/tests/js_to_cpp_tests", &cpp_side_connection); | 449 RunTest("mojo/edk/js/tests/js_to_cpp_tests", &cpp_side_connection); |
| 451 EXPECT_TRUE(cpp_side_connection.DidSucceed()); | 450 EXPECT_TRUE(cpp_side_connection.DidSucceed()); |
| 452 } | 451 } |
| 453 | 452 |
| 454 } // namespace js | 453 } // namespace js |
| 455 } // namespace edk | 454 } // namespace edk |
| 456 } // namespace mojo | 455 } // namespace mojo |
| OLD | NEW |