diff options
Diffstat (limited to 'chromium/ui/message_center')
14 files changed, 204 insertions, 97 deletions
diff --git a/chromium/ui/message_center/notification_list.cc b/chromium/ui/message_center/notification_list.cc index 2e283dd0094..b381a669625 100644 --- a/chromium/ui/message_center/notification_list.cc +++ b/chromium/ui/message_center/notification_list.cc @@ -321,10 +321,18 @@ void NotificationList::PushNotification( state = iter->second; EraseNotification(iter); } else { + // For critical ChromeOS system notifications, we ignore the standard quiet + // mode behaviour and show the notification anyways. + bool effective_quiet_mode = quiet_mode_; +#if defined(OS_CHROMEOS) + effective_quiet_mode &= notification->system_notification_warning_level() != + SystemNotificationWarningLevel::CRITICAL_WARNING; +#endif + // TODO(mukai): needs to distinguish if a notification is dismissed by // the quiet mode or user operation. state.shown_as_popup = - message_center_->IsMessageCenterVisible() || quiet_mode_; + message_center_->IsMessageCenterVisible() || effective_quiet_mode; } if (notification->priority() == MIN_PRIORITY) state.is_read = true; diff --git a/chromium/ui/message_center/public/cpp/message_center_constants.h b/chromium/ui/message_center/public/cpp/message_center_constants.h index 9b585cbba68..b912fa72a42 100644 --- a/chromium/ui/message_center/public/cpp/message_center_constants.h +++ b/chromium/ui/message_center/public/cpp/message_center_constants.h @@ -69,9 +69,6 @@ constexpr SkColor kSmallImageMaskForegroundColor = SK_ColorWHITE; constexpr SkColor kSmallImageMaskBackgroundColor = SkColorSetRGB(0xa3, 0xa3, 0xa3); -// Default accent color of notifications that are not generated by system. -constexpr SkColor kNotificationDefaultAccentColor = gfx::kChromeIconGrey; - // For list notifications. // Not used when --enabled-new-style-notification is set. const size_t kNotificationMaximumItems = 5; diff --git a/chromium/ui/message_center/public/cpp/notification.h b/chromium/ui/message_center/public/cpp/notification.h index 9a374b2bc07..4214799f36f 100644 --- a/chromium/ui/message_center/public/cpp/notification.h +++ b/chromium/ui/message_center/public/cpp/notification.h @@ -433,6 +433,17 @@ class MESSAGE_CENTER_PUBLIC_EXPORT Notification { // method explicitly, to avoid setting it accidentally. void SetSystemPriority(); +#if defined(OS_CHROMEOS) + void set_system_notification_warning_level( + SystemNotificationWarningLevel warning_level) { + system_notification_warning_level_ = warning_level; + } + + SystemNotificationWarningLevel system_notification_warning_level() const { + return system_notification_warning_level_; + } +#endif // defined(OS_CHROMEOS) + const std::string& custom_view_type() const { return custom_view_type_; } void set_custom_view_type(const std::string& custom_view_type) { DCHECK_EQ(type(), NotificationType::NOTIFICATION_TYPE_CUSTOM); @@ -475,6 +486,12 @@ class MESSAGE_CENTER_PUBLIC_EXPORT Notification { // creating the view for this notification. The type should match the type // used to register the factory in MessageViewFactory. std::string custom_view_type_; + +#if defined(OS_CHROMEOS) + // The warning level of a system notification. + SystemNotificationWarningLevel system_notification_warning_level_ = + SystemNotificationWarningLevel::NORMAL; +#endif // defined(OS_CHROMEOS) }; } // namespace message_center diff --git a/chromium/ui/message_center/vector_icons/vector_icons.cc.template b/chromium/ui/message_center/vector_icons/vector_icons.cc.template index 7c12b34bfad..17fae3bd6a0 100644 --- a/chromium/ui/message_center/vector_icons/vector_icons.cc.template +++ b/chromium/ui/message_center/vector_icons/vector_icons.cc.template @@ -7,7 +7,6 @@ #include "ui/message_center/vector_icons.h" -#include "base/logging.h" #include "components/vector_icons/cc_macros.h" #include "ui/gfx/vector_icon_types.h" diff --git a/chromium/ui/message_center/views/message_popup_collection.cc b/chromium/ui/message_center/views/message_popup_collection.cc index 95fd1e78b37..87c96aa4acb 100644 --- a/chromium/ui/message_center/views/message_popup_collection.cc +++ b/chromium/ui/message_center/views/message_popup_collection.cc @@ -226,8 +226,19 @@ void MessagePopupCollection::TransitionFromAnimation() { UpdateByAnimation(); // If FADE_OUT animation is finished, remove the animated popup. - if (state_ == State::FADE_OUT) + if (state_ == State::FADE_OUT) { + // In inverse mode if the popups are not removed in the order they were + // added (the ones on the top are removed while the ones at the bottom stay) + // we need to move the remaining popups down. This might happen if the + // popups have different TTL. + bool move_down_needed = inverse_ && !AreAllAnimatingPopupsFirst(); CloseAnimatingPopups(); + if (move_down_needed) { + state_ = State::MOVE_DOWN; + MoveDownPopups(); + return; + } + } if (state_ == State::FADE_IN || state_ == State::MOVE_DOWN || (state_ == State::FADE_OUT && popup_items_.empty())) { @@ -536,6 +547,16 @@ void MessagePopupCollection::ResetHotMode() { hot_top_ = 0; } +bool MessagePopupCollection::AreAllAnimatingPopupsFirst() const { + bool previous_item_was_animating = true; + for (const auto& item : popup_items_) { + if (item.is_animating && !previous_item_was_animating) + return false; + previous_item_was_animating = item.is_animating; + } + return true; +} + void MessagePopupCollection::CloseAnimatingPopups() { for (auto& item : popup_items_) { if (!item.is_animating) diff --git a/chromium/ui/message_center/views/message_popup_collection.h b/chromium/ui/message_center/views/message_popup_collection.h index b3c1381bf0b..c64fa55ffcf 100644 --- a/chromium/ui/message_center/views/message_popup_collection.h +++ b/chromium/ui/message_center/views/message_popup_collection.h @@ -229,6 +229,11 @@ class MESSAGE_CENTER_EXPORT MessagePopupCollection void ClosePopupsOutsideWorkArea(); void RemoveClosedPopupItems(); + // Returns true if all the animating popups are at the beginning of the + // collection or the queue is empty. Returns false only if there is an + // animating popup after a non-animating one. + bool AreAllAnimatingPopupsFirst() const; + // Stops all the animation and closes all the popups immediately. void CloseAllPopupsNow(); 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 a79a6379d58..9d5a3d675b9 100644 --- a/chromium/ui/message_center/views/message_popup_collection_unittest.cc +++ b/chromium/ui/message_center/views/message_popup_collection_unittest.cc @@ -571,6 +571,48 @@ TEST_F(MessagePopupCollectionTest, NotificationsMoveDown) { EXPECT_FALSE(IsAnimating()); } +TEST_F(MessagePopupCollectionTest, NotificationsMoveDownInverse) { + popup_collection()->set_inverse(); + + std::vector<std::string> ids; + for (size_t i = 0; i < kMaxVisiblePopupNotifications; ++i) + ids.push_back(AddNotification()); + + std::string dismissed_id = ids[kMaxVisiblePopupNotifications - 1]; + std::string new_bottom_id = ids[kMaxVisiblePopupNotifications - 2]; + + AnimateUntilIdle(); + + EXPECT_EQ(kMaxVisiblePopupNotifications, GetPopupCounts()); + EXPECT_FALSE(IsAnimating()); + + gfx::Rect dismissed = GetPopup(dismissed_id)->GetBoundsInScreen(); + + MessageCenter::Get()->MarkSinglePopupAsShown(dismissed_id, false); + EXPECT_TRUE(IsAnimating()); + + AnimateToMiddle(); + EXPECT_GT(1.0f, GetPopup(dismissed_id)->GetOpacity()); + EXPECT_EQ(dismissed_id, GetPopup(dismissed_id)->id()); + + AnimateToEnd(); + EXPECT_EQ(ids[1], GetPopup(new_bottom_id)->id()); + EXPECT_TRUE(IsAnimating()); + + gfx::Rect before = GetPopup(new_bottom_id)->GetBoundsInScreen(); + + AnimateToMiddle(); + gfx::Rect moving = GetPopup(new_bottom_id)->GetBoundsInScreen(); + EXPECT_GT(moving.bottom(), before.bottom()); + EXPECT_GT(dismissed.bottom(), moving.bottom()); + + AnimateToEnd(); + gfx::Rect after = GetPopup(new_bottom_id)->GetBoundsInScreen(); + EXPECT_EQ(dismissed, after); + EXPECT_EQ(kMaxVisiblePopupNotifications - 1, GetPopupCounts()); + EXPECT_FALSE(IsAnimating()); +} + TEST_F(MessagePopupCollectionTest, NotificationsMoveUpForInverse) { popup_collection()->set_inverse(); diff --git a/chromium/ui/message_center/views/message_view.h b/chromium/ui/message_center/views/message_view.h index 51e6c26377a..0aea059a420 100644 --- a/chromium/ui/message_center/views/message_view.h +++ b/chromium/ui/message_center/views/message_view.h @@ -189,7 +189,7 @@ class MESSAGE_CENTER_EXPORT MessageView bool is_nested() const { return is_nested_; } - views::FocusRing* focus_ring() { return focus_ring_.get(); } + views::FocusRing* focus_ring() { return focus_ring_; } private: friend class test::MessagePopupCollectionTest; @@ -230,7 +230,7 @@ class MESSAGE_CENTER_EXPORT MessageView bool disable_slide_ = false; views::FocusManager* focus_manager_ = nullptr; - std::unique_ptr<views::FocusRing> focus_ring_; + views::FocusRing* focus_ring_ = nullptr; // Radius values used to determine the rounding for the rounded rectangular // shape of the notification. diff --git a/chromium/ui/message_center/views/notification_header_view.cc b/chromium/ui/message_center/views/notification_header_view.cc index 11cb93f4b5f..a9f6984e6cb 100644 --- a/chromium/ui/message_center/views/notification_header_view.cc +++ b/chromium/ui/message_center/views/notification_header_view.cc @@ -150,7 +150,6 @@ gfx::Insets CalculateTopPadding(int font_list_height) { } #endif - DCHECK_EQ(15, font_list_height); return kTextViewPaddingDefault; } @@ -193,7 +192,6 @@ NotificationHeaderView::NotificationHeaderView(views::ButtonListener* listener) label->SetLineHeight(font_list_height); label->SetHorizontalAlignment(gfx::ALIGN_LEFT); label->SetBorder(views::CreateEmptyBorder(text_view_padding)); - DCHECK_EQ(kInnerHeaderHeight, label->GetPreferredSize().height()); return label; }; @@ -250,7 +248,6 @@ NotificationHeaderView::NotificationHeaderView(views::ButtonListener* listener) spacer->SetProperty(views::kFlexBehaviorKey, kSpacerFlex); AddChildView(spacer); - SetAccentColor(accent_color_); SetPreferredSize(gfx::Size(kNotificationWidth, kHeaderHeight)); } @@ -262,9 +259,8 @@ void NotificationHeaderView::SetAppIcon(const gfx::ImageSkia& img) { } void NotificationHeaderView::ClearAppIcon() { - app_icon_view_->SetImage( - gfx::CreateVectorIcon(kProductIcon, kSmallImageSizeMD, accent_color_)); using_default_app_icon_ = true; + UpdateColors(); } void NotificationHeaderView::SetAppName(const base::string16& name) { @@ -309,6 +305,11 @@ void NotificationHeaderView::GetAccessibleNodeData(ui::AXNodeData* node_data) { node_data->AddState(ax::mojom::State::kExpanded); } +void NotificationHeaderView::OnThemeChanged() { + Button::OnThemeChanged(); + UpdateColors(); +} + void NotificationHeaderView::SetTimestamp(base::Time timestamp) { base::string16 relative_time; base::TimeDelta next_update; @@ -343,9 +344,7 @@ void NotificationHeaderView::SetExpandButtonEnabled(bool enabled) { void NotificationHeaderView::SetExpanded(bool expanded) { is_expanded_ = expanded; - expand_button_->SetImage(gfx::CreateVectorIcon( - expanded ? kNotificationExpandLessIcon : kNotificationExpandMoreIcon, - kExpandIconSize, accent_color_)); + UpdateColors(); expand_button_->set_tooltip_text(l10n_util::GetStringUTF16( expanded ? IDS_MESSAGE_CENTER_COLLAPSE_NOTIFICATION : IDS_MESSAGE_CENTER_EXPAND_NOTIFICATION)); @@ -354,15 +353,7 @@ void NotificationHeaderView::SetExpanded(bool expanded) { void NotificationHeaderView::SetAccentColor(SkColor color) { accent_color_ = color; - app_name_view_->SetEnabledColor(accent_color_); - summary_text_view_->SetEnabledColor(accent_color_); - summary_text_divider_->SetEnabledColor(accent_color_); - SetExpanded(is_expanded_); - - // If we are using the default app icon we should clear it so we refresh it - // with the new accent color. - if (using_default_app_icon_) - ClearAppIcon(); + UpdateColors(); } void NotificationHeaderView::SetBackgroundColor(SkColor color) { @@ -406,4 +397,21 @@ void NotificationHeaderView::UpdateSummaryTextVisibility() { detail_views_->InvalidateLayout(); } +void NotificationHeaderView::UpdateColors() { + SkColor color = accent_color_.value_or(GetNativeTheme()->GetSystemColor( + ui::NativeTheme::kColorId_NotificationDefaultAccentColor)); + app_name_view_->SetEnabledColor(color); + summary_text_view_->SetEnabledColor(color); + summary_text_divider_->SetEnabledColor(color); + + expand_button_->SetImage(gfx::CreateVectorIcon( + is_expanded_ ? kNotificationExpandLessIcon : kNotificationExpandMoreIcon, + kExpandIconSize, color)); + + if (using_default_app_icon_) { + app_icon_view_->SetImage( + gfx::CreateVectorIcon(kProductIcon, kSmallImageSizeMD, color)); + } +} + } // namespace message_center diff --git a/chromium/ui/message_center/views/notification_header_view.h b/chromium/ui/message_center/views/notification_header_view.h index b5c9dace7b4..f3285564b70 100644 --- a/chromium/ui/message_center/views/notification_header_view.h +++ b/chromium/ui/message_center/views/notification_header_view.h @@ -41,8 +41,8 @@ class MESSAGE_CENTER_EXPORT NotificationHeaderView : public views::Button { void SetExpandButtonEnabled(bool enabled); void SetExpanded(bool expanded); - // Set the unified theme color used among the app icon, app name, and expand - // button. + // Calls UpdateColors() to set the unified theme color used among the + // app icon, app name, and expand button. void SetAccentColor(SkColor color); // Sets the background color of the notification. This is used to ensure that @@ -57,10 +57,11 @@ class MESSAGE_CENTER_EXPORT NotificationHeaderView : public views::Button { // views::View: void GetAccessibleNodeData(ui::AXNodeData* node_data) override; + void OnThemeChanged() override; views::ImageView* expand_button() { return expand_button_; } - SkColor accent_color_for_testing() { return accent_color_; } + base::Optional<SkColor> accent_color_for_testing() { return accent_color_; } const views::Label* summary_text_for_testing() const { return summary_text_view_; @@ -84,7 +85,9 @@ class MESSAGE_CENTER_EXPORT NotificationHeaderView : public views::Button { // Update visibility for both |summary_text_view_| and |timestamp_view_|. void UpdateSummaryTextVisibility(); - SkColor accent_color_ = kNotificationDefaultAccentColor; + void UpdateColors(); + + base::Optional<SkColor> accent_color_; // Timer that updates the timestamp over time. base::OneShotTimer timestamp_update_timer_; diff --git a/chromium/ui/message_center/views/notification_header_view_unittest.cc b/chromium/ui/message_center/views/notification_header_view_unittest.cc index 26520d11392..20c2e115401 100644 --- a/chromium/ui/message_center/views/notification_header_view_unittest.cc +++ b/chromium/ui/message_center/views/notification_header_view_unittest.cc @@ -32,8 +32,8 @@ class NotificationHeaderViewTest : public views::ViewsTestBase { params.bounds = gfx::Rect(200, 200); params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget_.Init(std::move(params)); - views::View* container = new views::View(); - widget_.SetContentsView(container); + views::View* container = + widget_.SetContentsView(std::make_unique<views::View>()); notification_header_view_ = new NotificationHeaderView(nullptr); container->AddChildView(notification_header_view_); diff --git a/chromium/ui/message_center/views/notification_view_md.cc b/chromium/ui/message_center/views/notification_view_md.cc index eadc6d89ea7..606a596838c 100644 --- a/chromium/ui/message_center/views/notification_view_md.cc +++ b/chromium/ui/message_center/views/notification_view_md.cc @@ -586,13 +586,10 @@ NotificationViewMD::NotificationViewMD(const Notification& notification) AddChildView(ink_drop_container_); - control_buttons_view_ = - std::make_unique<NotificationControlButtonsView>(this); - control_buttons_view_->set_owned_by_client(); - // |header_row_| contains app_icon, app_name, control buttons, etc... header_row_ = new NotificationHeaderView(this); - header_row_->AddChildView(control_buttons_view_.get()); + control_buttons_view_ = header_row_->AddChildView( + std::make_unique<NotificationControlButtonsView>(this)); AddChildView(header_row_); // |content_row_| contains title, message, image, progressbar, etc... @@ -864,9 +861,8 @@ void NotificationViewMD::OnNotificationInputSubmit(size_t index, void NotificationViewMD::CreateOrUpdateContextTitleView( const Notification& notification) { - header_row_->SetAccentColor(notification.accent_color() == SK_ColorTRANSPARENT - ? kNotificationDefaultAccentColor - : notification.accent_color()); + if (notification.accent_color() != SK_ColorTRANSPARENT) + header_row_->SetAccentColor(notification.accent_color()); header_row_->SetTimestamp(notification.timestamp()); header_row_->SetAppNameElideBehavior(gfx::ELIDE_TAIL); header_row_->SetSummaryText(base::string16()); @@ -1090,9 +1086,11 @@ void NotificationViewMD::CreateOrUpdateSmallIconView( // TODO(knollr): figure out if this has a performance impact and // cache images if so. (crbug.com/768748) gfx::Image masked_small_icon = notification.GenerateMaskedSmallIcon( - kSmallImageSizeMD, notification.accent_color() == SK_ColorTRANSPARENT - ? message_center::kNotificationDefaultAccentColor - : notification.accent_color()); + kSmallImageSizeMD, + notification.accent_color() == SK_ColorTRANSPARENT + ? GetNativeTheme()->GetSystemColor( + ui::NativeTheme::kColorId_NotificationDefaultAccentColor) + : notification.accent_color()); if (masked_small_icon.IsEmpty()) { header_row_->ClearAppIcon(); @@ -1395,7 +1393,7 @@ void NotificationViewMD::UpdateCornerRadius(int top_radius, int bottom_radius) { NotificationControlButtonsView* NotificationViewMD::GetControlButtonsView() const { - return control_buttons_view_.get(); + return control_buttons_view_; } bool NotificationViewMD::IsExpanded() const { @@ -1436,6 +1434,11 @@ void NotificationViewMD::OnThemeChanged() { inline_settings_visible ? ui::NativeTheme::kColorId_NotificationInlineSettingsBackground : ui::NativeTheme::kColorId_NotificationDefaultBackground)); + + auto* notification = + MessageCenter::Get()->FindVisibleNotificationById(notification_id()); + if (notification) + CreateOrUpdateSmallIconView(*notification); } void NotificationViewMD::Activate() { diff --git a/chromium/ui/message_center/views/notification_view_md.h b/chromium/ui/message_center/views/notification_view_md.h index bc0520e7bf5..bb92431650e 100644 --- a/chromium/ui/message_center/views/notification_view_md.h +++ b/chromium/ui/message_center/views/notification_view_md.h @@ -276,7 +276,7 @@ class MESSAGE_CENTER_EXPORT NotificationViewMD views::InkDropContainerView* const ink_drop_container_; // View containing close and settings buttons - std::unique_ptr<NotificationControlButtonsView> control_buttons_view_; + NotificationControlButtonsView* control_buttons_view_; // Whether this notification is expanded or not. bool expanded_ = false; 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 66d0f5e7f04..77311c9aafa 100644 --- a/chromium/ui/message_center/views/notification_view_md_unittest.cc +++ b/chromium/ui/message_center/views/notification_view_md_unittest.cc @@ -117,13 +117,7 @@ class NotificationViewMDTest : public views::InkDropObserver, // Overridden from views::ViewObserver: void OnViewPreferredSizeChanged(views::View* observed_view) override; - NotificationViewMD* notification_view() const { - return notification_view_.get(); - } - views::Widget* widget() const { - DCHECK_EQ(widget_, notification_view()->GetWidget()); - return widget_; - } + NotificationViewMD* notification_view() const { return notification_view_; } // Overridden from message_center::MessageCenterObserver: void OnNotificationRemoved(const std::string& notification_id, @@ -168,8 +162,7 @@ class NotificationViewMDTest : public views::InkDropObserver, bool delete_on_notification_removed_ = false; std::set<std::string> removed_ids_; scoped_refptr<NotificationTestDelegate> delegate_; - std::unique_ptr<NotificationViewMD> notification_view_; - views::Widget* widget_; + NotificationViewMD* notification_view_ = nullptr; private: DISALLOW_COPY_AND_ASSIGN(NotificationViewMDTest); @@ -215,9 +208,9 @@ void NotificationViewMDTest::TearDown() { delete_on_notification_removed_); if (notification_view_) { notification_view_->SetInkDropMode(MessageView::InkDropMode::OFF); - static_cast<views::View*>(notification_view_.get())->RemoveObserver(this); - widget()->Close(); - notification_view_.reset(); + static_cast<views::View*>(notification_view_)->RemoveObserver(this); + notification_view_->GetWidget()->Close(); + notification_view_ = nullptr; } MessageCenter::Shutdown(); views::ViewsTestBase::TearDown(); @@ -227,19 +220,20 @@ void NotificationViewMDTest::OnViewPreferredSizeChanged( views::View* observed_view) { EXPECT_EQ(observed_view, notification_view()); if (delete_on_preferred_size_changed_) { - widget()->CloseNow(); - notification_view_.reset(); + notification_view_->GetWidget()->CloseNow(); + notification_view_ = nullptr; return; } - widget()->SetSize(notification_view()->GetPreferredSize()); + notification_view_->GetWidget()->SetSize( + notification_view()->GetPreferredSize()); } void NotificationViewMDTest::OnNotificationRemoved( const std::string& notification_id, bool by_user) { if (delete_on_notification_removed_) { - widget()->CloseNow(); - notification_view_.reset(); + notification_view_->GetWidget()->CloseNow(); + notification_view_ = nullptr; return; } } @@ -309,19 +303,19 @@ void NotificationViewMDTest::UpdateNotificationViews( // MessageViewFactory::Create. // TODO(tetsui): Confirm that NotificationViewMD options are same as one // created by the method. - notification_view_ = std::make_unique<NotificationViewMD>(notification); - static_cast<views::View*>(notification_view_.get())->AddObserver(this); - notification_view_->set_owned_by_client(); + auto notification_view = std::make_unique<NotificationViewMD>(notification); + static_cast<views::View*>(notification_view.get())->AddObserver(this); views::Widget::InitParams init_params( CreateParams(views::Widget::InitParams::TYPE_POPUP)); - widget_ = new views::Widget(); - widget_->Init(std::move(init_params)); - widget_->SetContentsView(notification_view_.get()); - widget_->SetSize(notification_view_->GetPreferredSize()); - widget_->Show(); - widget_->widget_delegate()->SetCanActivate(true); - widget_->Activate(); + // The native widget owns |widget| and |widget| owns |notification_view_|. + auto* widget = new views::Widget(); + widget->Init(std::move(init_params)); + notification_view_ = widget->SetContentsView(std::move(notification_view)); + widget->SetSize(notification_view_->GetPreferredSize()); + widget->Show(); + widget->widget_delegate()->SetCanActivate(true); + widget->Activate(); } else { notification_view_->UpdateWithNotification(notification); } @@ -472,7 +466,7 @@ TEST_F(NotificationViewMDTest, TestIconSizing) { TEST_F(NotificationViewMDTest, UpdateButtonsStateTest) { std::unique_ptr<Notification> notification = CreateSimpleNotification(); notification_view()->CreateOrUpdateViews(*notification); - widget()->Show(); + notification_view()->GetWidget()->Show(); // When collapsed, new buttons are not shown. EXPECT_FALSE(notification_view()->expanded_); @@ -526,7 +520,7 @@ TEST_F(NotificationViewMDTest, UpdateButtonCountTest) { std::unique_ptr<Notification> notification = CreateSimpleNotification(); notification->set_buttons(CreateButtons(2)); UpdateNotificationViews(*notification); - widget()->Show(); + notification_view()->GetWidget()->Show(); // Action buttons are hidden by collapsed state. if (!notification_view()->expanded_) @@ -576,9 +570,10 @@ TEST_F(NotificationViewMDTest, TestActionButtonClick) { notification->set_buttons(CreateButtons(2)); UpdateNotificationViews(*notification); - widget()->Show(); + notification_view()->GetWidget()->Show(); - ui::test::EventGenerator generator(GetRootWindow(widget())); + ui::test::EventGenerator generator( + GetRootWindow(notification_view()->GetWidget())); // Action buttons are hidden by collapsed state. if (!notification_view()->expanded_) @@ -604,9 +599,10 @@ TEST_F(NotificationViewMDTest, TestInlineReply) { buttons[1].placeholder = base::string16(); notification->set_buttons(buttons); UpdateNotificationViews(*notification); - widget()->Show(); + notification_view()->GetWidget()->Show(); - ui::test::EventGenerator generator(GetRootWindow(widget())); + ui::test::EventGenerator generator( + GetRootWindow(notification_view()->GetWidget())); // Action buttons are hidden by collapsed state. if (!notification_view()->expanded_) @@ -691,9 +687,10 @@ TEST_F(NotificationViewMDTest, TestInlineReplyRemovedByUpdate) { buttons[1].placeholder = base::string16(); notification->set_buttons(buttons); UpdateNotificationViews(*notification); - widget()->Show(); + notification_view()->GetWidget()->Show(); - ui::test::EventGenerator generator(GetRootWindow(widget())); + ui::test::EventGenerator generator( + GetRootWindow(notification_view()->GetWidget())); // Action buttons are hidden by collapsed state. if (!notification_view()->expanded_) @@ -740,13 +737,14 @@ TEST_F(NotificationViewMDTest, TestInlineReplyActivateWithKeyPress) { buttons[1].placeholder = base::string16(); notification->set_buttons(buttons); UpdateNotificationViews(*notification); - widget()->Show(); + notification_view()->GetWidget()->Show(); // Action buttons are hidden by collapsed state. if (!notification_view()->expanded_) notification_view()->ToggleExpanded(); - ui::test::EventGenerator generator(GetRootWindow(widget())); + ui::test::EventGenerator generator( + GetRootWindow(notification_view()->GetWidget())); // Press and release space key to open inline reply text field. // Note: VKEY_RETURN should work too, but triggers a click on MacOS. @@ -968,7 +966,8 @@ TEST_F(NotificationViewMDTest, ExpandLongMessage) { gfx::Point done_cursor_location(1, 1); views::View::ConvertPointToScreen(notification_view()->header_row_, &done_cursor_location); - ui::test::EventGenerator generator(GetRootWindow(widget())); + ui::test::EventGenerator generator( + GetRootWindow(notification_view()->GetWidget())); generator.MoveMouseTo(done_cursor_location); generator.ClickLeftButton(); @@ -982,17 +981,16 @@ TEST_F(NotificationViewMDTest, TestAccentColor) { std::unique_ptr<Notification> notification = CreateSimpleNotification(); notification->set_buttons(CreateButtons(2)); UpdateNotificationViews(*notification); - widget()->Show(); + notification_view()->GetWidget()->Show(); // Action buttons are hidden by collapsed state. if (!notification_view()->expanded_) notification_view()->ToggleExpanded(); EXPECT_TRUE(notification_view()->actions_row_->GetVisible()); - // By default, header does not have accent color (default grey), and - // buttons have default accent color. - EXPECT_EQ(kNotificationDefaultAccentColor, - notification_view()->header_row_->accent_color_for_testing()); + // By default, header does not have accent color. + EXPECT_FALSE( + notification_view()->header_row_->accent_color_for_testing().has_value()); EXPECT_EQ( kActionButtonTextColor, notification_view()->action_buttons_[0]->enabled_color_for_testing()); @@ -1004,8 +1002,10 @@ TEST_F(NotificationViewMDTest, TestAccentColor) { // same accent color. notification->set_accent_color(kCustomAccentColor); UpdateNotificationViews(*notification); - EXPECT_EQ(kCustomAccentColor, - notification_view()->header_row_->accent_color_for_testing()); + auto accent_color = + notification_view()->header_row_->accent_color_for_testing(); + ASSERT_TRUE(accent_color.has_value()); + EXPECT_EQ(kCustomAccentColor, accent_color.value()); EXPECT_EQ( kCustomAccentColor, notification_view()->action_buttons_[0]->enabled_color_for_testing()); @@ -1097,7 +1097,8 @@ TEST_F(NotificationViewMDTest, UpdateInSettings) { notification->set_type(NOTIFICATION_TYPE_SIMPLE); UpdateNotificationViews(*notification); - ui::test::EventGenerator generator(GetRootWindow(widget())); + ui::test::EventGenerator generator( + GetRootWindow(notification_view()->GetWidget())); // Inline settings will be shown by clicking settings button. EXPECT_FALSE(notification_view()->settings_row_->GetVisible()); @@ -1124,7 +1125,8 @@ TEST_F(NotificationViewMDTest, InlineSettings) { notification->set_type(NOTIFICATION_TYPE_SIMPLE); UpdateNotificationViews(*notification); - ui::test::EventGenerator generator(GetRootWindow(widget())); + ui::test::EventGenerator generator( + GetRootWindow(notification_view()->GetWidget())); // Inline settings will be shown by clicking settings button. EXPECT_FALSE(notification_view()->settings_row_->GetVisible()); @@ -1183,7 +1185,8 @@ TEST_F(NotificationViewMDTest, InlineSettingsInkDropAnimation) { notification->set_type(NOTIFICATION_TYPE_SIMPLE); UpdateNotificationViews(*notification); - ui::test::EventGenerator generator(GetRootWindow(widget())); + ui::test::EventGenerator generator( + GetRootWindow(notification_view()->GetWidget())); // Inline settings will be shown by clicking settings button. EXPECT_FALSE(notification_view()->settings_row_->GetVisible()); @@ -1198,9 +1201,9 @@ TEST_F(NotificationViewMDTest, InlineSettingsInkDropAnimation) { notification_view()->GetInkDrop()->AddObserver(this); // Resize the widget by 1px to simulate the expand animation. - gfx::Rect size = widget()->GetWindowBoundsInScreen(); + gfx::Rect size = notification_view()->GetWidget()->GetWindowBoundsInScreen(); size.Inset(0, 0, 0, 1); - widget()->SetBounds(size); + notification_view()->GetWidget()->SetBounds(size); notification_view()->GetInkDrop()->RemoveObserver(this); @@ -1213,7 +1216,7 @@ TEST_F(NotificationViewMDTest, TestClick) { delegate_->set_expecting_click(true); UpdateNotificationViews(*notification); - widget()->Show(); + notification_view()->GetWidget()->Show(); ui::test::EventGenerator generator( GetRootWindow(notification_view()->GetWidget())); @@ -1237,9 +1240,10 @@ TEST_F(NotificationViewMDTest, TestClickExpanded) { delegate_->set_expecting_click(true); UpdateNotificationViews(*notification); - widget()->Show(); + notification_view()->GetWidget()->Show(); - ui::test::EventGenerator generator(GetRootWindow(widget())); + ui::test::EventGenerator generator( + GetRootWindow(notification_view()->GetWidget())); // Expand the notification if it's collapsed. if (!notification_view()->expanded_) |