chromium/base/task/thread_pool/delayed_task_manager_unittest.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {};

}  // namespace

// Verify that a delayed task isn't forwarded before Start().
TEST_F(ThreadPoolDelayedTaskManagerTest, DelayedTaskDoesNotRunBeforeStart) {}

// Verify that a delayed task added before Start() and whose delay expires after
// Start() is forwarded when its delay expires.
TEST_F(ThreadPoolDelayedTaskManagerTest,
       DelayedTaskPostedBeforeStartExpiresAfterStartRunsOnExpire) {}

// Verify that a delayed task added before Start() and whose delay expires
// before Start() is forwarded when Start() is called.
TEST_F(ThreadPoolDelayedTaskManagerTest,
       DelayedTaskPostedBeforeStartExpiresBeforeStartRunsOnStart) {}

// Verify that a delayed task added after Start() isn't forwarded before it is
// ripe for execution.
TEST_F(ThreadPoolDelayedTaskManagerTest, DelayedTaskDoesNotRunTooEarly) {}

// Verify that a delayed task added after Start() is forwarded when it is ripe
// for execution.
TEST_F(ThreadPoolDelayedTaskManagerTest, DelayedTaskRunsAfterDelay) {}

// Verify that a delayed task posted with kFlexiblePreferEarly delay policy
// is forwarded within the leeway period preceding the deadline.
TEST_F(ThreadPoolDelayedTaskManagerTest,
       DelayedTaskRunsAtTime_FlexiblePreferEarly) {}

// Verify that a delayed task added after Start() is forwarded when it is
// canceled, even if its delay hasn't expired.
TEST_F(ThreadPoolDelayedTaskManagerTest, DelayedTaskRunsAfterCancelled) {}

// Verify that multiple delayed tasks added after Start() are forwarded when
// they are ripe for execution.
TEST_F(ThreadPoolDelayedTaskManagerTest, DelayedTasksRunAfterDelay) {}

// Verify that multiple delayed tasks are forwarded respecting the order
// prescibed by their latest deadline.
TEST_F(ThreadPoolDelayedTaskManagerTest,
       DelayedTasksRunAtTime_MixedDelayPolicy) {}

TEST_F(ThreadPoolDelayedTaskManagerTest, PostTaskDuringStart) {}

}  // namespace internal
}  // namespace base