#include "base/task/thread_pool/task_tracker.h"
#include <stdint.h>
#include <memory>
#include <utility>
#include <vector>
#include "base/barrier_closure.h"
#include "base/check_op.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_samples.h"
#include "base/sequence_token.h"
#include "base/synchronization/atomic_flag.h"
#include "base/task/common/checked_lock.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool/task.h"
#include "base/task/thread_pool/test_utils.h"
#include "base/test/bind.h"
#include "base/test/gtest_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/test_simple_task_runner.h"
#include "base/test/test_timeouts.h"
#include "base/test/test_waitable_event.h"
#include "base/threading/platform_thread.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/simple_thread.h"
#include "base/threading/thread_restrictions.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
namespace internal {
namespace {
constexpr size_t kLoadTestNumIterations = …;
class CallbackThread : public SimpleThread { … };
class ThreadPostingAndRunningTask : public SimpleThread { … };
class ThreadPoolTaskTrackerTest
: public testing::TestWithParam<TaskShutdownBehavior> { … };
#define WAIT_FOR_ASYNC_SHUTDOWN_COMPLETED() …
#define VERIFY_ASYNC_SHUTDOWN_IN_PROGRESS() …
#define WAIT_FOR_ASYNC_FLUSHES_RETURNED() …
#define VERIFY_ASYNC_FLUSHES_IN_PROGRESS() …
}
TEST_P(ThreadPoolTaskTrackerTest, WillPostAndRunBeforeShutdown) { … }
TEST_P(ThreadPoolTaskTrackerTest, WillPostAndRunLongTaskBeforeShutdown) { … }
TEST_F(ThreadPoolTaskTrackerTest, PostAfterShutdownFromContinueOnShutdown) { … }
TEST_P(ThreadPoolTaskTrackerTest, WillPostBeforeShutdownQueueDuringShutdown) { … }
TEST_P(ThreadPoolTaskTrackerTest, WillPostBeforeShutdownRunDuringShutdown) { … }
TEST_P(ThreadPoolTaskTrackerTest, WillPostBeforeShutdownRunAfterShutdown) { … }
TEST_P(ThreadPoolTaskTrackerTest, WillPostAndRunDuringShutdown) { … }
TEST_P(ThreadPoolTaskTrackerTest, WillPostAfterShutdown) { … }
TEST_P(ThreadPoolTaskTrackerTest, SingletonAllowed) { … }
TEST_P(ThreadPoolTaskTrackerTest, IOAllowed) { … }
static void RunTaskRunnerCurrentDefaultHandleVerificationTask(
TaskTracker* tracker,
Task verify_task,
TaskTraits traits,
scoped_refptr<SequencedTaskRunner> task_runner,
TaskSourceExecutionMode execution_mode) { … }
static void VerifyNoTaskRunnerCurrentDefaultHandle() { … }
TEST_P(ThreadPoolTaskTrackerTest, TaskRunnerHandleIsNotSetOnParallel) { … }
static void VerifySequencedTaskRunnerCurrentDefaultHandle(
const SequencedTaskRunner* expected_task_runner) { … }
TEST_P(ThreadPoolTaskTrackerTest,
SequencedTaskRunnerHasCurrentDefaultOnSequenced) { … }
static void VerifySingleThreadTaskRunnerCurrentDefaultHandle(
const SingleThreadTaskRunner* expected_task_runner) { … }
TEST_P(ThreadPoolTaskTrackerTest,
SingleThreadTaskRunnerCurrentDefaultHandleIsSetOnSingleThreaded) { … }
TEST_P(ThreadPoolTaskTrackerTest, FlushPendingDelayedTask) { … }
TEST_P(ThreadPoolTaskTrackerTest, FlushAsyncForTestingPendingDelayedTask) { … }
TEST_P(ThreadPoolTaskTrackerTest, FlushPendingUndelayedTask) { … }
TEST_P(ThreadPoolTaskTrackerTest, MultipleFlushes) { … }
TEST_P(ThreadPoolTaskTrackerTest, FlushAsyncForTestingPendingUndelayedTask) { … }
TEST_P(ThreadPoolTaskTrackerTest, MultipleFlushAsyncForTesting) { … }
TEST_P(ThreadPoolTaskTrackerTest, PostTaskDuringFlush) { … }
TEST_P(ThreadPoolTaskTrackerTest, PostTaskDuringFlushAsyncForTesting) { … }
TEST_P(ThreadPoolTaskTrackerTest, RunDelayedTaskDuringFlush) { … }
TEST_P(ThreadPoolTaskTrackerTest, RunDelayedTaskDuringFlushAsyncForTesting) { … }
TEST_P(ThreadPoolTaskTrackerTest, FlushAfterShutdown) { … }
TEST_P(ThreadPoolTaskTrackerTest, FlushAfterShutdownAsync) { … }
TEST_P(ThreadPoolTaskTrackerTest, ShutdownDuringFlush) { … }
TEST_P(ThreadPoolTaskTrackerTest, ShutdownDuringFlushAsyncForTesting) { … }
TEST_P(ThreadPoolTaskTrackerTest, PostTasksDoNotBlockShutdown) { … }
TEST_P(ThreadPoolTaskTrackerTest, DelayedRunTasks) { … }
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
namespace {
void ExpectSequenceToken(SequenceToken sequence_token) { … }
}
TEST_F(ThreadPoolTaskTrackerTest, CurrentSequenceToken) { … }
TEST_F(ThreadPoolTaskTrackerTest, LoadWillPostAndRunBeforeShutdown) { … }
TEST_F(ThreadPoolTaskTrackerTest,
LoadWillPostBeforeShutdownAndRunDuringShutdown) { … }
TEST_F(ThreadPoolTaskTrackerTest, LoadWillPostAndRunDuringShutdown) { … }
TEST_F(ThreadPoolTaskTrackerTest,
RunAndPopNextTaskReturnsSequenceToReschedule) { … }
namespace {
class WaitAllowedTestThread : public SimpleThread { … };
}
TEST(ThreadPoolTaskTrackerWaitAllowedTest, WaitAllowed) { … }
}
}