#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "base/message_loop/message_pump_glib.h"
#include <glib.h>
#include <math.h>
#include <algorithm>
#include <string_view>
#include <vector>
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.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/ref_counted.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/single_thread_task_executor.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/task_environment.h"
#include "base/test/trace_event_analyzer.h"
#include "base/threading/thread.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
namespace {
class EventInjector { … };
GSourceFuncs EventInjector::SourceFuncs = …;
void IncrementInt(int *value) { … }
void ExpectProcessedEvents(EventInjector* injector, int count) { … }
void PostMessageLoopTask(const Location& from_here, OnceClosure task) { … }
class MessagePumpGLibTest : public testing::Test { … };
}
TEST_F(MessagePumpGLibTest, TestQuit) { … }
TEST_F(MessagePumpGLibTest, TestEventTaskInterleave) { … }
TEST_F(MessagePumpGLibTest, TestWorkWhileWaitingForEvents) { … }
TEST_F(MessagePumpGLibTest, TestEventsWhileWaitingForWork) { … }
namespace {
class ConcurrentHelper : public RefCounted<ConcurrentHelper> { … };
}
TEST_F(MessagePumpGLibTest, TestConcurrentEventPostedTask) { … }
namespace {
void AddEventsAndDrainGLib(EventInjector* injector, OnceClosure on_drained) { … }
}
TEST_F(MessagePumpGLibTest, TestDrainingGLib) { … }
namespace {
class GLibLoopRunner : public RefCounted<GLibLoopRunner> { … };
void TestGLibLoopInternal(EventInjector* injector, OnceClosure done) { … }
void TestGtkLoopInternal(EventInjector* injector, OnceClosure done) { … }
}
TEST_F(MessagePumpGLibTest, TestGLibLoop) { … }
TEST_F(MessagePumpGLibTest, TestGtkLoop) { … }
namespace {
class NestedEventAnalyzer { … };
}
TEST_F(MessagePumpGLibTest, TestNativeNestedLoopWithoutDoWork) { … }
class MessagePumpGLibFdWatchTest : public testing::Test { … };
namespace {
class BaseWatcher : public MessagePumpGlib::FdWatcher { … };
class DeleteWatcher : public BaseWatcher { … };
class StopWatcher : public BaseWatcher { … };
void QuitMessageLoopAndStart(OnceClosure quit_closure) { … }
class NestedPumpWatcher : public MessagePumpGlib::FdWatcher { … };
class QuitWatcher : public DeleteWatcher { … };
void WriteFDWrapper(const int fd,
const char* buf,
int size,
WaitableEvent* event) { … }
}
TEST_F(MessagePumpGLibFdWatchTest, DeleteWatcher) { … }
TEST_F(MessagePumpGLibFdWatchTest, StopWatcher) { … }
TEST_F(MessagePumpGLibFdWatchTest, NestedPumpWatcher) { … }
TEST_F(MessagePumpGLibFdWatchTest, QuitWatcher) { … }
}