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

Unified Diff: ipc/ipc_channel_mojo_unittest.cc

Issue 2665053002: Add tests for detecting lost associated interfaces. (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | ipc/ipc_test.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_mojo_unittest.cc
diff --git a/ipc/ipc_channel_mojo_unittest.cc b/ipc/ipc_channel_mojo_unittest.cc
index 5e75fbd7cfd5b00ea06ca2544d566b3aea8eb49f..b2582cf13b8940e6a4ab94e1a8af1b2e3b1f02b1 100644
--- a/ipc/ipc_channel_mojo_unittest.cc
+++ b/ipc/ipc_channel_mojo_unittest.cc
@@ -12,6 +12,7 @@
#include "base/base_paths.h"
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/files/file.h"
#include "base/files/scoped_temp_dir.h"
#include "base/location.h"
@@ -1264,6 +1265,54 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT_WITH_CUSTOM_FIXTURE(CreatePausedClient,
DestroyProxy();
}
+TEST_F(IPCChannelProxyMojoTest, AssociatedRequestClose) {
+ Init("DropAssociatedRequest");
+
+ DummyListener listener;
+ CreateProxy(&listener);
+ RunProxy();
+
+ IPC::mojom::AssociatedInterfaceVendorAssociatedPtr vendor;
+ proxy()->GetRemoteAssociatedInterface(&vendor);
+ IPC::mojom::SimpleTestDriverAssociatedPtr tester;
+ vendor->GetTestInterface(
+ mojo::MakeRequest(&tester, vendor.associated_group()));
+ base::RunLoop run_loop;
+ tester.set_connection_error_handler(run_loop.QuitClosure());
+ run_loop.Run();
+
+ proxy()->GetRemoteAssociatedInterface(&tester);
+ EXPECT_TRUE(WaitForClientShutdown());
+ DestroyProxy();
+}
+
+class AssociatedInterfaceDroppingListener : public IPC::Listener {
+ public:
+ AssociatedInterfaceDroppingListener(const base::Closure& callback)
+ : callback_(callback) {}
+ bool OnMessageReceived(const IPC::Message& message) override { return false; }
+
+ void OnAssociatedInterfaceRequest(
+ const std::string& interface_name,
+ mojo::ScopedInterfaceEndpointHandle handle) override {
+ if (interface_name == IPC::mojom::SimpleTestDriver::Name_)
+ base::ResetAndReturn(&callback_).Run();
+ }
+
+ private:
+ base::Closure callback_;
+};
+
+DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT_WITH_CUSTOM_FIXTURE(DropAssociatedRequest,
+ ChannelProxyClient) {
+ base::RunLoop run_loop;
+ AssociatedInterfaceDroppingListener listener(run_loop.QuitClosure());
+ CreateProxy(&listener);
+ RunProxy();
+ run_loop.Run();
+ DestroyProxy();
+}
+
#if defined(OS_POSIX)
class ListenerThatExpectsFile : public IPC::Listener {
« no previous file with comments | « no previous file | ipc/ipc_test.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698