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

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

Issue 2034863002: Move SelectionBound from ui/base/touch to ui/gfx to be used by cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated views_unittests Created 4 years, 6 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 "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 void EnableLongPressDragSelection() { 115 void EnableLongPressDragSelection() {
116 TouchSelectionController::Config config = DefaultConfig(); 116 TouchSelectionController::Config config = DefaultConfig();
117 config.enable_longpress_drag_selection = true; 117 config.enable_longpress_drag_selection = true;
118 controller_.reset(new TouchSelectionController(this, config)); 118 controller_.reset(new TouchSelectionController(this, config));
119 } 119 }
120 120
121 void SetAnimationEnabled(bool enabled) { animation_enabled_ = enabled; } 121 void SetAnimationEnabled(bool enabled) { animation_enabled_ = enabled; }
122 void SetDraggingEnabled(bool enabled) { dragging_enabled_ = enabled; } 122 void SetDraggingEnabled(bool enabled) { dragging_enabled_ = enabled; }
123 123
124 void ClearSelection() { 124 void ClearSelection() {
125 controller_->OnSelectionBoundsChanged(SelectionBound(), 125 controller_->OnSelectionBoundsChanged(gfx::SelectionBound(),
126 SelectionBound()); 126 gfx::SelectionBound());
127 } 127 }
128 128
129 void ClearInsertion() { ClearSelection(); } 129 void ClearInsertion() { ClearSelection(); }
130 130
131 void ChangeInsertion(const gfx::RectF& rect, bool visible) { 131 void ChangeInsertion(const gfx::RectF& rect, bool visible) {
132 SelectionBound bound; 132 gfx::SelectionBound bound;
133 bound.set_type(SelectionBound::CENTER); 133 bound.set_type(gfx::SelectionBound::CENTER);
134 bound.SetEdge(rect.origin(), rect.bottom_left()); 134 bound.SetEdge(rect.origin(), rect.bottom_left());
135 bound.set_visible(visible); 135 bound.set_visible(visible);
136 controller_->OnSelectionBoundsChanged(bound, bound); 136 controller_->OnSelectionBoundsChanged(bound, bound);
137 } 137 }
138 138
139 void ChangeSelection(const gfx::RectF& start_rect, 139 void ChangeSelection(const gfx::RectF& start_rect,
140 bool start_visible, 140 bool start_visible,
141 const gfx::RectF& end_rect, 141 const gfx::RectF& end_rect,
142 bool end_visible) { 142 bool end_visible) {
143 SelectionBound start_bound, end_bound; 143 gfx::SelectionBound start_bound, end_bound;
144 start_bound.set_type(SelectionBound::LEFT); 144 start_bound.set_type(gfx::SelectionBound::LEFT);
145 end_bound.set_type(SelectionBound::RIGHT); 145 end_bound.set_type(gfx::SelectionBound::RIGHT);
146 start_bound.SetEdge(start_rect.origin(), start_rect.bottom_left()); 146 start_bound.SetEdge(start_rect.origin(), start_rect.bottom_left());
147 end_bound.SetEdge(end_rect.origin(), end_rect.bottom_left()); 147 end_bound.SetEdge(end_rect.origin(), end_rect.bottom_left());
148 start_bound.set_visible(start_visible); 148 start_bound.set_visible(start_visible);
149 end_bound.set_visible(end_visible); 149 end_bound.set_visible(end_visible);
150 controller_->OnSelectionBoundsChanged(start_bound, end_bound); 150 controller_->OnSelectionBoundsChanged(start_bound, end_bound);
151 } 151 }
152 152
153 void OnLongPressEvent() { 153 void OnLongPressEvent() {
154 ASSERT_FALSE(controller().WillHandleLongPressEvent(base::TimeTicks(), 154 ASSERT_FALSE(controller().WillHandleLongPressEvent(base::TimeTicks(),
155 kIgnoredPoint)); 155 kIgnoredPoint));
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 offset_rect.x(), offset_rect.bottom()); 1475 offset_rect.x(), offset_rect.bottom());
1476 EXPECT_TRUE(controller().WillHandleTouchEvent(event)); 1476 EXPECT_TRUE(controller().WillHandleTouchEvent(event));
1477 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_HANDLE_DRAG_STOPPED)); 1477 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_HANDLE_DRAG_STOPPED));
1478 EXPECT_EQ(test_controller.GetStartHandleOrientation(), 1478 EXPECT_EQ(test_controller.GetStartHandleOrientation(),
1479 TouchHandleOrientation::LEFT); 1479 TouchHandleOrientation::LEFT);
1480 EXPECT_EQ(test_controller.GetEndHandleOrientation(), 1480 EXPECT_EQ(test_controller.GetEndHandleOrientation(),
1481 TouchHandleOrientation::RIGHT); 1481 TouchHandleOrientation::RIGHT);
1482 } 1482 }
1483 1483
1484 } // namespace ui 1484 } // namespace ui
OLDNEW
« no previous file with comments | « ui/touch_selection/touch_selection_controller.cc ('k') | ui/touch_selection/ui_touch_selection.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698