chromium/base/timer/timer_unittest.cc

// Copyright 2012 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/timer/timer.h"

#include <stddef.h>

#include <memory>

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/bind.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "base/test/test_simple_task_runner.h"
#include "base/time/tick_clock.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {

namespace {

constexpr TimeDelta kTestDelay =;
constexpr TimeDelta kLongTestDelay =;

// The main thread types on which each timer should be tested.
const test::TaskEnvironment::MainThreadType testing_main_threads[] =;

class Receiver {};

// Basic test with same setup as RunTest_OneShotTimers_Cancel below to confirm
// that |timer| would be fired in that test if it wasn't for the deletion.
void RunTest_OneShotTimers(
    test::TaskEnvironment::MainThreadType main_thread_type) {}

void RunTest_OneShotTimers_Cancel(
    test::TaskEnvironment::MainThreadType main_thread_type) {}

void RunTest_OneShotSelfDeletingTimer(
    test::TaskEnvironment::MainThreadType main_thread_type) {}

void RunTest_RepeatingTimer(
    test::TaskEnvironment::MainThreadType main_thread_type,
    const TimeDelta& delay) {}

void RunTest_RepeatingTimer_Cancel(
    test::TaskEnvironment::MainThreadType main_thread_type,
    const TimeDelta& delay) {}

void RunTest_DelayTimer_NoCall(
    test::TaskEnvironment::MainThreadType main_thread_type) {}

void RunTest_DelayTimer_OneCall(
    test::TaskEnvironment::MainThreadType main_thread_type) {}

void RunTest_DelayTimer_Reset(
    test::TaskEnvironment::MainThreadType main_thread_type) {}

void RunTest_DelayTimer_Deleted(
    test::TaskEnvironment::MainThreadType main_thread_type) {}

}  // namespace

//-----------------------------------------------------------------------------
// Each test is run against each type of main thread.  That way we are sure
// that timers work properly in all configurations.

class TimerTestWithThreadType
    : public testing::TestWithParam<test::TaskEnvironment::MainThreadType> {};

TEST_P(TimerTestWithThreadType, OneShotTimers) {}

TEST_P(TimerTestWithThreadType, OneShotTimers_Cancel) {}

// If underline timer does not handle properly, we will crash or fail
// in full page heap environment.
TEST_P(TimerTestWithThreadType, OneShotSelfDeletingTimer) {}

TEST(TimerTest, OneShotTimer_CustomTaskRunner) {}

TEST(TimerTest, OneShotTimerWithTickClock) {}

TEST_P(TimerTestWithThreadType, RepeatingTimer) {}

TEST_P(TimerTestWithThreadType, RepeatingTimer_Cancel) {}

TEST_P(TimerTestWithThreadType, RepeatingTimerZeroDelay) {}

TEST_P(TimerTestWithThreadType, RepeatingTimerZeroDelay_Cancel) {}

TEST(TimerTest, RepeatingTimerWithTickClock) {}

TEST_P(TimerTestWithThreadType, DelayTimer_NoCall) {}

TEST_P(TimerTestWithThreadType, DelayTimer_OneCall) {}

TEST_P(TimerTestWithThreadType, DelayTimer_Reset) {}

TEST_P(TimerTestWithThreadType, DelayTimer_Deleted) {}

TEST(TimerTest, DelayTimerWithTickClock) {}

TEST(TimerTest, TaskEnvironmentShutdown) {}

TEST(TimerTest, TaskEnvironmentSelfOwningTimer) {}

TEST(TimerTest, TaskEnvironmentSelfOwningTimerStopped) {}

TEST(TimerTest, NonRepeatIsRunning) {}

TEST(TimerTest, NonRepeatTaskEnvironmentDeath) {}

TEST(TimerTest, RetainRepeatIsRunning) {}

TEST(TimerTest, RetainNonRepeatIsRunning) {}

//-----------------------------------------------------------------------------

TEST(TimerTest, ContinuationStopStart) {}

TEST(TimerTest, ContinuationReset) {}

TEST(TimerTest, AbandonedTaskIsCancelled) {}

TEST(TimerTest, DeadlineTimer) {}

TEST(TimerTest, DeadlineTimerCancel) {}

TEST(TimerTest, DeadlineTimerTaskDestructed) {}

TEST(TimerTest, DeadlineTimerStartTwice) {}

TEST(TimerTest, MetronomeTimer) {}

TEST(TimerTest, MetronomeTimerCustomPhase) {}

TEST(TimerTest, MetronomeTimerReset) {}

TEST(TimerTest, MetronomeTimerStartTwice) {}

TEST(TimerTest, MetronomeTimerMultiple) {}

TEST(TimerTest, MetronomeTimerCancel) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace base