chromium/third_party/perfetto/src/base/periodic_task_unittest.cc

/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "perfetto/ext/base/periodic_task.h"

#include "perfetto/ext/base/file_utils.h"
#include "src/base/test/test_task_runner.h"
#include "test/gtest_and_gmock.h"

#if PERFETTO_BUILDFLAG(PERFETTO_OS_LINUX) || \
    PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
#include <unistd.h>
#endif

#include <chrono>
#include <thread>

namespace perfetto {
namespace base {

namespace {

TEST(PeriodicTaskTest, PostDelayedTaskMode) {}

TEST(PeriodicTaskTest, OneShot) {}

// Call Reset() from a callback, ensure no further calls are made.
TEST(PeriodicTaskTest, ResetFromCallback) {}

// Invalidates the timerfd, by replacing it with /dev/null, in the middle of
// the periodic ticks. That causes the next read() to fail and fall back on
// PostDelayedTask().
// On Mac and other systems where timerfd is not supported this will fall back
// on PostDelayedTask() immediately (and work).
TEST(PeriodicTaskTest, FallbackIfTimerfdFails) {}

TEST(PeriodicTaskTest, DestroyedFromCallback) {}

TEST(PeriodicTaskTest, DestroyedFromAnotherTask) {}

// Checks the generation logic.
TEST(PeriodicTaskTest, RestartWhileRunning) {}

TEST(PeriodicTaskTest, ImmediateExecution) {}

}  // namespace
}  // namespace base
}  // namespace perfetto