chromium/third_party/blink/renderer/platform/mojo/heap_mojo_associated_remote_set_test.cc

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

#include "third_party/blink/renderer/platform/mojo/heap_mojo_associated_remote_set.h"

#include <string>
#include <tuple>
#include <utility>

#include "base/memory/raw_ptr.h"
#include "base/test/null_task_runner.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/remote_set.h"
#include "mojo/public/interfaces/bindings/tests/sample_service.mojom-blink.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/platform/context_lifecycle_notifier.h"
#include "third_party/blink/renderer/platform/heap/heap_test_utilities.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/heap_observer_set.h"
#include "third_party/blink/renderer/platform/mojo/heap_mojo_wrapper_mode.h"
#include "third_party/blink/renderer/platform/mojo/mojo_binding_context.h"
#include "third_party/blink/renderer/platform/testing/mock_context_lifecycle_notifier.h"

namespace blink {

namespace {

template <HeapMojoWrapperMode Mode>
class HeapMojoAssociatedRemoteSetGCBaseTest;

template <HeapMojoWrapperMode Mode>
class GCOwner final : public GarbageCollected<GCOwner<Mode>> {};

template <HeapMojoWrapperMode Mode>
class HeapMojoAssociatedRemoteSetGCBaseTest : public TestSupportingGC {};

}  // namespace

class HeapMojoAssociatedRemoteSetGCWithContextObserverTest
    : public HeapMojoAssociatedRemoteSetGCBaseTest<
          HeapMojoWrapperMode::kWithContextObserver> {};
class HeapMojoAssociatedRemoteSetGCWithoutContextObserverTest
    : public HeapMojoAssociatedRemoteSetGCBaseTest<
          HeapMojoWrapperMode::kForceWithoutContextObserver> {};

// GC the HeapMojoAssociatedRemoteSet with context observer and verify that the
// remote is no longer part of the set, and that the service was deleted.
TEST_F(HeapMojoAssociatedRemoteSetGCWithContextObserverTest, RemovesRemote) {}

// Check that the wrapper does not outlive the owner when ConservativeGC finds
// the wrapper.
TEST_F(HeapMojoAssociatedRemoteSetGCWithContextObserverTest,
       NoClearOnConservativeGC) {}

// GC the HeapMojoAssociatedRemoteSet without context observer and verify that
// the remote is no longer part of the set, and that the service was deleted.
TEST_F(HeapMojoAssociatedRemoteSetGCWithoutContextObserverTest, RemovesRemote) {}

// GC the HeapMojoAssociatedRemoteSet with context observer and verify that the
// remote is no longer part of the set, and that the service was deleted.
TEST_F(HeapMojoAssociatedRemoteSetGCWithContextObserverTest,
       ClearLeavesSetEmpty) {}

// GC the HeapMojoAssociatedRemoteSet without context observer and verify that
// the remote is no longer part of the set, and that the service was deleted.
TEST_F(HeapMojoAssociatedRemoteSetGCWithoutContextObserverTest,
       ClearLeavesSetEmpty) {}

// Add several remote and confirm that remote_set holds properly.
TEST_F(HeapMojoAssociatedRemoteSetGCWithContextObserverTest,
       AddSeveralRemoteSet) {}

}  // namespace blink