| 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 8f0521c850ae0e2b3ec10c8dcfa073c023820689..a93b57c53e924b2334b190a0e509fb5b709f0056 100644
|
| --- a/mojo/public/cpp/bindings/tests/binding_unittest.cc
|
| +++ b/mojo/public/cpp/bindings/tests/binding_unittest.cc
|
| @@ -424,6 +424,27 @@ TEST_F(BindingTest, FlushForTestingWithClosedPeer) {
|
| binding.FlushForTesting();
|
| }
|
|
|
| +TEST_F(BindingTest, ConnectionErrorWithReason) {
|
| + sample::ServicePtr ptr;
|
| + auto request = GetProxy(&ptr);
|
| + ServiceImpl impl;
|
| + Binding<sample::Service> binding(&impl, std::move(request));
|
| +
|
| + base::RunLoop run_loop;
|
| + binding.set_connection_error_with_reason_handler(base::Bind(
|
| + [](const base::Closure& quit_closure, uint32_t custom_reason,
|
| + const std::string& description) {
|
| + EXPECT_EQ(1234u, custom_reason);
|
| + EXPECT_EQ("hello", description);
|
| + quit_closure.Run();
|
| + },
|
| + run_loop.QuitClosure()));
|
| +
|
| + ptr.ResetWithReason(1234u, "hello");
|
| +
|
| + run_loop.Run();
|
| +}
|
| +
|
| // StrongBindingTest -----------------------------------------------------------
|
|
|
| using StrongBindingTest = BindingTestBase;
|
| @@ -526,5 +547,25 @@ TEST_F(StrongBindingTest, FlushForTestingWithClosedPeer) {
|
| ASSERT_FALSE(binding);
|
| }
|
|
|
| +TEST_F(StrongBindingTest, ConnectionErrorWithReason) {
|
| + sample::ServicePtr ptr;
|
| + auto request = GetProxy(&ptr);
|
| + auto binding =
|
| + MakeStrongBinding(base::MakeUnique<ServiceImpl>(), std::move(request));
|
| + base::RunLoop run_loop;
|
| + binding->set_connection_error_with_reason_handler(base::Bind(
|
| + [](const base::Closure& quit_closure, uint32_t custom_reason,
|
| + const std::string& description) {
|
| + EXPECT_EQ(5678u, custom_reason);
|
| + EXPECT_EQ("hello", description);
|
| + quit_closure.Run();
|
| + },
|
| + run_loop.QuitClosure()));
|
| +
|
| + ptr.ResetWithReason(5678u, "hello");
|
| +
|
| + run_loop.Run();
|
| +}
|
| +
|
| } // namespace
|
| } // mojo
|
|
|