#include "ui/aura/window_event_dispatcher.h"
#include <stddef.h>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#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/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/types/cxx23_to_underlying.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/event_client.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/env.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/test/env_test_helper.h"
#include "ui/aura/test/test_cursor_client.h"
#include "ui/aura/test/test_screen.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
#include "ui/aura/window_targeter.h"
#include "ui/aura/window_tracker.h"
#include "ui/base/hit_test.h"
#include "ui/base/ime/mock_input_method.h"
#include "ui/base/ui_base_features.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
#include "ui/events/event_handler.h"
#include "ui/events/event_utils.h"
#include "ui/events/gesture_detection/gesture_configuration.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/test/event_generator.h"
#include "ui/events/test/test_event_handler.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/transform.h"
#include "ui/platform_window/platform_window_init_properties.h"
#include "ui/wm/core/capture_controller.h"
#if BUILDFLAG(IS_OZONE)
#include "ui/events/ozone/events_ozone.h"
#endif
namespace aura {
namespace {
class NonClientDelegate : public test::TestWindowDelegate { … };
class ConsumeKeyHandler : public ui::test::TestEventHandler { … };
class TestImeKeyEventDispatcher : public ui::ImeKeyEventDispatcher { … };
bool IsFocusedWindow(aura::Window* window) { … }
gfx::Point GetLastTouchPoint(
aura::Window* window,
std::optional<gfx::Point> fallback = std::nullopt) { … }
}
WindowEventDispatcherTest;
TEST_F(WindowEventDispatcherTest, OnHostMouseEvent) { … }
TEST_F(WindowEventDispatcherTest, RepostEvent) { … }
TEST_F(WindowEventDispatcherTest, TouchDownState) { … }
TEST_F(WindowEventDispatcherTest, MouseButtonState) { … }
TEST_F(WindowEventDispatcherTest, TranslatedEvent) { … }
namespace {
class TestEventClient : public client::EventClient { … };
}
TEST_F(WindowEventDispatcherTest, GetCanProcessEventsWithinSubtree) { … }
TEST_F(WindowEventDispatcherTest, DontIgnoreUnknownKeys) { … }
TEST_F(WindowEventDispatcherTest, NoDelegateWindowReceivesKeyEvents) { … }
TEST_F(WindowEventDispatcherTest, TouchEventsOutsideBounds) { … }
TEST_F(WindowEventDispatcherTest, ScrollEventDispatch) { … }
TEST_F(WindowEventDispatcherTest, PreDispatchKeyEventToIme) { … }
namespace {
class EventFilterRecorder : public ui::EventHandler { … };
std::string EventTypeToString(ui::EventType type) { … }
std::string EventTypesToString(const EventFilterRecorder::Events& events) { … }
}
#if BUILDFLAG(IS_WIN) && defined(ARCH_CPU_X86)
#define MAYBE …
#else
#define MAYBE(x) …
#endif
TEST_F(WindowEventDispatcherTest, MAYBE(RepostTargetsCaptureWindow)) { … }
TEST_F(WindowEventDispatcherTest, MouseMovesHeld) { … }
TEST_F(WindowEventDispatcherTest, TouchMovesHeld) { … }
TEST_F(WindowEventDispatcherTest, MouseEventWithoutTargetWindow) { … }
TEST_F(WindowEventDispatcherTest, DispatchMouseExitWhenHidingWindow) { … }
TEST_F(WindowEventDispatcherTest, HeldMovesDispatchMouseExitWhenHidingWindow) { … }
TEST_F(WindowEventDispatcherTest, NoMouseExitInShutdown) { … }
TEST_F(WindowEventDispatcherTest, CallToProcessedTouchEvent) { … }
class HoldPointerOnScrollHandler : public ui::test::TestEventHandler { … };
TEST_F(WindowEventDispatcherTest, TouchMovesHeldOnScroll) { … }
TEST_F(WindowEventDispatcherTest, HeldTouchMoveContributesToGesture) { … }
TEST_F(WindowEventDispatcherTest, DispatchSyntheticMouseEvents) { … }
TEST_F(WindowEventDispatcherTest, DoNotSynthesizeWhileButtonDown) { … }
TEST_F(WindowEventDispatcherTest, DoNotDispatchInShutdown) { … }
#if BUILDFLAG(IS_WIN) && defined(ARCH_CPU_X86)
#define MAYBE …
#else
#define MAYBE(x) …
#endif
TEST_F(WindowEventDispatcherTest,
MAYBE(SynthesizeMouseEventsOnWindowBoundsChanged)) { … }
TEST_F(WindowEventDispatcherTest, DispatchMouseExitWhenCursorHidden) { … }
TEST_F(WindowEventDispatcherTest,
DispatchSyntheticMouseExitAfterMouseEventsDisabled) { … }
class DeletingEventFilter : public ui::EventHandler { … };
class DeletingWindowDelegate : public test::TestWindowDelegate { … };
TEST_F(WindowEventDispatcherTest, DeleteWindowDuringDispatch) { … }
namespace {
class DetachesParentOnTapDelegate : public test::TestWindowDelegate { … };
}
TEST_F(WindowEventDispatcherTest,
GestureRecognizerResetsTargetWhenParentHides) { … }
namespace {
class NestedGestureDelegate : public test::TestWindowDelegate { … };
}
TEST_F(WindowEventDispatcherTest, GestureEndDeliveredAfterNestedGestures) { … }
TEST_F(WindowEventDispatcherTest, RepostTapdownGestureTest) { … }
class RepostGestureEventRecorder : public EventFilterRecorder { … };
TEST_F(WindowEventDispatcherTest, GestureRepostEventOrder) { … }
template <class T>
class OnMouseExitDeletingEventFilter : public EventFilterRecorder { … };
TEST_F(WindowEventDispatcherTest, DeleteWindowDuringMouseMovedDispatch) { … }
TEST_F(WindowEventDispatcherTest, DeleteDispatcherDuringPreDispatch) { … }
namespace {
class ValidRootDuringDestructionWindowObserver : public aura::WindowObserver { … };
}
TEST_F(WindowEventDispatcherTest, ValidRootDuringDestruction) { … }
namespace {
class DontResetHeldEventWindowDelegate : public test::TestWindowDelegate { … };
}
TEST_F(WindowEventDispatcherTest, DontResetHeldEvent) { … }
namespace {
class DeleteHostFromHeldMouseEventDelegate : public test::TestWindowDelegate { … };
}
TEST_F(WindowEventDispatcherTest, DeleteHostFromHeldMouseEvent) { … }
TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveTouches) { … }
TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveGestures) { … }
TEST_F(WindowEventDispatcherTest, TouchpadPinchEventsRetargetOnCapture) { … }
TEST_F(WindowEventDispatcherTest, EndingEventDoesntRetarget) { … }
namespace {
class CaptureWindowTracker : public test::TestWindowDelegate { … };
}
TEST_F(WindowEventDispatcherTest, CaptureWindowHidden) { … }
TEST_F(WindowEventDispatcherTest, CaptureWindowDestroyed) { … }
namespace {
class RunLoopHandler : public ui::EventHandler { … };
}
TEST_F(WindowEventDispatcherTest, HeldTouchMoveWithRunLoop) { … }
class ExitMessageLoopOnMousePress : public ui::test::TestEventHandler { … };
class WindowEventDispatcherTestWithMessageLoop
: public WindowEventDispatcherTest { … };
TEST_F(WindowEventDispatcherTestWithMessageLoop, EventRepostedInNonNestedLoop) { … }
class WindowEventDispatcherTestInHighDPI : public WindowEventDispatcherTest { … };
TEST_F(WindowEventDispatcherTestInHighDPI, EventLocationTransform) { … }
TEST_F(WindowEventDispatcherTestInHighDPI, TouchMovesHeldOnScroll) { … }
class TriggerNestedLoopOnRightMousePress : public ui::test::TestEventHandler { … };
TEST_F(WindowEventDispatcherTestInHighDPI,
EventsTransformedInRepostedEventTriggeredNestedLoop) { … }
class SelfDestructDelegate : public test::TestWindowDelegate { … };
TEST_F(WindowEventDispatcherTest, SynthesizedLocatedEvent) { … }
TEST_F(WindowEventDispatcherTest, DestroyWindowOnCaptureChanged) { … }
class StaticFocusClient : public client::FocusClient { … };
TEST_F(WindowEventDispatcherTest, HostCancelModeWithFocusedWindowOutside) { … }
class DispatchEventHandler : public ui::EventHandler { … };
class MoveWindowHandler : public ui::EventHandler { … };
TEST_F(WindowEventDispatcherTest, NestedEventDispatchTargetMoved) { … }
class AlwaysMouseDownInputStateLookup : public InputStateLookup { … };
TEST_F(WindowEventDispatcherTest,
CursorVisibilityChangedWhileCaptureWindowInAnotherDispatcher) { … }
TEST_F(WindowEventDispatcherTest,
RedirectedEventToDifferentDispatcherLocation) { … }
class AsyncWindowDelegate : public test::TestWindowDelegate { … };
TEST_F(WindowEventDispatcherTest, GestureEventCoordinates) { … }
TEST_F(WindowEventDispatcherTest, TouchMovesMarkedWhenCausingScroll) { … }
TEST_F(WindowEventDispatcherTest, OnCursorMovedToRootLocationUpdatesHover) { … }
TEST_F(WindowEventDispatcherTest, TouchEventWithScaledWindow) { … }
TEST_F(WindowEventDispatcherTest, TargetIsDestroyedByHeldEvent) { … }
TEST_F(WindowEventDispatcherTest, FilteredTouchProcessGesture) { … }
TEST_F(WindowEventDispatcherTest, LastTouchPoint) { … }
}