chromium/third_party/blink/renderer/platform/heap/test/cross_thread_handle_test.cc

// Copyright 2022 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/heap/cross_thread_handle.h"
#include "base/memory/scoped_refptr.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.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/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_base.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h"

namespace WTF {

template <>
struct CrossThreadCopier<
    base::internal::UnretainedWrapper<void,
                                      base::unretained_traits::MayNotDangle>>
    : public CrossThreadCopierPassThrough<base::internal::UnretainedWrapper<
          void,
          base::unretained_traits::MayNotDangle>> {};

}  // namespace WTF

namespace blink {
namespace {

class CrossThreadHandleTest : public TestSupportingGC {};

class PingPongBase;
class GCed final : public GarbageCollected<GCed> {};

TEST_F(CrossThreadHandleTest, GetOnCreationThread) {}

TEST_F(CrossThreadHandleTest, UnwrapperGetOnCreationThread) {}

class PingPongBase : public WTF::ThreadSafeRefCounted<PingPongBase> {};

void GCed::SetReceivedPong(scoped_refptr<PingPongBase> ping_pong) {}

class PassThroughPingPong final : public PingPongBase {};

TEST_F(CrossThreadHandleTest, PassThroughPingPong) {}

class UnwrappingPingPong final : public PingPongBase {};

TEST_F(CrossThreadHandleTest, UnwrappingPingPong) {}

class BindToMethodPingPong final : public PingPongBase {};

TEST_F(CrossThreadHandleTest, BindToMethodPingPong) {}

class BindToMethodDiscardingPingPong final : public PingPongBase {};

TEST_F(CrossThreadHandleTest, BindToMethodDiscardingPingPong) {}

}  // namespace
}  // namespace blink