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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 controller().OnTapEvent(); | 902 controller().OnTapEvent(); |
903 EXPECT_THAT(GetAndResetEvents(), IsEmpty()); | 903 EXPECT_THAT(GetAndResetEvents(), IsEmpty()); |
904 EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart()); | 904 EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart()); |
905 | 905 |
906 controller().OnTapEvent(); | 906 controller().OnTapEvent(); |
907 ClearSelection(); | 907 ClearSelection(); |
908 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_CLEARED)); | 908 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_CLEARED)); |
909 EXPECT_EQ(gfx::PointF(), GetLastEventStart()); | 909 EXPECT_EQ(gfx::PointF(), GetLastEventStart()); |
910 } | 910 } |
911 | 911 |
| 912 TEST_F(TouchSelectionControllerTest, NoSelectionAfterLongpressThenTap) { |
| 913 gfx::RectF start_rect(5, 5, 0, 10); |
| 914 gfx::RectF end_rect(50, 5, 0, 10); |
| 915 bool visible = true; |
| 916 |
| 917 // Tap-triggered selections should not be allowed. |
| 918 controller().OnLongPressEvent(); |
| 919 controller().OnTapEvent(); |
| 920 ChangeSelection(start_rect, visible, end_rect, visible); |
| 921 EXPECT_THAT(GetAndResetEvents(), IsEmpty()); |
| 922 |
| 923 // Subsequent longpress selections will be allowed. |
| 924 controller().OnLongPressEvent(); |
| 925 ChangeSelection(start_rect, visible, end_rect, visible); |
| 926 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_SHOWN)); |
| 927 } |
| 928 |
912 TEST_F(TouchSelectionControllerTest, AllowShowingFromCurrentSelection) { | 929 TEST_F(TouchSelectionControllerTest, AllowShowingFromCurrentSelection) { |
913 gfx::RectF start_rect(5, 5, 0, 10); | 930 gfx::RectF start_rect(5, 5, 0, 10); |
914 gfx::RectF end_rect(50, 5, 0, 10); | 931 gfx::RectF end_rect(50, 5, 0, 10); |
915 bool visible = true; | 932 bool visible = true; |
916 | 933 |
917 // The selection should not be activated, as it wasn't yet allowed. | 934 // The selection should not be activated, as it wasn't yet allowed. |
918 ChangeSelection(start_rect, visible, end_rect, visible); | 935 ChangeSelection(start_rect, visible, end_rect, visible); |
919 EXPECT_EQ(gfx::PointF(), GetLastEventStart()); | 936 EXPECT_EQ(gfx::PointF(), GetLastEventStart()); |
920 | 937 |
921 // Now explicitly allow showing from the previously supplied bounds. | 938 // Now explicitly allow showing from the previously supplied bounds. |
(...skipping 17 matching lines...) Expand all Loading... |
939 controller().OnSelectionEmpty(false); | 956 controller().OnSelectionEmpty(false); |
940 controller().HideAndDisallowShowingAutomatically(); | 957 controller().HideAndDisallowShowingAutomatically(); |
941 gfx::RectF insertion_rect(5, 5, 0, 10); | 958 gfx::RectF insertion_rect(5, 5, 0, 10); |
942 ChangeInsertion(insertion_rect, visible); | 959 ChangeInsertion(insertion_rect, visible); |
943 controller().AllowShowingFromCurrentSelection(); | 960 controller().AllowShowingFromCurrentSelection(); |
944 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_SHOWN)); | 961 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_SHOWN)); |
945 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventStart()); | 962 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventStart()); |
946 } | 963 } |
947 | 964 |
948 } // namespace ui | 965 } // namespace ui |
OLD | NEW |