| 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 "ui/touch_selection/touch_selection_controller.h" | 5 #include "ui/touch_selection/touch_selection_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 // Start dragging the handle on the small line. | 877 // Start dragging the handle on the small line. |
| 878 MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, | 878 MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, |
| 879 small_line_rect.x(), small_line_rect.y()); | 879 small_line_rect.x(), small_line_rect.y()); |
| 880 SetDraggingEnabled(true); | 880 SetDraggingEnabled(true); |
| 881 EXPECT_TRUE(controller().WillHandleTouchEvent(event)); | 881 EXPECT_TRUE(controller().WillHandleTouchEvent(event)); |
| 882 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_DRAG_STARTED)); | 882 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_DRAG_STARTED)); |
| 883 // The drag coordinate for large lines should be capped to a reasonable | 883 // The drag coordinate for large lines should be capped to a reasonable |
| 884 // offset, allowing seamless transition to neighboring lines with different | 884 // offset, allowing seamless transition to neighboring lines with different |
| 885 // sizes. The drag coordinate for small lines should have an offset | 885 // sizes. The drag coordinate for small lines should have an offset |
| 886 // commensurate with the small line size. | 886 // commensurate with the small line size. |
| 887 EXPECT_EQ(large_line_rect.bottom_left() - gfx::Vector2dF(0, 5.f), | 887 EXPECT_EQ(large_line_rect.bottom_left() - gfx::Vector2dF(0, 8.f), |
| 888 GetLastSelectionStart()); | 888 GetLastSelectionStart()); |
| 889 EXPECT_EQ(small_line_rect.CenterPoint(), GetLastSelectionEnd()); | 889 EXPECT_EQ(small_line_rect.CenterPoint(), GetLastSelectionEnd()); |
| 890 | 890 |
| 891 small_line_rect += gfx::Vector2dF(25.f, 0); | 891 small_line_rect += gfx::Vector2dF(25.f, 0); |
| 892 event = MockMotionEvent(MockMotionEvent::ACTION_MOVE, event_time, | 892 event = MockMotionEvent(MockMotionEvent::ACTION_MOVE, event_time, |
| 893 small_line_rect.x(), small_line_rect.y()); | 893 small_line_rect.x(), small_line_rect.y()); |
| 894 EXPECT_TRUE(controller().WillHandleTouchEvent(event)); | 894 EXPECT_TRUE(controller().WillHandleTouchEvent(event)); |
| 895 EXPECT_TRUE(GetAndResetSelectionMoved()); | 895 EXPECT_TRUE(GetAndResetSelectionMoved()); |
| 896 EXPECT_EQ(small_line_rect.CenterPoint(), GetLastSelectionEnd()); | 896 EXPECT_EQ(small_line_rect.CenterPoint(), GetLastSelectionEnd()); |
| 897 } | 897 } |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 ASSERT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_MOVED)); | 1257 ASSERT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_MOVED)); |
| 1258 EXPECT_EQ(gfx::RectF(6, 5, 44, 10), controller().GetRectBetweenBounds()); | 1258 EXPECT_EQ(gfx::RectF(6, 5, 44, 10), controller().GetRectBetweenBounds()); |
| 1259 EXPECT_EQ(GetLastEventBoundsRect(), controller().GetRectBetweenBounds()); | 1259 EXPECT_EQ(GetLastEventBoundsRect(), controller().GetRectBetweenBounds()); |
| 1260 | 1260 |
| 1261 ClearSelection(); | 1261 ClearSelection(); |
| 1262 ASSERT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_CLEARED)); | 1262 ASSERT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_CLEARED)); |
| 1263 EXPECT_EQ(gfx::RectF(), controller().GetRectBetweenBounds()); | 1263 EXPECT_EQ(gfx::RectF(), controller().GetRectBetweenBounds()); |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 } // namespace ui | 1266 } // namespace ui |
| OLD | NEW |