| 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 <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 MojoHandle dupe = DuplicateBuffer(h); | 43 MojoHandle dupe = DuplicateBuffer(h); |
| 44 MojoHandle p0, p1; | 44 MojoHandle p0, p1; |
| 45 CreateMessagePipe(&p0, &p1); | 45 CreateMessagePipe(&p0, &p1); |
| 46 | 46 |
| 47 WriteMessageWithHandles(p0, "...", &dupe, 1); | 47 WriteMessageWithHandles(p0, "...", &dupe, 1); |
| 48 EXPECT_EQ("...", ReadMessageWithHandles(p1, &dupe, 1)); | 48 EXPECT_EQ("...", ReadMessageWithHandles(p1, &dupe, 1)); |
| 49 | 49 |
| 50 ExpectBufferContents(dupe, 0, message); | 50 ExpectBufferContents(dupe, 0, message); |
| 51 } | 51 } |
| 52 | 52 |
| 53 #if !defined(OS_IOS) |
| 54 |
| 53 // Reads a single message with a shared buffer handle, maps the buffer, copies | 55 // Reads a single message with a shared buffer handle, maps the buffer, copies |
| 54 // the message contents into it, then exits. | 56 // the message contents into it, then exits. |
| 55 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(CopyToBufferClient, SharedBufferTest, h) { | 57 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(CopyToBufferClient, SharedBufferTest, h) { |
| 56 MojoHandle b; | 58 MojoHandle b; |
| 57 std::string message = ReadMessageWithHandles(h, &b, 1); | 59 std::string message = ReadMessageWithHandles(h, &b, 1); |
| 58 WriteToBuffer(b, 0, message); | 60 WriteToBuffer(b, 0, message); |
| 59 | 61 |
| 60 EXPECT_EQ("quit", ReadMessage(h)); | 62 EXPECT_EQ("quit", ReadMessage(h)); |
| 61 } | 63 } |
| 62 | 64 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 EXPECT_EQ("ok", ReadMessage(h1)); | 154 EXPECT_EQ("ok", ReadMessage(h1)); |
| 153 END_CHILD() | 155 END_CHILD() |
| 154 WriteMessage(h0, "quit"); | 156 WriteMessage(h0, "quit"); |
| 155 EXPECT_EQ("ok", ReadMessage(h0)); | 157 EXPECT_EQ("ok", ReadMessage(h0)); |
| 156 END_CHILD() | 158 END_CHILD() |
| 157 | 159 |
| 158 // The second child should have written this message. | 160 // The second child should have written this message. |
| 159 ExpectBufferContents(b, 0, message); | 161 ExpectBufferContents(b, 0, message); |
| 160 } | 162 } |
| 161 | 163 |
| 162 | |
| 163 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(CreateAndPassBufferParent, SharedBufferTest, | 164 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(CreateAndPassBufferParent, SharedBufferTest, |
| 164 parent) { | 165 parent) { |
| 165 RUN_CHILD_ON_PIPE(CreateAndPassBuffer, child) | 166 RUN_CHILD_ON_PIPE(CreateAndPassBuffer, child) |
| 166 // Read a pipe from the parent and forward it to our child. | 167 // Read a pipe from the parent and forward it to our child. |
| 167 MojoHandle pipe; | 168 MojoHandle pipe; |
| 168 std::string message = ReadMessageWithHandles(parent, &pipe, 1); | 169 std::string message = ReadMessageWithHandles(parent, &pipe, 1); |
| 169 | 170 |
| 170 WriteMessageWithHandles(child, message, &pipe, 1); | 171 WriteMessageWithHandles(child, message, &pipe, 1); |
| 171 | 172 |
| 172 // Read a buffer handle from the child and pass it back to the parent. | 173 // Read a buffer handle from the child and pass it back to the parent. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 EXPECT_EQ("ok", ReadMessage(child2)); | 220 EXPECT_EQ("ok", ReadMessage(child2)); |
| 220 END_CHILD() | 221 END_CHILD() |
| 221 WriteMessage(child1, "quit"); | 222 WriteMessage(child1, "quit"); |
| 222 EXPECT_EQ("ok", ReadMessage(child1)); | 223 EXPECT_EQ("ok", ReadMessage(child1)); |
| 223 END_CHILD() | 224 END_CHILD() |
| 224 | 225 |
| 225 // The second grandchild should have written this message. | 226 // The second grandchild should have written this message. |
| 226 ExpectBufferContents(b, 0, message); | 227 ExpectBufferContents(b, 0, message); |
| 227 } | 228 } |
| 228 | 229 |
| 230 #endif // !defined(OS_IOS) |
| 231 |
| 229 } // namespace | 232 } // namespace |
| 230 } // namespace edk | 233 } // namespace edk |
| 231 } // namespace mojo | 234 } // namespace mojo |
| OLD | NEW |