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

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

Issue 698253004: Reland: Implement Aura side of unified touch text selection for contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased after addition of touch_handle_orientation file Created 5 years, 9 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
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 this, 110 this,
111 base::TimeDelta::FromMilliseconds(kDefaultTapTimeoutMs), 111 base::TimeDelta::FromMilliseconds(kDefaultTapTimeoutMs),
112 kDefaulTapSlop, 112 kDefaulTapSlop,
113 show_on_tap_for_empty_editable)); 113 show_on_tap_for_empty_editable));
114 } 114 }
115 115
116 void SetAnimationEnabled(bool enabled) { animation_enabled_ = enabled; } 116 void SetAnimationEnabled(bool enabled) { animation_enabled_ = enabled; }
117 void SetDraggingEnabled(bool enabled) { dragging_enabled_ = enabled; } 117 void SetDraggingEnabled(bool enabled) { dragging_enabled_ = enabled; }
118 118
119 void ClearSelection() { 119 void ClearSelection() {
120 controller_->OnSelectionBoundsChanged(SelectionBound(), 120 controller_->OnSelectionBoundsUpdated(SelectionBound(),
121 SelectionBound()); 121 SelectionBound());
122 } 122 }
123 123
124 void ClearInsertion() { ClearSelection(); } 124 void ClearInsertion() { ClearSelection(); }
125 125
126 void ChangeInsertion(const gfx::RectF& rect, bool visible) { 126 void ChangeInsertion(const gfx::RectF& rect, bool visible) {
127 SelectionBound bound; 127 SelectionBound bound;
128 bound.set_type(SelectionBound::CENTER); 128 bound.set_type(SelectionBound::CENTER);
129 bound.SetEdge(rect.origin(), rect.bottom_left()); 129 bound.SetEdge(rect.origin(), rect.bottom_left());
130 bound.set_visible(visible); 130 bound.set_visible(visible);
131 controller_->OnSelectionBoundsChanged(bound, bound); 131 controller_->OnSelectionBoundsUpdated(bound, bound);
132 } 132 }
133 133
134 void ChangeSelection(const gfx::RectF& start_rect, 134 void ChangeSelection(const gfx::RectF& start_rect,
135 bool start_visible, 135 bool start_visible,
136 const gfx::RectF& end_rect, 136 const gfx::RectF& end_rect,
137 bool end_visible) { 137 bool end_visible) {
138 SelectionBound start_bound, end_bound; 138 SelectionBound start_bound, end_bound;
139 start_bound.set_type(SelectionBound::LEFT); 139 start_bound.set_type(SelectionBound::LEFT);
140 end_bound.set_type(SelectionBound::RIGHT); 140 end_bound.set_type(SelectionBound::RIGHT);
141 start_bound.SetEdge(start_rect.origin(), start_rect.bottom_left()); 141 start_bound.SetEdge(start_rect.origin(), start_rect.bottom_left());
142 end_bound.SetEdge(end_rect.origin(), end_rect.bottom_left()); 142 end_bound.SetEdge(end_rect.origin(), end_rect.bottom_left());
143 start_bound.set_visible(start_visible); 143 start_bound.set_visible(start_visible);
144 end_bound.set_visible(end_visible); 144 end_bound.set_visible(end_visible);
145 controller_->OnSelectionBoundsChanged(start_bound, end_bound); 145 controller_->OnSelectionBoundsUpdated(start_bound, end_bound);
146 } 146 }
147 147
148 void Animate() { 148 void Animate() {
149 base::TimeTicks now = base::TimeTicks::Now(); 149 base::TimeTicks now = base::TimeTicks::Now();
150 while (needs_animate_) { 150 while (needs_animate_) {
151 needs_animate_ = controller_->Animate(now); 151 needs_animate_ = controller_->Animate(now);
152 now += base::TimeDelta::FromMilliseconds(16); 152 now += base::TimeDelta::FromMilliseconds(16);
153 } 153 }
154 } 154 }
155 155
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 controller().OnSelectionEmpty(false); 925 controller().OnSelectionEmpty(false);
926 controller().HideAndDisallowShowingAutomatically(); 926 controller().HideAndDisallowShowingAutomatically();
927 gfx::RectF insertion_rect(5, 5, 0, 10); 927 gfx::RectF insertion_rect(5, 5, 0, 10);
928 ChangeInsertion(insertion_rect, visible); 928 ChangeInsertion(insertion_rect, visible);
929 controller().AllowShowingFromCurrentSelection(); 929 controller().AllowShowingFromCurrentSelection();
930 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_SHOWN)); 930 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_SHOWN));
931 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventAnchor()); 931 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventAnchor());
932 } 932 }
933 933
934 } // namespace ui 934 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698