OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1649 MOJO_DEADLINE_INDEFINITE, &hss)); | 1649 MOJO_DEADLINE_INDEFINITE, &hss)); |
1650 // Peer could have become closed while we're still waiting for data. | 1650 // Peer could have become closed while we're still waiting for data. |
1651 EXPECT_TRUE(MOJO_HANDLE_SIGNAL_READABLE & hss.satisfied_signals); | 1651 EXPECT_TRUE(MOJO_HANDLE_SIGNAL_READABLE & hss.satisfied_signals); |
1652 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED, | 1652 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
1653 hss.satisfiable_signals); | 1653 hss.satisfiable_signals); |
1654 } | 1654 } |
1655 | 1655 |
1656 return num_bytes == 0; | 1656 return num_bytes == 0; |
1657 } | 1657 } |
1658 | 1658 |
| 1659 #if !defined(OS_IOS) |
| 1660 |
1659 #if defined(OS_ANDROID) | 1661 #if defined(OS_ANDROID) |
1660 // Android multi-process tests are not executing the new process. This is flaky. | 1662 // Android multi-process tests are not executing the new process. This is flaky. |
1661 #define MAYBE_Multiprocess DISABLED_Multiprocess | 1663 #define MAYBE_Multiprocess DISABLED_Multiprocess |
1662 #else | 1664 #else |
1663 #define MAYBE_Multiprocess Multiprocess | 1665 #define MAYBE_Multiprocess Multiprocess |
1664 #endif // defined(OS_ANDROID) | 1666 #endif // defined(OS_ANDROID) |
1665 TEST_F(DataPipeTest, MAYBE_Multiprocess) { | 1667 TEST_F(DataPipeTest, MAYBE_Multiprocess) { |
1666 const uint32_t kTestDataSize = | 1668 const uint32_t kTestDataSize = |
1667 static_cast<uint32_t>(sizeof(kMultiprocessTestData)); | 1669 static_cast<uint32_t>(sizeof(kMultiprocessTestData)); |
1668 const MojoCreateDataPipeOptions options = { | 1670 const MojoCreateDataPipeOptions options = { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1828 | 1830 |
1829 std::string message(bytes.data(), bytes.size()); | 1831 std::string message(bytes.data(), bytes.size()); |
1830 EXPECT_EQ(expected_message, message); | 1832 EXPECT_EQ(expected_message, message); |
1831 | 1833 |
1832 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(c)); | 1834 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(c)); |
1833 | 1835 |
1834 // Wait for a quit message. | 1836 // Wait for a quit message. |
1835 EXPECT_EQ("quit", ReadMessage(h)); | 1837 EXPECT_EQ("quit", ReadMessage(h)); |
1836 } | 1838 } |
1837 | 1839 |
1838 TEST_F(DataPipeTest, SendConsumerAndCloseProducer) { | 1840 #if defined(OS_ANDROID) |
| 1841 // Android multi-process tests are not executing the new process. This is flaky. |
| 1842 #define MAYBE_SendConsumerAndCloseProducer DISABLED_SendConsumerAndCloseProducer |
| 1843 #else |
| 1844 #define MAYBE_SendConsumerAndCloseProducer SendConsumerAndCloseProducer |
| 1845 #endif // defined(OS_ANDROID) |
| 1846 TEST_F(DataPipeTest, MAYBE_SendConsumerAndCloseProducer) { |
1839 // Create a new data pipe. | 1847 // Create a new data pipe. |
1840 MojoHandle p, c; | 1848 MojoHandle p, c; |
1841 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateDataPipe(nullptr, &p ,&c)); | 1849 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateDataPipe(nullptr, &p ,&c)); |
1842 | 1850 |
1843 RUN_CHILD_ON_PIPE(WriteAndCloseProducer, producer_client) | 1851 RUN_CHILD_ON_PIPE(WriteAndCloseProducer, producer_client) |
1844 RUN_CHILD_ON_PIPE(ReadAndCloseConsumer, consumer_client) | 1852 RUN_CHILD_ON_PIPE(ReadAndCloseConsumer, consumer_client) |
1845 const std::string kMessage = "Hello, world!"; | 1853 const std::string kMessage = "Hello, world!"; |
1846 WriteMessageWithHandles(producer_client, kMessage, &p, 1); | 1854 WriteMessageWithHandles(producer_client, kMessage, &p, 1); |
1847 WriteMessageWithHandles(consumer_client, kMessage, &c, 1); | 1855 WriteMessageWithHandles(consumer_client, kMessage, &c, 1); |
1848 | 1856 |
(...skipping 22 matching lines...) Expand all Loading... |
1871 uint32_t num_bytes = static_cast<uint32_t>(kMessage.size()); | 1879 uint32_t num_bytes = static_cast<uint32_t>(kMessage.size()); |
1872 EXPECT_EQ(MOJO_RESULT_OK, MojoWriteData(p, kMessage.data(), &num_bytes, | 1880 EXPECT_EQ(MOJO_RESULT_OK, MojoWriteData(p, kMessage.data(), &num_bytes, |
1873 MOJO_WRITE_DATA_FLAG_NONE)); | 1881 MOJO_WRITE_DATA_FLAG_NONE)); |
1874 EXPECT_EQ(num_bytes, static_cast<uint32_t>(kMessage.size())); | 1882 EXPECT_EQ(num_bytes, static_cast<uint32_t>(kMessage.size())); |
1875 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(p)); | 1883 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(p)); |
1876 | 1884 |
1877 // Wait for a quit message. | 1885 // Wait for a quit message. |
1878 EXPECT_EQ("quit", ReadMessage(h)); | 1886 EXPECT_EQ("quit", ReadMessage(h)); |
1879 } | 1887 } |
1880 | 1888 |
1881 TEST_F(DataPipeTest, CreateInChild) { | 1889 #if defined(OS_ANDROID) |
| 1890 // Android multi-process tests are not executing the new process. This is flaky. |
| 1891 #define MAYBE_CreateInChild DISABLED_CreateInChild |
| 1892 #else |
| 1893 #define MAYBE_CreateInChild CreateInChild |
| 1894 #endif // defined(OS_ANDROID) |
| 1895 TEST_F(DataPipeTest, MAYBE_CreateInChild) { |
1882 RUN_CHILD_ON_PIPE(CreateAndWrite, child) | 1896 RUN_CHILD_ON_PIPE(CreateAndWrite, child) |
1883 MojoHandle c; | 1897 MojoHandle c; |
1884 std::string expected_message = ReadMessageWithHandles(child, &c, 1); | 1898 std::string expected_message = ReadMessageWithHandles(child, &c, 1); |
1885 | 1899 |
1886 // Wait for the consumer to become readable. | 1900 // Wait for the consumer to become readable. |
1887 EXPECT_EQ(MOJO_RESULT_OK, MojoWait(c, MOJO_HANDLE_SIGNAL_READABLE, | 1901 EXPECT_EQ(MOJO_RESULT_OK, MojoWait(c, MOJO_HANDLE_SIGNAL_READABLE, |
1888 MOJO_DEADLINE_INDEFINITE, nullptr)); | 1902 MOJO_DEADLINE_INDEFINITE, nullptr)); |
1889 | 1903 |
1890 // Drain the consumer and expect to find the given message. | 1904 // Drain the consumer and expect to find the given message. |
1891 uint32_t num_bytes = static_cast<uint32_t>(expected_message.size()); | 1905 uint32_t num_bytes = static_cast<uint32_t>(expected_message.size()); |
1892 std::vector<char> bytes(expected_message.size()); | 1906 std::vector<char> bytes(expected_message.size()); |
1893 EXPECT_EQ(MOJO_RESULT_OK, MojoReadData(c, bytes.data(), &num_bytes, | 1907 EXPECT_EQ(MOJO_RESULT_OK, MojoReadData(c, bytes.data(), &num_bytes, |
1894 MOJO_READ_DATA_FLAG_NONE)); | 1908 MOJO_READ_DATA_FLAG_NONE)); |
1895 EXPECT_EQ(num_bytes, static_cast<uint32_t>(bytes.size())); | 1909 EXPECT_EQ(num_bytes, static_cast<uint32_t>(bytes.size())); |
1896 | 1910 |
1897 std::string message(bytes.data(), bytes.size()); | 1911 std::string message(bytes.data(), bytes.size()); |
1898 EXPECT_EQ(expected_message, message); | 1912 EXPECT_EQ(expected_message, message); |
1899 | 1913 |
1900 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(c)); | 1914 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(c)); |
1901 WriteMessage(child, "quit"); | 1915 WriteMessage(child, "quit"); |
1902 END_CHILD() | 1916 END_CHILD() |
1903 } | 1917 } |
1904 | 1918 |
| 1919 #endif // !defined(OS_IOS) |
| 1920 |
1905 } // namespace | 1921 } // namespace |
1906 } // namespace edk | 1922 } // namespace edk |
1907 } // namespace mojo | 1923 } // namespace mojo |
OLD | NEW |