a11y: Update accessible name for notification expand button
We want to have more details in the tooltip for the expand button to include the notification title. Fixed: b:278915898 Change-Id: I4037fe31d81f8f880fa43fbf10cd8838f1f36216 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4936396 Reviewed-by: Alex Newcomer <newcomer@chromium.org> Commit-Queue: Andre Le <leandre@chromium.org> Cr-Commit-Position: refs/heads/main@{#1209685}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
dbf77c49ab
commit
7f0aef671c
@ -5113,10 +5113,10 @@ Some features are limited to increase battery life.
|
||||
|
||||
<!-- Notification -->
|
||||
<message name="IDS_ASH_NOTIFICATION_EXPAND_TOOLTIP" desc="The tooltip for the expand button, indicating action to expand the notification.">
|
||||
Expand notification
|
||||
Expand <ph name="NOTIFICATION_TITLE">$1<ex>Restore</ex></ph> notification
|
||||
</message>
|
||||
<message name="IDS_ASH_NOTIFICATION_COLLAPSE_TOOLTIP" desc="The tooltip for the expand button, indicating action to collapse the notification.">
|
||||
Collapse notification
|
||||
Collapse <ph name="NOTIFICATION_TITLE">$1<ex>Restore</ex></ph> notification
|
||||
</message>
|
||||
<message name="IDS_ASH_NOTIFICATION_EXPAND_DISABLED_TOOLTIP" desc="The tooltip for the expand button when it is disabled, indicating that user cannot expand the notification in this situation.">
|
||||
You can't expand the notification while a panel is open. Close the panel below first.
|
||||
|
@ -1 +1 @@
|
||||
aa789d2b13e11fe6116fb31e009fa6b9d6ab9fd0
|
||||
84edc1b1e0106b4530c4a2c93114706b479d25b7
|
@ -1 +1 @@
|
||||
b163fe6c3f3872c03f55bc3345e7a6501741c082
|
||||
db51350be7db5ff59e083b0e4834da526a96b511
|
@ -247,6 +247,15 @@ void AshNotificationExpandButton::SetExpandCollapseEnabled(bool enabled) {
|
||||
UpdateTooltip();
|
||||
}
|
||||
|
||||
void AshNotificationExpandButton::SetNotificationTitleForButtonTooltip(
|
||||
const std::u16string& notification_title) {
|
||||
if (notification_title_ == notification_title) {
|
||||
return;
|
||||
}
|
||||
notification_title_ = notification_title;
|
||||
UpdateTooltip();
|
||||
}
|
||||
|
||||
void AshNotificationExpandButton::AnimateBoundsChange(
|
||||
int duration_in_ms,
|
||||
gfx::Tween::Type tween_type,
|
||||
@ -310,9 +319,10 @@ void AshNotificationExpandButton::UpdateTooltip() {
|
||||
tooltip_text =
|
||||
l10n_util::GetStringUTF16(IDS_ASH_NOTIFICATION_EXPAND_DISABLED_TOOLTIP);
|
||||
} else {
|
||||
tooltip_text = l10n_util::GetStringUTF16(
|
||||
tooltip_text = l10n_util::GetStringFUTF16(
|
||||
expanded_ ? IDS_ASH_NOTIFICATION_COLLAPSE_TOOLTIP
|
||||
: IDS_ASH_NOTIFICATION_EXPAND_TOOLTIP);
|
||||
: IDS_ASH_NOTIFICATION_EXPAND_TOOLTIP,
|
||||
notification_title_);
|
||||
}
|
||||
|
||||
image_->SetTooltipText(tooltip_text);
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef ASH_SYSTEM_MESSAGE_CENTER_ASH_NOTIFICATION_EXPAND_BUTTON_H_
|
||||
#define ASH_SYSTEM_MESSAGE_CENTER_ASH_NOTIFICATION_EXPAND_BUTTON_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "ui/views/controls/button/button.h"
|
||||
@ -53,6 +55,9 @@ class AshNotificationExpandButton : public views::Button {
|
||||
|
||||
void SetExpandCollapseEnabled(bool enabled);
|
||||
|
||||
void SetNotificationTitleForButtonTooltip(
|
||||
const std::u16string& notification_title);
|
||||
|
||||
void set_label_fading_out(bool label_fading_out) {
|
||||
label_fading_out_ = label_fading_out;
|
||||
}
|
||||
@ -96,6 +101,10 @@ class AshNotificationExpandButton : public views::Button {
|
||||
|
||||
bool disable_expand_collapse_ = false;
|
||||
|
||||
// Cache of the notification title. Used this to display in the button
|
||||
// tooltip.
|
||||
std::u16string notification_title_;
|
||||
|
||||
base::WeakPtrFactory<AshNotificationExpandButton> weak_factory_{this};
|
||||
};
|
||||
BEGIN_VIEW_BUILDER(/*no export*/, AshNotificationExpandButton, views::Button)
|
||||
|
@ -1321,6 +1321,8 @@ void AshNotificationView::CreateOrUpdateTitleView(
|
||||
ReorderViewInLeftContent(title_row_);
|
||||
}
|
||||
|
||||
expand_button_->SetNotificationTitleForButtonTooltip(title);
|
||||
|
||||
int max_available_width = notification.icon().IsEmpty()
|
||||
? kTitleRowMinimumWidth
|
||||
: kTitleRowMinimumWidthWithIcon;
|
||||
|
@ -1217,6 +1217,35 @@ TEST_F(AshNotificationViewTest, RecordExpandButtonClickAction) {
|
||||
metrics_utils::ExpandButtonClickAction::COLLAPSE_GROUP, 1);
|
||||
}
|
||||
|
||||
TEST_F(AshNotificationViewTest, ExpandButtonAccessibleName) {
|
||||
std::u16string notification_title = u"Test title";
|
||||
auto notification = CreateTestNotification();
|
||||
notification->set_title(notification_title);
|
||||
notification_view()->UpdateWithNotification(*notification);
|
||||
notification_view()->SetExpanded(false);
|
||||
|
||||
auto* expand_button = notification_view()->expand_button_for_test();
|
||||
|
||||
EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_ASH_NOTIFICATION_EXPAND_TOOLTIP,
|
||||
notification_title),
|
||||
expand_button->GetAccessibleName());
|
||||
|
||||
notification_view()->ToggleExpand();
|
||||
EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_ASH_NOTIFICATION_COLLAPSE_TOOLTIP,
|
||||
notification_title),
|
||||
expand_button->GetAccessibleName());
|
||||
|
||||
// Update the notification title. The expand button tooltip text should be
|
||||
// updated accordingly.
|
||||
notification_title = u"Updated test title";
|
||||
notification->set_title(notification_title);
|
||||
notification_view()->UpdateWithNotification(*notification);
|
||||
|
||||
EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_ASH_NOTIFICATION_COLLAPSE_TOOLTIP,
|
||||
notification_title),
|
||||
expand_button->GetAccessibleName());
|
||||
}
|
||||
|
||||
TEST_F(AshNotificationViewTest, OnThemeChangedWithoutMessageLabel) {
|
||||
EXPECT_NE(nullptr, GetMessageLabel(notification_view()));
|
||||
|
||||
|
Reference in New Issue
Block a user