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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 EXPECT_FALSE(GetAndResetNeedsAnimate()); | 645 EXPECT_FALSE(GetAndResetNeedsAnimate()); |
646 | 646 |
647 visible = true; | 647 visible = true; |
648 ChangeInsertion(insertion_rect, visible); | 648 ChangeInsertion(insertion_rect, visible); |
649 EXPECT_FALSE(GetAndResetNeedsAnimate()); | 649 EXPECT_FALSE(GetAndResetNeedsAnimate()); |
650 | 650 |
651 controller().SetTemporarilyHidden(false); | 651 controller().SetTemporarilyHidden(false); |
652 EXPECT_TRUE(GetAndResetNeedsAnimate()); | 652 EXPECT_TRUE(GetAndResetNeedsAnimate()); |
653 } | 653 } |
654 | 654 |
| 655 TEST_F(TouchSelectionControllerTest, SelectionClearOnTap) { |
| 656 gfx::RectF start_rect(5, 5, 0, 10); |
| 657 gfx::RectF end_rect(50, 5, 0, 10); |
| 658 bool visible = true; |
| 659 |
| 660 controller().OnLongPressEvent(); |
| 661 ChangeSelection(start_rect, visible, end_rect, visible); |
| 662 |
| 663 // Selection should not be cleared if the selection bounds have not changed. |
| 664 controller().OnTapEvent(); |
| 665 EXPECT_EQ(SELECTION_SHOWN, GetLastEventType()); |
| 666 EXPECT_EQ(start_rect.bottom_left(), GetLastEventAnchor()); |
| 667 |
| 668 controller().OnTapEvent(); |
| 669 ClearSelection(); |
| 670 EXPECT_EQ(SELECTION_CLEARED, GetLastEventType()); |
| 671 EXPECT_EQ(gfx::PointF(), GetLastEventAnchor()); |
| 672 } |
| 673 |
655 } // namespace content | 674 } // namespace content |
OLD | NEW |