Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: mojo/edk/system/shared_buffer_unittest.cc

Issue 1910233003: Implement a new child test helper for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Reads a single message with a shared buffer handle, maps the buffer, copies 56 // Reads a single message with a shared buffer handle, maps the buffer, copies
57 // the message contents into it, then exits. 57 // the message contents into it, then exits.
58 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(CopyToBufferClient, SharedBufferTest, h) { 58 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(CopyToBufferClient, SharedBufferTest, h) {
59 MojoHandle b; 59 MojoHandle b;
60 std::string message = ReadMessageWithHandles(h, &b, 1); 60 std::string message = ReadMessageWithHandles(h, &b, 1);
61 WriteToBuffer(b, 0, message); 61 WriteToBuffer(b, 0, message);
62 62
63 EXPECT_EQ("quit", ReadMessage(h)); 63 EXPECT_EQ("quit", ReadMessage(h));
64 } 64 }
65 65
66 #if defined(OS_ANDROID) 66 TEST_F(SharedBufferTest, PassSharedBufferCrossProcess) {
67 // Android multi-process tests are not executing the new process. This is flaky.
68 #define MAYBE_PassSharedBufferCrossProcess DISABLED_PassSharedBufferCrossProcess
69 #else
70 #define MAYBE_PassSharedBufferCrossProcess PassSharedBufferCrossProcess
71 #endif
72 TEST_F(SharedBufferTest, MAYBE_PassSharedBufferCrossProcess) {
73 const std::string message = "hello"; 67 const std::string message = "hello";
74 MojoHandle b = CreateBuffer(message.size()); 68 MojoHandle b = CreateBuffer(message.size());
75 69
76 RUN_CHILD_ON_PIPE(CopyToBufferClient, h) 70 RUN_CHILD_ON_PIPE(CopyToBufferClient, h)
77 MojoHandle dupe = DuplicateBuffer(b, false); 71 MojoHandle dupe = DuplicateBuffer(b, false);
78 WriteMessageWithHandles(h, message, &dupe, 1); 72 WriteMessageWithHandles(h, message, &dupe, 1);
79 WriteMessage(h, "quit"); 73 WriteMessage(h, "quit");
80 END_CHILD() 74 END_CHILD()
81 75
82 ExpectBufferContents(b, 0, message); 76 ExpectBufferContents(b, 0, message);
83 } 77 }
84 78
85 // Creates a new buffer, maps it, writes a message contents to it, unmaps it, 79 // Creates a new buffer, maps it, writes a message contents to it, unmaps it,
86 // and finally passes it back to the parent. 80 // and finally passes it back to the parent.
87 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(CreateBufferClient, SharedBufferTest, h) { 81 DEFINE_TEST_CLIENT_TEST_WITH_PIPE(CreateBufferClient, SharedBufferTest, h) {
88 std::string message = ReadMessage(h); 82 std::string message = ReadMessage(h);
89 MojoHandle b = CreateBuffer(message.size()); 83 MojoHandle b = CreateBuffer(message.size());
90 WriteToBuffer(b, 0, message); 84 WriteToBuffer(b, 0, message);
91 WriteMessageWithHandles(h, "have a buffer", &b, 1); 85 WriteMessageWithHandles(h, "have a buffer", &b, 1);
92 86
93 EXPECT_EQ("quit", ReadMessage(h)); 87 EXPECT_EQ("quit", ReadMessage(h));
94 } 88 }
95 89
96 #if defined(OS_ANDROID) 90 TEST_F(SharedBufferTest, PassSharedBufferFromChild) {
97 // Android multi-process tests are not executing the new process. This is flaky.
98 #define MAYBE_PassSharedBufferFromChild DISABLED_PassSharedBufferFromChild
99 #else
100 #define MAYBE_PassSharedBufferFromChild PassSharedBufferFromChild
101 #endif
102 TEST_F(SharedBufferTest, MAYBE_PassSharedBufferFromChild) {
103 const std::string message = "hello"; 91 const std::string message = "hello";
104 MojoHandle b; 92 MojoHandle b;
105 RUN_CHILD_ON_PIPE(CreateBufferClient, h) 93 RUN_CHILD_ON_PIPE(CreateBufferClient, h)
106 WriteMessage(h, message); 94 WriteMessage(h, message);
107 ReadMessageWithHandles(h, &b, 1); 95 ReadMessageWithHandles(h, &b, 1);
108 WriteMessage(h, "quit"); 96 WriteMessage(h, "quit");
109 END_CHILD() 97 END_CHILD()
110 98
111 ExpectBufferContents(b, 0, message); 99 ExpectBufferContents(b, 0, message);
112 } 100 }
(...skipping 24 matching lines...) Expand all
137 // Receive a shared buffer from the other child. 125 // Receive a shared buffer from the other child.
138 MojoHandle b; 126 MojoHandle b;
139 ReadMessageWithHandles(other_child, &b, 1); 127 ReadMessageWithHandles(other_child, &b, 1);
140 128
141 // Write the message from the parent into the buffer and exit. 129 // Write the message from the parent into the buffer and exit.
142 WriteToBuffer(b, 0, message); 130 WriteToBuffer(b, 0, message);
143 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(b)); 131 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(b));
144 EXPECT_EQ("quit", ReadMessage(h)); 132 EXPECT_EQ("quit", ReadMessage(h));
145 } 133 }
146 134
147 #if defined(OS_ANDROID) 135 TEST_F(SharedBufferTest, PassSharedBufferFromChildToChild) {
148 // Android multi-process tests are not executing the new process. This is flaky.
149 #define MAYBE_PassSharedBufferFromChildToChild \
150 DISABLED_PassSharedBufferFromChildToChild
151 #else
152 #define MAYBE_PassSharedBufferFromChildToChild PassSharedBufferFromChildToChild
153 #endif
154 TEST_F(SharedBufferTest, MAYBE_PassSharedBufferFromChildToChild) {
155 const std::string message = "hello"; 136 const std::string message = "hello";
156 MojoHandle p0, p1; 137 MojoHandle p0, p1;
157 CreateMessagePipe(&p0, &p1); 138 CreateMessagePipe(&p0, &p1);
158 139
159 MojoHandle b; 140 MojoHandle b;
160 RUN_CHILD_ON_PIPE(CreateAndPassBuffer, h0) 141 RUN_CHILD_ON_PIPE(CreateAndPassBuffer, h0)
161 RUN_CHILD_ON_PIPE(ReceiveAndEditBuffer, h1) 142 RUN_CHILD_ON_PIPE(ReceiveAndEditBuffer, h1)
162 // Send one end of the pipe to each child. The first child will create 143 // Send one end of the pipe to each child. The first child will create
163 // and pass a buffer to the second child and back to us. The second child 144 // and pass a buffer to the second child and back to us. The second child
164 // will write our message into the buffer. 145 // will write our message into the buffer.
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 WriteMessage(h, "quit"); 309 WriteMessage(h, "quit");
329 EXPECT_EQ("ok", ReadMessage(h)); 310 EXPECT_EQ("ok", ReadMessage(h));
330 END_CHILD() 311 END_CHILD()
331 } 312 }
332 313
333 #endif // !defined(OS_IOS) 314 #endif // !defined(OS_IOS)
334 315
335 } // namespace 316 } // namespace
336 } // namespace edk 317 } // namespace edk
337 } // namespace mojo 318 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/multiprocess_message_pipe_unittest.cc ('k') | mojo/edk/test/multiprocess_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698