0

VC UI: Add accessible name for return to app button

Add accessible strings for the summary row button and the return to app
buttons.

Fixed: b:266477004
Change-Id: Iaded4cd06b91069f3097a479fbc7be1a7cd94c1d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4499982
Commit-Queue: Andre Le <leandre@chromium.org>
Reviewed-by: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1138669}
This commit is contained in:
Andre Le
2023-05-02 23:41:30 +00:00
committed by Chromium LUCI CQ
parent 385d94d851
commit bd08b415b8
6 changed files with 95 additions and 2 deletions

@ -1569,6 +1569,12 @@ Style notes:
<message name="IDS_ASH_VIDEO_CONFERENCE_MICROPHONE_NAME" desc="Text display for the microphone.">
microphone
</message>
<message name="VIDEO_CONFERENCE_RETURN_TO_APP_PERIPHERALS_ACCESSIBLE_NAME" desc="Tooltip shown for the return to app button regarding peripherals in the video conference panel.">
<ph name="CAPTURE_MEDIUM">$1<ex>Camera</ex></ph> in use.
</message>
<message name="VIDEO_CONFERENCE_RETURN_TO_APP_ACCESSIBLE_NAME" desc="Tooltip shown for the return to app button in the video conference panel.">
Return to <ph name="APP_TITLE">$1<ex>Meet</ex></ph>.
</message>
<!-- Phone Hub tray-->
<message name="IDS_ASH_PHONE_HUB_TRAY_ACCESSIBLE_NAME" desc="The accessible name of the Phone Hub tray bubble for screen readers.">

@ -0,0 +1 @@
d8baf18ecd82635c27e1d49864eb666bfea0433d

@ -0,0 +1 @@
c102acadb00c5863a2323eb456308a87279270d8

@ -325,8 +325,17 @@ ReturnToAppButton::ReturnToAppButton(
icons_container_->layer()->SetFillsBoundsOpaquely(false);
}
// TODO(b/253646076): Double check accessible name for this button.
SetAccessibleName(display_text);
// An empty `id` means that this view is not associated with any particular
// app and it is the summary row, so we will just use the `display_text` as
// accessible name in this case rather than the full string.
std::u16string return_to_app_accessible_name =
id.is_empty()
? display_text
: l10n_util::GetStringFUTF16(
VIDEO_CONFERENCE_RETURN_TO_APP_ACCESSIBLE_NAME, display_text);
SetAccessibleName(GetPeripheralsAccessibleName() +
return_to_app_accessible_name);
// When we show the bubble for the first time, only the top row is visible.
SetVisible(is_top_row);
@ -386,6 +395,28 @@ void ReturnToAppButton::OnButtonClicked(
}
}
std::u16string ReturnToAppButton::GetPeripheralsAccessibleName() {
std::u16string tooltip_text;
if (is_capturing_camera_) {
tooltip_text += l10n_util::GetStringFUTF16(
VIDEO_CONFERENCE_RETURN_TO_APP_PERIPHERALS_ACCESSIBLE_NAME,
l10n_util::GetStringUTF16(VIDEO_CONFERENCE_TOGGLE_BUTTON_TYPE_CAMERA));
}
if (is_capturing_microphone_) {
tooltip_text += l10n_util::GetStringFUTF16(
VIDEO_CONFERENCE_RETURN_TO_APP_PERIPHERALS_ACCESSIBLE_NAME,
l10n_util::GetStringUTF16(
VIDEO_CONFERENCE_TOGGLE_BUTTON_TYPE_MICROPHONE));
}
if (is_capturing_screen_) {
tooltip_text += l10n_util::GetStringFUTF16(
VIDEO_CONFERENCE_RETURN_TO_APP_PERIPHERALS_ACCESSIBLE_NAME,
l10n_util::GetStringUTF16(
VIDEO_CONFERENCE_TOGGLE_BUTTON_TYPE_SCREEN_SHARE));
}
return tooltip_text;
}
// -----------------------------------------------------------------------------
// ReturnToAppContainer:

@ -91,6 +91,10 @@ class ASH_EXPORT ReturnToAppButton : public views::Button {
void OnButtonClicked(const base::UnguessableToken& id,
crosapi::mojom::VideoConferenceAppType app_type);
// Get the text regarding the peripherals part of the return to app button
// accessible name.
std::u16string GetPeripheralsAccessibleName();
// Indicates if the running app is using camera, microphone, or screen
// sharing.
const bool is_capturing_camera_;

@ -600,4 +600,54 @@ TEST_F(ReturnToAppPanelTest, ReturnToAppButtonTextElide) {
kEllipsisString));
}
TEST_F(ReturnToAppPanelTest, ReturnToAppButtonAccessibleName) {
controller()->ClearMediaApps();
controller()->AddMediaApp(CreateFakeMediaApp(
/*is_capturing_camera=*/true, /*is_capturing_microphone=*/false,
/*is_capturing_screen=*/false, /*title=*/u"Meet",
/*url=*/kMeetTestUrl));
controller()->AddMediaApp(CreateFakeMediaApp(
/*is_capturing_camera=*/false, /*is_capturing_microphone=*/true,
/*is_capturing_screen=*/true, /*title=*/u"Zoom",
/*url=*/""));
LeftClickOn(toggle_bubble_button());
auto* return_to_app_panel = GetReturnToAppPanel();
auto* return_to_app_container = GetReturnToAppContainer(return_to_app_panel);
auto* summary_row = static_cast<ReturnToAppButton*>(
return_to_app_container->children().front());
auto* first_app_row =
static_cast<ReturnToAppButton*>(return_to_app_container->children()[1]);
auto* second_app_row =
static_cast<ReturnToAppButton*>(return_to_app_container->children()[2]);
auto expected_camera_text = l10n_util::GetStringFUTF16(
VIDEO_CONFERENCE_RETURN_TO_APP_PERIPHERALS_ACCESSIBLE_NAME,
l10n_util::GetStringUTF16(VIDEO_CONFERENCE_TOGGLE_BUTTON_TYPE_CAMERA));
auto expected_microphone_text = l10n_util::GetStringFUTF16(
VIDEO_CONFERENCE_RETURN_TO_APP_PERIPHERALS_ACCESSIBLE_NAME,
l10n_util::GetStringUTF16(
VIDEO_CONFERENCE_TOGGLE_BUTTON_TYPE_MICROPHONE));
auto expected_screen_share_text = l10n_util::GetStringFUTF16(
VIDEO_CONFERENCE_RETURN_TO_APP_PERIPHERALS_ACCESSIBLE_NAME,
l10n_util::GetStringUTF16(
VIDEO_CONFERENCE_TOGGLE_BUTTON_TYPE_SCREEN_SHARE));
// Verify accessible name for each row.
EXPECT_EQ(expected_camera_text + expected_microphone_text +
expected_screen_share_text +
l10n_util::GetStringFUTF16Int(
IDS_ASH_VIDEO_CONFERENCE_RETURN_TO_APP_SUMMARY_TEXT, 2),
summary_row->GetAccessibleName());
EXPECT_EQ(expected_camera_text +
l10n_util::GetStringFUTF16(
VIDEO_CONFERENCE_RETURN_TO_APP_ACCESSIBLE_NAME, u"Meet"),
first_app_row->GetAccessibleName());
EXPECT_EQ(expected_microphone_text + expected_screen_share_text +
l10n_util::GetStringFUTF16(
VIDEO_CONFERENCE_RETURN_TO_APP_ACCESSIBLE_NAME, u"Zoom"),
second_app_row->GetAccessibleName());
}
} // namespace ash::video_conference