Commit ae029647 authored by Ana Salazar's avatar Ana Salazar Committed by Commit Bot

Set Launcher's window title for ChromeVox

Update the title for launcher's window when the launcher changes states.
This will give Chomevox the information needed to read the title of the
window when the user is navigating through the launcher and presses
search + a, w.

For a partially shown launcher (peeking), the title will be "Launcher,
partial view".

For the fullscreen launcher, the title will be "Launcher, all apps".

If the searchbox or the assistant is displaying results, the title will
be "Launcher"

Bug: 1111165
Change-Id: I6715ea095b568f72466182ed20a33b7fffde8538
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2476618
Commit-Queue: Ana Salazar <anasalazar@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820394}
parent 83d1d823
......@@ -1572,11 +1572,42 @@ void AppListView::SetState(AppListViewState new_state) {
GetInitiallyFocusedView()->RequestFocus();
}
UpdateWindowTitle();
// Updates the visibility of app list items according to the change of
// |app_list_state_|.
GetAppsContainerView()->UpdateControlVisibility(app_list_state_, is_in_drag_);
}
void AppListView::UpdateWindowTitle() {
if (!GetWidget())
return;
gfx::NativeView window = GetWidget()->GetNativeView();
AppListState contents_view_state = app_list_main_view_->model()->state();
if (window) {
if (contents_view_state == AppListState::kStateSearchResults ||
contents_view_state == AppListState::kStateEmbeddedAssistant) {
window->SetTitle(l10n_util::GetStringUTF16(
IDS_APP_LIST_LAUNCHER_ACCESSIBILITY_ANNOUNCEMENT));
return;
}
switch (app_list_state_) {
case AppListViewState::kPeeking:
window->SetTitle(l10n_util::GetStringUTF16(
IDS_APP_LIST_SUGGESTED_APPS_ACCESSIBILITY_ANNOUNCEMENT));
break;
case AppListViewState::kFullscreenAllApps:
window->SetTitle(l10n_util::GetStringUTF16(
IDS_APP_LIST_ALL_APPS_ACCESSIBILITY_ANNOUNCEMENT));
break;
case AppListViewState::kClosed:
case AppListViewState::kHalf:
case AppListViewState::kFullscreenSearch:
break;
}
}
}
base::TimeDelta AppListView::GetStateTransitionAnimationDuration(
AppListViewState target_state) {
if (ShortAnimationsForTesting() || is_side_shelf_ ||
......
......@@ -377,6 +377,9 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
// page. Called when the app list's visibility changes.
void UpdatePageResetTimer(bool app_list_visibility);
// Updates the title of the window that contains the launcher.
void UpdateWindowTitle();
private:
FRIEND_TEST_ALL_PREFIXES(AppListControllerImplTest,
CheckAppListViewBoundsWhenVKeyboardEnabled);
......
......@@ -27,11 +27,13 @@
#include "base/check_op.h"
#include "base/notreached.h"
#include "base/numerics/ranges.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/view_constants_aura.h"
#include "ui/views/view_model.h"
......@@ -309,6 +311,7 @@ void ContentsView::ActivePageChanged() {
GetAppListMainView()->model()->SetState(state);
UpdateSearchBoxVisibility(state);
app_list_view_->UpdateWindowTitle();
}
void ContentsView::ShowSearchResults(bool show) {
......
......@@ -14,6 +14,7 @@
#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/profiles/profile.h"
#include "chrome/browser/ui/app_list/app_list_client_impl.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
......@@ -23,6 +24,7 @@
#include "chromeos/constants/chromeos_switches.h"
#include "components/user_manager/user_names.h"
#include "content/public/test/browser_test.h"
#include "extensions/browser/browsertest_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/ui_base_features.h"
......@@ -105,6 +107,12 @@ class SpokenFeedbackAppListTest
}
}
void ReadWindowTitle() {
extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait(
browser()->profile(), extension_misc::kChromeVoxExtensionId,
"CommandHandler.onCommand('readCurrentTitle');");
}
private:
ash::test::AppListTestModel* app_list_test_model_ = nullptr;
ash::SearchModel* search_model = nullptr;
......@@ -543,4 +551,40 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest, AppListReordering) {
sm_.Replay();
}
IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest,
LauncherWindowTitleAnnouncement) {
EnableChromeVox();
sm_.Call(
[this]() { EXPECT_TRUE(PerformAcceleratorAction(ash::FOCUS_SHELF)); });
sm_.ExpectSpeechPattern("Launcher");
sm_.ExpectSpeech("Button");
sm_.ExpectSpeech("Shelf");
sm_.ExpectSpeech("Tool bar");
// Press space on the launcher button in shelf, this opens peeking
// launcher.
sm_.Call([this]() { SendKeyPressWithSearch(ui::VKEY_SPACE); });
sm_.ExpectSpeechPattern("Search your device,*");
sm_.ExpectSpeech("Edit text");
sm_.ExpectSpeech("Launcher, partial view");
sm_.Call([this]() { ReadWindowTitle(); });
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_.ExpectSpeechPattern("Search your device,*");
sm_.ExpectSpeech("Edit text");
sm_.ExpectSpeech("Launcher, all apps");
sm_.Call([this]() { ReadWindowTitle(); });
sm_.ExpectSpeech("Launcher, all apps");
// Activate the search widget.
sm_.Call([this]() { SendKeyPress(ui::VKEY_A); });
sm_.ExpectSpeechPattern("Displaying *");
sm_.Call([this]() { ReadWindowTitle(); });
sm_.ExpectSpeech("Launcher");
sm_.Replay();
}
} // namespace chromeos
......@@ -940,6 +940,9 @@ need to be translated for each locale.-->
<message name="IDS_APP_LIST_SUGGESTED_APPS_ACCESSIBILITY_ANNOUNCEMENT" desc="The accessibility announcement that notifies users that the UI is showing a small version of the app list">
Launcher, partial view
</message>
<message name="IDS_APP_LIST_LAUNCHER_ACCESSIBILITY_ANNOUNCEMENT" desc="The accessibility announcement that notifies users that the UI is showing the search results">
Launcher
</message>
<message name="IDS_APP_LIST_CLEAR_SEARCHBOX" desc="Tooltip for the button that clears all text from the search box in the app list.">
Clear searchbox text
</message>
......
13c79cfac43e1052063608d5b032e434c82d53b2
\ 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