Commit 0dbc80a7 authored by Becca Hughes's avatar Becca Hughes Committed by Commit Bot

[Lock Screen Media Controls] Fix close button ChromeVox issue

The close button is not accessible by ChromeVox since
it is not drawn. Therefore, we should switch between a
blank image and the icon.

BUG=994838

Change-Id: I008b08b8620c20504806958eedeb8e26a112c0ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1758718
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688226}
parent ba8ec6c1
...@@ -219,6 +219,12 @@ class LockScreenMediaControlsViewTest : public LoginTestBase { ...@@ -219,6 +219,12 @@ class LockScreenMediaControlsViewTest : public LoginTestBase {
return header_row()->close_button_for_testing(); return header_row()->close_button_for_testing();
} }
bool CloseButtonHasImage() const {
return !close_button()
->GetImage(views::Button::ButtonState::STATE_NORMAL)
.isNull();
}
const views::ImageView* icon_view() const { const views::ImageView* icon_view() const {
return header_row()->app_icon_for_testing(); return header_row()->app_icon_for_testing();
} }
...@@ -409,7 +415,8 @@ TEST_F(LockScreenMediaControlsViewTest, ProgressBarVisibility) { ...@@ -409,7 +415,8 @@ TEST_F(LockScreenMediaControlsViewTest, ProgressBarVisibility) {
TEST_F(LockScreenMediaControlsViewTest, CloseButtonVisibility) { TEST_F(LockScreenMediaControlsViewTest, CloseButtonVisibility) {
EXPECT_TRUE(media_controls_view_->IsDrawn()); EXPECT_TRUE(media_controls_view_->IsDrawn());
EXPECT_FALSE(close_button()->IsDrawn()); EXPECT_TRUE(close_button()->IsDrawn());
EXPECT_FALSE(CloseButtonHasImage());
// Move the mouse inside |media_controls_view_|. // Move the mouse inside |media_controls_view_|.
ui::test::EventGenerator* generator = GetEventGenerator(); ui::test::EventGenerator* generator = GetEventGenerator();
...@@ -417,14 +424,17 @@ TEST_F(LockScreenMediaControlsViewTest, CloseButtonVisibility) { ...@@ -417,14 +424,17 @@ TEST_F(LockScreenMediaControlsViewTest, CloseButtonVisibility) {
media_controls_view_->GetBoundsInScreen().CenterPoint()); media_controls_view_->GetBoundsInScreen().CenterPoint());
// Verify that the close button is shown. // Verify that the close button is shown.
EXPECT_TRUE(media_controls_view_->IsDrawn());
EXPECT_TRUE(close_button()->IsDrawn()); EXPECT_TRUE(close_button()->IsDrawn());
EXPECT_TRUE(CloseButtonHasImage());
// Move the mouse outside |media_controls_view_|. // Move the mouse outside |media_controls_view_|.
generator->MoveMouseBy(500, 500); generator->MoveMouseBy(500, 500);
// Verify that the close button is hidden. // Verify that the close button is hidden.
EXPECT_TRUE(media_controls_view_->IsDrawn()); EXPECT_TRUE(media_controls_view_->IsDrawn());
EXPECT_FALSE(close_button()->IsDrawn()); EXPECT_TRUE(close_button()->IsDrawn());
EXPECT_FALSE(CloseButtonHasImage());
} }
TEST_F(LockScreenMediaControlsViewTest, CloseButtonClick) { TEST_F(LockScreenMediaControlsViewTest, CloseButtonClick) {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "components/vector_icons/vector_icons.h" #include "components/vector_icons/vector_icons.h"
#include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_node_data.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/font_list.h" #include "ui/gfx/font_list.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/views/background.h" #include "ui/views/background.h"
...@@ -90,14 +91,13 @@ MediaControlsHeaderView::MediaControlsHeaderView( ...@@ -90,14 +91,13 @@ MediaControlsHeaderView::MediaControlsHeaderView(
AddChildView(std::move(spacer)); AddChildView(std::move(spacer));
auto close_button = CreateVectorImageButton(this); auto close_button = CreateVectorImageButton(this);
SetImageFromVectorIcon(close_button.get(), vector_icons::kCloseRoundedIcon,
kCloseButtonIconSize, gfx::kGoogleGrey700);
close_button->SetPreferredSize(kCloseButtonSize); close_button->SetPreferredSize(kCloseButtonSize);
close_button->SetFocusBehavior(View::FocusBehavior::ALWAYS); close_button->SetFocusBehavior(View::FocusBehavior::ALWAYS);
base::string16 close_button_label( base::string16 close_button_label(
l10n_util::GetStringUTF16(IDS_ASH_LOCK_SCREEN_MEDIA_CONTROLS_CLOSE)); l10n_util::GetStringUTF16(IDS_ASH_LOCK_SCREEN_MEDIA_CONTROLS_CLOSE));
close_button->SetAccessibleName(close_button_label); close_button->SetAccessibleName(close_button_label);
close_button->SetVisible(false); close_button->set_ink_drop_base_color(
color_utils::DeriveDefaultIconColor(gfx::kGoogleGrey700));
close_button_ = AddChildView(std::move(close_button)); close_button_ = AddChildView(std::move(close_button));
} }
...@@ -112,9 +112,11 @@ void MediaControlsHeaderView::SetAppName(const base::string16& name) { ...@@ -112,9 +112,11 @@ void MediaControlsHeaderView::SetAppName(const base::string16& name) {
} }
void MediaControlsHeaderView::SetCloseButtonVisibility(bool visible) { void MediaControlsHeaderView::SetCloseButtonVisibility(bool visible) {
if (visible != close_button_->GetVisible()) { if (visible) {
close_button_->SetVisible(visible); SetImageFromVectorIcon(close_button_, vector_icons::kCloseRoundedIcon,
Layout(); kCloseButtonIconSize, gfx::kGoogleGrey700);
} else {
close_button_->SetImage(views::Button::ButtonState::STATE_NORMAL, nullptr);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment