#include "base/task/thread_pool/delayed_task_manager.h"
#include <memory>
#include <utility>
#include "base/cancelable_callback.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/task_features.h"
#include "base/task/thread_pool/task.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
namespace internal {
namespace {
constexpr TimeDelta kLongerDelay = …;
constexpr TimeDelta kLongDelay = …;
constexpr TimeDelta kLeeway = …;
class MockCallback { … };
void PostTaskNow(Task task) { … }
Task ConstructMockedTask(testing::StrictMock<MockCallback>& mock_task,
TimeTicks now,
TimeDelta delay) { … }
Task ConstructMockedTask(testing::StrictMock<MockCallback>& mock_task,
TimeTicks now,
TimeTicks delayed_run_time,
subtle::DelayPolicy delay_policy) { … }
class ThreadPoolDelayedTaskManagerTest : public testing::Test { … };
}
TEST_F(ThreadPoolDelayedTaskManagerTest, DelayedTaskDoesNotRunBeforeStart) { … }
TEST_F(ThreadPoolDelayedTaskManagerTest,
DelayedTaskPostedBeforeStartExpiresAfterStartRunsOnExpire) { … }
TEST_F(ThreadPoolDelayedTaskManagerTest,
DelayedTaskPostedBeforeStartExpiresBeforeStartRunsOnStart) { … }
TEST_F(ThreadPoolDelayedTaskManagerTest, DelayedTaskDoesNotRunTooEarly) { … }
TEST_F(ThreadPoolDelayedTaskManagerTest, DelayedTaskRunsAfterDelay) { … }
TEST_F(ThreadPoolDelayedTaskManagerTest,
DelayedTaskRunsAtTime_FlexiblePreferEarly) { … }
TEST_F(ThreadPoolDelayedTaskManagerTest, DelayedTaskRunsAfterCancelled) { … }
TEST_F(ThreadPoolDelayedTaskManagerTest, DelayedTasksRunAfterDelay) { … }
TEST_F(ThreadPoolDelayedTaskManagerTest,
DelayedTasksRunAtTime_MixedDelayPolicy) { … }
TEST_F(ThreadPoolDelayedTaskManagerTest, PostTaskDuringStart) { … }
}
}