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

Unified Diff: mojo/public/cpp/bindings/tests/associated_interface_unittest.cc

Issue 1475813002: Mojo C++ bindings: support passing associated interface pointers/requests in method parameter lists… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@25_use_multiplex_router
Patch Set: Created 5 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/cpp/bindings/tests/array_unittest.cc ('k') | mojo/public/cpp/bindings/tests/map_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/tests/associated_interface_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/associated_interface_unittest.cc b/mojo/public/cpp/bindings/tests/associated_interface_unittest.cc
index d3686ec0f62f85e5e6128fdaa101c3206987ec6a..3ba9941e895d6ed6b986010c6dd6e05773573226 100644
--- a/mojo/public/cpp/bindings/tests/associated_interface_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/associated_interface_unittest.cc
@@ -56,6 +56,33 @@ class IntegerSenderImpl : public IntegerSender {
base::Callback<void(int32_t)> notify_send_method_called_;
};
+class IntegerSenderConnectionImpl : public IntegerSenderConnection {
+ public:
+ explicit IntegerSenderConnectionImpl(
+ InterfaceRequest<IntegerSenderConnection> request)
+ : binding_(this, request.Pass()) {}
+
+ ~IntegerSenderConnectionImpl() override {}
+
+ void GetSender(AssociatedInterfaceRequest<IntegerSender> sender) override {
+ IntegerSenderImpl* sender_impl = new IntegerSenderImpl(sender.Pass());
+ sender_impl->set_connection_error_handler(
+ [sender_impl]() { delete sender_impl; });
+ }
+
+ void AsyncGetSender(const AsyncGetSenderCallback& callback) override {
+ AssociatedInterfaceRequest<IntegerSender> request;
+ AssociatedInterfacePtrInfo<IntegerSender> ptr_info;
+ binding_.associated_group()->CreateAssociatedInterface(
+ AssociatedGroup::WILL_PASS_PTR, &ptr_info, &request);
+ GetSender(request.Pass());
+ callback.Run(ptr_info.Pass());
+ }
+
+ private:
+ Binding<IntegerSenderConnection> binding_;
+};
+
class AssociatedInterfaceTest : public testing::Test {
public:
AssociatedInterfaceTest() : loop_(common::MessagePumpMojo::Create()) {}
@@ -446,6 +473,32 @@ TEST_F(AssociatedInterfaceTest, FIFO) {
}
}
+TEST_F(AssociatedInterfaceTest, PassAssociatedInterfaces) {
+ IntegerSenderConnectionPtr connection_ptr;
+ IntegerSenderConnectionImpl connection(GetProxy(&connection_ptr));
+
+ AssociatedInterfacePtr<IntegerSender> sender0;
+ connection_ptr->GetSender(
+ GetProxy(&sender0, connection_ptr.associated_group()));
+
+ int32_t echoed_value = 0;
+ sender0->Echo(123, [&echoed_value](int32_t value) { echoed_value = value; });
+ PumpMessages();
+ EXPECT_EQ(123, echoed_value);
+
+ AssociatedInterfacePtr<IntegerSender> sender1;
+ connection_ptr->AsyncGetSender(
+ [&sender1](AssociatedInterfacePtrInfo<IntegerSender> ptr_info) {
+ sender1.Bind(ptr_info.Pass());
+ });
+ PumpMessages();
+ EXPECT_TRUE(sender1);
+
+ sender1->Echo(456, [&echoed_value](int32_t value) { echoed_value = value; });
+ PumpMessages();
+ EXPECT_EQ(456, echoed_value);
+}
+
} // namespace
} // namespace test
} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/tests/array_unittest.cc ('k') | mojo/public/cpp/bindings/tests/map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698