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

Side by Side Diff: ui/message_center/views/custom_notification_view_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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 views::ViewsTestBase::TearDown(); 217 views::ViewsTestBase::TearDown();
218 } 218 }
219 219
220 SkColor GetBackgroundColor() const { 220 SkColor GetBackgroundColor() const {
221 return notification_view_->background_view()->background()->get_color(); 221 return notification_view_->background_view()->background()->get_color();
222 } 222 }
223 223
224 void PerformClick(const gfx::Point& point) { 224 void PerformClick(const gfx::Point& point) {
225 ui::MouseEvent pressed_event = ui::MouseEvent( 225 ui::MouseEvent pressed_event = ui::MouseEvent(
226 ui::ET_MOUSE_PRESSED, point, point, ui::EventTimeForNow(), 226 ui::ET_MOUSE_PRESSED, point, point, ui::EventTimeForNow(),
227 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); 227 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
228 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
228 widget()->OnMouseEvent(&pressed_event); 229 widget()->OnMouseEvent(&pressed_event);
229 ui::MouseEvent released_event = ui::MouseEvent( 230 ui::MouseEvent released_event = ui::MouseEvent(
230 ui::ET_MOUSE_RELEASED, point, point, ui::EventTimeForNow(), 231 ui::ET_MOUSE_RELEASED, point, point, ui::EventTimeForNow(),
231 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); 232 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
233 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
232 widget()->OnMouseEvent(&released_event); 234 widget()->OnMouseEvent(&released_event);
233 } 235 }
234 236
235 void PerformKeyEvents(ui::KeyboardCode code) { 237 void PerformKeyEvents(ui::KeyboardCode code) {
236 ui::KeyEvent event1 = ui::KeyEvent(ui::ET_KEY_PRESSED, code, ui::EF_NONE); 238 ui::KeyEvent event1 = ui::KeyEvent(ui::ET_KEY_PRESSED, code, ui::EF_NONE);
237 widget()->OnKeyEvent(&event1); 239 widget()->OnKeyEvent(&event1);
238 ui::KeyEvent event2 = ui::KeyEvent(ui::ET_KEY_RELEASED, code, ui::EF_NONE); 240 ui::KeyEvent event2 = ui::KeyEvent(ui::ET_KEY_RELEASED, code, ui::EF_NONE);
239 widget()->OnKeyEvent(&event2); 241 widget()->OnKeyEvent(&event2);
240 } 242 }
241 243
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 TEST_F(CustomNotificationViewTest, Events) { 280 TEST_F(CustomNotificationViewTest, Events) {
279 widget()->Show(); 281 widget()->Show();
280 custom_view()->RequestFocus(); 282 custom_view()->RequestFocus();
281 283
282 EXPECT_EQ(0, custom_view()->mouse_event_count()); 284 EXPECT_EQ(0, custom_view()->mouse_event_count());
283 gfx::Point cursor_location(1, 1); 285 gfx::Point cursor_location(1, 1);
284 views::View::ConvertPointToWidget(custom_view(), &cursor_location); 286 views::View::ConvertPointToWidget(custom_view(), &cursor_location);
285 PerformClick(cursor_location); 287 PerformClick(cursor_location);
286 EXPECT_EQ(2, custom_view()->mouse_event_count()); 288 EXPECT_EQ(2, custom_view()->mouse_event_count());
287 289
288 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, 290 ui::MouseEvent move(
289 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 291 ui::ET_MOUSE_MOVED, cursor_location, cursor_location,
292 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
293 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
290 widget()->OnMouseEvent(&move); 294 widget()->OnMouseEvent(&move);
291 EXPECT_EQ(3, custom_view()->mouse_event_count()); 295 EXPECT_EQ(3, custom_view()->mouse_event_count());
292 296
293 EXPECT_EQ(0, custom_view()->keyboard_event_count()); 297 EXPECT_EQ(0, custom_view()->keyboard_event_count());
294 KeyPress(ui::VKEY_A); 298 KeyPress(ui::VKEY_A);
295 EXPECT_EQ(1, custom_view()->keyboard_event_count()); 299 EXPECT_EQ(1, custom_view()->keyboard_event_count());
296 } 300 }
297 301
298 TEST_F(CustomNotificationViewTest, SlideOut) { 302 TEST_F(CustomNotificationViewTest, SlideOut) {
299 UpdateNotificationViews(); 303 UpdateNotificationViews();
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 EXPECT_EQ("360x10", size.ToString()); 395 EXPECT_EQ("360x10", size.ToString());
392 396
393 // The long notification. 397 // The long notification.
394 custom_view()->set_preferred_size(gfx::Size(1000, 1000)); 398 custom_view()->set_preferred_size(gfx::Size(1000, 1000));
395 size = notification_view()->GetPreferredSize(); 399 size = notification_view()->GetPreferredSize();
396 size.Enlarge(0, -notification_view()->GetInsets().height()); 400 size.Enlarge(0, -notification_view()->GetInsets().height());
397 EXPECT_EQ("360x1000", size.ToString()); 401 EXPECT_EQ("360x1000", size.ToString());
398 } 402 }
399 403
400 } // namespace message_center 404 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698