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

Side by Side 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, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/input/touch_selection_controller_client_ aura.h" 5 #include "content/browser/renderer_host/input/touch_selection_controller_client_ aura.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 bool GetPointInsideTextfield(gfx::PointF* point) { 146 bool GetPointInsideTextfield(gfx::PointF* point) {
147 std::string str; 147 std::string str;
148 if (ExecuteScriptAndExtractString(shell(), "get_point_inside_textfield()", 148 if (ExecuteScriptAndExtractString(shell(), "get_point_inside_textfield()",
149 &str)) { 149 &str)) {
150 return JSONToPoint(str, point); 150 return JSONToPoint(str, point);
151 } 151 }
152 return false; 152 return false;
153 } 153 }
154 154
155 bool ClearTextfield() { return ExecuteScript(shell(), "clear_textfield()"); }
156
155 RenderWidgetHostViewAura* GetRenderWidgetHostViewAura() { 157 RenderWidgetHostViewAura* GetRenderWidgetHostViewAura() {
156 return static_cast<RenderWidgetHostViewAura*>( 158 return static_cast<RenderWidgetHostViewAura*>(
157 shell()->web_contents()->GetRenderWidgetHostView()); 159 shell()->web_contents()->GetRenderWidgetHostView());
158 } 160 }
159 161
160 TestTouchSelectionControllerClientAura* selection_controller_client() { 162 TestTouchSelectionControllerClientAura* selection_controller_client() {
161 return selection_controller_client_; 163 return selection_controller_client_;
162 } 164 }
163 165
164 void InitSelectionController() { 166 void InitSelectionController() {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 rwhva->selection_controller()->GetStartHandleRect().CenterPoint()); 266 rwhva->selection_controller()->GetStartHandleRect().CenterPoint());
265 generator_delegate->ConvertPointFromTarget(native_view, &handle_center); 267 generator_delegate->ConvertPointFromTarget(native_view, &handle_center);
266 generator.GestureTapAt(handle_center); 268 generator.GestureTapAt(handle_center);
267 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); 269 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
268 270
269 // Tap once more on the insertion handle; the quick menu should disappear. 271 // Tap once more on the insertion handle; the quick menu should disappear.
270 generator.GestureTapAt(handle_center); 272 generator.GestureTapAt(handle_center);
271 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); 273 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
272 } 274 }
273 275
276 // Tests that tapping in an empty textfield does not bring up the insertion
277 // handle.
278 IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest,
279 EmptyTextfieldInsertionOnTap) {
280 // Set the test page up.
281 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html"));
282 InitSelectionController();
283
284 RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura();
285
286 // Clear textfield contents.
287 ASSERT_TRUE(ClearTextfield());
288
289 EXPECT_EQ(ui::TouchSelectionController::INACTIVE,
290 rwhva->selection_controller()->active_status());
291 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
292
293 // Tap inside the textfield and wait for the insertion cursor.
294 selection_controller_client()->InitWaitForSelectionEvent(
295 ui::SELECTION_ESTABLISHED);
296
297 gfx::PointF point;
298 ASSERT_TRUE(GetPointInsideTextfield(&point));
299 ui::GestureEventDetails tap_details(ui::ET_GESTURE_TAP);
300 tap_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHSCREEN);
301 tap_details.set_tap_count(1);
302 ui::GestureEvent tap(point.x(), point.y(), 0, ui::EventTimeForNow(),
303 tap_details);
304 rwhva->OnGestureEvent(&tap);
305
306 selection_controller_client()->Wait();
307
308 // Check that insertion is not active and the quick menu is not showing.
309 EXPECT_EQ(ui::TouchSelectionController::INACTIVE,
310 rwhva->selection_controller()->active_status());
311 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
312 }
313
314 // Tests that long-pressing on an empty textfield brings up the insertion handle
315 // and the quick menu.
316 IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest,
317 EmptyTextfieldInsertionOnLongPress) {
318 // Set the test page up.
319 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html"));
320 InitSelectionController();
321
322 RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura();
323
324 // Clear textfield contents.
325 ASSERT_TRUE(ClearTextfield());
326
327 EXPECT_EQ(ui::TouchSelectionController::INACTIVE,
328 rwhva->selection_controller()->active_status());
329 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
330
331 // Long-press inside the textfield and wait for the insertion handle.
332 selection_controller_client()->InitWaitForSelectionEvent(
333 ui::INSERTION_HANDLE_SHOWN);
334
335 gfx::PointF point;
336 ASSERT_TRUE(GetPointInsideTextfield(&point));
337 ui::GestureEventDetails long_press_details(ui::ET_GESTURE_LONG_PRESS);
338 long_press_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHSCREEN);
339 ui::GestureEvent long_press(point.x(), point.y(), 0, ui::EventTimeForNow(),
340 long_press_details);
341 rwhva->OnGestureEvent(&long_press);
342
343 selection_controller_client()->Wait();
344
345 // Check that insertion is active and the quick menu is showing.
346 EXPECT_EQ(ui::TouchSelectionController::INSERTION_ACTIVE,
347 rwhva->selection_controller()->active_status());
348 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
349 }
350
274 // Tests that the quick menu is hidden whenever a touch point is active. 351 // Tests that the quick menu is hidden whenever a touch point is active.
275 IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, 352 IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest,
276 QuickMenuHiddenOnTouch) { 353 QuickMenuHiddenOnTouch) {
277 // Set the test page up. 354 // Set the test page up.
278 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html")); 355 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html"));
279 InitSelectionController(); 356 InitSelectionController();
280 357
281 RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura(); 358 RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura();
282 EXPECT_EQ(ui::TouchSelectionController::INACTIVE, 359 EXPECT_EQ(ui::TouchSelectionController::INACTIVE,
283 rwhva->selection_controller()->active_status()); 360 rwhva->selection_controller()->active_status());
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 713
637 // The handle should have moved to right. 714 // The handle should have moved to right.
638 EXPECT_EQ(initial_handle_rect.y(), moved_handle_rect.y()); 715 EXPECT_EQ(initial_handle_rect.y(), moved_handle_rect.y());
639 EXPECT_LT(initial_handle_rect.x(), moved_handle_rect.x()); 716 EXPECT_LT(initial_handle_rect.x(), moved_handle_rect.x());
640 717
641 EXPECT_EQ(ui::TouchSelectionController::INSERTION_ACTIVE, 718 EXPECT_EQ(ui::TouchSelectionController::INSERTION_ACTIVE,
642 rwhva->selection_controller()->active_status()); 719 rwhva->selection_controller()->active_status());
643 } 720 }
644 721
645 } // namespace content 722 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698