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

Side by Side Diff: ui/views/controls/label_unittest.cc

Issue 2786693002: Add PointerDetails to ui::MouseEvent's constructors (Closed)
Patch Set: mouse event constructor Created 3 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/views/controls/label.h" 5 #include "ui/views/controls/label.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 152 }
153 153
154 protected: 154 protected:
155 View* GetFocusedView() { 155 View* GetFocusedView() {
156 return widget()->GetFocusManager()->GetFocusedView(); 156 return widget()->GetFocusManager()->GetFocusedView();
157 } 157 }
158 158
159 void PerformMousePress(const gfx::Point& point, int extra_flags = 0) { 159 void PerformMousePress(const gfx::Point& point, int extra_flags = 0) {
160 ui::MouseEvent pressed_event = ui::MouseEvent( 160 ui::MouseEvent pressed_event = ui::MouseEvent(
161 ui::ET_MOUSE_PRESSED, point, point, ui::EventTimeForNow(), 161 ui::ET_MOUSE_PRESSED, point, point, ui::EventTimeForNow(),
162 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON | extra_flags); 162 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON | extra_flags,
163 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
163 label()->OnMousePressed(pressed_event); 164 label()->OnMousePressed(pressed_event);
164 } 165 }
165 166
166 void PerformMouseRelease(const gfx::Point& point) { 167 void PerformMouseRelease(const gfx::Point& point) {
167 ui::MouseEvent released_event = ui::MouseEvent( 168 ui::MouseEvent released_event = ui::MouseEvent(
168 ui::ET_MOUSE_RELEASED, point, point, ui::EventTimeForNow(), 169 ui::ET_MOUSE_RELEASED, point, point, ui::EventTimeForNow(),
169 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); 170 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
171 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
170 label()->OnMouseReleased(released_event); 172 label()->OnMouseReleased(released_event);
171 } 173 }
172 174
173 void PerformClick(const gfx::Point& point, int extra_flags = 0) { 175 void PerformClick(const gfx::Point& point, int extra_flags = 0) {
174 PerformMousePress(point, extra_flags); 176 PerformMousePress(point, extra_flags);
175 PerformMouseRelease(point); 177 PerformMouseRelease(point);
176 } 178 }
177 179
178 void PerformMouseDragTo(const gfx::Point& point) { 180 void PerformMouseDragTo(const gfx::Point& point) {
179 ui::MouseEvent drag(ui::ET_MOUSE_DRAGGED, point, point, 181 ui::MouseEvent drag(
180 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); 182 ui::ET_MOUSE_DRAGGED, point, point, ui::EventTimeForNow(),
183 ui::EF_LEFT_MOUSE_BUTTON, 0,
184 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
181 label()->OnMouseDragged(drag); 185 label()->OnMouseDragged(drag);
182 } 186 }
183 187
184 // Used to force layout on the underlying RenderText instance. 188 // Used to force layout on the underlying RenderText instance.
185 void SimulatePaint() { 189 void SimulatePaint() {
186 gfx::Canvas canvas; 190 gfx::Canvas canvas;
187 label()->OnPaint(&canvas); 191 label()->OnPaint(&canvas);
188 } 192 }
189 193
190 gfx::Point GetCursorPoint(int index) { 194 gfx::Point GetCursorPoint(int index) {
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 label()->SetObscured(false); 1117 label()->SetObscured(false);
1114 1118
1115 // For an empty label, both COPY and SELECT_ALL should be disabled. 1119 // For an empty label, both COPY and SELECT_ALL should be disabled.
1116 label()->SetText(base::string16()); 1120 label()->SetText(base::string16());
1117 ASSERT_TRUE(label()->SetSelectable(true)); 1121 ASSERT_TRUE(label()->SetSelectable(true));
1118 EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_COPY)); 1122 EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_COPY));
1119 EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_SELECT_ALL)); 1123 EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_SELECT_ALL));
1120 } 1124 }
1121 1125
1122 } // namespace views 1126 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698