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

Unified Diff: ipc/ipc_channel_mojo_unittest.cc

Issue 2163633003: Support early associated interface binding on ChannelMojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@explicit-channel-ipc-task-runner
Patch Set: . Created 4 years, 5 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 | « ipc/ipc_channel_mojo.cc ('k') | ipc/ipc_channel_proxy.h » ('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 041672023a6a84f173bc45e4c82c27d7ab6b89d2..f7652e7156c6d2eab2c4480e58a0a7c511ba07f9 100644
--- a/ipc/ipc_channel_mojo_unittest.cc
+++ b/ipc/ipc_channel_mojo_unittest.cc
@@ -758,6 +758,10 @@ class IPCChannelProxyMojoTest : public IPCChannelMojoTestBase {
}
void CreateProxy(IPC::Listener* listener) { runner_->CreateProxy(listener); }
void RunProxy() { runner_->RunProxy(); }
+ void DestroyProxy() {
+ runner_.reset();
+ base::RunLoop().RunUntilIdle();
+ }
IPC::ChannelProxy* proxy() { return runner_->proxy(); }
@@ -808,6 +812,7 @@ class ListenerWithSimpleProxyAssociatedInterface
void RequestQuit(const RequestQuitCallback& callback) override {
received_quit_ = true;
callback.Run();
+ binding_.Close();
base::MessageLoop::current()->QuitWhenIdle();
}
@@ -838,7 +843,7 @@ TEST_F(IPCChannelProxyMojoTest, ProxyThreadAssociatedInterface) {
EXPECT_TRUE(WaitForClientShutdown());
EXPECT_TRUE(listener.received_all_messages());
- base::RunLoop().RunUntilIdle();
+ DestroyProxy();
}
class ChannelProxyClient {
@@ -848,6 +853,10 @@ class ChannelProxyClient {
}
void CreateProxy(IPC::Listener* listener) { runner_->CreateProxy(listener); }
void RunProxy() { runner_->RunProxy(); }
+ void DestroyProxy() {
+ runner_.reset();
+ base::RunLoop().RunUntilIdle();
+ }
IPC::ChannelProxy* proxy() { return runner_->proxy(); }
@@ -856,26 +865,17 @@ class ChannelProxyClient {
std::unique_ptr<ChannelProxyRunner> runner_;
};
-class ListenerThatWaitsForConnect : public IPC::Listener {
+class DummyListener : public IPC::Listener {
public:
- explicit ListenerThatWaitsForConnect(const base::Closure& connect_handler)
- : connect_handler_(connect_handler) {}
-
// IPC::Listener
bool OnMessageReceived(const IPC::Message& message) override { return true; }
- void OnChannelConnected(int32_t) override { connect_handler_.Run(); }
-
- private:
- base::Closure connect_handler_;
};
DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(ProxyThreadAssociatedInterfaceClient,
ChannelProxyClient) {
- base::RunLoop connect_loop;
- ListenerThatWaitsForConnect listener(connect_loop.QuitClosure());
+ DummyListener listener;
CreateProxy(&listener);
RunProxy();
- connect_loop.Run();
// Send a bunch of interleaved messages, alternating between the associated
// interface and a legacy IPC::Message.
@@ -889,6 +889,8 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(ProxyThreadAssociatedInterfaceClient,
}
driver->RequestQuit(base::MessageLoop::QuitWhenIdleClosure());
base::RunLoop().Run();
+
+ DestroyProxy();
}
#if defined(OS_POSIX)
« no previous file with comments | « ipc/ipc_channel_mojo.cc ('k') | ipc/ipc_channel_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698