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

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

Issue 2318793002: Mojo C++ bindings: support disconnect with a reason. (Closed)
Patch Set: . 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
Index: mojo/public/cpp/bindings/tests/binding_set_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/binding_set_unittest.cc b/mojo/public/cpp/bindings/tests/binding_set_unittest.cc
index b388365abce1dd3b3e73863c5689c61bebe7da01..b12be4440fbd972e3bbecf59629272ac7785455f 100644
--- a/mojo/public/cpp/bindings/tests/binding_set_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/binding_set_unittest.cc
@@ -115,6 +115,25 @@ TEST_F(BindingSetTest, BindingSetContext) {
EXPECT_TRUE(bindings_.empty());
}
+TEST_F(BindingSetTest, BindingSetConnectionErrorWithReason) {
+ PingImpl impl;
+ PingServicePtr ptr;
+ BindingSet<PingService> bindings;
+ bindings.AddBinding(&impl, GetProxy(&ptr));
+
+ base::RunLoop run_loop;
+ bindings.set_connection_error_with_reason_handler(base::Bind(
+ [](const base::Closure& quit_closure, uint32_t custom_reason,
+ const std::string& description) {
+ EXPECT_EQ(1024u, custom_reason);
+ EXPECT_EQ("bye", description);
+ quit_closure.Run();
+ },
+ run_loop.QuitClosure()));
+
+ ptr.ResetWithReason(1024u, "bye");
+}
+
class PingProviderImpl : public AssociatedPingProvider, public PingService {
public:
PingProviderImpl() : ping_bindings_(BindingSetDispatchMode::WITH_CONTEXT) {}
@@ -263,6 +282,30 @@ TEST_F(BindingSetTest, MasterInterfaceBindingSetContext) {
EXPECT_TRUE(bindings.empty());
}
+TEST_F(BindingSetTest, AssociatedBindingSetConnectionErrorWithReason) {
+ AssociatedPingProviderPtr master_ptr;
+ PingProviderImpl master_impl;
+ Binding<AssociatedPingProvider> master_binding(&master_impl, &master_ptr);
+
+ base::RunLoop run_loop;
+ master_impl.ping_bindings().set_connection_error_with_reason_handler(
+ base::Bind(
+ [](const base::Closure& quit_closure, uint32_t custom_reason,
+ const std::string& description) {
+ EXPECT_EQ(2048u, custom_reason);
+ EXPECT_EQ("bye", description);
+ quit_closure.Run();
+ },
+ run_loop.QuitClosure()));
+
+ PingServiceAssociatedPtr ptr;
+ master_ptr->GetPing(GetProxy(&ptr, master_ptr.associated_group()));
+
+ ptr.ResetWithReason(2048u, "bye");
+
+ run_loop.Run();
+}
+
} // namespace
} // namespace test
} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/tests/associated_interface_unittest.cc ('k') | mojo/public/cpp/bindings/tests/binding_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698