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 b59cc2bd010a0c14a22ad0066f8813b3e08efa6b..348b5e6fea0e69081e2e41ef286901b8b358082d 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 |
@@ -4,6 +4,7 @@ |
#include "content/browser/renderer_host/input/touch_selection_controller_client_aura.h" |
+#include "base/command_line.h" |
#include "base/json/json_reader.h" |
#include "base/macros.h" |
#include "base/run_loop.h" |
@@ -17,6 +18,7 @@ |
#include "ui/aura/window_tree_host.h" |
#include "ui/events/event_utils.h" |
#include "ui/events/test/event_generator.h" |
+#include "ui/gfx/switches.h" |
#include "ui/touch_selection/touch_selection_controller_test_api.h" |
namespace content { |
@@ -153,6 +155,23 @@ class TouchSelectionControllerClientAuraTest : public ContentBrowserTest { |
"empty_textfield()"); |
} |
+ RenderWidgetHostViewAura* GetRenderWidgetHostViewAura() { |
+ return static_cast<RenderWidgetHostViewAura*>( |
+ shell()->web_contents()->GetRenderWidgetHostView()); |
+ } |
+ |
+ TestTouchSelectionControllerClientAura* selection_controller_client() { |
+ return selection_controller_client_; |
+ } |
+ |
+ void InitSelectionController() { |
+ RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura(); |
+ selection_controller_client_ = |
+ new TestTouchSelectionControllerClientAura(rwhva); |
+ rwhva->SetSelectionControllerClientForTest( |
+ make_scoped_ptr(selection_controller_client_)); |
+ } |
+ |
private: |
void SetUpOnMainThread() override { |
ContentBrowserTest::SetUpOnMainThread(); |
@@ -162,11 +181,15 @@ class TouchSelectionControllerClientAuraTest : public ContentBrowserTest { |
void TearDownOnMainThread() override { |
menu_runner_ = nullptr; |
+ selection_controller_client_ = nullptr; |
ContentBrowserTest::TearDownOnMainThread(); |
} |
scoped_ptr<TestTouchSelectionMenuRunner> menu_runner_; |
+ TestTouchSelectionControllerClientAura* selection_controller_client_ = |
+ nullptr; |
+ |
DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerClientAuraTest); |
}; |
@@ -175,21 +198,15 @@ class TouchSelectionControllerClientAuraTest : public ContentBrowserTest { |
IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, BasicSelection) { |
// Set the test page up. |
ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html")); |
- WebContents* web_contents = |
- static_cast<WebContentsImpl*>(shell()->web_contents()); |
- RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( |
- web_contents->GetRenderWidgetHostView()); |
- TestTouchSelectionControllerClientAura* selection_controller_client = |
- new TestTouchSelectionControllerClientAura(rwhva); |
- rwhva->SetSelectionControllerClientForTest( |
- make_scoped_ptr(selection_controller_client)); |
+ InitSelectionController(); |
+ RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura(); |
EXPECT_EQ(ui::TouchSelectionController::INACTIVE, |
rwhva->selection_controller()->active_status()); |
EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); |
// Long-press on the text and wait for handles to appear. |
- selection_controller_client->InitWaitForSelectionEvent( |
+ selection_controller_client()->InitWaitForSelectionEvent( |
ui::SELECTION_HANDLES_SHOWN); |
gfx::PointF point; |
@@ -199,7 +216,7 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, BasicSelection) { |
ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); |
rwhva->OnGestureEvent(&long_press); |
- selection_controller_client->Wait(); |
+ selection_controller_client()->Wait(); |
// Check that selection is active and the quick menu is showing. |
EXPECT_EQ(ui::TouchSelectionController::SELECTION_ACTIVE, |
@@ -214,36 +231,29 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, |
BasicInsertionFollowedByTapsOnHandle) { |
// Set the test page up. |
ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html")); |
- WebContents* web_contents = |
- static_cast<WebContentsImpl*>(shell()->web_contents()); |
- RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( |
- web_contents->GetRenderWidgetHostView()); |
- TestTouchSelectionControllerClientAura* selection_controller_client = |
- new TestTouchSelectionControllerClientAura(rwhva); |
- rwhva->SetSelectionControllerClientForTest( |
- make_scoped_ptr(selection_controller_client)); |
+ InitSelectionController(); |
+ RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura(); |
EXPECT_EQ(ui::TouchSelectionController::INACTIVE, |
rwhva->selection_controller()->active_status()); |
EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); |
ui::test::EventGeneratorDelegate* generator_delegate = |
ui::test::EventGenerator::default_delegate; |
- ui::test::EventGenerator generator( |
- web_contents->GetContentNativeView()->GetRootWindow()); |
+ gfx::NativeView native_view = rwhva->GetNativeView(); |
+ ui::test::EventGenerator generator(native_view->GetRootWindow()); |
// Tap inside the textfield and wait for the insertion handle to appear. |
- selection_controller_client->InitWaitForSelectionEvent( |
+ selection_controller_client()->InitWaitForSelectionEvent( |
ui::INSERTION_HANDLE_SHOWN); |
gfx::PointF point_f; |
ASSERT_TRUE(GetPointInsideTextfield(&point_f)); |
gfx::Point point = gfx::ToRoundedPoint(point_f); |
- generator_delegate->ConvertPointFromTarget( |
- web_contents->GetContentNativeView(), &point); |
+ generator_delegate->ConvertPointFromTarget(native_view, &point); |
generator.GestureTapAt(point); |
- selection_controller_client->Wait(); |
+ selection_controller_client()->Wait(); |
// Check that insertion is active, but the quick menu is not showing. |
EXPECT_EQ(ui::TouchSelectionController::INSERTION_ACTIVE, |
@@ -253,8 +263,7 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, |
// Tap on the insertion handle; the quick menu should appear. |
gfx::Point handle_center = gfx::ToRoundedPoint( |
rwhva->selection_controller()->GetStartHandleRect().CenterPoint()); |
- generator_delegate->ConvertPointFromTarget( |
- web_contents->GetContentNativeView(), &handle_center); |
+ generator_delegate->ConvertPointFromTarget(native_view, &handle_center); |
generator.GestureTapAt(handle_center); |
EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); |
@@ -269,14 +278,9 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, |
EmptyTextfieldInsertionOnTap) { |
// Set the test page up. |
ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html")); |
- WebContents* web_contents = |
- static_cast<WebContentsImpl*>(shell()->web_contents()); |
- RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( |
- web_contents->GetRenderWidgetHostView()); |
- TestTouchSelectionControllerClientAura* selection_controller_client = |
- new TestTouchSelectionControllerClientAura(rwhva); |
- rwhva->SetSelectionControllerClientForTest( |
- make_scoped_ptr(selection_controller_client)); |
+ InitSelectionController(); |
+ |
+ RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura(); |
// Clear textfield contents. |
ASSERT_TRUE(EmptyTextfield()); |
@@ -286,7 +290,7 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, |
EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); |
// Tap inside the textfield and wait for the insertion cursor. |
- selection_controller_client->InitWaitForSelectionEvent( |
+ selection_controller_client()->InitWaitForSelectionEvent( |
ui::SELECTION_ESTABLISHED); |
gfx::PointF point; |
@@ -297,7 +301,7 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, |
tap_details); |
rwhva->OnGestureEvent(&tap); |
- selection_controller_client->Wait(); |
+ selection_controller_client()->Wait(); |
// Check that insertion is not active and the quick menu is not showing. |
EXPECT_EQ(ui::TouchSelectionController::INACTIVE, |
@@ -310,21 +314,15 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, |
QuickMenuHiddenOnTouch) { |
// Set the test page up. |
ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html")); |
- WebContents* web_contents = |
- static_cast<WebContentsImpl*>(shell()->web_contents()); |
- RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( |
- web_contents->GetRenderWidgetHostView()); |
- TestTouchSelectionControllerClientAura* selection_controller_client = |
- new TestTouchSelectionControllerClientAura(rwhva); |
- rwhva->SetSelectionControllerClientForTest( |
- make_scoped_ptr(selection_controller_client)); |
+ InitSelectionController(); |
+ RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura(); |
EXPECT_EQ(ui::TouchSelectionController::INACTIVE, |
rwhva->selection_controller()->active_status()); |
EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); |
// Long-press on the text and wait for selection handles to appear. |
- selection_controller_client->InitWaitForSelectionEvent( |
+ selection_controller_client()->InitWaitForSelectionEvent( |
ui::SELECTION_HANDLES_SHOWN); |
gfx::PointF point; |
@@ -334,15 +332,14 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, |
ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); |
rwhva->OnGestureEvent(&long_press); |
- selection_controller_client->Wait(); |
+ selection_controller_client()->Wait(); |
EXPECT_EQ(ui::TouchSelectionController::SELECTION_ACTIVE, |
rwhva->selection_controller()->active_status()); |
EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); |
- ui::test::EventGenerator generator( |
- web_contents->GetContentNativeView()->GetRootWindow(), |
- web_contents->GetContentNativeView()); |
+ ui::test::EventGenerator generator(rwhva->GetNativeView()->GetRootWindow(), |
+ rwhva->GetNativeView()); |
// Put the first finger down: the quick menu should get hidden. |
generator.PressTouchId(0); |
@@ -373,14 +370,9 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, |
IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, HiddenOnScroll) { |
// Set the test page up. |
ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html")); |
- WebContents* web_contents = |
- static_cast<WebContentsImpl*>(shell()->web_contents()); |
- RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( |
- web_contents->GetRenderWidgetHostView()); |
- TestTouchSelectionControllerClientAura* selection_controller_client = |
- new TestTouchSelectionControllerClientAura(rwhva); |
- rwhva->SetSelectionControllerClientForTest( |
- make_scoped_ptr(selection_controller_client)); |
+ InitSelectionController(); |
+ |
+ RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura(); |
ui::TouchSelectionControllerTestApi selection_controller_test_api( |
rwhva->selection_controller()); |
@@ -389,7 +381,7 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, HiddenOnScroll) { |
EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); |
// Long-press on the text and wait for selection handles to appear. |
- selection_controller_client->InitWaitForSelectionEvent( |
+ selection_controller_client()->InitWaitForSelectionEvent( |
ui::SELECTION_HANDLES_SHOWN); |
gfx::PointF point; |
@@ -399,7 +391,7 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, HiddenOnScroll) { |
ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); |
rwhva->OnGestureEvent(&long_press); |
- selection_controller_client->Wait(); |
+ selection_controller_client()->Wait(); |
EXPECT_EQ(ui::TouchSelectionController::SELECTION_ACTIVE, |
rwhva->selection_controller()->active_status()); |
@@ -452,21 +444,15 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, |
HiddenAfterOverscroll) { |
// Set the page up. |
ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html")); |
- WebContents* web_contents = |
- static_cast<WebContentsImpl*>(shell()->web_contents()); |
- RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( |
- web_contents->GetRenderWidgetHostView()); |
- TestTouchSelectionControllerClientAura* selection_controller_client = |
- new TestTouchSelectionControllerClientAura(rwhva); |
- rwhva->SetSelectionControllerClientForTest( |
- make_scoped_ptr(selection_controller_client)); |
+ InitSelectionController(); |
+ RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura(); |
EXPECT_EQ(ui::TouchSelectionController::INACTIVE, |
rwhva->selection_controller()->active_status()); |
EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); |
// Long-press on the text and wait for touch handles to appear. |
- selection_controller_client->InitWaitForSelectionEvent( |
+ selection_controller_client()->InitWaitForSelectionEvent( |
ui::SELECTION_HANDLES_SHOWN); |
gfx::PointF point; |
@@ -476,7 +462,7 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, |
ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); |
rwhva->OnGestureEvent(&long_press); |
- selection_controller_client->Wait(); |
+ selection_controller_client()->Wait(); |
EXPECT_EQ(ui::TouchSelectionController::SELECTION_ACTIVE, |
rwhva->selection_controller()->active_status()); |
@@ -484,7 +470,7 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, |
// Scroll such that an overscroll is initiated and wait for it to complete: |
// touch selection should not be active at the end. |
- selection_controller_client->InitWaitForSelectionEvent( |
+ selection_controller_client()->InitWaitForSelectionEvent( |
ui::SELECTION_HANDLES_CLEARED); |
ui::GestureEvent scroll_begin( |
@@ -502,11 +488,182 @@ IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraTest, |
ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); |
rwhva->OnGestureEvent(&scroll_end); |
- selection_controller_client->Wait(); |
+ selection_controller_client()->Wait(); |
EXPECT_EQ(ui::TouchSelectionController::INACTIVE, |
rwhva->selection_controller()->active_status()); |
EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); |
} |
+class TouchSelectionControllerClientAuraScaleFactorTest |
+ : public TouchSelectionControllerClientAuraTest { |
+ public: |
+ void SetUpCommandLine(base::CommandLine* command_line) override { |
+ command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "2"); |
+ } |
+}; |
+ |
+#if defined(OS_WIN) |
+// High DPI tests are disabled on Windows due to crbug.com/545547. |
+#define MAYBE_SelectionHandleCoordinates DISABLED_SelectionHandleCoordinates |
+#define MAYBE_InsertionHandleCoordinates DISABLED_InsertionHandleCoordinates |
+#else |
+#define MAYBE_SelectionHandleCoordinates SelectionHandleCoordinates |
+#define MAYBE_InsertionHandleCoordinates InsertionHandleCoordinates |
+#endif |
+ |
+// Tests that selection handles are properly positioned at 2x DSF. |
+IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraScaleFactorTest, |
+ MAYBE_SelectionHandleCoordinates) { |
+ // Set the test page up. |
+ ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html")); |
+ InitSelectionController(); |
+ |
+ RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura(); |
+ |
+ EXPECT_EQ(ui::TouchSelectionController::INACTIVE, |
+ rwhva->selection_controller()->active_status()); |
+ EXPECT_FALSE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); |
+ EXPECT_EQ(2.f, rwhva->current_device_scale_factor()); |
+ |
+ // Long-press on the text and wait for handles to appear. |
+ selection_controller_client()->InitWaitForSelectionEvent( |
+ ui::SELECTION_HANDLES_SHOWN); |
+ gfx::PointF point; |
+ ASSERT_TRUE(GetPointInsideText(&point)); |
+ ui::GestureEvent long_press( |
+ point.x(), point.y(), 0, ui::EventTimeForNow(), |
+ ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); |
+ rwhva->OnGestureEvent(&long_press); |
+ selection_controller_client()->Wait(); |
+ |
+ // Check that selection is active and the quick menu is showing. |
+ EXPECT_EQ(ui::TouchSelectionController::SELECTION_ACTIVE, |
+ rwhva->selection_controller()->active_status()); |
+ EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); |
+ const ui::TouchSelectionController* controller = |
+ GetRenderWidgetHostViewAura()->selection_controller(); |
+ |
+ gfx::PointF start_top = controller->start().edge_top(); |
+ |
+ // The selection start should be uppper left, and selection end should be |
+ // upper right. |
+ EXPECT_LT(controller->start().edge_top().x(), point.x()); |
+ EXPECT_LT(controller->start().edge_bottom().x(), point.x()); |
+ |
+ EXPECT_LT(point.x(), controller->end().edge_top().x()); |
+ EXPECT_LT(point.x(), controller->end().edge_bottom().x()); |
+ |
+ // Handles are created below the selection. The top position should roughly |
+ // be within the handle size from the touch position. |
+ float handle_size = controller->start().edge_bottom().y() - |
+ controller->start().edge_top().y(); |
+ float handle_max_bottom = point.y() + handle_size; |
+ EXPECT_GT(handle_max_bottom, controller->start().edge_top().y()); |
+ EXPECT_GT(handle_max_bottom, controller->end().edge_top().y()); |
+ |
+ gfx::Point handle_point = gfx::ToRoundedPoint( |
+ rwhva->selection_controller()->GetStartHandleRect().CenterPoint()); |
+ |
+ // Move the selection handle. Touch the handle first. |
+ selection_controller_client()->InitWaitForSelectionEvent( |
+ ui::SELECTION_HANDLE_DRAG_STARTED); |
+ ui::TouchEvent touch_down(ui::ET_TOUCH_PRESSED, handle_point, 0, |
+ ui::EventTimeForNow()); |
+ rwhva->OnTouchEvent(&touch_down); |
+ selection_controller_client()->Wait(); |
+ |
+ // Move it. |
+ selection_controller_client()->InitWaitForSelectionEvent( |
+ ui::SELECTION_HANDLES_MOVED); |
+ handle_point.Offset(10, 0); |
+ ui::TouchEvent touch_move(ui::ET_TOUCH_MOVED, handle_point, 0, |
+ ui::EventTimeForNow()); |
+ rwhva->OnTouchEvent(&touch_move); |
+ selection_controller_client()->Wait(); |
+ |
+ // Then release. |
+ selection_controller_client()->InitWaitForSelectionEvent( |
+ ui::SELECTION_HANDLE_DRAG_STOPPED); |
+ ui::TouchEvent touch_up(ui::ET_TOUCH_RELEASED, handle_point, 0, |
+ ui::EventTimeForNow()); |
+ rwhva->OnTouchEvent(&touch_up); |
+ selection_controller_client()->Wait(); |
+ |
+ // The handle should have moved to right. |
+ EXPECT_EQ(start_top.y(), controller->start().edge_top().y()); |
+ EXPECT_LT(start_top.x(), controller->start().edge_top().x()); |
+ |
+ EXPECT_EQ(ui::TouchSelectionController::SELECTION_ACTIVE, |
+ rwhva->selection_controller()->active_status()); |
+} |
+ |
+// Tests that insertion handles are properly positioned at 2x DSF. |
+IN_PROC_BROWSER_TEST_F(TouchSelectionControllerClientAuraScaleFactorTest, |
+ MAYBE_InsertionHandleCoordinates) { |
+ // Set the test page up. |
+ ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/touch_selection.html")); |
+ InitSelectionController(); |
+ |
+ RenderWidgetHostViewAura* rwhva = GetRenderWidgetHostViewAura(); |
+ |
+ // Tap inside the textfield and wait for the insertion cursor. |
+ selection_controller_client()->InitWaitForSelectionEvent( |
+ ui::INSERTION_HANDLE_SHOWN); |
+ |
+ gfx::PointF point; |
+ ASSERT_TRUE(GetPointInsideTextfield(&point)); |
+ ui::GestureEventDetails tap_details(ui::ET_GESTURE_TAP); |
+ 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(); |
+ |
+ EXPECT_EQ(ui::TouchSelectionController::INSERTION_ACTIVE, |
+ rwhva->selection_controller()->active_status()); |
+ |
+ gfx::RectF initial_handle_rect = |
+ rwhva->selection_controller()->GetStartHandleRect(); |
+ |
+ // Move the insertion handle. Touch the handle first. |
+ gfx::Point handle_point = |
+ gfx::ToRoundedPoint(initial_handle_rect.CenterPoint()); |
+ |
+ selection_controller_client()->InitWaitForSelectionEvent( |
+ ui::INSERTION_HANDLE_DRAG_STARTED); |
+ ui::TouchEvent touch_down(ui::ET_TOUCH_PRESSED, handle_point, 0, |
+ ui::EventTimeForNow()); |
+ rwhva->OnTouchEvent(&touch_down); |
+ selection_controller_client()->Wait(); |
+ |
+ // Move it. |
+ selection_controller_client()->InitWaitForSelectionEvent( |
+ ui::INSERTION_HANDLE_MOVED); |
+ handle_point.Offset(10, 0); |
+ ui::TouchEvent touch_move(ui::ET_TOUCH_MOVED, handle_point, 0, |
+ ui::EventTimeForNow()); |
+ rwhva->OnTouchEvent(&touch_move); |
+ selection_controller_client()->Wait(); |
+ |
+ // Then release. |
+ selection_controller_client()->InitWaitForSelectionEvent( |
+ ui::INSERTION_HANDLE_DRAG_STOPPED); |
+ ui::TouchEvent touch_up(ui::ET_TOUCH_RELEASED, handle_point, 0, |
+ ui::EventTimeForNow()); |
+ rwhva->OnTouchEvent(&touch_up); |
+ selection_controller_client()->Wait(); |
+ |
+ gfx::RectF moved_handle_rect = |
+ rwhva->selection_controller()->GetStartHandleRect(); |
+ |
+ // The handle should have moved to right. |
+ EXPECT_EQ(initial_handle_rect.y(), moved_handle_rect.y()); |
+ EXPECT_LT(initial_handle_rect.x(), moved_handle_rect.x()); |
+ |
+ EXPECT_EQ(ui::TouchSelectionController::INSERTION_ACTIVE, |
+ rwhva->selection_controller()->active_status()); |
+} |
+ |
} // namespace content |