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

Side by Side Diff: content/browser/renderer_host/input/touch_selection_controller_unittest.cc

Issue 494823002: Plumb selection edge points through the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 4 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 "content/browser/renderer_host/input/touch_selection_controller.h" 5 #include "content/browser/renderer_host/input/touch_selection_controller.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/events/test/mock_motion_event.h" 8 #include "ui/events/test/mock_motion_event.h"
9 9
10 using ui::test::MockMotionEvent; 10 using ui::test::MockMotionEvent;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() OVERRIDE { 79 virtual scoped_ptr<TouchHandleDrawable> CreateDrawable() OVERRIDE {
80 return scoped_ptr<TouchHandleDrawable>( 80 return scoped_ptr<TouchHandleDrawable>(
81 new MockTouchHandleDrawable(&dragging_enabled_)); 81 new MockTouchHandleDrawable(&dragging_enabled_));
82 } 82 }
83 83
84 void SetAnimationEnabled(bool enabled) { animation_enabled_ = enabled; } 84 void SetAnimationEnabled(bool enabled) { animation_enabled_ = enabled; }
85 void SetDraggingEnabled(bool enabled) { dragging_enabled_ = enabled; } 85 void SetDraggingEnabled(bool enabled) { dragging_enabled_ = enabled; }
86 86
87 void ClearSelection() { 87 void ClearSelection() {
88 controller_->OnSelectionBoundsChanged(gfx::RectF(), 88 controller_->OnSelectionBoundsChanged(cc::ViewportSelectionBound(),
89 TOUCH_HANDLE_ORIENTATION_UNDEFINED, 89 cc::ViewportSelectionBound());
90 false,
91 gfx::RectF(),
92 TOUCH_HANDLE_ORIENTATION_UNDEFINED,
93 false);
94 } 90 }
95 91
96 void ClearInsertion() { ClearSelection(); } 92 void ClearInsertion() { ClearSelection(); }
97 93
98 void ChangeInsertion(const gfx::RectF& rect,
99 TouchHandleOrientation orientation,
100 bool visible) {
101 controller_->OnSelectionBoundsChanged(
102 rect, orientation, visible, rect, orientation, visible);
103 }
104
105 void ChangeInsertion(const gfx::RectF& rect, bool visible) { 94 void ChangeInsertion(const gfx::RectF& rect, bool visible) {
106 ChangeInsertion(rect, TOUCH_HANDLE_CENTER, visible); 95 cc::ViewportSelectionBound bound;
107 } 96 bound.type = cc::SELECTION_BOUND_CENTER;
108 97 bound.edge_top = rect.origin();
109 void ChangeSelection(const gfx::RectF& start_rect, 98 bound.edge_bottom = rect.bottom_left();
110 TouchHandleOrientation start_orientation, 99 bound.visible = visible;
111 bool start_visible, 100 controller_->OnSelectionBoundsChanged(bound, bound);
112 const gfx::RectF& end_rect,
113 TouchHandleOrientation end_orientation,
114 bool end_visible) {
115 controller_->OnSelectionBoundsChanged(start_rect,
116 start_orientation,
117 start_visible,
118 end_rect,
119 end_orientation,
120 end_visible);
121 } 101 }
122 102
123 void ChangeSelection(const gfx::RectF& start_rect, 103 void ChangeSelection(const gfx::RectF& start_rect,
124 bool start_visible, 104 bool start_visible,
125 const gfx::RectF& end_rect, 105 const gfx::RectF& end_rect,
126 bool end_visible) { 106 bool end_visible) {
127 ChangeSelection(start_rect, 107 cc::ViewportSelectionBound start_bound, end_bound;
128 TOUCH_HANDLE_LEFT, 108 start_bound.type = cc::SELECTION_BOUND_LEFT;
129 start_visible, 109 end_bound.type = cc::SELECTION_BOUND_RIGHT;
130 end_rect, 110 start_bound.edge_top = start_rect.origin();
131 TOUCH_HANDLE_RIGHT, 111 start_bound.edge_bottom = start_rect.bottom_left();
132 end_visible); 112 end_bound.edge_top = end_rect.origin();
113 end_bound.edge_bottom = end_rect.bottom_left();
114 start_bound.visible = start_visible;
115 end_bound.visible = end_visible;
116 controller_->OnSelectionBoundsChanged(start_bound, end_bound);
133 } 117 }
134 118
135 void Animate() { 119 void Animate() {
136 base::TimeTicks now = base::TimeTicks::Now(); 120 base::TimeTicks now = base::TimeTicks::Now();
137 while (needs_animate_) { 121 while (needs_animate_) {
138 needs_animate_ = controller_->Animate(now); 122 needs_animate_ = controller_->Animate(now);
139 now += base::TimeDelta::FromMilliseconds(16); 123 now += base::TimeDelta::FromMilliseconds(16);
140 } 124 }
141 } 125 }
142 126
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 EXPECT_EQ(SELECTION_SHOWN, GetLastEventType()); 649 EXPECT_EQ(SELECTION_SHOWN, GetLastEventType());
666 EXPECT_EQ(start_rect.bottom_left(), GetLastEventAnchor()); 650 EXPECT_EQ(start_rect.bottom_left(), GetLastEventAnchor());
667 651
668 controller().OnTapEvent(); 652 controller().OnTapEvent();
669 ClearSelection(); 653 ClearSelection();
670 EXPECT_EQ(SELECTION_CLEARED, GetLastEventType()); 654 EXPECT_EQ(SELECTION_CLEARED, GetLastEventType());
671 EXPECT_EQ(gfx::PointF(), GetLastEventAnchor()); 655 EXPECT_EQ(gfx::PointF(), GetLastEventAnchor());
672 } 656 }
673 657
674 } // namespace content 658 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698