| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/public/cpp/bindings/lib/synchronous_connector.h" | 5 #include "mojo/public/cpp/bindings/lib/synchronous_connector.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 Message message_received; | 39 Message message_received; |
| 40 EXPECT_TRUE(connector1.BlockingRead(&message_received)); | 40 EXPECT_TRUE(connector1.BlockingRead(&message_received)); |
| 41 | 41 |
| 42 EXPECT_EQ( | 42 EXPECT_EQ( |
| 43 kText, | 43 kText, |
| 44 std::string(reinterpret_cast<const char*>(message_received.payload()))); | 44 std::string(reinterpret_cast<const char*>(message_received.payload()))); |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Writing to a closed pipe should fail. | 47 // Writing to a closed pipe should fail. |
| 48 TEST(SynchronousConnectorTest, WriteToClosedPipe) { | 48 TEST(SynchronousConnectorTest, WriteToClosedPipe) { |
| 49 Environment env; | |
| 50 MessagePipe pipe; | 49 MessagePipe pipe; |
| 51 internal::SynchronousConnector connector0(std::move(pipe.handle0)); | 50 internal::SynchronousConnector connector0(std::move(pipe.handle0)); |
| 52 | 51 |
| 53 // Close the other end of the pipe. | 52 // Close the other end of the pipe. |
| 54 pipe.handle1.reset(); | 53 pipe.handle1.reset(); |
| 55 | 54 |
| 56 Message message; | 55 Message message; |
| 57 EXPECT_FALSE(connector0.Write(&message)); | 56 EXPECT_FALSE(connector0.Write(&message)); |
| 58 } | 57 } |
| 59 | 58 |
| 60 // Reading from a closed pipe should fail (while waiting on it). | 59 // Reading from a closed pipe should fail (while waiting on it). |
| 61 TEST(SynchronousConnectorTest, ReadFromClosedPipe) { | 60 TEST(SynchronousConnectorTest, ReadFromClosedPipe) { |
| 62 Environment env; | |
| 63 MessagePipe pipe; | 61 MessagePipe pipe; |
| 64 internal::SynchronousConnector connector0(std::move(pipe.handle0)); | 62 internal::SynchronousConnector connector0(std::move(pipe.handle0)); |
| 65 | 63 |
| 66 // Close the other end of the pipe. | 64 // Close the other end of the pipe. |
| 67 pipe.handle1.reset(); | 65 pipe.handle1.reset(); |
| 68 | 66 |
| 69 Message message; | 67 Message message; |
| 70 EXPECT_FALSE(connector0.BlockingRead(&message)); | 68 EXPECT_FALSE(connector0.BlockingRead(&message)); |
| 71 } | 69 } |
| 72 | 70 |
| 73 } // namespace | 71 } // namespace |
| 74 } // namespace test | 72 } // namespace test |
| 75 } // namespace mojo | 73 } // namespace mojo |
| OLD | NEW |