chromium/base/synchronization/waitable_event_watcher_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/synchronization/waitable_event_watcher.h"

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "base/threading/platform_thread.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {

namespace {

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

void QuitWhenSignaled(base::OnceClosure quit_closure, WaitableEvent* event) {}

class DecrementCountContainer {};

}  // namespace

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

TEST_P(WaitableEventWatcherTest, BasicSignalManual) {}

TEST_P(WaitableEventWatcherTest, BasicSignalAutomatic) {}

TEST_P(WaitableEventWatcherTest, BasicCancel) {}

TEST_P(WaitableEventWatcherTest, CancelAfterSet) {}

TEST_P(WaitableEventWatcherTest, OutlivesTaskEnvironment) {}

TEST_P(WaitableEventWatcherTest, SignaledAtStartManual) {}

TEST_P(WaitableEventWatcherTest, SignaledAtStartAutomatic) {}

TEST_P(WaitableEventWatcherTest, StartWatchingInCallback) {}

TEST_P(WaitableEventWatcherTest, MultipleWatchersManual) {}

// Tests that only one async waiter gets called back for an auto-reset event.
TEST_P(WaitableEventWatcherTest, MultipleWatchersAutomatic) {}

// To help detect errors around deleting WaitableEventWatcher, an additional
// bool parameter is used to test sleeping between watching and deletion.
class WaitableEventWatcherDeletionTest
    : public testing::TestWithParam<
          std::tuple<test::TaskEnvironment::MainThreadType, bool>> {};

TEST_P(WaitableEventWatcherDeletionTest, DeleteUnder) {}

TEST_P(WaitableEventWatcherDeletionTest, SignalAndDelete) {}

// Tests deleting the WaitableEventWatcher between signaling the event and
// when the callback should be run.
TEST_P(WaitableEventWatcherDeletionTest, DeleteWatcherBeforeCallback) {}

INSTANTIATE_TEST_SUITE_P();

INSTANTIATE_TEST_SUITE_P();

}  // namespace base