#include "base/run_loop.h"
#include <functional>
#include <memory>
#include <utility>
#include "base/containers/queue.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/gtest_util.h"
#include "base/test/scoped_run_loop_timeout.h"
#include "base/test/task_environment.h"
#include "base/test/test_timeouts.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread.h"
#include "base/threading/thread_checker_impl.h"
#include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
namespace {
void QuitWhenIdleTask(RunLoop* run_loop, int* counter) { … }
void RunNestedLoopTask(int* counter) { … }
class SimpleSingleThreadTaskRunner : public SingleThreadTaskRunner { … };
class InjectableTestDelegate : public RunLoop::Delegate { … };
class TestBoundDelegate final : public InjectableTestDelegate { … };
enum class RunLoopTestType { … };
class RunLoopTestEnvironment { … };
class RunLoopTest : public testing::TestWithParam<RunLoopTestType> { … };
}
TEST_P(RunLoopTest, QuitWhenIdle) { … }
TEST_P(RunLoopTest, QuitWhenIdleNestedLoop) { … }
TEST_P(RunLoopTest, QuitWhenIdleClosure) { … }
TEST_P(RunLoopTest, QuitWhenIdleClosureAfterRunLoopScope) { … }
TEST_P(RunLoopTest, QuitFromOtherSequence) { … }
TEST_P(RunLoopTest, QuitFromOtherSequenceWithClosure) { … }
TEST_P(RunLoopTest, QuitFromOtherSequenceRacy) { … }
TEST_P(RunLoopTest, QuitFromOtherSequenceRacyWithClosure) { … }
TEST_P(RunLoopTest, QuitWhenIdleFromOtherSequence) { … }
TEST_P(RunLoopTest, QuitWhenIdleFromOtherSequenceWithClosure) { … }
TEST_P(RunLoopTest, IsRunningOnCurrentThread) { … }
TEST_P(RunLoopTest, IsNestedOnCurrentThread) { … }
TEST_P(RunLoopTest, CannotRunMoreThanOnce) { … }
TEST_P(RunLoopTest, CanRunUntilIdleMoreThanOnce) { … }
TEST_P(RunLoopTest, CanRunUntilIdleThenRunIfNotQuit) { … }
TEST_P(RunLoopTest, CannotRunUntilIdleThenRunIfQuit) { … }
TEST_P(RunLoopTest, CannotRunAgainIfQuitWhenIdle) { … }
namespace {
class MockNestingObserver : public RunLoop::NestingObserver { … };
class MockTask { … };
}
TEST_P(RunLoopTest, NestingObservers) { … }
TEST_P(RunLoopTest, DisallowRunning) { … }
TEST_P(RunLoopTest, ExpiredDisallowRunning) { … }
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
TEST(RunLoopDeathTest, MustRegisterBeforeInstantiating) { … }
TEST(RunLoopDelegateTest, NestableTasksDontRunInDefaultNestedLoops) { … }
}