| Index: mojo/public/cpp/bindings/tests/binding_unittest.cc
|
| diff --git a/mojo/public/cpp/bindings/tests/binding_unittest.cc b/mojo/public/cpp/bindings/tests/binding_unittest.cc
|
| index e76993bb68ddeff3508a202975a631f171f2b4ef..bd3a7e3f61f8024840fea44690c6a112b78246b9 100644
|
| --- a/mojo/public/cpp/bindings/tests/binding_unittest.cc
|
| +++ b/mojo/public/cpp/bindings/tests/binding_unittest.cc
|
| @@ -21,6 +21,8 @@
|
| #include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| +#include "media/base/run_on_destruction.h"
|
| +
|
| namespace mojo {
|
| namespace {
|
|
|
| @@ -55,8 +57,12 @@ class ServiceImpl : public sample::Service {
|
| callback.Run(1);
|
| }
|
| void GetPort(InterfaceRequest<sample::Port> port) override {}
|
| + void EatCallback(const EatCallbackCallback& callback) override {
|
| + eat_callback_ = callback;
|
| + }
|
|
|
| bool* const was_deleted_;
|
| + EatCallbackCallback eat_callback_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ServiceImpl);
|
| };
|
| @@ -77,6 +83,11 @@ base::Callback<void(Args...)> SetFlagAndRunClosure(
|
| return base::Bind(&DoSetFlagAndRunClosure<Args...>, flag, callback);
|
| }
|
|
|
| +void OnResult(bool* result_storage, bool result) {
|
| + LOG(ERROR) << __func__ << ": " << result;
|
| + *result_storage = result;
|
| +}
|
| +
|
| // BindingTest -----------------------------------------------------------------
|
|
|
| using BindingTest = BindingTestBase;
|
| @@ -107,15 +118,18 @@ TEST_F(BindingTest, DestroyClosesMessagePipe) {
|
| ptr.set_connection_error_handler(
|
| SetFlagAndRunClosure(&encountered_error, run_loop.QuitClosure()));
|
| bool called = false;
|
| + bool result = false;
|
| base::RunLoop run_loop2;
|
| {
|
| Binding<sample::Service> binding(&impl, std::move(request));
|
| ptr->Frobinate(nullptr, sample::Service::BazOptions::REGULAR, nullptr,
|
| SetFlagAndRunClosure<int32_t>(&called,
|
| run_loop2.QuitClosure()));
|
| + ptr->EatCallback(media::RunOnDestruction(base::Bind(&OnResult, &result), true));
|
| run_loop2.Run();
|
| EXPECT_TRUE(called);
|
| EXPECT_FALSE(encountered_error);
|
| + EXPECT_FALSE(result);
|
| }
|
| // Now that the Binding is out of scope we should detect an error on the other
|
| // end of the pipe.
|
| @@ -129,6 +143,7 @@ TEST_F(BindingTest, DestroyClosesMessagePipe) {
|
| run_loop2.QuitClosure()));
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_FALSE(called);
|
| + EXPECT_TRUE(result);
|
| }
|
|
|
| // Tests that the binding's connection error handler gets called when the other
|
|
|