| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/edk/test/multiprocess_test_helper.h" | 5 #include "mojo/edk/test/multiprocess_test_helper.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 9 #include "mojo/edk/embedder/scoped_platform_handle.h" | 11 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 10 #include "mojo/edk/system/test_utils.h" | 12 #include "mojo/edk/system/test_utils.h" |
| 11 #include "mojo/edk/test/test_utils.h" | 13 #include "mojo/edk/test/test_utils.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 15 |
| 14 #if defined(OS_POSIX) | 16 #if defined(OS_POSIX) |
| 15 #include <fcntl.h> | 17 #include <fcntl.h> |
| 16 #endif | 18 #endif |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 #define MAYBE_PassedChannel DISABLED_PassedChannel | 83 #define MAYBE_PassedChannel DISABLED_PassedChannel |
| 82 #else | 84 #else |
| 83 #define MAYBE_PassedChannel PassedChannel | 85 #define MAYBE_PassedChannel PassedChannel |
| 84 #endif // defined(OS_ANDROID) | 86 #endif // defined(OS_ANDROID) |
| 85 TEST_F(MultiprocessTestHelperTest, MAYBE_PassedChannel) { | 87 TEST_F(MultiprocessTestHelperTest, MAYBE_PassedChannel) { |
| 86 MultiprocessTestHelper helper; | 88 MultiprocessTestHelper helper; |
| 87 EXPECT_TRUE(helper.server_platform_handle.is_valid()); | 89 EXPECT_TRUE(helper.server_platform_handle.is_valid()); |
| 88 helper.StartChild("PassedChannel"); | 90 helper.StartChild("PassedChannel"); |
| 89 | 91 |
| 90 // Take ownership of the handle. | 92 // Take ownership of the handle. |
| 91 ScopedPlatformHandle handle = helper.server_platform_handle.Pass(); | 93 ScopedPlatformHandle handle = std::move(helper.server_platform_handle); |
| 92 | 94 |
| 93 // The handle should be non-blocking. | 95 // The handle should be non-blocking. |
| 94 EXPECT_TRUE(IsNonBlocking(handle.get())); | 96 EXPECT_TRUE(IsNonBlocking(handle.get())); |
| 95 | 97 |
| 96 // Write a byte. | 98 // Write a byte. |
| 97 const char c = 'X'; | 99 const char c = 'X'; |
| 98 EXPECT_TRUE(WriteByte(handle.get(), c)); | 100 EXPECT_TRUE(WriteByte(handle.get(), c)); |
| 99 | 101 |
| 100 // It'll echo it back to us, incremented. | 102 // It'll echo it back to us, incremented. |
| 101 char d = 0; | 103 char d = 0; |
| 102 EXPECT_TRUE(ReadByte(handle.get(), &d)); | 104 EXPECT_TRUE(ReadByte(handle.get(), &d)); |
| 103 EXPECT_EQ(c + 1, d); | 105 EXPECT_EQ(c + 1, d); |
| 104 | 106 |
| 105 // And return it, incremented again. | 107 // And return it, incremented again. |
| 106 EXPECT_EQ(c + 2, helper.WaitForChildShutdown()); | 108 EXPECT_EQ(c + 2, helper.WaitForChildShutdown()); |
| 107 } | 109 } |
| 108 | 110 |
| 109 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PassedChannel) { | 111 MOJO_MULTIPROCESS_TEST_CHILD_MAIN(PassedChannel) { |
| 110 CHECK(MultiprocessTestHelper::client_platform_handle.is_valid()); | 112 CHECK(MultiprocessTestHelper::client_platform_handle.is_valid()); |
| 111 | 113 |
| 112 // Take ownership of the handle. | 114 // Take ownership of the handle. |
| 113 ScopedPlatformHandle handle = | 115 ScopedPlatformHandle handle = |
| 114 MultiprocessTestHelper::client_platform_handle.Pass(); | 116 std::move(MultiprocessTestHelper::client_platform_handle); |
| 115 | 117 |
| 116 // The handle should be non-blocking. | 118 // The handle should be non-blocking. |
| 117 EXPECT_TRUE(IsNonBlocking(handle.get())); | 119 EXPECT_TRUE(IsNonBlocking(handle.get())); |
| 118 | 120 |
| 119 // Read a byte. | 121 // Read a byte. |
| 120 char c = 0; | 122 char c = 0; |
| 121 EXPECT_TRUE(ReadByte(handle.get(), &c)); | 123 EXPECT_TRUE(ReadByte(handle.get(), &c)); |
| 122 | 124 |
| 123 // Write it back, incremented. | 125 // Write it back, incremented. |
| 124 c++; | 126 c++; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 << "DISREGARD: Expected failure #1 in child process"; | 190 << "DISREGARD: Expected failure #1 in child process"; |
| 189 EXPECT_FALSE( | 191 EXPECT_FALSE( |
| 190 IsNonBlocking(MultiprocessTestHelper::client_platform_handle.get())) | 192 IsNonBlocking(MultiprocessTestHelper::client_platform_handle.get())) |
| 191 << "DISREGARD: Expected failure #2 in child process"; | 193 << "DISREGARD: Expected failure #2 in child process"; |
| 192 } | 194 } |
| 193 | 195 |
| 194 } // namespace | 196 } // namespace |
| 195 } // namespace test | 197 } // namespace test |
| 196 } // namespace edk | 198 } // namespace edk |
| 197 } // namespace mojo | 199 } // namespace mojo |
| OLD | NEW |