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

Side by Side Diff: mojo/public/tests/bindings_connector_unittest.cc

Issue 65043004: Add better handle tracking, and optimize Connector::Accept. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update per review feedback Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « mojo/public/bindings/lib/message_queue.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "mojo/public/bindings/lib/bindings_support.h" 8 #include "mojo/public/bindings/lib/bindings_support.h"
9 #include "mojo/public/bindings/lib/connector.h" 9 #include "mojo/public/bindings/lib/connector.h"
10 #include "mojo/public/bindings/lib/message_queue.h" 10 #include "mojo/public/bindings/lib/message_queue.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 AllocMessage(kText, &message); 164 AllocMessage(kText, &message);
165 165
166 Close(handle0_); // Close the handle before writing to it. 166 Close(handle0_); // Close the handle before writing to it.
167 167
168 bool ok = connector0.Accept(&message); 168 bool ok = connector0.Accept(&message);
169 EXPECT_FALSE(ok); 169 EXPECT_FALSE(ok);
170 170
171 EXPECT_TRUE(connector0.EncounteredError()); 171 EXPECT_TRUE(connector0.EncounteredError());
172 } 172 }
173 173
174 #if 0
175 // Enable this test once MojoWriteMessage supports passing handles.
176 TEST_F(BindingsConnectorTest, MessageWithHandles) {
177 Connector connector0(handle0_);
178 Connector connector1(handle1_);
179
180 const char kText[] = "hello world";
181
182 Message message;
183 AllocMessage(kText, &message);
184
185 Handle handles[2];
186 CreateMessagePipe(&handles[0], &handles[1]);
187 message.handles.push_back(handles[0]);
188 message.handles.push_back(handles[1]);
189
190 connector0.Accept(&message);
191
192 // The message should have been transferred.
193 EXPECT_TRUE(message.data == NULL);
194 EXPECT_TRUE(message.handles.empty());
195
196 MessageAccumulator accumulator;
197 connector1.SetIncomingReceiver(&accumulator);
198
199 PumpMessages();
200
201 ASSERT_FALSE(accumulator.IsEmpty());
202
203 Message message_received;
204 accumulator.Pop(&message_received);
205
206 EXPECT_EQ(std::string(kText),
207 std::string(
208 reinterpret_cast<char*>(message_received.data->payload)));
209 ASSERT_EQ(2U, message_received.handles.size());
210 EXPECT_EQ(handles[0].value, message_received.handles[0].value);
211 EXPECT_EQ(handles[1].value, message_received.handles[1].value);
212 }
213 #endif
214
174 } // namespace test 215 } // namespace test
175 } // namespace mojo 216 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/bindings/lib/message_queue.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698