aboutsummaryrefslogtreecommitdiff
path: root/src/ipc/client_impl_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipc/client_impl_unittest.cc')
-rw-r--r--src/ipc/client_impl_unittest.cc44
1 files changed, 10 insertions, 34 deletions
diff --git a/src/ipc/client_impl_unittest.cc b/src/ipc/client_impl_unittest.cc
index 0a31a8c61..183fbf0b7 100644
--- a/src/ipc/client_impl_unittest.cc
+++ b/src/ipc/client_impl_unittest.cc
@@ -17,6 +17,7 @@
#include "src/ipc/client_impl.h"
#include <stdio.h>
+#include <unistd.h>
#include <string>
@@ -45,7 +46,7 @@ using ::testing::InSequence;
using ::testing::Invoke;
using ::testing::Mock;
-ipc::TestSocket kTestSocket{"client_impl_unittest"};
+constexpr char kSockName[] = TEST_SOCK_NAME("client_impl_unittest");
// A fake ServiceProxy. This fakes the client-side class that would be
// auto-generated from .proto-files.
@@ -78,8 +79,8 @@ class MockEventListener : public ServiceProxy::EventListener {
MOCK_METHOD0(OnDisconnect, void());
};
-// A fake host implementation. Listens on |kTestSocket.name()| and replies to
-// IPC metohds like a real one.
+// A fake host implementation. Listens on |kSockName| and replies to IPC
+// metohds like a real one.
class FakeHost : public base::UnixSocket::EventListener {
public:
struct FakeMethod {
@@ -104,13 +105,13 @@ class FakeHost : public base::UnixSocket::EventListener {
}; // FakeService.
explicit FakeHost(base::TaskRunner* task_runner) {
- kTestSocket.Destroy();
- listening_sock =
- base::UnixSocket::Listen(kTestSocket.name(), this, task_runner,
- kTestSocket.family(), base::SockType::kStream);
+ DESTROY_TEST_SOCK(kSockName);
+ listening_sock = base::UnixSocket::Listen(kSockName, this, task_runner,
+ base::SockFamily::kUnix,
+ base::SockType::kStream);
EXPECT_TRUE(listening_sock->is_listening());
}
- ~FakeHost() override { kTestSocket.Destroy(); }
+ ~FakeHost() override { DESTROY_TEST_SOCK(kSockName); }
FakeService* AddFakeService(const std::string& name) {
auto it_and_inserted =
@@ -204,8 +205,7 @@ class ClientImplTest : public ::testing::Test {
void SetUp() override {
task_runner_.reset(new base::TestTaskRunner());
host_.reset(new FakeHost(task_runner_.get()));
- cli_ = Client::CreateInstance({kTestSocket.name(), /*retry=*/false},
- task_runner_.get());
+ cli_ = Client::CreateInstance(kSockName, task_runner_.get());
}
void TearDown() override {
@@ -340,8 +340,6 @@ TEST_F(ClientImplTest, BindAndInvokeStreamingMethod) {
ASSERT_EQ(kNumReplies, replies_seen);
}
-#if !PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
-// File descriptor sending over IPC is not supported on Windows.
TEST_F(ClientImplTest, ReceiveFileDescriptor) {
auto* host_svc = host_->AddFakeService("FakeSvc");
auto* host_method = host_svc->AddFakeMethod("FakeMethod1");
@@ -431,7 +429,6 @@ TEST_F(ClientImplTest, SendFileDescriptor) {
PERFETTO_EINTR(read(*rx_fd, buf, sizeof(buf))));
ASSERT_STREQ(kFileContent, buf);
}
-#endif // !OS_WIN
TEST_F(ClientImplTest, BindSameServiceMultipleTimesShouldFail) {
host_->AddFakeService("FakeSvc");
@@ -578,27 +575,6 @@ TEST_F(ClientImplTest, HostDisconnection) {
task_runner_->RunUntilCheckpoint("on_disconnect");
}
-TEST_F(ClientImplTest, HostConnectionFailure) {
- ipc::TestSocket kNonexistentSock{"client_impl_unittest_nonexistent"};
- std::unique_ptr<Client> client = Client::CreateInstance(
- {kNonexistentSock.name(), /*retry=*/false}, task_runner_.get());
-
- // Connect a client to a non-existent socket, which will always fail. The
- // client will notify the proxy of disconnection.
- std::unique_ptr<FakeProxy> proxy(new FakeProxy("FakeSvc", &proxy_events_));
- client->BindService(proxy->GetWeakPtr());
-
- // Make sure the client copes with being deleted by the disconnection
- // callback.
- auto on_disconnect_reached = task_runner_->CreateCheckpoint("on_disconnect");
- auto on_disconnect = [&] {
- client.reset();
- on_disconnect_reached();
- };
- EXPECT_CALL(proxy_events_, OnDisconnect()).WillOnce(Invoke(on_disconnect));
- task_runner_->RunUntilCheckpoint("on_disconnect");
-}
-
// TODO(primiano): add the tests below.
// TEST(ClientImplTest, UnparsableReply) {}