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

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: fixed contextual search test function 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 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 bool GetPointInsideTextfield(gfx::PointF* point) { 145 bool GetPointInsideTextfield(gfx::PointF* point) {
146 std::string str; 146 std::string str;
147 if (ExecuteScriptAndExtractString(shell(), "get_point_inside_textfield()", 147 if (ExecuteScriptAndExtractString(shell(), "get_point_inside_textfield()",
148 &str)) { 148 &str)) {
149 return JSONToPoint(str, point); 149 return JSONToPoint(str, point);
150 } 150 }
151 return false; 151 return false;
152 } 152 }
153 153
154 bool ClearTextfield() { return ExecuteScript(shell(), "clear_textfield()"); }
mohsen 2016/10/15 03:49:36 I think you can also remove clear_textfield() from
amaralp 2016/10/19 04:26:38 Done.
155
156 RenderWidgetHostViewAura* GetRenderWidgetHostViewAura() { 154 RenderWidgetHostViewAura* GetRenderWidgetHostViewAura() {
157 return static_cast<RenderWidgetHostViewAura*>( 155 return static_cast<RenderWidgetHostViewAura*>(
158 shell()->web_contents()->GetRenderWidgetHostView()); 156 shell()->web_contents()->GetRenderWidgetHostView());
159 } 157 }
160 158
161 TestTouchSelectionControllerClientAura* selection_controller_client() { 159 TestTouchSelectionControllerClientAura* selection_controller_client() {
162 return selection_controller_client_; 160 return selection_controller_client_;
163 } 161 }
164 162
165 void InitSelectionController() { 163 void InitSelectionController() {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 rwhva->selection_controller()->GetStartHandleRect().CenterPoint()); 262 rwhva->selection_controller()->GetStartHandleRect().CenterPoint());
265 generator_delegate->ConvertPointFromTarget(native_view, &handle_center); 263 generator_delegate->ConvertPointFromTarget(native_view, &handle_center);
266 generator.GestureTapAt(handle_center); 264 generator.GestureTapAt(handle_center);
267 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); 265 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
268 266
269 // Tap once more on the insertion handle; the quick menu should disappear. 267 // Tap once more on the insertion handle; the quick menu should disappear.
270 generator.GestureTapAt(handle_center); 268 generator.GestureTapAt(handle_center);
271 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); 269 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
272 } 270 }
273 271
274 // Tests that tapping in an empty textfield does not bring up the insertion
275 // handle.
276 IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest,
277 EmptyTextfieldInsertionOnTap) {
278 // Set the test page up.
279 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html"));
280 InitSelectionController();
281
282 RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura();
283
284 // Clear textfield contents.
285 ASSERT_TRUE(ClearTextfield());
286
287 EXPECT_EQ(ui::TouchSelectionController::INACTIVE,
288 rwhva->selection_controller()->active_status());
289 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
290
291 // Tap inside the textfield and wait for the insertion cursor.
292 selection_controller_client()->InitWaitForSelectionEvent(
293 ui::SELECTION_ESTABLISHED);
294
295 gfx::PointF point;
296 ASSERT_TRUE(GetPointInsideTextfield(&point));
297 ui::GestureEventDetails tap_details(ui::ET_GESTURE_TAP);
298 tap_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHSCREEN);
299 tap_details.set_tap_count(1);
300 ui::GestureEvent tap(point.x(), point.y(), 0, ui::EventTimeForNow(),
301 tap_details);
302 rwhva->OnGestureEvent(&tap);
303
304 selection_controller_client()->Wait();
305
306 // Check that insertion is not active and the quick menu is not showing.
307 EXPECT_EQ(ui::TouchSelectionController::INACTIVE,
308 rwhva->selection_controller()->active_status());
309 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
310 }
311
312 // Tests that long-pressing on an empty textfield brings up the insertion handle
313 // and the quick menu.
314 IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest,
315 EmptyTextfieldInsertionOnLongPress) {
316 // Set the test page up.
317 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html"));
318 InitSelectionController();
319
320 RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura();
321
322 // Clear textfield contents.
323 ASSERT_TRUE(ClearTextfield());
324
325 EXPECT_EQ(ui::TouchSelectionController::INACTIVE,
326 rwhva->selection_controller()->active_status());
327 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
328
329 // Long-press inside the textfield and wait for the insertion handle.
330 selection_controller_client()->InitWaitForSelectionEvent(
331 ui::INSERTION_HANDLE_SHOWN);
332
333 gfx::PointF point;
334 ASSERT_TRUE(GetPointInsideTextfield(&point));
335 ui::GestureEventDetails long_press_details(ui::ET_GESTURE_LONG_PRESS);
336 long_press_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHSCREEN);
337 ui::GestureEvent long_press(point.x(), point.y(), 0, ui::EventTimeForNow(),
338 long_press_details);
339 rwhva->OnGestureEvent(&long_press);
340
341 selection_controller_client()->Wait();
342
343 // Check that insertion is active and the quick menu is showing.
344 EXPECT_EQ(ui::TouchSelectionController::INSERTION_ACTIVE,
345 rwhva->selection_controller()->active_status());
346 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
347 }
348
349 // Tests that the quick menu is hidden whenever a touch point is active. 272 // Tests that the quick menu is hidden whenever a touch point is active.
350 IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, 273 IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest,
351 QuickMenuHiddenOnTouch) { 274 QuickMenuHiddenOnTouch) {
352 // Set the test page up. 275 // Set the test page up.
353 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html")); 276 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html"));
354 InitSelectionController(); 277 InitSelectionController();
355 278
356 RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura(); 279 RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura();
357 EXPECT_EQ(ui::TouchSelectionController::INACTIVE, 280 EXPECT_EQ(ui::TouchSelectionController::INACTIVE,
358 rwhva->selection_controller()->active_status()); 281 rwhva->selection_controller()->active_status());
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 634
712 // The handle should have moved to right. 635 // The handle should have moved to right.
713 EXPECT_EQ(initial_handle_rect.y(), moved_handle_rect.y()); 636 EXPECT_EQ(initial_handle_rect.y(), moved_handle_rect.y());
714 EXPECT_LT(initial_handle_rect.x(), moved_handle_rect.x()); 637 EXPECT_LT(initial_handle_rect.x(), moved_handle_rect.x());
715 638
716 EXPECT_EQ(ui::TouchSelectionController::INSERTION_ACTIVE, 639 EXPECT_EQ(ui::TouchSelectionController::INSERTION_ACTIVE,
717 rwhva->selection_controller()->active_status()); 640 rwhva->selection_controller()->active_status());
718 } 641 }
719 642
720 } // namespace content 643 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698