Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Unified Diff: third_party/WebKit/Source/core/input/EventHandlerTest.cpp

Issue 2201853002: Blink handle selection handle visibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try running even rebaseline tests Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/input/EventHandlerTest.cpp
diff --git a/third_party/WebKit/Source/core/input/EventHandlerTest.cpp b/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
index 580cc0d7a8eb85494373a402451e6f03e49d2d73..79596c9c29137bd02d708fa86d78be8cf991b1f0 100644
--- a/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
+++ b/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
@@ -47,6 +47,18 @@ class TapEventBuilder : public PlatformGestureEvent {
}
};
+class LongPressEventBuilder : public PlatformGestureEvent {
+ public:
+ LongPressEventBuilder(IntPoint position)
+ : PlatformGestureEvent(PlatformEvent::GestureLongPress,
+ position,
+ position,
+ IntSize(5, 5),
+ WTF::monotonicallyIncreasingTime(),
+ static_cast<PlatformEvent::Modifiers>(0),
+ PlatformGestureSourceTouchscreen) {}
+};
+
void EventHandlerTest::SetUp() {
m_dummyPageHolder = DummyPageHolder::create(IntSize(300, 400));
}
@@ -254,4 +266,79 @@ TEST_F(EventHandlerTest, sendContextMenuEventWithHover) {
document().frame()->eventHandler().sendContextMenuEvent(mouseDownEvent));
}
+TEST_F(EventHandlerTest, EmptyTextfieldInsertionOnTap) {
+ setHtmlInnerHTML("<textarea cols=50 rows=50></textarea>");
+
+ FrameSelection& selection = document().frame()->selection();
+
+ TapEventBuilder singleTapEvent(IntPoint(200, 200), 1);
+ document().frame()->eventHandler().handleGestureEvent(singleTapEvent);
+
+ ASSERT_TRUE(selection.isCaret());
+ ASSERT_FALSE(selection.selection().isHandleVisible());
+}
+
+TEST_F(EventHandlerTest, NonEmptyTextfieldInsertionOnTap) {
+ setHtmlInnerHTML("<textarea cols=50 rows=50>Enter text</textarea>");
+
+ FrameSelection& selection = document().frame()->selection();
+
+ TapEventBuilder singleTapEvent(IntPoint(200, 200), 1);
+ document().frame()->eventHandler().handleGestureEvent(singleTapEvent);
+
+ ASSERT_TRUE(selection.isCaret());
+ ASSERT_TRUE(selection.selection().isHandleVisible());
+}
+
+TEST_F(EventHandlerTest, EmptyTextfieldInsertionOnLongPress) {
+ setHtmlInnerHTML("<textarea cols=50 rows=50></textarea>");
+
+ FrameSelection& selection = document().frame()->selection();
+
+ LongPressEventBuilder longPressEvent(IntPoint(200, 200));
+ document().frame()->eventHandler().handleGestureEvent(longPressEvent);
+
+ ASSERT_TRUE(selection.isCaret());
+ ASSERT_TRUE(selection.selection().isHandleVisible());
+
+ // Single Tap on an empty edit field should clear insertion handle
+ TapEventBuilder singleTapEvent(IntPoint(200, 200), 1);
+ document().frame()->eventHandler().handleGestureEvent(singleTapEvent);
+
+ ASSERT_TRUE(selection.isCaret());
+ ASSERT_FALSE(selection.selection().isHandleVisible());
+}
+
+TEST_F(EventHandlerTest, NonEmptyTextfieldInsertionOnLongPress) {
+ setHtmlInnerHTML("<textarea cols=50 rows=50>Enter text</textarea>");
+
+ FrameSelection& selection = document().frame()->selection();
+
+ LongPressEventBuilder longPressEvent(IntPoint(200, 200));
+ document().frame()->eventHandler().handleGestureEvent(longPressEvent);
+
+ ASSERT_TRUE(selection.selection().isCaret());
+ ASSERT_TRUE(selection.selection().isHandleVisible());
+}
+
+TEST_F(EventHandlerTest, ClearHandleAfterTap) {
+ setHtmlInnerHTML("<textarea cols=50 rows=50>Enter text</textarea>");
+
+ FrameSelection& selection = document().frame()->selection();
+
+ // Show handle
+ LongPressEventBuilder longPressEvent(IntPoint(200, 200));
+ document().frame()->eventHandler().handleGestureEvent(longPressEvent);
+
+ ASSERT_TRUE(selection.selection().isCaret());
+ ASSERT_TRUE(selection.selection().isHandleVisible());
+
+ // Tap away from text area should clear handle
+ TapEventBuilder singleTapEvent(IntPoint(700, 700), 1);
+ document().frame()->eventHandler().handleGestureEvent(singleTapEvent);
+
+ ASSERT_TRUE(selection.isNone());
+ ASSERT_FALSE(selection.selection().isHandleVisible());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698