diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-16 09:59:13 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-20 10:28:53 +0000 |
commit | 6c11fb357ec39bf087b8b632e2b1e375aef1b38b (patch) | |
tree | c8315530db18a8ee566521c39ab8a6af4f72bc03 /chromium/ui/message_center | |
parent | 3ffaed019d0772e59d6cdb2d0d32fe4834c31f72 (diff) | |
download | qtwebengine-chromium-6c11fb357ec39bf087b8b632e2b1e375aef1b38b.tar.gz |
BASELINE: Update Chromium to 74.0.3729.159
Change-Id: I8d2497da544c275415aedd94dd25328d555de811
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/ui/message_center')
19 files changed, 190 insertions, 60 deletions
diff --git a/chromium/ui/message_center/fake_message_center.cc b/chromium/ui/message_center/fake_message_center.cc index abd23cb323a..c83cd728ebf 100644 --- a/chromium/ui/message_center/fake_message_center.cc +++ b/chromium/ui/message_center/fake_message_center.cc @@ -3,31 +3,30 @@ // found in the LICENSE file. #include "ui/message_center/fake_message_center.h" + +#include <utility> + #include "base/strings/string_util.h" #include "ui/message_center/notification_list.h" namespace message_center { -FakeMessageCenter::FakeMessageCenter() { -} +FakeMessageCenter::FakeMessageCenter() : notifications_(this) {} -FakeMessageCenter::~FakeMessageCenter() { -} +FakeMessageCenter::~FakeMessageCenter() {} void FakeMessageCenter::AddObserver(MessageCenterObserver* observer) { - observer_list_.AddObserver(observer); + observers_.AddObserver(observer); } void FakeMessageCenter::RemoveObserver(MessageCenterObserver* observer) { - observer_list_.RemoveObserver(observer); + observers_.RemoveObserver(observer); } -void FakeMessageCenter::AddNotificationBlocker(NotificationBlocker* blocker) { -} +void FakeMessageCenter::AddNotificationBlocker(NotificationBlocker* blocker) {} void FakeMessageCenter::RemoveNotificationBlocker( - NotificationBlocker* blocker) { -} + NotificationBlocker* blocker) {} size_t FakeMessageCenter::NotificationCount() const { return 0u; @@ -43,37 +42,61 @@ bool FakeMessageCenter::IsQuietMode() const { Notification* FakeMessageCenter::FindVisibleNotificationById( const std::string& id) { - for (auto* notification : GetVisibleNotifications()) { - if (id == notification->id()) + const auto& notifications = GetVisibleNotifications(); + for (auto* notification : notifications) { + if (notification->id() == id) return notification; } + return nullptr; } NotificationList::Notifications FakeMessageCenter::FindNotificationsByAppId( const std::string& app_id) { - return NotificationList::Notifications(); + return notifications_.GetNotificationsByAppId(app_id); } const NotificationList::Notifications& FakeMessageCenter::GetVisibleNotifications() { - return empty_notifications_; + return visible_notifications_; } NotificationList::PopupNotifications - FakeMessageCenter::GetPopupNotifications() { +FakeMessageCenter::GetPopupNotifications() { return NotificationList::PopupNotifications(); } void FakeMessageCenter::AddNotification( - std::unique_ptr<Notification> notification) {} + std::unique_ptr<Notification> notification) { + std::string id = notification->id(); + notifications_.AddNotification(std::move(notification)); + visible_notifications_ = notifications_.GetVisibleNotifications(blockers_); + for (auto& observer : observers_) + observer.OnNotificationAdded(id); +} void FakeMessageCenter::UpdateNotification( const std::string& old_id, - std::unique_ptr<Notification> new_notification) {} + std::unique_ptr<Notification> new_notification) { + std::string new_id = new_notification->id(); + notifications_.UpdateNotificationMessage(old_id, std::move(new_notification)); + visible_notifications_ = notifications_.GetVisibleNotifications(blockers_); + for (auto& observer : observers_) { + if (old_id == new_id) { + observer.OnNotificationUpdated(old_id); + } else { + observer.OnNotificationRemoved(old_id, false /* by_user */); + observer.OnNotificationAdded(new_id); + } + } +} void FakeMessageCenter::RemoveNotification(const std::string& id, bool by_user) { + notifications_.RemoveNotification(id); + visible_notifications_ = notifications_.GetVisibleNotifications(blockers_); + for (auto& observer : observers_) + observer.OnNotificationRemoved(id, by_user); } void FakeMessageCenter::RemoveNotificationsForNotifierId( @@ -82,19 +105,15 @@ void FakeMessageCenter::RemoveNotificationsForNotifierId( void FakeMessageCenter::RemoveAllNotifications(bool by_user, RemoveType type) {} void FakeMessageCenter::SetNotificationIcon(const std::string& notification_id, - const gfx::Image& image) { -} + const gfx::Image& image) {} void FakeMessageCenter::SetNotificationImage(const std::string& notification_id, - const gfx::Image& image) { -} + const gfx::Image& image) {} -void FakeMessageCenter::ClickOnNotification(const std::string& id) { -} +void FakeMessageCenter::ClickOnNotification(const std::string& id) {} void FakeMessageCenter::ClickOnNotificationButton(const std::string& id, - int button_index) { -} + int button_index) {} void FakeMessageCenter::ClickOnNotificationButtonWithReply( const std::string& id, @@ -115,11 +134,9 @@ void FakeMessageCenter::DisplayedNotification(const std::string& id, void FakeMessageCenter::SetQuietMode(bool in_quiet_mode) {} void FakeMessageCenter::EnterQuietModeWithExpire( - const base::TimeDelta& expires_in) { -} + const base::TimeDelta& expires_in) {} -void FakeMessageCenter::SetVisibility(Visibility visible) { -} +void FakeMessageCenter::SetVisibility(Visibility visible) {} bool FakeMessageCenter::IsMessageCenterVisible() const { return false; diff --git a/chromium/ui/message_center/fake_message_center.h b/chromium/ui/message_center/fake_message_center.h index cb884b89102..5488a6c2934 100644 --- a/chromium/ui/message_center/fake_message_center.h +++ b/chromium/ui/message_center/fake_message_center.h @@ -7,8 +7,13 @@ #include <stddef.h> +#include <memory> +#include <string> +#include <vector> + #include "base/macros.h" #include "ui/message_center/message_center.h" +#include "ui/message_center/message_center_observer.h" #include "ui/message_center/message_center_types.h" namespace message_center { @@ -73,12 +78,14 @@ class FakeMessageCenter : public MessageCenter { void DisableTimersForTest() override; const base::ObserverList<MessageCenterObserver>::Unchecked& observer_list() const { - return observer_list_; + return observers_; } private: - base::ObserverList<MessageCenterObserver>::Unchecked observer_list_; - const NotificationList::Notifications empty_notifications_; + base::ObserverList<MessageCenterObserver>::Unchecked observers_; + NotificationList notifications_; + NotificationList::Notifications visible_notifications_; + std::vector<NotificationBlocker*> blockers_; bool has_message_center_view_ = true; DISALLOW_COPY_AND_ASSIGN(FakeMessageCenter); diff --git a/chromium/ui/message_center/lock_screen/empty_lock_screen_controller.cc b/chromium/ui/message_center/lock_screen/empty_lock_screen_controller.cc index e362dbcca08..dae819bd820 100644 --- a/chromium/ui/message_center/lock_screen/empty_lock_screen_controller.cc +++ b/chromium/ui/message_center/lock_screen/empty_lock_screen_controller.cc @@ -8,7 +8,8 @@ namespace message_center { void EmptyLockScreenController::DismissLockScreenThenExecute( base::OnceClosure pending_callback, - base::OnceClosure cancel_callback) { + base::OnceClosure cancel_callback, + int message_id) { std::move(pending_callback).Run(); } diff --git a/chromium/ui/message_center/lock_screen/empty_lock_screen_controller.h b/chromium/ui/message_center/lock_screen/empty_lock_screen_controller.h index ba9126116cb..91adf33aadf 100644 --- a/chromium/ui/message_center/lock_screen/empty_lock_screen_controller.h +++ b/chromium/ui/message_center/lock_screen/empty_lock_screen_controller.h @@ -15,7 +15,8 @@ class EmptyLockScreenController : public LockScreenController { ~EmptyLockScreenController() override = default; void DismissLockScreenThenExecute(base::OnceClosure pending_callback, - base::OnceClosure cancal_callback) override; + base::OnceClosure cancal_callback, + int message_id) override; bool IsScreenLocked() const override; private: diff --git a/chromium/ui/message_center/lock_screen/fake_lock_screen_controller.cc b/chromium/ui/message_center/lock_screen/fake_lock_screen_controller.cc index e236fa84b43..2be3b3b6ea1 100644 --- a/chromium/ui/message_center/lock_screen/fake_lock_screen_controller.cc +++ b/chromium/ui/message_center/lock_screen/fake_lock_screen_controller.cc @@ -11,7 +11,8 @@ FakeLockScreenController::~FakeLockScreenController() = default; void FakeLockScreenController::DismissLockScreenThenExecute( base::OnceClosure pending_callback, - base::OnceClosure cancel_callback) { + base::OnceClosure cancel_callback, + int message_id) { DCHECK(pending_callback) << "pending_callback must not be null"; if (!is_screen_locked_) { diff --git a/chromium/ui/message_center/lock_screen/fake_lock_screen_controller.h b/chromium/ui/message_center/lock_screen/fake_lock_screen_controller.h index 4bc68b5c700..734b233b56a 100644 --- a/chromium/ui/message_center/lock_screen/fake_lock_screen_controller.h +++ b/chromium/ui/message_center/lock_screen/fake_lock_screen_controller.h @@ -15,7 +15,8 @@ class FakeLockScreenController : public LockScreenController { ~FakeLockScreenController() override; void DismissLockScreenThenExecute(base::OnceClosure pending_callback, - base::OnceClosure cancal_callback) override; + base::OnceClosure cancal_callback, + int message_id) override; bool IsScreenLocked() const override; // Methods for tests: diff --git a/chromium/ui/message_center/lock_screen/lock_screen_controller.h b/chromium/ui/message_center/lock_screen/lock_screen_controller.h index e8154ed8668..41d0c70baab 100644 --- a/chromium/ui/message_center/lock_screen/lock_screen_controller.h +++ b/chromium/ui/message_center/lock_screen/lock_screen_controller.h @@ -24,9 +24,9 @@ class MESSAGE_CENTER_EXPORT LockScreenController { // the cancel callback is run. In other words, onlt one of the pending or // cancel callback must be run. The cancel callback may be run even when the // device is locked. - virtual void DismissLockScreenThenExecute( - base::OnceClosure pending_callback, - base::OnceClosure cancel_callback) = 0; + virtual void DismissLockScreenThenExecute(base::OnceClosure pending_callback, + base::OnceClosure cancel_callback, + int message_id = -1) = 0; // Returns the status of the device lock. True if locked, false otherwise. virtual bool IsScreenLocked() const = 0; diff --git a/chromium/ui/message_center/message_center_impl.cc b/chromium/ui/message_center/message_center_impl.cc index 3dd44cb8e2e..f35cc7874a3 100644 --- a/chromium/ui/message_center/message_center_impl.cc +++ b/chromium/ui/message_center/message_center_impl.cc @@ -10,6 +10,7 @@ #include <vector> #include "base/auto_reset.h" +#include "base/bind.h" #include "base/command_line.h" #include "base/macros.h" #include "base/observer_list.h" @@ -143,7 +144,14 @@ bool MessageCenterImpl::IsQuietMode() const { Notification* MessageCenterImpl::FindVisibleNotificationById( const std::string& id) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - return notification_list_->GetNotificationById(id); + + const auto& notifications = GetVisibleNotifications(); + for (auto* notification : notifications) { + if (notification->id() == id) + return notification; + } + + return nullptr; } NotificationList::Notifications MessageCenterImpl::FindNotificationsByAppId( @@ -216,7 +224,7 @@ void MessageCenterImpl::RemoveNotification(const std::string& id, bool by_user) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - Notification* notification = FindVisibleNotificationById(id); + Notification* notification = notification_list_->GetNotificationById(id); if (!notification) return; diff --git a/chromium/ui/message_center/message_center_impl_unittest.cc b/chromium/ui/message_center/message_center_impl_unittest.cc index 80214ba549e..a29e7206881 100644 --- a/chromium/ui/message_center/message_center_impl_unittest.cc +++ b/chromium/ui/message_center/message_center_impl_unittest.cc @@ -859,6 +859,28 @@ TEST_F(MessageCenterImplTest, RemoveWhileMessageCenterVisible) { EXPECT_FALSE(message_center()->FindVisibleNotificationById(id)); } +TEST_F(MessageCenterImplTest, RemoveNonVisibleNotification) { + // Add two notifications. + message_center()->AddNotification(CreateSimpleNotification("id1")); + message_center()->AddNotification(CreateSimpleNotification("id2")); + EXPECT_EQ(2u, message_center()->GetVisibleNotifications().size()); + + // Add a blocker to block all notifications. + NotifierId allowed_notifier_id(NotifierType::APPLICATION, "notifier"); + TotalNotificationBlocker blocker(message_center(), allowed_notifier_id); + blocker.SetNotificationsEnabled(false); + EXPECT_EQ(0u, message_center()->GetVisibleNotifications().size()); + + // Removing a non-visible notification should work. + message_center()->RemoveNotification("id1", false); + blocker.SetNotificationsEnabled(true); + EXPECT_EQ(1u, message_center()->GetVisibleNotifications().size()); + + // Also try removing a visible notification. + message_center()->RemoveNotification("id2", false); + EXPECT_EQ(0u, message_center()->GetVisibleNotifications().size()); +} + TEST_F(MessageCenterImplTest, FindNotificationsByAppId) { message_center()->SetHasMessageCenterView(true); diff --git a/chromium/ui/message_center/popup_timer.cc b/chromium/ui/message_center/popup_timer.cc index 66e9b20c34a..6c094533fe9 100644 --- a/chromium/ui/message_center/popup_timer.cc +++ b/chromium/ui/message_center/popup_timer.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "ui/message_center/popup_timer.h" +#include "base/bind.h" namespace message_center { diff --git a/chromium/ui/message_center/public/cpp/notification_types.h b/chromium/ui/message_center/public/cpp/notification_types.h index 1ab3876b7e6..f5497e41c6d 100644 --- a/chromium/ui/message_center/public/cpp/notification_types.h +++ b/chromium/ui/message_center/public/cpp/notification_types.h @@ -25,6 +25,8 @@ enum NotificationPriority { MIN_PRIORITY = -2, LOW_PRIORITY = -1, DEFAULT_PRIORITY = 0, + // Priorities > |DEFAULT_PRIORITY| have the capability to wake the display up + // if it was off. HIGH_PRIORITY = 1, MAX_PRIORITY = 2, diff --git a/chromium/ui/message_center/views/message_popup_collection.cc b/chromium/ui/message_center/views/message_popup_collection.cc index e6d93b9d4f2..59455a47cb9 100644 --- a/chromium/ui/message_center/views/message_popup_collection.cc +++ b/chromium/ui/message_center/views/message_popup_collection.cc @@ -119,7 +119,13 @@ void MessagePopupCollection::NotifyPopupClosed(MessagePopupView* popup) { void MessagePopupCollection::OnNotificationAdded( const std::string& notification_id) { - Update(); + // Should not call MessagePopupCollection::Update here. Because notification + // may be removed before animation which is triggered by the previous + // operation on MessagePopupCollection ends. As result, when a new + // notification with the same ID is created, calling + // MessagePopupCollection::Update will not update the popup's content. Then + // the new notification popup fails to show. (see https://crbug.com/921402) + OnNotificationUpdated(notification_id); } void MessagePopupCollection::OnNotificationRemoved( diff --git a/chromium/ui/message_center/views/message_popup_collection_unittest.cc b/chromium/ui/message_center/views/message_popup_collection_unittest.cc index e80a138bc2d..a6a23e95ea9 100644 --- a/chromium/ui/message_center/views/message_popup_collection_unittest.cc +++ b/chromium/ui/message_center/views/message_popup_collection_unittest.cc @@ -116,7 +116,9 @@ class MockMessagePopupView : public MessagePopupView { MockMessagePopupCollection* popup_collection) : MessagePopupView(alignment_delegate, popup_collection), popup_collection_(popup_collection), - id_(id) { + id_(id), + title_(base::UTF16ToUTF8( + MessageCenter::Get()->FindVisibleNotificationById(id)->title())) { auto* view = new views::View; view->SetPreferredSize(gfx::Size(kNotificationWidth, init_height)); AddChildView(view); @@ -134,6 +136,7 @@ class MockMessagePopupView : public MessagePopupView { SetPreferredHeight(height_after_update_.value()); popup_collection_->NotifyPopupResized(); updated_ = true; + title_ = base::UTF16ToUTF8(notification.title()); } void AutoCollapse() override { @@ -158,13 +161,15 @@ class MockMessagePopupView : public MessagePopupView { } void Activate() { - set_can_activate(true); + SetCanActivate(true); GetWidget()->Activate(); } const std::string& id() const { return id_; } bool updated() const { return updated_; } + const std::string& title() const { return title_; } + void set_expandable(bool expandable) { expandable_ = expandable; } void set_height_after_update(base::Optional<int> height_after_update) { @@ -177,6 +182,7 @@ class MockMessagePopupView : public MessagePopupView { std::string id_; bool updated_ = false; bool expandable_ = false; + std::string title_; base::Optional<int> height_after_update_; }; @@ -235,8 +241,13 @@ class MessagePopupCollectionTest : public views::ViewsTestBase, protected: std::unique_ptr<Notification> CreateNotification(const std::string& id) { + return CreateNotification(id, "test title"); + } + + std::unique_ptr<Notification> CreateNotification(const std::string& id, + const std::string& title) { return std::make_unique<Notification>( - NOTIFICATION_TYPE_BASE_FORMAT, id, base::UTF8ToUTF16("test title"), + NOTIFICATION_TYPE_BASE_FORMAT, id, base::UTF8ToUTF16(title), base::UTF8ToUTF16("test message"), gfx::Image(), base::string16() /* display_source */, GURL(), NotifierId(), RichNotificationData(), new NotificationDelegate()); @@ -1100,4 +1111,44 @@ TEST_F(MessagePopupCollectionTest, HighPriorityNotificationShownAgain) { EXPECT_EQ(1u, GetPopupCounts()); } +// Notification removing may occur while the animation triggered by the previous +// operation is running. As result, notification is removed from the message +// center but its popup is still kept. At this moment, a new notification with +// the same notification id may be added to the message center. This can happen +// on Chrome OS when an external display is connected with the Chromebook device +// (see https://crbug.com/921402). This test case emulates the procedure of +// the external display connection that is mentioned in the link above. Verifies +// that under this circumstance the notification popup is updated. +TEST_F(MessagePopupCollectionTest, RemoveNotificationWhileAnimating) { + const std::string notification_id("test_id"); + const std::string old_notification_title("old_title"); + const std::string new_notification_title("new_title"); + + // Create a notification and add it to message center. + auto old_notification = + CreateNotification(notification_id, old_notification_title); + MessageCenter::Get()->AddNotification(std::move(old_notification)); + AnimateToMiddle(); + + // On real device, MessageCenter::RemoveNotification is called before the + // animation ends. As result, notification is removed while popup keeps still. + EXPECT_TRUE(IsAnimating()); + MessageCenter::Get()->RemoveNotification(notification_id, false); + EXPECT_FALSE(MessageCenter::Get()->HasPopupNotifications()); + EXPECT_EQ(1u, GetPopupCounts()); + EXPECT_EQ(old_notification_title, GetPopup(notification_id)->title()); + + // On real device, the new notification with the same notification id is + // created and added to message center before the animation ends. + auto new_notification = + CreateNotification(notification_id, new_notification_title); + EXPECT_TRUE(IsAnimating()); + MessageCenter::Get()->AddNotification(std::move(new_notification)); + AnimateUntilIdle(); + + // Verifies that the new notification popup is shown. + EXPECT_EQ(1u, GetPopupCounts()); + EXPECT_EQ(new_notification_title, GetPopup(notification_id)->title()); +} + } // namespace message_center diff --git a/chromium/ui/message_center/views/message_view_context_menu_controller.cc b/chromium/ui/message_center/views/message_view_context_menu_controller.cc index bcd9817db11..6d738fcffd6 100644 --- a/chromium/ui/message_center/views/message_view_context_menu_controller.cc +++ b/chromium/ui/message_center/views/message_view_context_menu_controller.cc @@ -4,6 +4,7 @@ #include "ui/message_center/views/message_view_context_menu_controller.h" +#include "base/bind.h" #include "ui/base/models/menu_model.h" #include "ui/message_center/message_center.h" #include "ui/message_center/views/message_view.h" @@ -18,7 +19,7 @@ MessageViewContextMenuController::MessageViewContextMenuController() = default; MessageViewContextMenuController::~MessageViewContextMenuController() = default; -void MessageViewContextMenuController::ShowContextMenuForView( +void MessageViewContextMenuController::ShowContextMenuForViewImpl( views::View* source, const gfx::Point& point, ui::MenuSourceType source_type) { diff --git a/chromium/ui/message_center/views/message_view_context_menu_controller.h b/chromium/ui/message_center/views/message_view_context_menu_controller.h index 8ee27f0eea9..00bf1727253 100644 --- a/chromium/ui/message_center/views/message_view_context_menu_controller.h +++ b/chromium/ui/message_center/views/message_view_context_menu_controller.h @@ -30,9 +30,9 @@ class MESSAGE_CENTER_EXPORT MessageViewContextMenuController private: // Overridden from views::ContextMenuController: - void ShowContextMenuForView(views::View* source, - const gfx::Point& point, - ui::MenuSourceType source_type) override; + void ShowContextMenuForViewImpl(views::View* source, + const gfx::Point& point, + ui::MenuSourceType source_type) override; // Callback for MenuRunner void OnMenuClosed(); diff --git a/chromium/ui/message_center/views/notification_view_md.cc b/chromium/ui/message_center/views/notification_view_md.cc index 9da43a65e37..71aff7aefbe 100644 --- a/chromium/ui/message_center/views/notification_view_md.cc +++ b/chromium/ui/message_center/views/notification_view_md.cc @@ -136,7 +136,7 @@ constexpr int kTextFontSizeDelta = 1; constexpr double kProgressNotificationMessageRatio = 0.7; // This key/property allows tagging the textfield with its index. -DEFINE_LOCAL_UI_CLASS_PROPERTY_KEY(int, kTextfieldIndexKey, 0U); +DEFINE_UI_CLASS_PROPERTY_KEY(int, kTextfieldIndexKey, 0U) // FontList for the texts except for the header. gfx::FontList GetTextFontList() { @@ -1021,8 +1021,7 @@ void NotificationViewMD::CreateOrUpdateActionButtonViews( for (auto* item : action_buttons_) delete item; action_buttons_.clear(); - if (buttons.empty()) - actions_row_->SetVisible(false); + actions_row_->SetVisible(expanded_ && !buttons.empty()); } DCHECK_EQ(this, actions_row_->parent()); @@ -1291,7 +1290,7 @@ void NotificationViewMD::OnSettingsButtonPressed(const ui::Event& event) { } void NotificationViewMD::Activate() { - GetWidget()->widget_delegate()->set_can_activate(true); + GetWidget()->widget_delegate()->SetCanActivate(true); GetWidget()->Activate(); } diff --git a/chromium/ui/message_center/views/notification_view_md.h b/chromium/ui/message_center/views/notification_view_md.h index 9ec098ae9a1..a36343dddac 100644 --- a/chromium/ui/message_center/views/notification_view_md.h +++ b/chromium/ui/message_center/views/notification_view_md.h @@ -139,8 +139,8 @@ class NotificationInputContainerMD : public views::InkDropHostView, // Overridden from views::ButtonListener: void ButtonPressed(views::Button* sender, const ui::Event& event) override; - views::Textfield* textfield() const { return textfield_; }; - views::ImageButton* button() const { return button_; }; + views::Textfield* textfield() const { return textfield_; } + views::ImageButton* button() const { return button_; } private: NotificationInputDelegate* const delegate_; diff --git a/chromium/ui/message_center/views/notification_view_md_unittest.cc b/chromium/ui/message_center/views/notification_view_md_unittest.cc index bf98dcaf4db..dad0e37c5f6 100644 --- a/chromium/ui/message_center/views/notification_view_md_unittest.cc +++ b/chromium/ui/message_center/views/notification_view_md_unittest.cc @@ -317,7 +317,7 @@ void NotificationViewMDTest::UpdateNotificationViews( widget_->SetContentsView(notification_view_.get()); widget_->SetSize(notification_view_->GetPreferredSize()); widget_->Show(); - widget_->widget_delegate()->set_can_activate(true); + widget_->widget_delegate()->SetCanActivate(true); widget_->Activate(); } else { notification_view_->UpdateWithNotification(notification); @@ -461,13 +461,24 @@ TEST_F(NotificationViewMDTest, TestIconSizing) { TEST_F(NotificationViewMDTest, UpdateButtonsStateTest) { std::unique_ptr<Notification> notification = CreateSimpleNotification(); - notification->set_buttons(CreateButtons(2)); notification_view()->CreateOrUpdateViews(*notification); widget()->Show(); - // Action buttons are hidden by collapsed state. - if (!notification_view()->expanded_) - notification_view()->ToggleExpanded(); + // When collapsed, new buttons are not shown. + EXPECT_FALSE(notification_view()->expanded_); + notification->set_buttons(CreateButtons(2)); + notification_view()->CreateOrUpdateViews(*notification); + EXPECT_FALSE(notification_view()->actions_row_->visible()); + + // Adding buttons when expanded makes action buttons visible. + // Reset back to zero buttons first. + notification->set_buttons(CreateButtons(0)); + notification_view()->CreateOrUpdateViews(*notification); + // Expand, and add buttons. + notification_view()->ToggleExpanded(); + EXPECT_TRUE(notification_view()->expanded_); + notification->set_buttons(CreateButtons(2)); + notification_view()->CreateOrUpdateViews(*notification); EXPECT_TRUE(notification_view()->actions_row_->visible()); EXPECT_EQ(views::Button::STATE_NORMAL, diff --git a/chromium/ui/message_center/views/slide_out_controller.cc b/chromium/ui/message_center/views/slide_out_controller.cc index 28c5043570b..b49a7038b1a 100644 --- a/chromium/ui/message_center/views/slide_out_controller.cc +++ b/chromium/ui/message_center/views/slide_out_controller.cc @@ -4,6 +4,7 @@ #include "ui/message_center/views/slide_out_controller.h" +#include "base/bind.h" #include "ui/compositor/layer.h" #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/gfx/transform.h" |