| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.h" | 5 #include "content/browser/renderer_host/input/touch_selection_controller.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/events/test/mock_motion_event.h" | 8 #include "ui/events/test/mock_motion_event.h" |
| 9 | 9 |
| 10 using ui::test::MockMotionEvent; | 10 using ui::test::MockMotionEvent; |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 start_rect.Offset(1, 0); | 471 start_rect.Offset(1, 0); |
| 472 ChangeSelection(start_rect, visible, end_rect, visible); | 472 ChangeSelection(start_rect, visible, end_rect, visible); |
| 473 // Selection movement does not currently trigger a separate event. | 473 // Selection movement does not currently trigger a separate event. |
| 474 EXPECT_EQ(SELECTION_SHOWN, GetLastEventType()); | 474 EXPECT_EQ(SELECTION_SHOWN, GetLastEventType()); |
| 475 | 475 |
| 476 ClearSelection(); | 476 ClearSelection(); |
| 477 EXPECT_EQ(SELECTION_CLEARED, GetLastEventType()); | 477 EXPECT_EQ(SELECTION_CLEARED, GetLastEventType()); |
| 478 EXPECT_EQ(gfx::PointF(), GetLastEventAnchor()); | 478 EXPECT_EQ(gfx::PointF(), GetLastEventAnchor()); |
| 479 } | 479 } |
| 480 | 480 |
| 481 TEST_F(TouchSelectionControllerTest, SelectionRepeatedLongPress) { |
| 482 gfx::RectF start_rect(5, 5, 0, 10); |
| 483 gfx::RectF end_rect(50, 5, 0, 10); |
| 484 bool visible = true; |
| 485 |
| 486 controller().OnLongPressEvent(); |
| 487 ChangeSelection(start_rect, visible, end_rect, visible); |
| 488 EXPECT_EQ(SELECTION_SHOWN, GetLastEventType()); |
| 489 EXPECT_EQ(start_rect.bottom_left(), GetLastEventAnchor()); |
| 490 |
| 491 // A long press triggering a new selection should re-send the SELECTION_SHOWN |
| 492 // event notification. |
| 493 start_rect.Offset(10, 10); |
| 494 controller().OnLongPressEvent(); |
| 495 ChangeSelection(start_rect, visible, end_rect, visible); |
| 496 EXPECT_EQ(SELECTION_SHOWN, GetLastEventType()); |
| 497 EXPECT_EQ(start_rect.bottom_left(), GetLastEventAnchor()); |
| 498 } |
| 499 |
| 481 TEST_F(TouchSelectionControllerTest, SelectionDragged) { | 500 TEST_F(TouchSelectionControllerTest, SelectionDragged) { |
| 482 base::TimeTicks event_time = base::TimeTicks::Now(); | 501 base::TimeTicks event_time = base::TimeTicks::Now(); |
| 483 controller().OnLongPressEvent(); | 502 controller().OnLongPressEvent(); |
| 484 | 503 |
| 485 // The touch sequence should not be handled if selection is not active. | 504 // The touch sequence should not be handled if selection is not active. |
| 486 MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, 0, 0); | 505 MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, 0, 0); |
| 487 EXPECT_FALSE(controller().WillHandleTouchEvent(event)); | 506 EXPECT_FALSE(controller().WillHandleTouchEvent(event)); |
| 488 | 507 |
| 489 float line_height = 10.f; | 508 float line_height = 10.f; |
| 490 gfx::RectF start_rect(0, 0, 0, line_height); | 509 gfx::RectF start_rect(0, 0, 0, line_height); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 | 642 |
| 624 visible = true; | 643 visible = true; |
| 625 ChangeInsertion(insertion_rect, visible); | 644 ChangeInsertion(insertion_rect, visible); |
| 626 EXPECT_FALSE(GetAndResetNeedsAnimate()); | 645 EXPECT_FALSE(GetAndResetNeedsAnimate()); |
| 627 | 646 |
| 628 controller().SetTemporarilyHidden(false); | 647 controller().SetTemporarilyHidden(false); |
| 629 EXPECT_TRUE(GetAndResetNeedsAnimate()); | 648 EXPECT_TRUE(GetAndResetNeedsAnimate()); |
| 630 } | 649 } |
| 631 | 650 |
| 632 } // namespace content | 651 } // namespace content |
| OLD | NEW |