chromium/base/test/task_environment.cc

// Copyright 2017 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/test/task_environment.h"

#include <algorithm>
#include <memory>
#include <ostream>

#include "base/check.h"
#include "base/debug/stack_trace.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/message_loop/message_pump.h"
#include "base/message_loop/message_pump_type.h"
#include "base/no_destructor.h"
#include "base/process/process.h"
#include "base/run_loop.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
#include "base/task/common/lazy_now.h"
#include "base/task/sequence_manager/sequence_manager.h"
#include "base/task/sequence_manager/sequence_manager_impl.h"
#include "base/task/sequence_manager/task_queue.h"
#include "base/task/sequence_manager/time_domain.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool/thread_pool_impl.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/test/bind.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/test/test_timeouts.h"
#include "base/thread_annotations.h"
#include "base/threading/platform_thread.h"
#include "base/threading/sequence_local_storage_map.h"
#include "base/threading/thread_checker_impl.h"
#include "base/threading/thread_local.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/clock.h"
#include "base/time/tick_clock.h"
#include "base/time/time.h"
#include "base/time/time_override.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"

#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
#include <optional>

#include "base/files/file_descriptor_watcher_posix.h"
#endif

#if BUILDFLAG(ENABLE_BASE_TRACING)
#include "base/trace_event/trace_log.h"  // nogncheck
#endif                                   // BUILDFLAG(ENABLE_BASE_TRACING)

namespace base {
namespace test {

namespace {

ObserverList<TaskEnvironment::DestructionObserver>& GetDestructionObservers() {}

// A pointer to the current TestTaskTracker, if any, constant throughout the
// lifetime of a ThreadPoolInstance managed by a TaskEnvironment.
TaskEnvironment::TestTaskTracker* g_task_tracker =;

base::MessagePumpType GetMessagePumpTypeForMainThreadType(
    TaskEnvironment::MainThreadType main_thread_type) {}

std::unique_ptr<sequence_manager::SequenceManager>
CreateSequenceManagerForMainThreadType(
    TaskEnvironment::MainThreadType main_thread_type,
    sequence_manager::SequenceManager::PrioritySettings priority_settings) {}

class TickClockBasedClock : public Clock {};

}  // namespace

class TaskEnvironment::TestTaskTracker
    : public internal::ThreadPoolImpl::TaskTrackerImpl {};

class TaskEnvironment::MockTimeDomain : public sequence_manager::TimeDomain {};

TaskEnvironment::MockTimeDomain*
    TaskEnvironment::MockTimeDomain::current_mock_time_domain_ =;

TaskEnvironment::TaskEnvironment(
    sequence_manager::SequenceManager::PrioritySettings priority_settings,
    TimeSource time_source,
    MainThreadType main_thread_type,
    ThreadPoolExecutionMode thread_pool_execution_mode,
    ThreadingMode threading_mode,
    ThreadPoolCOMEnvironment thread_pool_com_environment,
    bool subclass_creates_default_taskrunner,
    trait_helpers::NotATraitTag)
    :{}

// static
TaskEnvironment::TestTaskTracker* TaskEnvironment::CreateThreadPool() {}

void TaskEnvironment::InitializeThreadPool() {}

void TaskEnvironment::CompleteInitialization() {}

TaskEnvironment::TaskEnvironment(TaskEnvironment&& other) = default;

TaskEnvironment::~TaskEnvironment() {}

void TaskEnvironment::DestroyTaskEnvironment() {}

void TaskEnvironment::ShutdownAndJoinThreadPool() {}

void TaskEnvironment::DestroyThreadPool() {}

sequence_manager::TimeDomain* TaskEnvironment::GetMockTimeDomain() const {}

sequence_manager::SequenceManager* TaskEnvironment::sequence_manager() const {}

void TaskEnvironment::DeferredInitFromSubclass(
    scoped_refptr<base::SingleThreadTaskRunner> task_runner) {}

scoped_refptr<base::SingleThreadTaskRunner>
TaskEnvironment::GetMainThreadTaskRunner() {}

bool TaskEnvironment::MainThreadIsIdle() const {}

RepeatingClosure TaskEnvironment::QuitClosure() {}

void TaskEnvironment::RunUntilQuit() {}

void TaskEnvironment::RunUntilIdle() {}

void TaskEnvironment::FastForwardBy(TimeDelta delta) {}

void TaskEnvironment::SuspendedFastForwardBy(TimeDelta delta) {}

void TaskEnvironment::FastForwardByInternal(TimeDelta delta,
                                            bool advance_live_ticks) {}

void TaskEnvironment::FastForwardUntilNoTasksRemain() {}

void TaskEnvironment::AdvanceClock(TimeDelta delta) {}

void TaskEnvironment::SuspendedAdvanceClock(TimeDelta delta) {}

const TickClock* TaskEnvironment::GetMockTickClock() const {}

base::TimeTicks TaskEnvironment::NowTicks() const {}

base::LiveTicks TaskEnvironment::NowLiveTicks() const {}

const Clock* TaskEnvironment::GetMockClock() const {}

size_t TaskEnvironment::GetPendingMainThreadTaskCount() const {}

TimeDelta TaskEnvironment::NextMainThreadPendingTaskDelay() const {}

bool TaskEnvironment::NextTaskIsDelayed() const {}

void TaskEnvironment::DescribeCurrentTasks() const {}

void TaskEnvironment::DetachFromThread() {}

// static
void TaskEnvironment::AddDestructionObserver(DestructionObserver* observer) {}

// static
void TaskEnvironment::RemoveDestructionObserver(DestructionObserver* observer) {}

TaskEnvironment::ParallelExecutionFence::ParallelExecutionFence(
    const char* error_message) {}

TaskEnvironment::ParallelExecutionFence::~ParallelExecutionFence() {}

TaskEnvironment::TestTaskTracker::TestTaskTracker()
    :{}

bool TaskEnvironment::TestTaskTracker::AllowRunTasks() {}

bool TaskEnvironment::TestTaskTracker::TasksAllowedToRun() const {}

bool TaskEnvironment::TestTaskTracker::DisallowRunTasks(TimeDelta timeout) {}

void TaskEnvironment::TestTaskTracker::RunTask(internal::Task task,
                                               internal::TaskSource* sequence,
                                               const TaskTraits& traits) {}

std::string TaskEnvironment::TestTaskTracker::DescribeRunningTasks() const {}

void TaskEnvironment::TestTaskTracker::BeginCompleteShutdown(
    base::WaitableEvent& shutdown_event) {}

void TaskEnvironment::TestTaskTracker::AssertFlushForTestingAllowed() {}

}  // namespace test
}  // namespace base