OLD | NEW |
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/message_center/views/notification_view.h" | 5 #include "ui/message_center/views/notification_view.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 widget()->Show(); | 374 widget()->Show(); |
375 | 375 |
376 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 376 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
377 notification_view()->action_buttons_[0]->state()); | 377 notification_view()->action_buttons_[0]->state()); |
378 | 378 |
379 // Now construct a mouse move event 1 pixel inside the boundary of the action | 379 // Now construct a mouse move event 1 pixel inside the boundary of the action |
380 // button. | 380 // button. |
381 gfx::Point cursor_location(1, 1); | 381 gfx::Point cursor_location(1, 1); |
382 views::View::ConvertPointToWidget(notification_view()->action_buttons_[0], | 382 views::View::ConvertPointToWidget(notification_view()->action_buttons_[0], |
383 &cursor_location); | 383 &cursor_location); |
384 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, | 384 ui::MouseEvent move( |
385 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 385 ui::ET_MOUSE_MOVED, cursor_location, cursor_location, |
| 386 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE, |
| 387 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
386 widget()->OnMouseEvent(&move); | 388 widget()->OnMouseEvent(&move); |
387 | 389 |
388 EXPECT_EQ(views::CustomButton::STATE_HOVERED, | 390 EXPECT_EQ(views::CustomButton::STATE_HOVERED, |
389 notification_view()->action_buttons_[0]->state()); | 391 notification_view()->action_buttons_[0]->state()); |
390 | 392 |
391 notification_view()->CreateOrUpdateViews(*notification()); | 393 notification_view()->CreateOrUpdateViews(*notification()); |
392 | 394 |
393 EXPECT_EQ(views::CustomButton::STATE_HOVERED, | 395 EXPECT_EQ(views::CustomButton::STATE_HOVERED, |
394 notification_view()->action_buttons_[0]->state()); | 396 notification_view()->action_buttons_[0]->state()); |
395 | 397 |
396 // Now construct a mouse move event 1 pixel outside the boundary of the | 398 // Now construct a mouse move event 1 pixel outside the boundary of the |
397 // widget. | 399 // widget. |
398 cursor_location = gfx::Point(-1, -1); | 400 cursor_location = gfx::Point(-1, -1); |
399 move = ui::MouseEvent(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, | 401 move = ui::MouseEvent( |
400 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 402 ui::ET_MOUSE_MOVED, cursor_location, cursor_location, |
| 403 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE, |
| 404 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
401 widget()->OnMouseEvent(&move); | 405 widget()->OnMouseEvent(&move); |
402 | 406 |
403 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 407 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
404 notification_view()->action_buttons_[0]->state()); | 408 notification_view()->action_buttons_[0]->state()); |
405 } | 409 } |
406 | 410 |
407 TEST_F(NotificationViewTest, UpdateButtonCountTest) { | 411 TEST_F(NotificationViewTest, UpdateButtonCountTest) { |
408 notification()->set_buttons(CreateButtons(2)); | 412 notification()->set_buttons(CreateButtons(2)); |
409 notification_view()->CreateOrUpdateViews(*notification()); | 413 notification_view()->CreateOrUpdateViews(*notification()); |
410 widget()->Show(); | 414 widget()->Show(); |
411 | 415 |
412 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 416 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
413 notification_view()->action_buttons_[0]->state()); | 417 notification_view()->action_buttons_[0]->state()); |
414 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 418 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
415 notification_view()->action_buttons_[1]->state()); | 419 notification_view()->action_buttons_[1]->state()); |
416 | 420 |
417 // Now construct a mouse move event 1 pixel inside the boundary of the action | 421 // Now construct a mouse move event 1 pixel inside the boundary of the action |
418 // button. | 422 // button. |
419 gfx::Point cursor_location(1, 1); | 423 gfx::Point cursor_location(1, 1); |
420 views::View::ConvertPointToWidget(notification_view()->action_buttons_[0], | 424 views::View::ConvertPointToWidget(notification_view()->action_buttons_[0], |
421 &cursor_location); | 425 &cursor_location); |
422 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, | 426 ui::MouseEvent move( |
423 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 427 ui::ET_MOUSE_MOVED, cursor_location, cursor_location, |
| 428 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE, |
| 429 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
424 widget()->OnMouseEvent(&move); | 430 widget()->OnMouseEvent(&move); |
425 | 431 |
426 EXPECT_EQ(views::CustomButton::STATE_HOVERED, | 432 EXPECT_EQ(views::CustomButton::STATE_HOVERED, |
427 notification_view()->action_buttons_[0]->state()); | 433 notification_view()->action_buttons_[0]->state()); |
428 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 434 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
429 notification_view()->action_buttons_[1]->state()); | 435 notification_view()->action_buttons_[1]->state()); |
430 | 436 |
431 notification()->set_buttons(CreateButtons(1)); | 437 notification()->set_buttons(CreateButtons(1)); |
432 notification_view()->CreateOrUpdateViews(*notification()); | 438 notification_view()->CreateOrUpdateViews(*notification()); |
433 | 439 |
434 EXPECT_EQ(views::CustomButton::STATE_HOVERED, | 440 EXPECT_EQ(views::CustomButton::STATE_HOVERED, |
435 notification_view()->action_buttons_[0]->state()); | 441 notification_view()->action_buttons_[0]->state()); |
436 EXPECT_EQ(1u, notification_view()->action_buttons_.size()); | 442 EXPECT_EQ(1u, notification_view()->action_buttons_.size()); |
437 | 443 |
438 // Now construct a mouse move event 1 pixel outside the boundary of the | 444 // Now construct a mouse move event 1 pixel outside the boundary of the |
439 // widget. | 445 // widget. |
440 cursor_location = gfx::Point(-1, -1); | 446 cursor_location = gfx::Point(-1, -1); |
441 move = ui::MouseEvent(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, | 447 move = ui::MouseEvent( |
442 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 448 ui::ET_MOUSE_MOVED, cursor_location, cursor_location, |
| 449 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE, |
| 450 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
443 widget()->OnMouseEvent(&move); | 451 widget()->OnMouseEvent(&move); |
444 | 452 |
445 EXPECT_EQ(views::CustomButton::STATE_NORMAL, | 453 EXPECT_EQ(views::CustomButton::STATE_NORMAL, |
446 notification_view()->action_buttons_[0]->state()); | 454 notification_view()->action_buttons_[0]->state()); |
447 } | 455 } |
448 | 456 |
449 TEST_F(NotificationViewTest, ViewOrderingTest) { | 457 TEST_F(NotificationViewTest, ViewOrderingTest) { |
450 // Tests that views are created in the correct vertical order. | 458 // Tests that views are created in the correct vertical order. |
451 notification()->set_buttons(CreateButtons(2)); | 459 notification()->set_buttons(CreateButtons(2)); |
452 | 460 |
453 // Layout the initial views. | 461 // Layout the initial views. |
454 UpdateNotificationViews(); | 462 UpdateNotificationViews(); |
455 | 463 |
456 // Double-check that vertical order is correct. | 464 // Double-check that vertical order is correct. |
457 CheckVerticalOrderInNotification(); | 465 CheckVerticalOrderInNotification(); |
458 | 466 |
459 // Tests that views remain in that order even after an update. | 467 // Tests that views remain in that order even after an update. |
460 UpdateNotificationViews(); | 468 UpdateNotificationViews(); |
461 CheckVerticalOrderInNotification(); | 469 CheckVerticalOrderInNotification(); |
462 } | 470 } |
463 | 471 |
464 } // namespace message_center | 472 } // namespace message_center |
OLD | NEW |