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

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

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/bindings/strong_binding.h ('k') | mojo/public/cpp/bindings/tests/binding_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 fafc73f62acb17bcf9b71ecaeb5d7490851fd1e7..32f0570bb3730b6e6b56ab327f2f64392352315f 100644
--- a/mojo/public/cpp/bindings/tests/associated_interface_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/associated_interface_unittest.cc
@@ -889,9 +889,10 @@ TEST_F(AssociatedInterfaceTest, BindingFlushForTestingWithClosedPeer) {
TEST_F(AssociatedInterfaceTest, StrongBindingFlushForTesting) {
IntegerSenderConnectionPtr ptr;
- IntegerSenderConnectionImpl impl(IntegerSenderConnectionRequest{});
- mojo::StrongBinding<IntegerSenderConnection> binding(&impl, GetProxy(&ptr));
- binding.set_connection_error_handler(base::Bind(&Fail));
+ auto binding =
+ MakeStrongBinding(base::MakeUnique<IntegerSenderConnectionImpl>(
+ IntegerSenderConnectionRequest{}),
+ GetProxy(&ptr));
bool called = false;
IntegerSenderAssociatedPtr sender_ptr;
ptr->GetSender(GetProxy(&sender_ptr, ptr.associated_group()));
@@ -900,23 +901,27 @@ TEST_F(AssociatedInterfaceTest, StrongBindingFlushForTesting) {
// Because the flush is sent from the binding, it only guarantees that the
// request has been received, not the response. The second flush waits for the
// response to be received.
- binding.FlushForTesting();
- binding.FlushForTesting();
+ ASSERT_TRUE(binding);
+ binding->FlushForTesting();
+ ASSERT_TRUE(binding);
+ binding->FlushForTesting();
EXPECT_TRUE(called);
}
TEST_F(AssociatedInterfaceTest, StrongBindingFlushForTestingWithClosedPeer) {
IntegerSenderConnectionPtr ptr;
- mojo::StrongBinding<IntegerSenderConnection> binding(
- new IntegerSenderConnectionImpl(IntegerSenderConnectionRequest{}),
- GetProxy(&ptr));
bool called = false;
- binding.set_connection_error_handler(base::Bind(&SetBool, &called));
+ auto binding =
+ MakeStrongBinding(base::MakeUnique<IntegerSenderConnectionImpl>(
+ IntegerSenderConnectionRequest{}),
+ GetProxy(&ptr));
+ binding->set_connection_error_handler(base::Bind(&SetBool, &called));
ptr.reset();
EXPECT_FALSE(called);
- binding.FlushForTesting();
+ ASSERT_TRUE(binding);
+ binding->FlushForTesting();
EXPECT_TRUE(called);
- binding.FlushForTesting();
+ ASSERT_FALSE(binding);
}
TEST_F(AssociatedInterfaceTest, PtrFlushForTesting) {
« no previous file with comments | « mojo/public/cpp/bindings/strong_binding.h ('k') | mojo/public/cpp/bindings/tests/binding_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698