| 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 <fcntl.h> | 7 #include <fcntl.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "mojo/edk/embedder/scoped_platform_handle.h" | 11 #include "mojo/edk/platform/platform_handle.h" |
| 12 #include "mojo/edk/platform/scoped_platform_handle.h" |
| 12 #include "mojo/edk/test/test_utils.h" | 13 #include "mojo/edk/test/test_utils.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 15 using mojo::embedder::ScopedPlatformHandle; | 16 using mojo::platform::PlatformHandle; |
| 17 using mojo::platform::ScopedPlatformHandle; |
| 16 | 18 |
| 17 namespace mojo { | 19 namespace mojo { |
| 18 namespace test { | 20 namespace test { |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 bool IsNonBlocking(const embedder::PlatformHandle& handle) { | 23 bool IsNonBlocking(const PlatformHandle& handle) { |
| 22 return fcntl(handle.fd, F_GETFL) & O_NONBLOCK; | 24 return fcntl(handle.fd, F_GETFL) & O_NONBLOCK; |
| 23 } | 25 } |
| 24 | 26 |
| 25 bool WriteByte(const embedder::PlatformHandle& handle, char c) { | 27 bool WriteByte(const PlatformHandle& handle, char c) { |
| 26 size_t bytes_written = 0; | 28 size_t bytes_written = 0; |
| 27 BlockingWrite(handle, &c, 1, &bytes_written); | 29 BlockingWrite(handle, &c, 1, &bytes_written); |
| 28 return bytes_written == 1; | 30 return bytes_written == 1; |
| 29 } | 31 } |
| 30 | 32 |
| 31 bool ReadByte(const embedder::PlatformHandle& handle, char* c) { | 33 bool ReadByte(const PlatformHandle& handle, char* c) { |
| 32 size_t bytes_read = 0; | 34 size_t bytes_read = 0; |
| 33 BlockingRead(handle, c, 1, &bytes_read); | 35 BlockingRead(handle, c, 1, &bytes_read); |
| 34 return bytes_read == 1; | 36 return bytes_read == 1; |
| 35 } | 37 } |
| 36 | 38 |
| 37 using MultiprocessTestHelperTest = testing::Test; | 39 using MultiprocessTestHelperTest = testing::Test; |
| 38 | 40 |
| 39 #if defined(OS_ANDROID) | 41 #if defined(OS_ANDROID) |
| 40 // Android multi-process tests are not executing the new process. This is flaky. | 42 // Android multi-process tests are not executing the new process. This is flaky. |
| 41 #define MAYBE_RunChild DISABLED_RunChild | 43 #define MAYBE_RunChild DISABLED_RunChild |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 EXPECT_FALSE(MultiprocessTestHelper::client_platform_handle.is_valid()) | 181 EXPECT_FALSE(MultiprocessTestHelper::client_platform_handle.is_valid()) |
| 180 << "DISREGARD: Expected failure #1 in child process"; | 182 << "DISREGARD: Expected failure #1 in child process"; |
| 181 EXPECT_FALSE( | 183 EXPECT_FALSE( |
| 182 IsNonBlocking(MultiprocessTestHelper::client_platform_handle.get())) | 184 IsNonBlocking(MultiprocessTestHelper::client_platform_handle.get())) |
| 183 << "DISREGARD: Expected failure #2 in child process"; | 185 << "DISREGARD: Expected failure #2 in child process"; |
| 184 } | 186 } |
| 185 | 187 |
| 186 } // namespace | 188 } // namespace |
| 187 } // namespace test | 189 } // namespace test |
| 188 } // namespace mojo | 190 } // namespace mojo |
| OLD | NEW |