#include "third_party/blink/renderer/core/input/event_handler.h"
#include <memory>
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/input/web_gesture_event.h"
#include "third_party/blink/public/common/input/web_keyboard_event.h"
#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
#include "third_party/blink/public/common/input/web_pointer_event.h"
#include "third_party/blink/public/mojom/input/focus_type.mojom-blink.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/focus_params.h"
#include "third_party/blink/renderer/core/dom/range.h"
#include "third_party/blink/renderer/core/editing/dom_selection.h"
#include "third_party/blink/renderer/core/editing/editing_behavior.h"
#include "third_party/blink/renderer/core/editing/editor.h"
#include "third_party/blink/renderer/core/editing/ephemeral_range.h"
#include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/selection_controller.h"
#include "third_party/blink/renderer/core/editing/selection_template.h"
#include "third_party/blink/renderer/core/editing/testing/editing_test_base.h"
#include "third_party/blink/renderer/core/editing/testing/selection_sample.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/frame/web_frame_widget_impl.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/canvas/html_canvas_element.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/html_iframe_element.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/layout/layout_embedded_content.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/loader/empty_clients.h"
#include "third_party/blink/renderer/core/page/autoscroll_controller.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/page_animator.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/scroll/scroll_animator_base.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/core/testing/sim/sim_request.h"
#include "third_party/blink/renderer/core/testing/sim/sim_test.h"
#include "third_party/blink/renderer/platform/keyboard_codes.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-blink.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-blink.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/dom_key.h"
namespace blink {
class EventHandlerTest : public PageTestBase { … };
class EventHandlerSimTest : public SimTest { … };
WebPointerEvent CreateMinimalTouchPointerEvent(WebInputEvent::Type type,
gfx::PointF position) { … }
WebGestureEvent CreateMinimalGestureEvent(WebInputEvent::Type type,
gfx::PointF position) { … }
class TapEventBuilder : public WebGestureEvent { … };
class TapDownEventBuilder : public WebGestureEvent { … };
class ShowPressEventBuilder : public WebGestureEvent { … };
class LongPressEventBuilder : public WebGestureEvent { … };
class MousePressEventBuilder : public WebMouseEvent { … };
void EventHandlerTest::SetUp() { … }
void EventHandlerTest::SetHtmlInnerHTML(const char* html_content) { … }
ShadowRoot* EventHandlerTest::SetShadowContent(const char* shadow_content,
const char* host) { … }
TEST_F(EventHandlerTest, UseCountSelectionChangeOnCancelledMouseMove) { … }
TEST_F(EventHandlerTest, UseCountDragDropOnCancelledMouseMove) { … }
TEST_F(EventHandlerTest, dragSelectionAfterScroll) { … }
TEST_F(EventHandlerTest, multiClickSelectionFromTap) { … }
TEST_F(EventHandlerTest, multiClickSelectionFromTapDisabledIfNotEditable) { … }
TEST_F(EventHandlerTest, draggedInlinePositionTest) { … }
TEST_F(EventHandlerTest, draggedSVGImagePositionTest) { … }
TEST_F(EventHandlerTest, HitOnNothingDoesNotShowIBeam) { … }
TEST_F(EventHandlerTest, HitOnTextShowsIBeam) { … }
TEST_F(EventHandlerTest, HitOnUserSelectNoneDoesNotShowIBeam) { … }
TEST_F(EventHandlerTest, ShadowChildCanOverrideUserSelectNone) { … }
TEST_F(EventHandlerTest, UserSelectAllCanOverrideUserSelectNone) { … }
TEST_F(EventHandlerTest, UserSelectNoneCanOverrideUserSelectAll) { … }
TEST_F(EventHandlerTest, UserSelectTextCanOverrideUserSelectNone) { … }
TEST_F(EventHandlerTest, UserSelectNoneCanOverrideUserSelectText) { … }
TEST_F(EventHandlerTest, ShadowChildCanOverrideUserSelectText) { … }
TEST_F(EventHandlerTest, InputFieldsCanStartSelection) { … }
TEST_F(EventHandlerTest, ReadOnlyInputDoesNotInheritUserSelect) { … }
TEST_F(EventHandlerTest, ImagesCannotStartSelection) { … }
TEST_F(EventHandlerTest, AnchorTextCannotStartSelection) { … }
TEST_F(EventHandlerTest, EditableAnchorTextCanStartSelection) { … }
TEST_F(EventHandlerTest, CursorForVerticalResizableTextArea) { … }
TEST_F(EventHandlerTest, CursorForHorizontalResizableTextArea) { … }
TEST_F(EventHandlerTest, CursorForResizableTextArea) { … }
TEST_F(EventHandlerTest, CursorForRtlResizableTextArea) { … }
TEST_F(EventHandlerTest, CursorForInlineVerticalWritingMode) { … }
TEST_F(EventHandlerTest, CursorForBlockVerticalWritingMode) { … }
TEST_F(EventHandlerTest, implicitSend) { … }
TEST_F(EventHandlerTest, sendContextMenuEventWithHover) { … }
TEST_F(EventHandlerTest, EmptyTextfieldInsertionOnTap) { … }
TEST_F(EventHandlerTest, NonEmptyTextfieldInsertionOnTap) { … }
TEST_F(EventHandlerTest, NewlineDivInsertionOnTap) { … }
TEST_F(EventHandlerTest, EmptyTextfieldInsertionOnLongPress) { … }
TEST_F(EventHandlerTest, NonEmptyTextfieldInsertionOnLongPress) { … }
TEST_F(EventHandlerTest, SelectionOnDoublePress) { … }
TEST_F(EventHandlerTest, SelectionOnDoublePressPreventDefaultMousePress) { … }
TEST_F(EventHandlerTest, ClearHandleAfterTap) { … }
TEST_F(EventHandlerTest, HandleNotShownOnMouseEvents) { … }
TEST_F(EventHandlerTest,
TripleClickUserSelectNoneParagraphWithSelectableChildren) { … }
TEST_F(EventHandlerTest, MisspellingContextMenuEvent) { … }
TEST_F(EventHandlerTest, TouchAdjustmentOnEditableDisplayContents) { … }
TEST_F(EventHandlerTest, GestureHandlingForHeldBackTouchPointer) { … }
TEST_F(EventHandlerTest, dragEndInNewDrag) { … }
TEST_F(EventHandlerTest, FakeMouseMoveNotStartDrag) { … }
class TooltipCapturingChromeClient : public EmptyChromeClient { … };
class EventHandlerTooltipTest : public EventHandlerTest { … };
TEST_F(EventHandlerTooltipTest, mouseLeaveClearsTooltip) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_FocusSetFromTabUpdatesTooltip …
#else
#define MAYBE_FocusSetFromTabUpdatesTooltip …
#endif
TEST_F(EventHandlerTooltipTest, MAYBE_FocusSetFromTabUpdatesTooltip) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_FocusSetFromAccessKeyUpdatesTooltip …
#else
#define MAYBE_FocusSetFromAccessKeyUpdatesTooltip …
#endif
TEST_F(EventHandlerTooltipTest, MAYBE_FocusSetFromAccessKeyUpdatesTooltip) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_FocusSetFromMouseDoesntUpdateTooltip …
#else
#define MAYBE_FocusSetFromMouseDoesntUpdateTooltip …
#endif
TEST_F(EventHandlerTooltipTest, MAYBE_FocusSetFromMouseDoesntUpdateTooltip) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_FocusSetFromScriptDoesntUpdateTooltip …
#else
#define MAYBE_FocusSetFromScriptDoesntUpdateTooltip …
#endif
TEST_F(EventHandlerTooltipTest, MAYBE_FocusSetFromScriptDoesntUpdateTooltip) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_FocusSetScriptInitiatedFromKeypressUpdatesTooltip …
#else
#define MAYBE_FocusSetScriptInitiatedFromKeypressUpdatesTooltip …
#endif
TEST_F(EventHandlerTooltipTest,
MAYBE_FocusSetScriptInitiatedFromKeypressUpdatesTooltip) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_FocusSetFromScriptClearsKeyboardTriggeredTooltip …
#else
#define MAYBE_FocusSetFromScriptClearsKeyboardTriggeredTooltip …
#endif
TEST_F(EventHandlerTooltipTest,
MAYBE_FocusSetFromScriptClearsKeyboardTriggeredTooltip) { … }
TEST_F(EventHandlerTooltipTest,
FocusSetFromScriptDoesntClearCursorTriggeredTooltip) { … }
class UnbufferedInputEventsTrackingChromeClient : public EmptyChromeClient { … };
class EventHandlerLatencyTest : public PageTestBase { … };
TEST_F(EventHandlerLatencyTest, NeedsUnbufferedInput) { … }
TEST_F(EventHandlerSimTest, MouseUpOffScrollbarGeneratesScrollEnd) { … }
TEST_F(EventHandlerSimTest, MouseUpOnlyOnScrollbar) { … }
TEST_F(EventHandlerSimTest, RightClickNoGestures) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_GestureTapWithScrollSnaps …
#else
#define MAYBE_GestureTapWithScrollSnaps …
#endif
TEST_F(EventHandlerSimTest, MAYBE_GestureTapWithScrollSnaps) { … }
TEST_F(EventHandlerTest, MouseLeaveResetsUnknownState) { … }
TEST_F(EventHandlerSimTest, MouseLeaveIFrameResets) { … }
TEST_F(EventHandlerSimTest, CursorStyleBeforeStartDragging) { … }
TEST_F(EventHandlerSimTest, TapActiveInFrame) { … }
TEST_F(EventHandlerSimTest, TestUpdateHoverAfterCompositorScrollAtBeginFrame) { … }
TEST_F(EventHandlerSimTest, TestUpdateHoverAfterJSScrollAtBeginFrame) { … }
TEST_F(EventHandlerSimTest, LargeCustomCursorIntersectsViewport) { … }
TEST_F(EventHandlerSimTest, SmallCustomCursorIntersectsViewport) { … }
TEST_F(EventHandlerSimTest, NeverExposeKeyboardEvent) { … }
TEST_F(EventHandlerSimTest, NotExposeKeyboardEvent) { … }
TEST_F(EventHandlerSimTest, DoNotScrollWithTouchpadIfOverflowIsHidden) { … }
TEST_F(EventHandlerSimTest, ElementTargetedGestureScroll) { … }
TEST_F(EventHandlerSimTest, ElementTargetedGestureScrollIFrame) { … }
TEST_F(EventHandlerSimTest, ElementTargetedGestureScrollViewport) { … }
TEST_F(EventHandlerSimTest, SelecteTransformedTextWhenCapturing) { … }
TEST_F(EventHandlerSimTest, MouseRightButtonDownMoveToIFrame) { … }
TEST_F(EventHandlerSimTest, PenDraggingOnElementActive) { … }
TEST_F(EventHandlerSimTest, TestNoCrashOnMouseWheelZeroDelta) { … }
TEST_F(EventHandlerSimTest, TestNoWheelEventWithPhaseMayBeginAndCancel) { … }
TEST_F(EventHandlerSimTest, TestWheelEventsWithDifferentPhases) { … }
TEST_F(EventHandlerSimTest, TestScrollendFiresOnKeyUpAfterScroll) { … }
TEST_F(EventHandlerSimTest, TestScrollendFiresAfterScrollWithEarlyKeyUp) { … }
TEST_F(EventHandlerSimTest, TestScrollendFiresOnKeyUpAfterScrollInstant) { … }
TEST_F(EventHandlerSimTest, DiscardEventsToRecentlyMovedIframe) { … }
TEST_F(EventHandlerSimTest, ValidClickPointerIdForUnseenPointerEvent) { … }
}