Commit 1127af8a authored by Matthew Mourgos's avatar Matthew Mourgos Committed by Commit Bot

CrOS AppList: Announce when a focused view has a notification badge.

This change adds a new announcement which occurs when chromevox is
enabled and an app list item with a notification badge is focused.

Bug: 1126492
Change-Id: If581feecd46141dfa5027349c6e55575829d6b34
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2423054Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Matthew Mourgos <mmourgos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809862}
parent 2794e381
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
#include "components/sync/model/string_ordinal.h" #include "components/sync/model/string_ordinal.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
class FastShowPickler;
namespace ash { namespace ash {
enum class AppListConfigType; enum class AppListConfigType;
class AppListControllerImpl; class AppListControllerImpl;
...@@ -88,11 +86,12 @@ class APP_LIST_MODEL_EXPORT AppListItem { ...@@ -88,11 +86,12 @@ class APP_LIST_MODEL_EXPORT AppListItem {
bool has_notification_badge() const { return has_notification_badge_; } bool has_notification_badge() const { return has_notification_badge_; }
void UpdateBadgeForTesting(bool has_badge) { UpdateBadge(has_badge); }
protected: protected:
// Subclasses also have mutable access to the metadata ptr. // Subclasses also have mutable access to the metadata ptr.
AppListItemMetadata* metadata() { return metadata_.get(); } AppListItemMetadata* metadata() { return metadata_.get(); }
friend class ::FastShowPickler;
friend class AppListControllerImpl; friend class AppListControllerImpl;
friend class AppListItemList; friend class AppListItemList;
friend class AppListItemListTest; friend class AppListItemListTest;
......
...@@ -973,6 +973,10 @@ void AppListItemView::EnsureLayer() { ...@@ -973,6 +973,10 @@ void AppListItemView::EnsureLayer() {
layer()->SetFillsBoundsOpaquely(false); layer()->SetFillsBoundsOpaquely(false);
} }
bool AppListItemView::HasNotificationBadge() {
return item_weak_->has_notification_badge();
}
void AppListItemView::FireMouseDragTimerForTest() { void AppListItemView::FireMouseDragTimerForTest() {
mouse_drag_timer_.FireNow(); mouse_drag_timer_.FireNow();
} }
......
...@@ -141,6 +141,8 @@ class APP_LIST_EXPORT AppListItemView : public views::Button, ...@@ -141,6 +141,8 @@ class APP_LIST_EXPORT AppListItemView : public views::Button,
// Ensures this item view has its own layer. // Ensures this item view has its own layer.
void EnsureLayer(); void EnsureLayer();
bool HasNotificationBadge();
void FireMouseDragTimerForTest(); void FireMouseDragTimerForTest();
bool FireTouchDragTimerForTest(); bool FireTouchDragTimerForTest();
......
...@@ -1432,6 +1432,8 @@ void AppsGridView::SetSelectedItemByIndex(const GridIndex& index) { ...@@ -1432,6 +1432,8 @@ void AppsGridView::SetSelectedItemByIndex(const GridIndex& index) {
selected_view_ = new_selection; selected_view_ = new_selection;
selected_view_->SchedulePaint(); selected_view_->SchedulePaint();
selected_view_->NotifyAccessibilityEvent(ax::mojom::Event::kFocus, true); selected_view_->NotifyAccessibilityEvent(ax::mojom::Event::kFocus, true);
if (selected_view_->HasNotificationBadge())
AnnounceItemNotificationBadge(selected_view_->title()->GetText());
} }
GridIndex AppsGridView::GetIndexOfView(const AppListItemView* view) const { GridIndex AppsGridView::GetIndexOfView(const AppListItemView* view) const {
...@@ -3794,6 +3796,17 @@ void AppsGridView::MaybeCreateFolderDroppingAccessibilityEvent() { ...@@ -3794,6 +3796,17 @@ void AppsGridView::MaybeCreateFolderDroppingAccessibilityEvent() {
drop_view->title()->GetText(), drop_view->is_folder()); drop_view->title()->GetText(), drop_view->is_folder());
} }
void AppsGridView::AnnounceItemNotificationBadge(
const base::string16& selected_view_title) {
// Set a11y name to announce the notification badge for the focused item.
auto* announcement_view =
contents_view_->app_list_view()->announcement_view();
announcement_view->GetViewAccessibility().OverrideName(
l10n_util::GetStringFUTF16(IDS_APP_LIST_APP_FOCUS_NOTIFICATION_BADGE,
selected_view_title));
announcement_view->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
}
void AppsGridView::AnnounceFolderDrop(const base::string16& moving_view_title, void AppsGridView::AnnounceFolderDrop(const base::string16& moving_view_title,
const base::string16& target_view_title, const base::string16& target_view_title,
bool target_is_folder) { bool target_is_folder) {
......
...@@ -708,6 +708,10 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -708,6 +708,10 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// folder or creating a folder with two apps. // folder or creating a folder with two apps.
void MaybeCreateFolderDroppingAccessibilityEvent(); void MaybeCreateFolderDroppingAccessibilityEvent();
// Modifies the announcement view to verbalize that the focused view has new
// updates, based on the item having a notification badge.
void AnnounceItemNotificationBadge(const base::string16& selected_view_title);
// Modifies the announcement view to verbalize that the current drag will move // Modifies the announcement view to verbalize that the current drag will move
// |moving_view_title| and create a folder or move it into an existing folder // |moving_view_title| and create a folder or move it into an existing folder
// with |target_view_title|. // with |target_view_title|.
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "ash/public/cpp/test/shell_test_api.h" #include "ash/public/cpp/test/shell_test_api.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.h" #include "chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.h"
#include "chrome/browser/ui/app_list/app_list_client_impl.h" #include "chrome/browser/ui/app_list/app_list_client_impl.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -24,6 +25,7 @@ ...@@ -24,6 +25,7 @@
#include "content/public/test/browser_test.h" #include "content/public/test/browser_test.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/ui_base_features.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/manager/display_manager.h" #include "ui/display/manager/display_manager.h"
...@@ -137,6 +139,65 @@ INSTANTIATE_TEST_SUITE_P(TestAsNormalAndGuestUser, ...@@ -137,6 +139,65 @@ INSTANTIATE_TEST_SUITE_P(TestAsNormalAndGuestUser,
::testing::Values(kTestAsNormalUser, ::testing::Values(kTestAsNormalUser,
kTestAsGuestUser)); kTestAsGuestUser));
class NotificationSpokenFeedbackAppListTest : public SpokenFeedbackAppListTest {
protected:
NotificationSpokenFeedbackAppListTest() {
scoped_features_.InitWithFeatures({::features::kNotificationIndicator}, {});
}
~NotificationSpokenFeedbackAppListTest() = default;
void SetUpCommandLine(base::CommandLine* command_line) override {
SpokenFeedbackAppListTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(ash::switches::kAshEnableTabletMode);
}
void SetNotificationBadgeForApp(const std::string& id, bool has_badge) {
auto* model = ash::Shell::Get()->app_list_controller()->GetModel();
auto* item = model->FindItem(id);
item->UpdateBadgeForTesting(has_badge);
}
private:
base::test::ScopedFeatureList scoped_features_;
};
INSTANTIATE_TEST_SUITE_P(TestAsNormalAndGuestUser,
NotificationSpokenFeedbackAppListTest,
::testing::Values(kTestAsNormalUser,
kTestAsGuestUser));
// Checks that when an app list item with a notification badge is focused, an
// announcement is made that the item has new updates.
IN_PROC_BROWSER_TEST_P(NotificationSpokenFeedbackAppListTest,
AppListItemNotificationBadgeAnnounced) {
PopulateApps(1);
SetNotificationBadgeForApp("Item 0", true);
EnableChromeVox();
sm_.Call(
[this]() { EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF)); });
sm_.ExpectSpeech("Shelf");
// Press space on the launcher button in shelf, this opens peeking
// launcher.
sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_SPACE); });
sm_.ExpectSpeech("Launcher, partial view");
// Move focus to expand all apps button.
sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_UP); });
sm_.ExpectSpeech("Expand to all apps");
// Press space on expand arrow to go to fullscreen launcher.
sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_SPACE); });
sm_.ExpectSpeech("Launcher, all apps");
// Move focus to 1st app;
sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_RIGHT); });
// Check that the announcmenet for items with a notification badge occurs.
sm_.ExpectSpeech("Item 0 has new updates.");
sm_.Replay();
}
// Checks that entering and exiting tablet mode with a browser window open does // Checks that entering and exiting tablet mode with a browser window open does
// not generate an accessibility event. // not generate an accessibility event.
IN_PROC_BROWSER_TEST_P( IN_PROC_BROWSER_TEST_P(
......
...@@ -895,6 +895,9 @@ need to be translated for each locale.--> ...@@ -895,6 +895,9 @@ need to be translated for each locale.-->
<message name="IDS_ALL_APPS_INDICATOR" desc="Indicator text in the launcher on top of all apps."> <message name="IDS_ALL_APPS_INDICATOR" desc="Indicator text in the launcher on top of all apps.">
ALL APPS ALL APPS
</message> </message>
<message name="IDS_APP_LIST_APP_FOCUS_NOTIFICATION_BADGE" desc="The spoken feedback text for when an app icon is focused and has a notification badge shown on the icon.">
<ph name="FOCUSED_APP_NAME">$1<ex>App Name</ex></ph> has new updates.
</message>
<message name="IDS_APP_LIST_APP_DRAG_LOCATION_ACCESSIBILE_NAME" desc="The spoken feedback which tells the location that a dragged app has dropped to."> <message name="IDS_APP_LIST_APP_DRAG_LOCATION_ACCESSIBILE_NAME" desc="The spoken feedback which tells the location that a dragged app has dropped to.">
Moved to Page <ph name="PAGE_NUMBER">$1<ex>1</ex></ph>, row <ph name="ROW_NUMBER">$2<ex>4</ex></ph>, column <ph name="COLUMN_NUMBER">$3<ex>2</ex></ph>. Moved to Page <ph name="PAGE_NUMBER">$1<ex>1</ex></ph>, row <ph name="ROW_NUMBER">$2<ex>4</ex></ph>, column <ph name="COLUMN_NUMBER">$3<ex>2</ex></ph>.
</message> </message>
......
ccc2b3ba2e096d406d2a17cb8bd10ae9fb75cf54
\ No newline at end of file
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