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

Side by Side Diff: content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc

Issue 2201853002: Blink handle selection handle visibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed ESTABLISHED/DISSOLVED Created 4 years, 1 month 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
157 RenderWidgetHostViewAura* GetRenderWidgetHostViewAura() { 155 RenderWidgetHostViewAura* GetRenderWidgetHostViewAura() {
158 return static_cast<RenderWidgetHostViewAura*>( 156 return static_cast<RenderWidgetHostViewAura*>(
159 shell()->web_contents()->GetRenderWidgetHostView()); 157 shell()->web_contents()->GetRenderWidgetHostView());
160 } 158 }
161 159
162 TestTouchSelectionControllerClientAura* selection_controller_client() { 160 TestTouchSelectionControllerClientAura* selection_controller_client() {
163 return selection_controller_client_; 161 return selection_controller_client_;
164 } 162 }
165 163
166 void InitSelectionController() { 164 void InitSelectionController() {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 rwhva->selection_controller()->GetStartHandleRect().CenterPoint()); 264 rwhva->selection_controller()->GetStartHandleRect().CenterPoint());
267 generator_delegate->ConvertPointFromTarget(native_view, &handle_center); 265 generator_delegate->ConvertPointFromTarget(native_view, &handle_center);
268 generator.GestureTapAt(handle_center); 266 generator.GestureTapAt(handle_center);
269 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); 267 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
270 268
271 // Tap once more on the insertion handle; the quick menu should disappear. 269 // Tap once more on the insertion handle; the quick menu should disappear.
272 generator.GestureTapAt(handle_center); 270 generator.GestureTapAt(handle_center);
273 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); 271 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
274 } 272 }
275 273
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
351 // Tests that the quick menu is hidden whenever a touch point is active. 274 // Tests that the quick menu is hidden whenever a touch point is active.
352 IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, 275 IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest,
353 QuickMenuHiddenOnTouch) { 276 QuickMenuHiddenOnTouch) {
354 // Set the test page up. 277 // Set the test page up.
355 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html")); 278 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html"));
356 InitSelectionController(); 279 InitSelectionController();
357 280
358 RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura(); 281 RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura();
359 EXPECT_EQ(ui::TouchSelectionController::INACTIVE, 282 EXPECT_EQ(ui::TouchSelectionController::INACTIVE,
360 rwhva->selection_controller()->active_status()); 283 rwhva->selection_controller()->active_status());
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 636
714 // The handle should have moved to right. 637 // The handle should have moved to right.
715 EXPECT_EQ(initial_handle_rect.y(), moved_handle_rect.y()); 638 EXPECT_EQ(initial_handle_rect.y(), moved_handle_rect.y());
716 EXPECT_LT(initial_handle_rect.x(), moved_handle_rect.x()); 639 EXPECT_LT(initial_handle_rect.x(), moved_handle_rect.x());
717 640
718 EXPECT_EQ(ui::TouchSelectionController::INSERTION_ACTIVE, 641 EXPECT_EQ(ui::TouchSelectionController::INSERTION_ACTIVE,
719 rwhva->selection_controller()->active_status()); 642 rwhva->selection_controller()->active_status());
720 } 643 }
721 644
722 } // namespace content 645 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698