chromium/base/message_loop/message_pump_epoll_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/message_loop/message_pump_epoll.h"

#include <fcntl.h>
#include <sys/socket.h>
#include <unistd.h>

#include <memory>
#include <string_view>
#include <utility>

#include "base/containers/span.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.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_type.h"
#include "base/posix/eintr_wrapper.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/synchronization/waitable_event_watcher.h"
#include "base/task/current_thread.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_executor.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/gtest_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/threading/thread.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {

class MessagePumpEpollTest : public testing::Test {};

namespace {

// Concrete implementation of MessagePumpEpoll::FdWatcher that does
// nothing useful.
class StupidWatcher : public MessagePumpEpoll::FdWatcher {};

TEST_F(MessagePumpEpollTest, QuitOutsideOfRun) {}

class BaseWatcher : public MessagePumpEpoll::FdWatcher {};

class DeleteWatcher : public BaseWatcher {};

TEST_F(MessagePumpEpollTest, DeleteWatcher) {}

class StopWatcher : public BaseWatcher {};

TEST_F(MessagePumpEpollTest, StopWatcher) {}

void QuitMessageLoopAndStart(OnceClosure quit_closure) {}

class NestedPumpWatcher : public MessagePumpEpoll::FdWatcher {};

TEST_F(MessagePumpEpollTest, NestedPumpWatcher) {}

void FatalClosure() {}

class QuitWatcher : public BaseWatcher {};

void WriteFDWrapper(const int fd,
                    const char* buf,
                    int size,
                    WaitableEvent* event) {}

// Tests that MessagePumpEpoll quits immediately when it is quit from
// within a wakeup.
TEST_F(MessagePumpEpollTest, QuitWatcher) {}

class InnerNestedWatcher : public MessagePumpEpoll::FdWatcher {};

class OuterNestedWatcher : public MessagePumpEpoll::FdWatcher {};

TEST_F(MessagePumpEpollTest, NestedNotification) {}

class RepeatWatcher : public BaseWatcher {};

void RepeatEventTest(bool persistent,
                     int repeat,
                     std::unique_ptr<MessagePumpEpoll> executor_pump,
                     int sender,
                     int receiver) {}

// Tests that MessagePumpEpoll calls FdWatcher's callback repeatedly when
// it's configured as persistent.
TEST_F(MessagePumpEpollTest, RepeatPersistentEvent) {}

// Tests that MessagePumpEpoll calls FdWatcher's callback repeatedly when it's
// not configured as persistent but reconfigured in the callback.
TEST_F(MessagePumpEpollTest, RepeatOneShotEvent) {}

}  // namespace
}  // namespace base