Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: ui/touch_selection/touch_selection_controller_unittest.cc

Issue 1139533006: Revert of Be explicit about forcing TouchSelectionController updates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/touch_selection/touch_selection_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
952 // Now explicitly allow showing from the previously supplied bounds. 949 // Now explicitly allow showing from the previously supplied bounds.
953 controller().AllowShowingFromCurrentSelection(); 950 controller().AllowShowingFromCurrentSelection();
954 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_SHOWN)); 951 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_SHOWN));
955 EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart()); 952 EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart());
956 953
957 // Repeated calls to show from the current selection should be ignored. 954 // Repeated calls to show from the current selection should be ignored.
958 controller().AllowShowingFromCurrentSelection(); 955 controller().AllowShowingFromCurrentSelection();
959 EXPECT_THAT(GetAndResetEvents(), IsEmpty()); 956 EXPECT_THAT(GetAndResetEvents(), IsEmpty());
960 EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart()); 957 EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart());
961 958
962 // Trying to show from an empty selection will have no result. 959 // Trying to show from an empty selection will have no result.
963 ClearSelection(); 960 ClearSelection();
964 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_CLEARED)); 961 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_CLEARED));
965 controller().AllowShowingFromCurrentSelection(); 962 controller().AllowShowingFromCurrentSelection();
966 EXPECT_THAT(GetAndResetEvents(), IsEmpty()); 963 EXPECT_THAT(GetAndResetEvents(), IsEmpty());
967 964
968 // Showing the insertion handle should also be supported. 965 // Showing the insertion handle should also be supported.
969 controller().OnSelectionEditable(true); 966 controller().OnSelectionEditable(true);
970 controller().OnSelectionEmpty(false); 967 controller().OnSelectionEmpty(false);
971 controller().HideAndDisallowShowingAutomatically(); 968 controller().HideAndDisallowShowingAutomatically();
972 gfx::RectF insertion_rect(5, 5, 0, 10); 969 gfx::RectF insertion_rect(5, 5, 0, 10);
973 ChangeInsertion(insertion_rect, visible); 970 ChangeInsertion(insertion_rect, visible);
974 controller().AllowShowingFromCurrentSelection(); 971 controller().AllowShowingFromCurrentSelection();
975 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_SHOWN)); 972 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_SHOWN));
976 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventStart()); 973 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventStart());
977 } 974 }
978 975
979 } // namespace ui 976 } // namespace ui
OLDNEW
« no previous file with comments | « ui/touch_selection/touch_selection_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698