#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "ui/events/platform/platform_event_source.h"
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/event_utils.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/events/platform/platform_event_observer.h"
#include "ui/events/platform/scoped_event_dispatcher.h"
namespace ui {
namespace {
void RemoveDispatcher(PlatformEventDispatcher* dispatcher) { … }
void RemoveDispatchers(PlatformEventDispatcher* first,
PlatformEventDispatcher* second) { … }
void AddDispatcher(PlatformEventDispatcher* dispatcher) { … }
}
class TestPlatformEventSource : public PlatformEventSource { … };
class TestPlatformEventDispatcher : public PlatformEventDispatcher { … };
class TestPlatformEventObserver : public PlatformEventObserver { … };
class PlatformEventTest : public testing::Test { … };
TEST_F(PlatformEventTest, DispatcherBasic) { … }
TEST_F(PlatformEventTest, DispatcherOrder) { … }
TEST_F(PlatformEventTest, DispatcherConsumesEventToStopDispatch) { … }
TEST_F(PlatformEventTest, ObserverBasic) { … }
TEST_F(PlatformEventTest, ObserverOrder) { … }
TEST_F(PlatformEventTest, DispatcherAndObserverOrder) { … }
TEST_F(PlatformEventTest, OverriddenDispatcherBasic) { … }
TEST_F(PlatformEventTest, OverriddenDispatcherInvokeDefaultDispatcher) { … }
class RunCallbackDuringDispatch : public TestPlatformEventDispatcher { … };
TEST_F(PlatformEventTest, DispatcherRemovesNextDispatcherDuringDispatch) { … }
TEST_F(PlatformEventTest, DispatcherRemovesSelfDuringDispatch) { … }
TEST_F(PlatformEventTest, DispatcherRemovesSelfDuringDispatchLast) { … }
TEST_F(PlatformEventTest, DispatcherRemovesPrevDispatcherDuringDispatch) { … }
TEST_F(PlatformEventTest, DispatcherRemovesPrevDispatchersDuringDispatch) { … }
TEST_F(PlatformEventTest, DispatcherAddedDuringDispatchReceivesEvent) { … }
class PlatformEventTestWithMessageLoop : public PlatformEventTest { … };
#define RUN_TEST_IN_MESSAGE_LOOP(name) …
class ScopedDispatcherRestoresAfterDestroy
: public PlatformEventTestWithMessageLoop { … };
RUN_TEST_IN_MESSAGE_LOOP(ScopedDispatcherRestoresAfterDestroy)
class DestroyScopedHandleDispatcher : public TestPlatformEventDispatcher { … };
class ConsecutiveOverriddenDispatcherInTheSameMessageLoopIteration
: public PlatformEventTestWithMessageLoop { … };
RUN_TEST_IN_MESSAGE_LOOP(
ConsecutiveOverriddenDispatcherInTheSameMessageLoopIteration)
}