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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/bindings/lib/message_queue.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tests/bindings_connector_unittest.cc
diff --git a/mojo/public/tests/bindings_connector_unittest.cc b/mojo/public/tests/bindings_connector_unittest.cc
index a5a21087da9eef21ba1028bb1fe9c85401d3e922..f21e8ee7fb193eb1725320a61ad8166dc1368165 100644
--- a/mojo/public/tests/bindings_connector_unittest.cc
+++ b/mojo/public/tests/bindings_connector_unittest.cc
@@ -171,5 +171,46 @@ TEST_F(BindingsConnectorTest, WriteToClosedPipe) {
EXPECT_TRUE(connector0.EncounteredError());
}
+#if 0
+// Enable this test once MojoWriteMessage supports passing handles.
+TEST_F(BindingsConnectorTest, MessageWithHandles) {
+ Connector connector0(handle0_);
+ Connector connector1(handle1_);
+
+ const char kText[] = "hello world";
+
+ Message message;
+ AllocMessage(kText, &message);
+
+ Handle handles[2];
+ CreateMessagePipe(&handles[0], &handles[1]);
+ message.handles.push_back(handles[0]);
+ message.handles.push_back(handles[1]);
+
+ connector0.Accept(&message);
+
+ // The message should have been transferred.
+ EXPECT_TRUE(message.data == NULL);
+ EXPECT_TRUE(message.handles.empty());
+
+ MessageAccumulator accumulator;
+ connector1.SetIncomingReceiver(&accumulator);
+
+ PumpMessages();
+
+ ASSERT_FALSE(accumulator.IsEmpty());
+
+ Message message_received;
+ accumulator.Pop(&message_received);
+
+ EXPECT_EQ(std::string(kText),
+ std::string(
+ reinterpret_cast<char*>(message_received.data->payload)));
+ ASSERT_EQ(2U, message_received.handles.size());
+ EXPECT_EQ(handles[0].value, message_received.handles[0].value);
+ EXPECT_EQ(handles[1].value, message_received.handles[1].value);
+}
+#endif
+
} // namespace test
} // namespace mojo
« 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