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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 | 939 |
940 TEST_F(TouchSelectionControllerTest, AllowShowingFromCurrentSelection) { | 940 TEST_F(TouchSelectionControllerTest, AllowShowingFromCurrentSelection) { |
941 gfx::RectF start_rect(5, 5, 0, 10); | 941 gfx::RectF start_rect(5, 5, 0, 10); |
942 gfx::RectF end_rect(50, 5, 0, 10); | 942 gfx::RectF end_rect(50, 5, 0, 10); |
943 bool visible = true; | 943 bool visible = true; |
944 | 944 |
945 // The selection should not be activated, as it wasn't yet allowed. | 945 // The selection should not be activated, as it wasn't yet allowed. |
946 ChangeSelection(start_rect, visible, end_rect, visible); | 946 ChangeSelection(start_rect, visible, end_rect, visible); |
947 EXPECT_EQ(gfx::PointF(), GetLastEventStart()); | 947 EXPECT_EQ(gfx::PointF(), GetLastEventStart()); |
948 | 948 |
| 949 // A longpress should have no immediate effect. |
| 950 controller().OnLongPressEvent(); |
| 951 |
949 // Now explicitly allow showing from the previously supplied bounds. | 952 // Now explicitly allow showing from the previously supplied bounds. |
950 controller().AllowShowingFromCurrentSelection(); | 953 controller().AllowShowingFromCurrentSelection(); |
951 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_SHOWN)); | 954 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_SHOWN)); |
952 EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart()); | 955 EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart()); |
953 | 956 |
954 // Repeated calls to show from the current selection should be ignored. | 957 // Repeated calls to show from the current selection should be ignored. |
955 controller().AllowShowingFromCurrentSelection(); | 958 controller().AllowShowingFromCurrentSelection(); |
956 EXPECT_THAT(GetAndResetEvents(), IsEmpty()); | 959 EXPECT_THAT(GetAndResetEvents(), IsEmpty()); |
957 EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart()); | 960 EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart()); |
958 | 961 |
959 // Trying to show from an empty selection will have no result. | 962 // Trying to show from an empty selection will have no result. |
960 ClearSelection(); | 963 ClearSelection(); |
961 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_CLEARED)); | 964 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_CLEARED)); |
962 controller().AllowShowingFromCurrentSelection(); | 965 controller().AllowShowingFromCurrentSelection(); |
963 EXPECT_THAT(GetAndResetEvents(), IsEmpty()); | 966 EXPECT_THAT(GetAndResetEvents(), IsEmpty()); |
964 | 967 |
965 // Showing the insertion handle should also be supported. | 968 // Showing the insertion handle should also be supported. |
966 controller().OnSelectionEditable(true); | 969 controller().OnSelectionEditable(true); |
967 controller().OnSelectionEmpty(false); | 970 controller().OnSelectionEmpty(false); |
968 controller().HideAndDisallowShowingAutomatically(); | 971 controller().HideAndDisallowShowingAutomatically(); |
969 gfx::RectF insertion_rect(5, 5, 0, 10); | 972 gfx::RectF insertion_rect(5, 5, 0, 10); |
970 ChangeInsertion(insertion_rect, visible); | 973 ChangeInsertion(insertion_rect, visible); |
971 controller().AllowShowingFromCurrentSelection(); | 974 controller().AllowShowingFromCurrentSelection(); |
972 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_SHOWN)); | 975 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_SHOWN)); |
973 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventStart()); | 976 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventStart()); |
974 } | 977 } |
975 | 978 |
976 } // namespace ui | 979 } // namespace ui |
OLD | NEW |