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

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: Inject main(). Created 4 years, 8 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 26 matching lines...) Expand all
139 MojoHandle b; 127 MojoHandle b;
140 ReadMessageWithHandles(other_child, &b, 1); 128 ReadMessageWithHandles(other_child, &b, 1);
141 129
142 // Write the message from the parent into the buffer and exit. 130 // Write the message from the parent into the buffer and exit.
143 WriteToBuffer(b, 0, message); 131 WriteToBuffer(b, 0, message);
144 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(b)); 132 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(b));
145 EXPECT_EQ("quit", ReadMessage(h)); 133 EXPECT_EQ("quit", ReadMessage(h));
146 WriteMessage(h, "ok"); 134 WriteMessage(h, "ok");
147 } 135 }
148 136
149 #if defined(OS_ANDROID) 137 TEST_F(SharedBufferTest, PassSharedBufferFromChildToChild) {
150 // Android multi-process tests are not executing the new process. This is flaky.
151 #define MAYBE_PassSharedBufferFromChildToChild \
152 DISABLED_PassSharedBufferFromChildToChild
153 #else
154 #define MAYBE_PassSharedBufferFromChildToChild PassSharedBufferFromChildToChild
155 #endif
156 TEST_F(SharedBufferTest, MAYBE_PassSharedBufferFromChildToChild) {
157 const std::string message = "hello"; 138 const std::string message = "hello";
158 MojoHandle p0, p1; 139 MojoHandle p0, p1;
159 CreateMessagePipe(&p0, &p1); 140 CreateMessagePipe(&p0, &p1);
160 141
161 MojoHandle b; 142 MojoHandle b;
162 RUN_CHILD_ON_PIPE(CreateAndPassBuffer, h0) 143 RUN_CHILD_ON_PIPE(CreateAndPassBuffer, h0)
163 RUN_CHILD_ON_PIPE(ReceiveAndEditBuffer, h1) 144 RUN_CHILD_ON_PIPE(ReceiveAndEditBuffer, h1)
164 // Send one end of the pipe to each child. The first child will create 145 // Send one end of the pipe to each child. The first child will create
165 // and pass a buffer to the second child and back to us. The second child 146 // and pass a buffer to the second child and back to us. The second child
166 // will write our message into the buffer. 147 // will write our message into the buffer.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 WriteMessage(h, "quit"); 319 WriteMessage(h, "quit");
339 EXPECT_EQ("ok", ReadMessage(h)); 320 EXPECT_EQ("ok", ReadMessage(h));
340 END_CHILD() 321 END_CHILD()
341 } 322 }
342 323
343 #endif // !defined(OS_IOS) 324 #endif // !defined(OS_IOS)
344 325
345 } // namespace 326 } // namespace
346 } // namespace edk 327 } // namespace edk
347 } // namespace mojo 328 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698