chromium/mojo/public/cpp/bindings/tests/receiver_unittest.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "mojo/public/cpp/bindings/receiver.h"

#include <stdint.h>

#include <optional>
#include <utility>

#include "base/check_op.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/bind.h"
#include "base/threading/thread.h"
#include "build/blink_buildflags.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/core/test/mojo_test_base.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "mojo/public/cpp/bindings/tests/bindings_test_base.h"
#include "mojo/public/cpp/bindings/tests/receiver_unittest.test-mojom.h"
#include "mojo/public/cpp/system/functions.h"
#include "mojo/public/interfaces/bindings/tests/ping_service.mojom.h"
#include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h"
#include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace mojo {
namespace test {
namespace receiver_unittest {

class ServiceImpl : public sample::Service {};

ReceiverTest;

TEST_P(ReceiverTest, Reset) {}

// Tests that destroying a mojo::Binding closes the bound message pipe handle.
TEST_P(ReceiverTest, DestroyClosesMessagePipe) {}

// Tests that the binding's connection error handler gets called when the other
// end is closed.
TEST_P(ReceiverTest, Disconnect) {}

// Tests that calling Close doesn't result in the connection error handler being
// called.
TEST_P(ReceiverTest, ResetDoesntCallDisconnectHandler) {}

class ServiceImplWithReceiver : public ServiceImpl {};

// Tests that the receiver may be deleted in its disconnect handler.
TEST_P(ReceiverTest, SelfDeleteOnDisconnect) {}

// Tests that explicitly calling Unbind followed by rebinding works.
TEST_P(ReceiverTest, Unbind) {}

class IntegerAccessorImpl : public sample::IntegerAccessor {};

TEST_P(ReceiverTest, PauseResume) {}

// Verifies the disconnect handler is not run while a receiver is paused.
TEST_P(ReceiverTest, ErrorHandleNotRunWhilePaused) {}

class PingServiceImpl : public test::PingService {};

class CallbackFilter : public MessageFilter {};

// Verifies that message filters are notified in the order they were added and
// are always notified before a message is dispatched.
TEST_P(ReceiverTest, MessageFilter) {}

void Fail() {}

TEST_P(ReceiverTest, FlushForTesting) {}

TEST_P(ReceiverTest, FlushForTestingWithClosedPeer) {}

TEST_P(ReceiverTest, DisconnectWithReason) {}

TEST_P(ReceiverTest, PendingRemoteResetWithReason) {}

template <typename T>
struct WeakPtrImplRefTraits {};

WeakReceiver;

TEST_P(ReceiverTest, CustomImplPointerType) {}

TEST_P(ReceiverTest, ReportBadMessage) {}

TEST_P(ReceiverTest, GetBadMessageCallback) {}

TEST_P(ReceiverTest, InvalidPendingReceivers) {}

TEST_P(ReceiverTest, GenericPendingReceiver) {}

TEST_P(ReceiverTest, GenericPendingAssociatedReceiver) {}

class RebindTestImpl : public mojom::RebindTestInterface {};

TEST_P(ReceiverTest, RebindWithScheduledSyncMessage) {}

class TestGenericBinderImpl : public mojom::TestGenericBinder {};

ReceiverSerializationTest;

TEST_P(ReceiverSerializationTest, NullGenericPendingReceiver) {}

TEST_P(ReceiverSerializationTest, NullGenericPendingAssociatedReceiver) {}

SelfOwnedReceiverTest;

TEST_P(SelfOwnedReceiverTest, CloseDestroysImplAndPipe) {}

TEST_P(SelfOwnedReceiverTest, DisconnectDestroysImplAndPipe) {}

class MultiprocessReceiverTest : public core::test::MojoTestBase,
                                 public mojom::TestInterface1 {};

class InterfaceDropper : public mojom::InterfaceDropper {};

DEFINE_TEST_CLIENT_TEST_WITH_PIPE(MultiprocessReceiverClient,
                                  MultiprocessReceiverTest,
                                  test_pipe) {}

// iOS doesn't have the ability to fork processes yet.
#if !BUILDFLAG(IS_IOS)
TEST_F(MultiprocessReceiverTest, MultiprocessReceiver) {}
#endif  // BUILDFLAG(USE_BLINK)

INSTANTIATE_MOJO_BINDINGS_TEST_SUITE_P();
INSTANTIATE_MOJO_BINDINGS_TEST_SUITE_P();

// These tests only make sense for serialized messages.
INSTANTIATE_TEST_SUITE_P();

}  // namespace receiver_unittest
}  // namespace test
}  // namespace mojo