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

Unified Diff: content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc

Issue 2664253002: Revert "Blink handle selection handle visibility" (Closed)
Patch Set: Created 3 years, 11 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: content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc
diff --git a/content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc b/content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc
index 167fde128d71906839157377f7f7a276ec982ab3..3f7dd525e9a3b5023c029ee2fa7c4dfef7f9e6f7 100644
--- a/content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc
+++ b/content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc
@@ -152,6 +152,8 @@ class TouchSelectionControllerClientAuraTest : public ContentBrowserTest {
return false;
}
+ bool ClearTextfield() { return ExecuteScript(shell(), "clear_textfield()"); }
+
RenderWidgetHostViewAura* GetRenderWidgetHostViewAura() {
return static_cast<RenderWidgetHostViewAura*>(
shell()->web_contents()->GetRenderWidgetHostView());
@@ -271,6 +273,81 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest,
EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
}
+// Tests that tapping in an empty textfield does not bring up the insertion
+// handle.
+IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest,
+ EmptyTextfieldInsertionOnTap) {
+ // Set the test page up.
+ ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html"));
+ InitSelectionController();
+
+ RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura();
+
+ // Clear textfield contents.
+ ASSERT_TRUE(ClearTextfield());
+
+ EXPECT_EQ(ui::TouchSelectionController::INACTIVE,
+ rwhva->selection_controller()->active_status());
+ EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
+
+ // Tap inside the textfield and wait for the insertion cursor.
+ selection_controller_client()->InitWaitForSelectionEvent(
+ ui::SELECTION_ESTABLISHED);
+
+ gfx::PointF point;
+ ASSERT_TRUE(GetPointInsideTextfield(&point));
+ ui::GestureEventDetails tap_details(ui::ET_GESTURE_TAP);
+ tap_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHSCREEN);
+ tap_details.set_tap_count(1);
+ ui::GestureEvent tap(point.x(), point.y(), 0, ui::EventTimeForNow(),
+ tap_details);
+ rwhva->OnGestureEvent(&tap);
+
+ selection_controller_client()->Wait();
+
+ // Check that insertion is not active and the quick menu is not showing.
+ EXPECT_EQ(ui::TouchSelectionController::INACTIVE,
+ rwhva->selection_controller()->active_status());
+ EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
+}
+
+// Tests that long-pressing on an empty textfield brings up the insertion handle
+// and the quick menu.
+IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest,
+ EmptyTextfieldInsertionOnLongPress) {
+ // Set the test page up.
+ ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html"));
+ InitSelectionController();
+
+ RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura();
+
+ // Clear textfield contents.
+ ASSERT_TRUE(ClearTextfield());
+
+ EXPECT_EQ(ui::TouchSelectionController::INACTIVE,
+ rwhva->selection_controller()->active_status());
+ EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
+
+ // Long-press inside the textfield and wait for the insertion handle.
+ selection_controller_client()->InitWaitForSelectionEvent(
+ ui::INSERTION_HANDLE_SHOWN);
+
+ gfx::PointF point;
+ ASSERT_TRUE(GetPointInsideTextfield(&point));
+ ui::GestureEventDetails long_press_details(ui::ET_GESTURE_LONG_PRESS);
+ long_press_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHSCREEN);
+ ui::GestureEvent long_press(point.x(), point.y(), 0, ui::EventTimeForNow(),
+ long_press_details);
+ rwhva->OnGestureEvent(&long_press);
+
+ selection_controller_client()->Wait();
+
+ // Check that insertion is active and the quick menu is showing.
+ EXPECT_EQ(ui::TouchSelectionController::INSERTION_ACTIVE,
+ rwhva->selection_controller()->active_status());
+ EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
+}
+
// Tests that the quick menu is hidden whenever a touch point is active.
IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest,
QuickMenuHiddenOnTouch) {

Powered by Google App Engine
This is Rietveld 408576698