Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 rwhva->OnGestureEvent(&tap); | 302 rwhva->OnGestureEvent(&tap); |
| 303 | 303 |
| 304 selection_controller_client()->Wait(); | 304 selection_controller_client()->Wait(); |
| 305 | 305 |
| 306 // Check that insertion is not active and the quick menu is not showing. | 306 // Check that insertion is not active and the quick menu is not showing. |
| 307 EXPECT_EQ(ui::TouchSelectionController::INACTIVE, | 307 EXPECT_EQ(ui::TouchSelectionController::INACTIVE, |
| 308 rwhva->selection_controller()->active_status()); | 308 rwhva->selection_controller()->active_status()); |
| 309 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); | 309 EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); |
| 310 } | 310 } |
| 311 | 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(EmptyTextfield()); | |
|
tdresser
2016/07/14 12:13:40
It isn't immediately clear to me whether this is j
mohsen
2016/07/22 01:22:47
Renamed!
| |
| 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 | |
| 312 // Tests that the quick menu is hidden whenever a touch point is active. | 349 // Tests that the quick menu is hidden whenever a touch point is active. |
| 313 IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, | 350 IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, |
| 314 QuickMenuHiddenOnTouch) { | 351 QuickMenuHiddenOnTouch) { |
| 315 // Set the test page up. | 352 // Set the test page up. |
| 316 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html")); | 353 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html")); |
| 317 InitSelectionController(); | 354 InitSelectionController(); |
| 318 | 355 |
| 319 RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura(); | 356 RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura(); |
| 320 EXPECT_EQ(ui::TouchSelectionController::INACTIVE, | 357 EXPECT_EQ(ui::TouchSelectionController::INACTIVE, |
| 321 rwhva->selection_controller()->active_status()); | 358 rwhva->selection_controller()->active_status()); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 674 | 711 |
| 675 // The handle should have moved to right. | 712 // The handle should have moved to right. |
| 676 EXPECT_EQ(initial_handle_rect.y(), moved_handle_rect.y()); | 713 EXPECT_EQ(initial_handle_rect.y(), moved_handle_rect.y()); |
| 677 EXPECT_LT(initial_handle_rect.x(), moved_handle_rect.x()); | 714 EXPECT_LT(initial_handle_rect.x(), moved_handle_rect.x()); |
| 678 | 715 |
| 679 EXPECT_EQ(ui::TouchSelectionController::INSERTION_ACTIVE, | 716 EXPECT_EQ(ui::TouchSelectionController::INSERTION_ACTIVE, |
| 680 rwhva->selection_controller()->active_status()); | 717 rwhva->selection_controller()->active_status()); |
| 681 } | 718 } |
| 682 | 719 |
| 683 } // namespace content | 720 } // namespace content |
| OLD | NEW |