OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents/touch_editable_impl_aura.h" | 5 #include "content/browser/web_contents/touch_editable_impl_aura.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 value->GetAsString(&selection); | 197 value->GetAsString(&selection); |
198 | 198 |
199 // Check if selection handles are showing. | 199 // Check if selection handles are showing. |
200 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); | 200 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); |
201 EXPECT_STREQ("Some text we can select", selection.c_str()); | 201 EXPECT_STREQ("Some text we can select", selection.c_str()); |
202 | 202 |
203 // Lets move the handles a bit to modify the selection | 203 // Lets move the handles a bit to modify the selection |
204 touch_editable->Reset(); | 204 touch_editable->Reset(); |
205 ui::SelectionBound anchor, focus; | 205 ui::SelectionBound anchor, focus; |
206 touch_editable->GetSelectionEndPoints(&anchor, &focus); | 206 touch_editable->GetSelectionEndPoints(&anchor, &focus); |
| 207 // The distance by which a handle image is offset from the bottom of the |
| 208 // selection/text baseline. |
| 209 const int kSelectionHandleVerticalVisualOffset = 2; |
207 int handle_grab_x = bounds.x() + anchor.edge_bottom_rounded().x(); | 210 int handle_grab_x = bounds.x() + anchor.edge_bottom_rounded().x(); |
208 int handle_grab_y = bounds.y() + anchor.edge_bottom_rounded().y() + 1; | 211 int handle_grab_y = bounds.y() + anchor.edge_bottom_rounded().y() + |
| 212 kSelectionHandleVerticalVisualOffset + 1; |
209 generator.GestureScrollSequence( | 213 generator.GestureScrollSequence( |
210 gfx::Point(handle_grab_x, handle_grab_y), | 214 gfx::Point(handle_grab_x, handle_grab_y), |
211 gfx::Point(handle_grab_x + 20, handle_grab_y), | 215 gfx::Point(handle_grab_x + 20, handle_grab_y), |
212 base::TimeDelta::FromMilliseconds(20), | 216 base::TimeDelta::FromMilliseconds(20), |
213 5); | 217 5); |
214 touch_editable->WaitForSelectionChangeCallback(); | 218 touch_editable->WaitForSelectionChangeCallback(); |
215 | 219 |
216 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); | 220 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); |
217 value = content::ExecuteScriptAndGetValue(main_frame, "get_selection()"); | 221 value = content::ExecuteScriptAndGetValue(main_frame, "get_selection()"); |
218 value->GetAsString(&selection); | 222 value->GetAsString(&selection); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 value = content::ExecuteScriptAndGetValue(main_frame, | 459 value = content::ExecuteScriptAndGetValue(main_frame, |
456 "get_cursor_position()"); | 460 "get_cursor_position()"); |
457 int new_cursor_pos = -1; | 461 int new_cursor_pos = -1; |
458 value->GetAsInteger(&new_cursor_pos); | 462 value->GetAsInteger(&new_cursor_pos); |
459 EXPECT_NE(-1, new_cursor_pos); | 463 EXPECT_NE(-1, new_cursor_pos); |
460 // Cursor should have moved. | 464 // Cursor should have moved. |
461 EXPECT_NE(new_cursor_pos, cursor_pos); | 465 EXPECT_NE(new_cursor_pos, cursor_pos); |
462 } | 466 } |
463 | 467 |
464 } // namespace content | 468 } // namespace content |
OLD | NEW |