#include "base/memory/weak_ptr.h"
#include <memory>
#include <string>
#include "base/debug/leak_annotations.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/gtest_util.h"
#include "base/test/test_timeouts.h"
#include "base/threading/thread.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
namespace subtle {
class BindWeakPtrFactoryForTesting { … };
}
namespace {
WeakPtr<int> PassThru(WeakPtr<int> ptr) { … }
template <class T>
class OffThreadObjectCreator { … };
struct Base { … };
struct Derived : public Base { … };
struct TargetBase { … };
struct Target : public TargetBase { … };
struct DerivedTarget : public Target { … };
struct DerivedTargetWithNestedBase : public Target { … };
struct VirtualDestructor { … };
struct DerivedTargetMultipleInheritance : public VirtualDestructor,
public Target { … };
struct Arrow { … };
struct TargetWithFactory : public Target { … };
class BackgroundThread : public Thread { … };
}
TEST(WeakPtrFactoryTest, Basic) { … }
TEST(WeakPtrFactoryTest, Comparison) { … }
TEST(WeakPtrFactoryTest, Move) { … }
TEST(WeakPtrFactoryTest, OutOfScope) { … }
TEST(WeakPtrFactoryTest, Multiple) { … }
TEST(WeakPtrFactoryTest, MultipleStaged) { … }
TEST(WeakPtrFactoryTest, Dereference) { … }
TEST(WeakPtrFactoryTest, UpCast) { … }
TEST(WeakPtrTest, ConstructFromNullptr) { … }
TEST(WeakPtrFactoryTest, BooleanTesting) { … }
TEST(WeakPtrFactoryTest, ComparisonToNull) { … }
struct ReallyBaseClass { … };
struct BaseClass : ReallyBaseClass { … };
struct OtherBaseClass { … };
struct WithWeak final : BaseClass, OtherBaseClass { … };
TEST(WeakPtrTest, ConversionOffsetsPointer) { … }
TEST(WeakPtrTest, InvalidateWeakPtrs) { … }
TEST(WeakPtrTest, WasInvalidatedByFactoryDestruction) { … }
TEST(WeakPtrTest, WasInvalidatedByInvalidateWeakPtrs) { … }
TEST(WeakPtrTest, WasInvalidatedWhilstNull) { … }
TEST(WeakPtrTest, MaybeValidOnSameSequence) { … }
TEST(WeakPtrTest, MaybeValidOnOtherSequence) { … }
TEST(WeakPtrTest, HasWeakPtrs) { … }
TEST(WeakPtrTest, ObjectAndWeakPtrOnDifferentThreads) { … }
TEST(WeakPtrTest, WeakPtrInitiateAndUseOnDifferentThreads) { … }
TEST(WeakPtrTest, MoveOwnershipImplicitly) { … }
TEST(WeakPtrTest, MoveOwnershipOfUnreferencedObject) { … }
TEST(WeakPtrTest, MoveOwnershipAfterInvalidate) { … }
TEST(WeakPtrTest, MainThreadRefOutlivesBackgroundThreadRef) { … }
TEST(WeakPtrTest, BackgroundThreadRefOutlivesMainThreadRef) { … }
TEST(WeakPtrTest, OwnerThreadDeletesObject) { … }
TEST(WeakPtrTest, NonOwnerThreadCanCopyAndAssignWeakPtr) { … }
TEST(WeakPtrTest, NonOwnerThreadCanCopyAndAssignWeakPtrBase) { … }
TEST(WeakPtrTest, NonOwnerThreadCanDeleteWeakPtr) { … }
TEST(WeakPtrTest, ConstUpCast) { … }
TEST(WeakPtrTest, ConstGetWeakPtr) { … }
TEST(WeakPtrTest, GetMutableWeakPtr) { … }
TEST(WeakPtrDeathTest, BindToCurrentSequence) { … }
TEST(WeakPtrDeathTest, WeakPtrCopyDoesNotChangeThreadBinding) { … }
TEST(WeakPtrDeathTest, NonOwnerThreadDereferencesWeakPtrAfterReference) { … }
TEST(WeakPtrDeathTest, NonOwnerThreadDeletesWeakPtrAfterReference) { … }
TEST(WeakPtrDeathTest, NonOwnerThreadDeletesObjectAfterReference) { … }
TEST(WeakPtrDeathTest, NonOwnerThreadReferencesObjectAfterDeletion) { … }
TEST(WeakPtrDeathTest, ArrowOperatorChecksOnBadDereference) { … }
TEST(WeakPtrDeathTest, StarOperatorChecksOnBadDereference) { … }
}