Commit 051153e8 authored by Matthew Mourgos's avatar Matthew Mourgos Committed by Commit Bot

Fix chromevox state transition announcement

- When ChromeVox is enabled, launcher state transitions to peeking or
  fullscreen are now announced.
- This fix also removes the ability to focus on the expand arrow while
  in fullscreen.

Bug: 779687
Change-Id: I942737bed53c258272aaea1a379cb7dd4053f605
Reviewed-on: https://chromium-review.googlesource.com/c/1423741Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarWeidong Guo <weidongg@chromium.org>
Commit-Queue: Matthew Mourgos <mmourgos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625756}
parent cb1067cf
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "ui/gfx/skia_util.h" #include "ui/gfx/skia_util.h"
#include "ui/keyboard/keyboard_controller.h" #include "ui/keyboard/keyboard_controller.h"
#include "ui/strings/grit/ui_strings.h" #include "ui/strings/grit/ui_strings.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/image_view.h" #include "ui/views/controls/image_view.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/fill_layout.h" #include "ui/views/layout/fill_layout.h"
...@@ -478,11 +479,6 @@ void AppListView::Layout() { ...@@ -478,11 +479,6 @@ void AppListView::Layout() {
UpdateAppListBackgroundYPosition(); UpdateAppListBackgroundYPosition();
} }
void AppListView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->SetName(state_announcement_);
node_data->role = ax::mojom::Role::kAlert;
}
ax::mojom::Role AppListView::GetAccessibleWindowRole() const { ax::mojom::Role AppListView::GetAccessibleWindowRole() const {
// Default role of root view is ax::mojom::Role::kWindow which traps ChromeVox // Default role of root view is ax::mojom::Role::kWindow which traps ChromeVox
// focus within the root view. Assign ax::mojom::Role::kGroup here to allow // focus within the root view. Assign ax::mojom::Role::kGroup here to allow
...@@ -549,6 +545,9 @@ void AppListView::InitContents(int initial_apps_page) { ...@@ -549,6 +545,9 @@ void AppListView::InitContents(int initial_apps_page) {
search_box_view_->Init(); search_box_view_->Init();
app_list_main_view_->Init(0, search_box_view_); app_list_main_view_->Init(0, search_box_view_);
announcement_view_ = new views::View;
AddChildView(announcement_view_);
} }
void AppListView::InitChildWidgets() { void AppListView::InitChildWidgets() {
...@@ -887,17 +886,17 @@ void AppListView::MaybeCreateAccessibilityEvent(AppListViewState new_state) { ...@@ -887,17 +886,17 @@ void AppListView::MaybeCreateAccessibilityEvent(AppListViewState new_state) {
new_state != AppListViewState::FULLSCREEN_ALL_APPS) new_state != AppListViewState::FULLSCREEN_ALL_APPS)
return; return;
DCHECK(state_announcement_ == base::string16()); base::string16 state_announcement;
if (new_state == AppListViewState::PEEKING) { if (new_state == AppListViewState::PEEKING) {
state_announcement_ = l10n_util::GetStringUTF16( state_announcement = l10n_util::GetStringUTF16(
IDS_APP_LIST_SUGGESTED_APPS_ACCESSIBILITY_ANNOUNCEMENT); IDS_APP_LIST_SUGGESTED_APPS_ACCESSIBILITY_ANNOUNCEMENT);
} else { } else {
state_announcement_ = l10n_util::GetStringUTF16( state_announcement = l10n_util::GetStringUTF16(
IDS_APP_LIST_ALL_APPS_ACCESSIBILITY_ANNOUNCEMENT); IDS_APP_LIST_ALL_APPS_ACCESSIBILITY_ANNOUNCEMENT);
} }
NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); announcement_view_->GetViewAccessibility().OverrideName(state_announcement);
state_announcement_ = base::string16(); announcement_view_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
} }
display::Display AppListView::GetDisplayNearestView() const { display::Display AppListView::GetDisplayNearestView() const {
......
...@@ -131,7 +131,6 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView { ...@@ -131,7 +131,6 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView {
bool CanProcessEventsWithinSubtree() const override; bool CanProcessEventsWithinSubtree() const override;
bool AcceleratorPressed(const ui::Accelerator& accelerator) override; bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
void Layout() override; void Layout() override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
// WidgetDelegate: // WidgetDelegate:
ax::mojom::Role GetAccessibleWindowRole() const override; ax::mojom::Role GetAccessibleWindowRole() const override;
...@@ -404,9 +403,6 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView { ...@@ -404,9 +403,6 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView {
// True if the dragging started from PEEKING state. // True if the dragging started from PEEKING state.
bool drag_started_from_peeking_ = false; bool drag_started_from_peeking_ = false;
// Accessibility announcement dialogue.
base::string16 state_announcement_;
// Metric reporter for state change animations. // Metric reporter for state change animations.
const std::unique_ptr<ui::AnimationMetricsReporter> const std::unique_ptr<ui::AnimationMetricsReporter>
state_animation_metrics_reporter_; state_animation_metrics_reporter_;
...@@ -414,6 +410,9 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView { ...@@ -414,6 +410,9 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView {
// Whether the on-screen keyboard is shown. // Whether the on-screen keyboard is shown.
bool onscreen_keyboard_shown_ = false; bool onscreen_keyboard_shown_ = false;
// View used to announce the state transition for peeking and fullscreen.
views::View* announcement_view_; // Owned by AppListView.
base::WeakPtrFactory<AppListView> weak_ptr_factory_; base::WeakPtrFactory<AppListView> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(AppListView); DISALLOW_COPY_AND_ASSIGN(AppListView);
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/keyboard/keyboard_controller.h" #include "ui/keyboard/keyboard_controller.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/view_model.h" #include "ui/views/view_model.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
...@@ -353,15 +354,21 @@ void ContentsView::UpdateExpandArrowOpacity(double progress, ...@@ -353,15 +354,21 @@ void ContentsView::UpdateExpandArrowOpacity(double progress,
void ContentsView::UpdateExpandArrowFocusBehavior( void ContentsView::UpdateExpandArrowFocusBehavior(
ash::AppListState current_state) { ash::AppListState current_state) {
if (current_state == ash::AppListState::kStateStart) { bool state_start = current_state == ash::AppListState::kStateStart;
// The expand arrow is only focusable and has InkDropMode on in peeking
// state. // The expand arrow is only focusable and has InkDropMode on in peeking
expand_arrow_view_->SetFocusBehavior(FocusBehavior::ALWAYS); // state.
expand_arrow_view_->SetInkDropMode(views::InkDropHostView::InkDropMode::ON); expand_arrow_view_->SetFocusBehavior(state_start ? FocusBehavior::ALWAYS
return; : FocusBehavior::NEVER);
} expand_arrow_view_->SetInkDropMode(
expand_arrow_view_->SetInkDropMode(views::InkDropHostView::InkDropMode::OFF); state_start ? views::InkDropHostView::InkDropMode::ON
expand_arrow_view_->SetFocusBehavior(FocusBehavior::NEVER); : views::InkDropHostView::InkDropMode::OFF);
// Allow ChromeVox to focus the expand arrow only when peeking launcher.
expand_arrow_view_->GetViewAccessibility().OverrideIsIgnored(
state_start ? false : true);
expand_arrow_view_->GetViewAccessibility().NotifyAccessibilityEvent(
ax::mojom::Event::kTreeChanged);
} }
PaginationModel* ContentsView::GetAppsPaginationModel() { PaginationModel* ContentsView::GetAppsPaginationModel() {
......
...@@ -350,6 +350,81 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_TypeInOmnibox) { ...@@ -350,6 +350,81 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_TypeInOmnibox) {
EXPECT_EQ("z", speech_monitor_.GetNextUtterance()); EXPECT_EQ("z", speech_monitor_.GetNextUtterance());
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, LauncherStateTransition) {
EnableChromeVox();
EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF));
while (true) {
std::string utterance = speech_monitor_.GetNextUtterance();
if (base::MatchPattern(utterance, "Launcher"))
break;
}
EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Shelf", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Tool bar", speech_monitor_.GetNextUtterance());
EXPECT_EQ(", window", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Press Search plus Space to activate.",
speech_monitor_.GetNextUtterance());
// Press space on the launcher button in shelf, this opens peeking launcher.
SendKeyPressWithSearch(ui::VKEY_SPACE);
EXPECT_EQ("Edit text", speech_monitor_.GetNextUtterance());
EXPECT_EQ(", window", speech_monitor_.GetNextUtterance());
// Check that Launcher, partial view state is announced.
EXPECT_EQ("Launcher, partial view", speech_monitor_.GetNextUtterance());
// Move focus to expand all apps button;
SendKeyPressWithSearchAndShift(ui::VKEY_TAB);
EXPECT_EQ("Expand to all apps", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
EXPECT_EQ("Press Search plus Space to activate.",
speech_monitor_.GetNextUtterance());
// Press space on expand arrow to go to fullscreen launcher.
SendKeyPressWithSearch(ui::VKEY_SPACE);
EXPECT_EQ("Edit text", speech_monitor_.GetNextUtterance());
// Check that Launcher, all apps state is announced.
EXPECT_EQ("Launcher, all apps", speech_monitor_.GetNextUtterance());
}
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DisabledFullscreenExpandButton) {
EnableChromeVox();
EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF));
while (speech_monitor_.GetNextUtterance() !=
"Press Search plus Space to activate.") {
}
// Press space on the launcher button in shelf, this opens peeking launcher.
SendKeyPressWithSearch(ui::VKEY_SPACE);
while (speech_monitor_.GetNextUtterance() != "Launcher, partial view") {
}
// Move focus to expand all apps button.
SendKeyPressWithSearchAndShift(ui::VKEY_TAB);
while (speech_monitor_.GetNextUtterance() !=
"Press Search plus Space to activate.") {
}
// Press space on expand arrow to go to fullscreen launcher.
SendKeyPressWithSearch(ui::VKEY_SPACE);
while (speech_monitor_.GetNextUtterance() != "Launcher, all apps") {
}
// Make sure the first traversal left is not the expand arrow button.
SendKeyPressWithSearch(ui::VKEY_LEFT);
EXPECT_NE("Expand to all apps", speech_monitor_.GetNextUtterance());
// Make sure the second traversal left is not the expand arrow button.
SendKeyPressWithSearch(ui::VKEY_LEFT);
EXPECT_NE("Expand to all apps", speech_monitor_.GetNextUtterance());
}
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusShelf) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusShelf) {
EnableChromeVox(); EnableChromeVox();
......
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