#include "base/observer_list_threadsafe.h"
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/test/bind.h"
#include "base/test/gtest_util.h"
#include "base/test/task_environment.h"
#include "base/test/test_waitable_event.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
namespace {
constexpr int kThreadRunTime = …;
class Foo { … };
class Adder : public Foo { … };
class AddInObserve : public Foo { … };
template <RemoveObserverPolicy RemovePolicy =
RemoveObserverPolicy::kAnySequence>
class AddRemoveThread : public Foo { … };
}
TEST(ObserverListThreadSafeTest, BasicTest) { … }
TEST(ObserverListThreadSafeTest, RemoveObserver) { … }
class FooRemover : public Foo { … };
TEST(ObserverListThreadSafeTest, RemoveMultipleObservers) { … }
template <
RemoveObserverPolicy RemovePolicy = RemoveObserverPolicy::kAnySequence>
static void ThreadSafeObserverHarness(int num_threads,
bool cross_thread_notifies = false,
bool cross_thread_removes = false) { … }
TEST(ObserverListThreadSafeTest, CrossThreadObserver) { … }
TEST(ObserverListThreadSafeTest, CrossThreadNotifications) { … }
TEST(ObserverListThreadSafeTest, CrossThreadRemoval) { … }
TEST(ObserverListThreadSafeTest, CrossThreadRemovalRestricted) { … }
TEST(ObserverListThreadSafeDeathTest, CrossThreadRemovalRestricted) { … }
TEST(ObserverListThreadSafeTest, OutlivesTaskEnvironment) { … }
TEST(ObserverListThreadSafeTest, OutlivesTaskEnvironmentRemovalRestricted) { … }
namespace {
class SequenceVerificationObserver : public Foo { … };
}
TEST(ObserverListThreadSafeTest, NotificationOnValidSequence) { … }
TEST(ObserverListThreadSafeTest, AddObserverFromNotificationNotifyAll) { … }
namespace {
class RemoveWhileNotificationIsRunningObserver : public Foo { … };
}
TEST(ObserverListThreadSafeTest, RemoveWhileNotificationIsRunning) { … }
TEST(ObserverListThreadSafeTest, AddRemoveWithPendingNotifications) { … }
TEST(ObserverListThreadSafeTest, Existing) { … }
}