| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/message_popup_collection.h" | 5 #include "ui/message_center/views/message_popup_collection.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 TEST_F(MessagePopupCollectionTest, DetectMouseHover) { | 578 TEST_F(MessagePopupCollectionTest, DetectMouseHover) { |
| 579 std::string id0 = AddNotification(); | 579 std::string id0 = AddNotification(); |
| 580 std::string id1 = AddNotification(); | 580 std::string id1 = AddNotification(); |
| 581 WaitForTransitionsDone(); | 581 WaitForTransitionsDone(); |
| 582 | 582 |
| 583 views::WidgetDelegateView* toast0 = GetToast(id0); | 583 views::WidgetDelegateView* toast0 = GetToast(id0); |
| 584 EXPECT_TRUE(toast0 != NULL); | 584 EXPECT_TRUE(toast0 != NULL); |
| 585 views::WidgetDelegateView* toast1 = GetToast(id1); | 585 views::WidgetDelegateView* toast1 = GetToast(id1); |
| 586 EXPECT_TRUE(toast1 != NULL); | 586 EXPECT_TRUE(toast1 != NULL); |
| 587 | 587 |
| 588 ui::MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 588 ui::MouseEvent event( |
| 589 ui::EventTimeForNow(), 0, 0); | 589 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), 0, |
| 590 0, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 590 | 591 |
| 591 // Test that mouse detection logic works in presence of out-of-order events. | 592 // Test that mouse detection logic works in presence of out-of-order events. |
| 592 toast0->OnMouseEntered(event); | 593 toast0->OnMouseEntered(event); |
| 593 EXPECT_TRUE(MouseInCollection()); | 594 EXPECT_TRUE(MouseInCollection()); |
| 594 toast1->OnMouseEntered(event); | 595 toast1->OnMouseEntered(event); |
| 595 EXPECT_TRUE(MouseInCollection()); | 596 EXPECT_TRUE(MouseInCollection()); |
| 596 toast0->OnMouseExited(event); | 597 toast0->OnMouseExited(event); |
| 597 EXPECT_TRUE(MouseInCollection()); | 598 EXPECT_TRUE(MouseInCollection()); |
| 598 toast1->OnMouseExited(event); | 599 toast1->OnMouseExited(event); |
| 599 EXPECT_FALSE(MouseInCollection()); | 600 EXPECT_FALSE(MouseInCollection()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 614 TEST_F(MessagePopupCollectionTest, DetectMouseHoverWithUserClose) { | 615 TEST_F(MessagePopupCollectionTest, DetectMouseHoverWithUserClose) { |
| 615 std::string id0 = AddNotification(); | 616 std::string id0 = AddNotification(); |
| 616 std::string id1 = AddNotification(); | 617 std::string id1 = AddNotification(); |
| 617 WaitForTransitionsDone(); | 618 WaitForTransitionsDone(); |
| 618 | 619 |
| 619 views::WidgetDelegateView* toast0 = GetToast(id0); | 620 views::WidgetDelegateView* toast0 = GetToast(id0); |
| 620 EXPECT_TRUE(toast0 != NULL); | 621 EXPECT_TRUE(toast0 != NULL); |
| 621 views::WidgetDelegateView* toast1 = GetToast(id1); | 622 views::WidgetDelegateView* toast1 = GetToast(id1); |
| 622 ASSERT_TRUE(toast1 != NULL); | 623 ASSERT_TRUE(toast1 != NULL); |
| 623 | 624 |
| 624 ui::MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 625 ui::MouseEvent event( |
| 625 ui::EventTimeForNow(), 0, 0); | 626 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), 0, |
| 627 0, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 626 toast1->OnMouseEntered(event); | 628 toast1->OnMouseEntered(event); |
| 627 static_cast<MessageCenterObserver*>(collection())->OnNotificationRemoved( | 629 static_cast<MessageCenterObserver*>(collection())->OnNotificationRemoved( |
| 628 id1, true); | 630 id1, true); |
| 629 | 631 |
| 630 EXPECT_FALSE(MouseInCollection()); | 632 EXPECT_FALSE(MouseInCollection()); |
| 631 std::string id2 = AddNotification(); | 633 std::string id2 = AddNotification(); |
| 632 | 634 |
| 633 WaitForTransitionsDone(); | 635 WaitForTransitionsDone(); |
| 634 views::WidgetDelegateView* toast2 = GetToast(id2); | 636 views::WidgetDelegateView* toast2 = GetToast(id2); |
| 635 EXPECT_TRUE(toast2 != NULL); | 637 EXPECT_TRUE(toast2 != NULL); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 MessageCenter::Get()->AddNotification(std::move(notification)); | 676 MessageCenter::Get()->AddNotification(std::move(notification)); |
| 675 WaitForTransitionsDone(); | 677 WaitForTransitionsDone(); |
| 676 | 678 |
| 677 // Confirms that there is a toast. | 679 // Confirms that there is a toast. |
| 678 EXPECT_EQ(1u, GetToastCounts()); | 680 EXPECT_EQ(1u, GetToastCounts()); |
| 679 EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount()); | 681 EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount()); |
| 680 | 682 |
| 681 // Close the toast. | 683 // Close the toast. |
| 682 views::WidgetDelegateView* toast1 = GetToast(kNotificationId); | 684 views::WidgetDelegateView* toast1 = GetToast(kNotificationId); |
| 683 ASSERT_TRUE(toast1 != NULL); | 685 ASSERT_TRUE(toast1 != NULL); |
| 684 ui::MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 686 ui::MouseEvent event( |
| 685 ui::EventTimeForNow(), 0, 0); | 687 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), 0, |
| 688 0, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 686 toast1->OnMouseEntered(event); | 689 toast1->OnMouseEntered(event); |
| 687 static_cast<MessageCenterObserver*>(collection()) | 690 static_cast<MessageCenterObserver*>(collection()) |
| 688 ->OnNotificationRemoved(kNotificationId, true); | 691 ->OnNotificationRemoved(kNotificationId, true); |
| 689 WaitForTransitionsDone(); | 692 WaitForTransitionsDone(); |
| 690 | 693 |
| 691 // Confirms that there is no toast. | 694 // Confirms that there is no toast. |
| 692 EXPECT_EQ(0u, GetToastCounts()); | 695 EXPECT_EQ(0u, GetToastCounts()); |
| 693 // But the notification still exists. | 696 // But the notification still exists. |
| 694 EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount()); | 697 EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount()); |
| 695 } | 698 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 << *checked_animation.error_msg(); | 746 << *checked_animation.error_msg(); |
| 744 } | 747 } |
| 745 } | 748 } |
| 746 | 749 |
| 747 CloseAllToasts(); | 750 CloseAllToasts(); |
| 748 WaitForTransitionsDone(); | 751 WaitForTransitionsDone(); |
| 749 } | 752 } |
| 750 | 753 |
| 751 } // namespace test | 754 } // namespace test |
| 752 } // namespace message_center | 755 } // namespace message_center |
| OLD | NEW |