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

Side by Side Diff: mojo/public/cpp/bindings/tests/associated_interface_unittest.cc

Issue 2696233002: Mojo C++ bindings: remove some usage of AssociatedGroup from user code. (Closed)
Patch Set: . Created 3 years, 10 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/synchronization/waitable_event.h" 17 #include "base/synchronization/waitable_event.h"
18 #include "base/threading/sequenced_task_runner_handle.h" 18 #include "base/threading/sequenced_task_runner_handle.h"
19 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
20 #include "base/threading/thread_task_runner_handle.h" 20 #include "base/threading/thread_task_runner_handle.h"
21 #include "mojo/public/cpp/bindings/associated_binding.h" 21 #include "mojo/public/cpp/bindings/associated_binding.h"
22 #include "mojo/public/cpp/bindings/associated_group.h"
23 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" 22 #include "mojo/public/cpp/bindings/associated_interface_ptr.h"
24 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" 23 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
25 #include "mojo/public/cpp/bindings/associated_interface_request.h" 24 #include "mojo/public/cpp/bindings/associated_interface_request.h"
26 #include "mojo/public/cpp/bindings/binding.h" 25 #include "mojo/public/cpp/bindings/binding.h"
27 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" 26 #include "mojo/public/cpp/bindings/lib/multiplex_router.h"
28 #include "mojo/public/cpp/bindings/strong_binding.h" 27 #include "mojo/public/cpp/bindings/strong_binding.h"
29 #include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h" 28 #include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h"
30 #include "mojo/public/interfaces/bindings/tests/ping_service.mojom.h" 29 #include "mojo/public/interfaces/bindings/tests/ping_service.mojom.h"
31 #include "mojo/public/interfaces/bindings/tests/test_associated_interfaces.mojom .h" 30 #include "mojo/public/interfaces/bindings/tests/test_associated_interfaces.mojom .h"
32 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 72
74 ~IntegerSenderConnectionImpl() override {} 73 ~IntegerSenderConnectionImpl() override {}
75 74
76 void GetSender(AssociatedInterfaceRequest<IntegerSender> sender) override { 75 void GetSender(AssociatedInterfaceRequest<IntegerSender> sender) override {
77 IntegerSenderImpl* sender_impl = new IntegerSenderImpl(std::move(sender)); 76 IntegerSenderImpl* sender_impl = new IntegerSenderImpl(std::move(sender));
78 sender_impl->set_connection_error_handler( 77 sender_impl->set_connection_error_handler(
79 base::Bind(&DeleteSender, sender_impl)); 78 base::Bind(&DeleteSender, sender_impl));
80 } 79 }
81 80
82 void AsyncGetSender(const AsyncGetSenderCallback& callback) override { 81 void AsyncGetSender(const AsyncGetSenderCallback& callback) override {
83 AssociatedInterfaceRequest<IntegerSender> request;
84 IntegerSenderAssociatedPtrInfo ptr_info; 82 IntegerSenderAssociatedPtrInfo ptr_info;
85 binding_.associated_group()->CreateAssociatedInterface( 83 auto request = MakeRequest(&ptr_info);
86 AssociatedGroup::WILL_PASS_PTR, &ptr_info, &request);
87 GetSender(std::move(request)); 84 GetSender(std::move(request));
88 callback.Run(std::move(ptr_info)); 85 callback.Run(std::move(ptr_info));
89 } 86 }
90 87
91 Binding<IntegerSenderConnection>* binding() { return &binding_; } 88 Binding<IntegerSenderConnection>* binding() { return &binding_; }
92 89
93 private: 90 private:
94 static void DeleteSender(IntegerSenderImpl* sender) { delete sender; } 91 static void DeleteSender(IntegerSenderImpl* sender) { delete sender; }
95 92
96 Binding<IntegerSenderConnection> binding_; 93 Binding<IntegerSenderConnection> binding_;
(...skipping 27 matching lines...) Expand all
124 *router1 = new MultiplexRouter(std::move(pipe.handle1), 121 *router1 = new MultiplexRouter(std::move(pipe.handle1),
125 MultiplexRouter::MULTI_INTERFACE, false, 122 MultiplexRouter::MULTI_INTERFACE, false,
126 base::ThreadTaskRunnerHandle::Get()); 123 base::ThreadTaskRunnerHandle::Get());
127 } 124 }
128 125
129 void CreateIntegerSenderWithExistingRouters( 126 void CreateIntegerSenderWithExistingRouters(
130 scoped_refptr<MultiplexRouter> router0, 127 scoped_refptr<MultiplexRouter> router0,
131 IntegerSenderAssociatedPtrInfo* ptr_info0, 128 IntegerSenderAssociatedPtrInfo* ptr_info0,
132 scoped_refptr<MultiplexRouter> router1, 129 scoped_refptr<MultiplexRouter> router1,
133 IntegerSenderAssociatedRequest* request1) { 130 IntegerSenderAssociatedRequest* request1) {
134 AssociatedGroup dummy_group; 131 *request1 = MakeRequest(ptr_info0);
135 dummy_group.CreateAssociatedInterface(AssociatedGroup::WILL_PASS_PTR,
136 ptr_info0, request1);
137 *ptr_info0 = EmulatePassingAssociatedPtrInfo(std::move(*ptr_info0), router1, 132 *ptr_info0 = EmulatePassingAssociatedPtrInfo(std::move(*ptr_info0), router1,
138 router0); 133 router0);
139 } 134 }
140 135
141 void CreateIntegerSender(IntegerSenderAssociatedPtrInfo* ptr_info, 136 void CreateIntegerSender(IntegerSenderAssociatedPtrInfo* ptr_info,
142 IntegerSenderAssociatedRequest* request) { 137 IntegerSenderAssociatedRequest* request) {
143 scoped_refptr<MultiplexRouter> router0; 138 scoped_refptr<MultiplexRouter> router0;
144 scoped_refptr<MultiplexRouter> router1; 139 scoped_refptr<MultiplexRouter> router1;
145 CreateRouterPair(&router0, &router1); 140 CreateRouterPair(&router0, &router1);
146 CreateIntegerSenderWithExistingRouters(router1, ptr_info, router0, request); 141 CreateIntegerSenderWithExistingRouters(router1, ptr_info, router0, request);
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 IntegerSenderAssociatedPtrInfo info) { 547 IntegerSenderAssociatedPtrInfo info) {
553 storage->Bind(std::move(info)); 548 storage->Bind(std::move(info));
554 closure.Run(); 549 closure.Run();
555 } 550 }
556 551
557 TEST_F(AssociatedInterfaceTest, PassAssociatedInterfaces) { 552 TEST_F(AssociatedInterfaceTest, PassAssociatedInterfaces) {
558 IntegerSenderConnectionPtr connection_ptr; 553 IntegerSenderConnectionPtr connection_ptr;
559 IntegerSenderConnectionImpl connection(MakeRequest(&connection_ptr)); 554 IntegerSenderConnectionImpl connection(MakeRequest(&connection_ptr));
560 555
561 IntegerSenderAssociatedPtr sender0; 556 IntegerSenderAssociatedPtr sender0;
562 connection_ptr->GetSender( 557 connection_ptr->GetSender(MakeRequest(&sender0));
563 MakeRequest(&sender0, connection_ptr.associated_group()));
564 558
565 int32_t echoed_value = 0; 559 int32_t echoed_value = 0;
566 base::RunLoop run_loop; 560 base::RunLoop run_loop;
567 sender0->Echo(123, base::Bind(&CaptureInt32, &echoed_value, 561 sender0->Echo(123, base::Bind(&CaptureInt32, &echoed_value,
568 run_loop.QuitClosure())); 562 run_loop.QuitClosure()));
569 run_loop.Run(); 563 run_loop.Run();
570 EXPECT_EQ(123, echoed_value); 564 EXPECT_EQ(123, echoed_value);
571 565
572 IntegerSenderAssociatedPtr sender1; 566 IntegerSenderAssociatedPtr sender1;
573 base::RunLoop run_loop2; 567 base::RunLoop run_loop2;
574 connection_ptr->AsyncGetSender( 568 connection_ptr->AsyncGetSender(
575 base::Bind(&CaptureSenderPtrInfo, &sender1, run_loop2.QuitClosure())); 569 base::Bind(&CaptureSenderPtrInfo, &sender1, run_loop2.QuitClosure()));
576 run_loop2.Run(); 570 run_loop2.Run();
577 EXPECT_TRUE(sender1); 571 EXPECT_TRUE(sender1);
578 572
579 base::RunLoop run_loop3; 573 base::RunLoop run_loop3;
580 sender1->Echo(456, base::Bind(&CaptureInt32, &echoed_value, 574 sender1->Echo(456, base::Bind(&CaptureInt32, &echoed_value,
581 run_loop3.QuitClosure())); 575 run_loop3.QuitClosure()));
582 run_loop3.Run(); 576 run_loop3.Run();
583 EXPECT_EQ(456, echoed_value); 577 EXPECT_EQ(456, echoed_value);
584 } 578 }
585 579
586 TEST_F(AssociatedInterfaceTest, BindingWaitAndPauseWhenNoAssociatedInterfaces) { 580 TEST_F(AssociatedInterfaceTest, BindingWaitAndPauseWhenNoAssociatedInterfaces) {
587 IntegerSenderConnectionPtr connection_ptr; 581 IntegerSenderConnectionPtr connection_ptr;
588 IntegerSenderConnectionImpl connection(MakeRequest(&connection_ptr)); 582 IntegerSenderConnectionImpl connection(MakeRequest(&connection_ptr));
589 583
590 IntegerSenderAssociatedPtr sender0; 584 IntegerSenderAssociatedPtr sender0;
591 connection_ptr->GetSender( 585 connection_ptr->GetSender(MakeRequest(&sender0));
592 MakeRequest(&sender0, connection_ptr.associated_group()));
593 586
594 EXPECT_FALSE(connection.binding()->HasAssociatedInterfaces()); 587 EXPECT_FALSE(connection.binding()->HasAssociatedInterfaces());
595 // There are no associated interfaces running on the pipe yet. It is okay to 588 // There are no associated interfaces running on the pipe yet. It is okay to
596 // pause. 589 // pause.
597 connection.binding()->PauseIncomingMethodCallProcessing(); 590 connection.binding()->PauseIncomingMethodCallProcessing();
598 connection.binding()->ResumeIncomingMethodCallProcessing(); 591 connection.binding()->ResumeIncomingMethodCallProcessing();
599 592
600 // There are no associated interfaces running on the pipe yet. It is okay to 593 // There are no associated interfaces running on the pipe yet. It is okay to
601 // wait. 594 // wait.
602 EXPECT_TRUE(connection.binding()->WaitForIncomingMethodCall()); 595 EXPECT_TRUE(connection.binding()->WaitForIncomingMethodCall());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 }; 683 };
691 684
692 // Verifies that filters work as expected on associated bindings, i.e. that 685 // Verifies that filters work as expected on associated bindings, i.e. that
693 // they're notified in order, before dispatch; and that each associated 686 // they're notified in order, before dispatch; and that each associated
694 // binding in a group operates with its own set of filters. 687 // binding in a group operates with its own set of filters.
695 TEST_F(AssociatedInterfaceTest, BindingWithFilters) { 688 TEST_F(AssociatedInterfaceTest, BindingWithFilters) {
696 AssociatedPingProviderPtr provider; 689 AssociatedPingProviderPtr provider;
697 PingProviderImpl provider_impl(MakeRequest(&provider)); 690 PingProviderImpl provider_impl(MakeRequest(&provider));
698 691
699 PingServiceAssociatedPtr ping_a, ping_b; 692 PingServiceAssociatedPtr ping_a, ping_b;
700 provider->GetPing(MakeRequest(&ping_a, provider.associated_group())); 693 provider->GetPing(MakeRequest(&ping_a));
701 provider->GetPing(MakeRequest(&ping_b, provider.associated_group())); 694 provider->GetPing(MakeRequest(&ping_b));
702 provider_impl.WaitForBindings(2); 695 provider_impl.WaitForBindings(2);
703 696
704 ASSERT_EQ(2u, provider_impl.ping_services().size()); 697 ASSERT_EQ(2u, provider_impl.ping_services().size());
705 PingServiceImpl& ping_a_impl = *provider_impl.ping_services()[0]; 698 PingServiceImpl& ping_a_impl = *provider_impl.ping_services()[0];
706 PingServiceImpl& ping_b_impl = *provider_impl.ping_services()[1]; 699 PingServiceImpl& ping_b_impl = *provider_impl.ping_services()[1];
707 700
708 int a_status, b_status; 701 int a_status, b_status;
709 auto handler_helper = [] (int* a_status, int* b_status, int expected_a_status, 702 auto handler_helper = [] (int* a_status, int* b_status, int expected_a_status,
710 int new_a_status, int expected_b_status, 703 int new_a_status, int expected_b_status,
711 int new_b_status) { 704 int new_b_status) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 } 862 }
870 863
871 TEST_F(AssociatedInterfaceTest, StrongBindingFlushForTesting) { 864 TEST_F(AssociatedInterfaceTest, StrongBindingFlushForTesting) {
872 IntegerSenderConnectionPtr ptr; 865 IntegerSenderConnectionPtr ptr;
873 auto binding = 866 auto binding =
874 MakeStrongBinding(base::MakeUnique<IntegerSenderConnectionImpl>( 867 MakeStrongBinding(base::MakeUnique<IntegerSenderConnectionImpl>(
875 IntegerSenderConnectionRequest{}), 868 IntegerSenderConnectionRequest{}),
876 MakeRequest(&ptr)); 869 MakeRequest(&ptr));
877 bool called = false; 870 bool called = false;
878 IntegerSenderAssociatedPtr sender_ptr; 871 IntegerSenderAssociatedPtr sender_ptr;
879 ptr->GetSender(MakeRequest(&sender_ptr, ptr.associated_group())); 872 ptr->GetSender(MakeRequest(&sender_ptr));
880 sender_ptr->Echo(1, base::Bind(&SetBoolWithUnusedParameter<int>, &called)); 873 sender_ptr->Echo(1, base::Bind(&SetBoolWithUnusedParameter<int>, &called));
881 EXPECT_FALSE(called); 874 EXPECT_FALSE(called);
882 // Because the flush is sent from the binding, it only guarantees that the 875 // Because the flush is sent from the binding, it only guarantees that the
883 // request has been received, not the response. The second flush waits for the 876 // request has been received, not the response. The second flush waits for the
884 // response to be received. 877 // response to be received.
885 ASSERT_TRUE(binding); 878 ASSERT_TRUE(binding);
886 binding->FlushForTesting(); 879 binding->FlushForTesting();
887 ASSERT_TRUE(binding); 880 ASSERT_TRUE(binding);
888 binding->FlushForTesting(); 881 binding->FlushForTesting();
889 EXPECT_TRUE(called); 882 EXPECT_TRUE(called);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 ptr.ResetWithReason(123u, "farewell"); 943 ptr.ResetWithReason(123u, "farewell");
951 944
952 run_loop.Run(); 945 run_loop.Run();
953 } 946 }
954 947
955 TEST_F(AssociatedInterfaceTest, 948 TEST_F(AssociatedInterfaceTest,
956 PendingAssociatedBindingConnectionErrorWithReason) { 949 PendingAssociatedBindingConnectionErrorWithReason) {
957 // Test that AssociatedBinding is notified with connection error when the 950 // Test that AssociatedBinding is notified with connection error when the
958 // interface hasn't associated with a message pipe and the peer is closed. 951 // interface hasn't associated with a message pipe and the peer is closed.
959 952
960 AssociatedGroup dummy_group;
961 IntegerSenderAssociatedPtr ptr; 953 IntegerSenderAssociatedPtr ptr;
962 IntegerSenderImpl impl(MakeRequest(&ptr, &dummy_group)); 954 IntegerSenderImpl impl(MakeRequest(&ptr));
963 955
964 base::RunLoop run_loop; 956 base::RunLoop run_loop;
965 impl.binding()->set_connection_error_with_reason_handler(base::Bind( 957 impl.binding()->set_connection_error_with_reason_handler(base::Bind(
966 [](const base::Closure& quit_closure, uint32_t custom_reason, 958 [](const base::Closure& quit_closure, uint32_t custom_reason,
967 const std::string& description) { 959 const std::string& description) {
968 EXPECT_EQ(123u, custom_reason); 960 EXPECT_EQ(123u, custom_reason);
969 EXPECT_EQ("farewell", description); 961 EXPECT_EQ("farewell", description);
970 quit_closure.Run(); 962 quit_closure.Run();
971 }, 963 },
972 run_loop.QuitClosure())); 964 run_loop.QuitClosure()));
(...skipping 24 matching lines...) Expand all
997 989
998 impl.binding()->CloseWithReason(456u, "farewell"); 990 impl.binding()->CloseWithReason(456u, "farewell");
999 991
1000 run_loop.Run(); 992 run_loop.Run();
1001 } 993 }
1002 994
1003 TEST_F(AssociatedInterfaceTest, PendingAssociatedPtrConnectionErrorWithReason) { 995 TEST_F(AssociatedInterfaceTest, PendingAssociatedPtrConnectionErrorWithReason) {
1004 // Test that AssociatedInterfacePtr is notified with connection error when the 996 // Test that AssociatedInterfacePtr is notified with connection error when the
1005 // interface hasn't associated with a message pipe and the peer is closed. 997 // interface hasn't associated with a message pipe and the peer is closed.
1006 998
1007 AssociatedGroup dummy_group;
1008 IntegerSenderAssociatedPtr ptr; 999 IntegerSenderAssociatedPtr ptr;
1009 auto request = MakeRequest(&ptr, &dummy_group); 1000 auto request = MakeRequest(&ptr);
1010 1001
1011 base::RunLoop run_loop; 1002 base::RunLoop run_loop;
1012 ptr.set_connection_error_with_reason_handler(base::Bind( 1003 ptr.set_connection_error_with_reason_handler(base::Bind(
1013 [](const base::Closure& quit_closure, uint32_t custom_reason, 1004 [](const base::Closure& quit_closure, uint32_t custom_reason,
1014 const std::string& description) { 1005 const std::string& description) {
1015 EXPECT_EQ(456u, custom_reason); 1006 EXPECT_EQ(456u, custom_reason);
1016 EXPECT_EQ("farewell", description); 1007 EXPECT_EQ("farewell", description);
1017 quit_closure.Run(); 1008 quit_closure.Run();
1018 }, 1009 },
1019 run_loop.QuitClosure())); 1010 run_loop.QuitClosure()));
(...skipping 24 matching lines...) Expand all
1044 request.ResetWithReason(789u, "long time no see"); 1035 request.ResetWithReason(789u, "long time no see");
1045 1036
1046 run_loop.Run(); 1037 run_loop.Run();
1047 } 1038 }
1048 1039
1049 TEST_F(AssociatedInterfaceTest, ThreadSafeAssociatedInterfacePtr) { 1040 TEST_F(AssociatedInterfaceTest, ThreadSafeAssociatedInterfacePtr) {
1050 IntegerSenderConnectionPtr connection_ptr; 1041 IntegerSenderConnectionPtr connection_ptr;
1051 IntegerSenderConnectionImpl connection(MakeRequest(&connection_ptr)); 1042 IntegerSenderConnectionImpl connection(MakeRequest(&connection_ptr));
1052 1043
1053 IntegerSenderAssociatedPtr sender; 1044 IntegerSenderAssociatedPtr sender;
1054 connection_ptr->GetSender( 1045 connection_ptr->GetSender(MakeRequest(&sender));
1055 MakeRequest(&sender, connection_ptr.associated_group()));
1056 1046
1057 scoped_refptr<ThreadSafeIntegerSenderAssociatedPtr> thread_safe_sender = 1047 scoped_refptr<ThreadSafeIntegerSenderAssociatedPtr> thread_safe_sender =
1058 ThreadSafeIntegerSenderAssociatedPtr::Create(std::move(sender)); 1048 ThreadSafeIntegerSenderAssociatedPtr::Create(std::move(sender));
1059 1049
1060 { 1050 {
1061 // Test the thread safe pointer can be used from the interface ptr thread. 1051 // Test the thread safe pointer can be used from the interface ptr thread.
1062 int32_t echoed_value = 0; 1052 int32_t echoed_value = 0;
1063 base::RunLoop run_loop; 1053 base::RunLoop run_loop;
1064 (*thread_safe_sender) 1054 (*thread_safe_sender)
1065 ->Echo(123, base::Bind(&CaptureInt32, &echoed_value, 1055 ->Echo(123, base::Bind(&CaptureInt32, &echoed_value,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 IntegerSenderAssociatedPtrInfo sender_info; 1109 IntegerSenderAssociatedPtrInfo sender_info;
1120 base::WaitableEvent sender_info_bound_event( 1110 base::WaitableEvent sender_info_bound_event(
1121 base::WaitableEvent::ResetPolicy::MANUAL, 1111 base::WaitableEvent::ResetPolicy::MANUAL,
1122 base::WaitableEvent::InitialState::NOT_SIGNALED); 1112 base::WaitableEvent::InitialState::NOT_SIGNALED);
1123 auto setup = [](base::WaitableEvent* sender_info_bound_event, 1113 auto setup = [](base::WaitableEvent* sender_info_bound_event,
1124 IntegerSenderAssociatedPtrInfo* sender_info, 1114 IntegerSenderAssociatedPtrInfo* sender_info,
1125 ForwarderTestContext* context) { 1115 ForwarderTestContext* context) {
1126 context->interface_impl = base::MakeUnique<IntegerSenderConnectionImpl>( 1116 context->interface_impl = base::MakeUnique<IntegerSenderConnectionImpl>(
1127 MakeRequest(&context->connection_ptr)); 1117 MakeRequest(&context->connection_ptr));
1128 1118
1129 IntegerSenderAssociatedPtr sender; 1119 auto sender_request = MakeRequest(sender_info);
1130 IntegerSenderAssociatedRequest sender_request =
1131 MakeRequest(&sender, context->connection_ptr.associated_group());
1132 *sender_info = sender.PassInterface();
1133
1134 context->connection_ptr->GetSender(std::move(sender_request)); 1120 context->connection_ptr->GetSender(std::move(sender_request));
1135 1121
1136 // Unblock the main thread as soon as |sender_info| is set. 1122 // Unblock the main thread as soon as |sender_info| is set.
1137 sender_info_bound_event->Signal(); 1123 sender_info_bound_event->Signal();
1138 }; 1124 };
1139 other_thread_task_runner->PostTask( 1125 other_thread_task_runner->PostTask(
1140 FROM_HERE, 1126 FROM_HERE,
1141 base::Bind(setup, &sender_info_bound_event, &sender_info, context)); 1127 base::Bind(setup, &sender_info_bound_event, &sender_info, context));
1142 sender_info_bound_event.Wait(); 1128 sender_info_bound_event.Wait();
1143 1129
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 void GetPingProvider( 1163 void GetPingProvider(
1178 AssociatedPingProviderAssociatedRequest request) override {} 1164 AssociatedPingProviderAssociatedRequest request) override {}
1179 }; 1165 };
1180 1166
1181 TEST_F(AssociatedInterfaceTest, CloseWithoutBindingAssociatedRequest) { 1167 TEST_F(AssociatedInterfaceTest, CloseWithoutBindingAssociatedRequest) {
1182 DiscardingAssociatedPingProviderProvider ping_provider_provider; 1168 DiscardingAssociatedPingProviderProvider ping_provider_provider;
1183 mojo::Binding<AssociatedPingProviderProvider> binding( 1169 mojo::Binding<AssociatedPingProviderProvider> binding(
1184 &ping_provider_provider); 1170 &ping_provider_provider);
1185 auto provider_provider = binding.CreateInterfacePtrAndBind(); 1171 auto provider_provider = binding.CreateInterfacePtrAndBind();
1186 AssociatedPingProviderAssociatedPtr provider; 1172 AssociatedPingProviderAssociatedPtr provider;
1187 provider_provider->GetPingProvider( 1173 provider_provider->GetPingProvider(mojo::MakeRequest(&provider));
1188 mojo::MakeRequest(&provider, provider_provider.associated_group()));
1189 PingServiceAssociatedPtr ping; 1174 PingServiceAssociatedPtr ping;
1190 provider->GetPing( 1175 provider->GetPing(mojo::MakeRequest(&ping));
1191 mojo::MakeRequest(&ping, provider.associated_group()));
1192 base::RunLoop run_loop; 1176 base::RunLoop run_loop;
1193 ping.set_connection_error_handler(run_loop.QuitClosure()); 1177 ping.set_connection_error_handler(run_loop.QuitClosure());
1194 run_loop.Run(); 1178 run_loop.Run();
1195 } 1179 }
1196 1180
1197 } // namespace 1181 } // namespace
1198 } // namespace test 1182 } // namespace test
1199 } // namespace mojo 1183 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/multiplex_router.cc ('k') | mojo/public/cpp/bindings/tests/bind_task_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698