Commit b4b210ad authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Use SystemTrayTestApi in a11y browser tests.

This CL restores disabled TrayAccessibilityTest browser tests by using
SystemTrayTestApi mojo interface.

Although now the style of the test is Mash compliant, it still doesn't
work with Mash because some a11y features are not yet ported to Mash.

TEST=browser_tests
BUG=850014

Change-Id: I25bc3ec4b7409eb97632e9b14fc91aedf8fed178
Reviewed-on: https://chromium-review.googlesource.com/c/1309554Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605227}
parent 17361802
...@@ -13,6 +13,11 @@ enum ViewID { ...@@ -13,6 +13,11 @@ enum ViewID {
// Ash IDs start above the range used in Chrome (c/b/ui/view_ids.h). // Ash IDs start above the range used in Chrome (c/b/ui/view_ids.h).
VIEW_ID_ASH_START = 10000, VIEW_ID_ASH_START = 10000,
// Row for auto click feature in accessibility detailed view.
VIEW_ID_ACCESSIBILITY_AUTOCLICK,
// Icon that indicates auto click is enabled.
VIEW_ID_ACCESSIBILITY_AUTOCLICK_ENABLED,
// Accessibility feature pod button in main view.
VIEW_ID_ACCESSIBILITY_TRAY_ITEM, VIEW_ID_ACCESSIBILITY_TRAY_ITEM,
VIEW_ID_BLUETOOTH_DEFAULT_VIEW, VIEW_ID_BLUETOOTH_DEFAULT_VIEW,
// System tray casting row elements. // System tray casting row elements.
......
...@@ -9,7 +9,7 @@ import "mojo/public/mojom/base/string16.mojom"; ...@@ -9,7 +9,7 @@ import "mojo/public/mojom/base/string16.mojom";
// Top-level items in the system tray bubble. // Top-level items in the system tray bubble.
// TODO(jamescook): Consolidate with SystemTrayItem::UmaType. // TODO(jamescook): Consolidate with SystemTrayItem::UmaType.
enum TrayItem { enum TrayItem {
kEnterprise, kAccessibility,
kNetwork, kNetwork,
}; };
...@@ -36,7 +36,11 @@ interface SystemTrayTestApi { ...@@ -36,7 +36,11 @@ interface SystemTrayTestApi {
ShowDetailedView(TrayItem item) => (); ShowDetailedView(TrayItem item) => ();
// Returns true if the view exists in the bubble and is visible. // Returns true if the view exists in the bubble and is visible.
IsBubbleViewVisible(int32 view_id) => (bool visible); // If |open_tray| is true, it also opens system tray bubble.
IsBubbleViewVisible(int32 view_id, bool open_tray) => (bool visible);
// Clicks the view |view_id|.
ClickBubbleView(int32 view_id) => ();
// Returns the tooltip for a bubble view, or the empty string if the view // Returns the tooltip for a bubble view, or the empty string if the view
// does not exist. // does not exist.
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "ash/system/accessibility/accessibility_feature_pod_controller.h" #include "ash/system/accessibility/accessibility_feature_pod_controller.h"
#include "ash/accessibility/accessibility_delegate.h" #include "ash/accessibility/accessibility_delegate.h"
#include "ash/public/cpp/ash_view_ids.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller.h" #include "ash/session/session_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -24,6 +25,7 @@ AccessibilityFeaturePodController::~AccessibilityFeaturePodController() = ...@@ -24,6 +25,7 @@ AccessibilityFeaturePodController::~AccessibilityFeaturePodController() =
FeaturePodButton* AccessibilityFeaturePodController::CreateButton() { FeaturePodButton* AccessibilityFeaturePodController::CreateButton() {
auto* button = new FeaturePodButton(this); auto* button = new FeaturePodButton(this);
button->set_id(ash::VIEW_ID_ACCESSIBILITY_TRAY_ITEM);
button->SetLabel( button->SetLabel(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY)); l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY));
button->SetVectorIcon(kUnifiedMenuAccessibilityIcon); button->SetVectorIcon(kUnifiedMenuAccessibilityIcon);
...@@ -35,6 +37,7 @@ FeaturePodButton* AccessibilityFeaturePodController::CreateButton() { ...@@ -35,6 +37,7 @@ FeaturePodButton* AccessibilityFeaturePodController::CreateButton() {
AccessibilityDelegate* delegate = Shell::Get()->accessibility_delegate(); AccessibilityDelegate* delegate = Shell::Get()->accessibility_delegate();
LoginStatus login_status = Shell::Get()->session_controller()->login_status(); LoginStatus login_status = Shell::Get()->session_controller()->login_status();
button->SetVisible(login_status == LoginStatus::NOT_LOGGED_IN || button->SetVisible(login_status == LoginStatus::NOT_LOGGED_IN ||
login_status == LoginStatus::LOCKED ||
delegate->ShouldShowAccessibilityMenu()); delegate->ShouldShowAccessibilityMenu());
return button; return button;
} }
......
...@@ -266,6 +266,9 @@ void AccessibilityDetailedView::AppendAccessibilityList() { ...@@ -266,6 +266,9 @@ void AccessibilityDetailedView::AppendAccessibilityList() {
kSystemMenuAccessibilityAutoClickIcon, kSystemMenuAccessibilityAutoClickIcon,
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_AUTOCLICK), l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_AUTOCLICK),
autoclick_enabled_); autoclick_enabled_);
autoclick_view_->set_id(ash::VIEW_ID_ACCESSIBILITY_AUTOCLICK);
autoclick_view_->right_view()->set_id(
ash::VIEW_ID_ACCESSIBILITY_AUTOCLICK_ENABLED);
virtual_keyboard_enabled_ = controller->IsVirtualKeyboardEnabled(); virtual_keyboard_enabled_ = controller->IsVirtualKeyboardEnabled();
virtual_keyboard_view_ = AddScrollListCheckableItem( virtual_keyboard_view_ = AddScrollListCheckableItem(
......
...@@ -96,6 +96,7 @@ class HoverHighlightView : public ActionableView { ...@@ -96,6 +96,7 @@ class HoverHighlightView : public ActionableView {
views::Label* text_label() { return text_label_; } views::Label* text_label() { return text_label_; }
views::Label* sub_text_label() { return sub_text_label_; } views::Label* sub_text_label() { return sub_text_label_; }
views::ImageView* left_icon() { return left_icon_; } views::ImageView* left_icon() { return left_icon_; }
views::View* right_view() { return right_view_; }
protected: protected:
// Override from Button to also set the tooltip for all child elements. // Override from Button to also set the tooltip for all child elements.
......
...@@ -79,20 +79,20 @@ void SystemTrayTestApi::CloseBubble(CloseBubbleCallback cb) { ...@@ -79,20 +79,20 @@ void SystemTrayTestApi::CloseBubble(CloseBubbleCallback cb) {
void SystemTrayTestApi::ShowDetailedView(mojom::TrayItem item, void SystemTrayTestApi::ShowDetailedView(mojom::TrayItem item,
ShowDetailedViewCallback cb) { ShowDetailedViewCallback cb) {
SystemTrayItem* tray_item; SystemTrayItem* tray_item = nullptr;
switch (item) { switch (item) {
case mojom::TrayItem::kEnterprise:
tray_item = tray_->tray_enterprise_;
break;
case mojom::TrayItem::kNetwork: case mojom::TrayItem::kNetwork:
tray_item = tray_->tray_network_; tray_item = tray_->tray_network_;
break; break;
default:
break;
} }
tray_->ShowDetailedView(tray_item, 0 /* delay */, BUBBLE_CREATE_NEW); tray_->ShowDetailedView(tray_item, 0 /* delay */, BUBBLE_CREATE_NEW);
std::move(cb).Run(); std::move(cb).Run();
} }
void SystemTrayTestApi::IsBubbleViewVisible(int view_id, void SystemTrayTestApi::IsBubbleViewVisible(int view_id,
bool open_tray,
IsBubbleViewVisibleCallback cb) { IsBubbleViewVisibleCallback cb) {
views::View* view = GetBubbleView(view_id); views::View* view = GetBubbleView(view_id);
std::move(cb).Run(view && view->visible()); std::move(cb).Run(view && view->visible());
......
...@@ -50,7 +50,9 @@ class SystemTrayTestApi : public mojom::SystemTrayTestApi { ...@@ -50,7 +50,9 @@ class SystemTrayTestApi : public mojom::SystemTrayTestApi {
void ShowDetailedView(mojom::TrayItem item, void ShowDetailedView(mojom::TrayItem item,
ShowDetailedViewCallback cb) override; ShowDetailedViewCallback cb) override;
void IsBubbleViewVisible(int view_id, void IsBubbleViewVisible(int view_id,
bool open_tray,
IsBubbleViewVisibleCallback cb) override; IsBubbleViewVisibleCallback cb) override;
void ClickBubbleView(int32_t view_id, ClickBubbleViewCallback cb) override {}
void GetBubbleViewTooltip(int view_id, void GetBubbleViewTooltip(int view_id,
GetBubbleViewTooltipCallback cb) override; GetBubbleViewTooltipCallback cb) override;
void GetBubbleLabelText(int view_id, GetBubbleLabelTextCallback cb) override; void GetBubbleLabelText(int view_id, GetBubbleLabelTextCallback cb) override;
......
...@@ -12,9 +12,11 @@ ...@@ -12,9 +12,11 @@
#include "ash/system/unified/unified_system_tray.h" #include "ash/system/unified/unified_system_tray.h"
#include "ash/system/unified/unified_system_tray_bubble.h" #include "ash/system/unified/unified_system_tray_bubble.h"
#include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_controller.h"
#include "base/run_loop.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/strong_binding.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/events/test/event_generator.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/view.h" #include "ui/views/view.h"
...@@ -63,15 +65,12 @@ void UnifiedSystemTrayTestApi::CloseBubble(CloseBubbleCallback cb) { ...@@ -63,15 +65,12 @@ void UnifiedSystemTrayTestApi::CloseBubble(CloseBubbleCallback cb) {
void UnifiedSystemTrayTestApi::ShowDetailedView(mojom::TrayItem item, void UnifiedSystemTrayTestApi::ShowDetailedView(mojom::TrayItem item,
ShowDetailedViewCallback cb) { ShowDetailedViewCallback cb) {
tray_->ShowBubble(false /* show_by_click */);
switch (item) { switch (item) {
case mojom::TrayItem::kEnterprise: case mojom::TrayItem::kAccessibility:
// TODO(tetsui): Remove this from .mojom, because both SystemTray and tray_->bubble_->controller_->ShowAccessibilityDetailedView();
// UnifiedSystemTray do not have enterprise detailed view, and this is not
// used from anywhere.
NOTREACHED();
break; break;
case mojom::TrayItem::kNetwork: case mojom::TrayItem::kNetwork:
tray_->ShowBubble(false /* show_by_click */);
tray_->bubble_->controller_->ShowNetworkDetailedView(true /* force */); tray_->bubble_->controller_->ShowNetworkDetailedView(true /* force */);
break; break;
} }
...@@ -80,11 +79,28 @@ void UnifiedSystemTrayTestApi::ShowDetailedView(mojom::TrayItem item, ...@@ -80,11 +79,28 @@ void UnifiedSystemTrayTestApi::ShowDetailedView(mojom::TrayItem item,
void UnifiedSystemTrayTestApi::IsBubbleViewVisible( void UnifiedSystemTrayTestApi::IsBubbleViewVisible(
int view_id, int view_id,
bool open_tray,
IsBubbleViewVisibleCallback cb) { IsBubbleViewVisibleCallback cb) {
if (open_tray)
tray_->ShowBubble(false /* show_by_click */);
views::View* view = GetBubbleView(view_id); views::View* view = GetBubbleView(view_id);
std::move(cb).Run(view && view->visible()); std::move(cb).Run(view && view->visible());
} }
void UnifiedSystemTrayTestApi::ClickBubbleView(int32_t view_id,
ClickBubbleViewCallback cb) {
views::View* view = GetBubbleView(view_id);
if (view && view->visible()) {
gfx::Point cursor_location(1, 1);
views::View::ConvertPointToScreen(view, &cursor_location);
ui::test::EventGenerator generator(view->GetWidget()->GetNativeWindow());
generator.MoveMouseTo(cursor_location);
generator.ClickLeftButton();
}
std::move(cb).Run();
}
void UnifiedSystemTrayTestApi::GetBubbleViewTooltip( void UnifiedSystemTrayTestApi::GetBubbleViewTooltip(
int view_id, int view_id,
GetBubbleViewTooltipCallback cb) { GetBubbleViewTooltipCallback cb) {
......
...@@ -41,7 +41,9 @@ class UnifiedSystemTrayTestApi : public mojom::SystemTrayTestApi { ...@@ -41,7 +41,9 @@ class UnifiedSystemTrayTestApi : public mojom::SystemTrayTestApi {
void ShowDetailedView(mojom::TrayItem item, void ShowDetailedView(mojom::TrayItem item,
ShowDetailedViewCallback cb) override; ShowDetailedViewCallback cb) override;
void IsBubbleViewVisible(int view_id, void IsBubbleViewVisible(int view_id,
bool open_tray,
IsBubbleViewVisibleCallback cb) override; IsBubbleViewVisibleCallback cb) override;
void ClickBubbleView(int32_t view_id, ClickBubbleViewCallback cb) override;
void GetBubbleViewTooltip(int view_id, void GetBubbleViewTooltip(int view_id,
GetBubbleViewTooltipCallback cb) override; GetBubbleViewTooltipCallback cb) override;
void GetBubbleLabelText(int view_id, GetBubbleLabelTextCallback cb) override; void GetBubbleLabelText(int view_id, GetBubbleLabelTextCallback cb) override;
......
...@@ -2,15 +2,9 @@ ...@@ -2,15 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/login_status.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_pref_names.h" #include "ash/public/cpp/ash_pref_names.h"
#include "ash/shell.h" #include "ash/public/cpp/ash_view_ids.h"
#include "ash/shell_test_api.h" #include "ash/public/interfaces/system_tray_test_api.mojom.h"
#include "ash/system/accessibility/tray_accessibility.h"
#include "ash/system/tray/hover_highlight_view.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_test_api.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/run_loop.h" #include "base/run_loop.h"
...@@ -35,7 +29,10 @@ ...@@ -35,7 +29,10 @@
#include "components/policy/policy_constants.h" #include "components/policy/policy_constants.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/session_manager/core/session_manager.h" #include "components/session_manager/core/session_manager.h"
#include "components/user_manager/user_manager.h"
#include "content/public/common/service_manager_connection.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "services/service_manager/public/cpp/connector.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button.h"
...@@ -135,6 +132,20 @@ class TrayAccessibilityTest ...@@ -135,6 +132,20 @@ class TrayAccessibilityTest
// The profile which should be used by these tests. // The profile which should be used by these tests.
Profile* GetProfile() { return ProfileManager::GetActiveUserProfile(); } Profile* GetProfile() { return ProfileManager::GetActiveUserProfile(); }
// Connect / reconnect to SystemTrayTestApi.
void BindTestApi() {
tray_test_api_.reset();
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
->BindInterface(ash::mojom::kServiceName, &tray_test_api_);
}
// InProcessBrowserTest:
void SetUpOnMainThread() override {
InProcessBrowserTest::SetUpOnMainThread();
BindTestApi();
}
void SetUpInProcessBrowserTestFixture() override { void SetUpInProcessBrowserTestFixture() override {
InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
EXPECT_CALL(provider_, IsInitializationComplete(_)) EXPECT_CALL(provider_, IsInitializationComplete(_))
...@@ -161,510 +172,491 @@ class TrayAccessibilityTest ...@@ -161,510 +172,491 @@ class TrayAccessibilityTest
} }
} }
static ash::TrayAccessibility* tray() { bool IsMenuButtonVisible() {
return ash::SystemTrayTestApi(ash::Shell::Get()->GetPrimarySystemTray()) ash::mojom::SystemTrayTestApiAsyncWaiter wait_for(tray_test_api_.get());
.tray_accessibility(); bool visible = false;
} wait_for.IsBubbleViewVisible(ash::VIEW_ID_ACCESSIBILITY_TRAY_ITEM,
true /* open_tray */, &visible);
views::View* CreateMenuItem() { wait_for.CloseBubble();
return tray()->CreateDefaultView(GetLoginStatus()); return visible;
}
void DestroyMenuItem() { return tray()->OnDefaultViewDestroyed(); }
bool CanCreateMenuItem() {
views::View* menu_item_view = CreateMenuItem();
DestroyMenuItem();
return menu_item_view != nullptr;
}
void SetLoginStatus(ash::LoginStatus status) {
tray()->UpdateAfterLoginStatusChange(status);
} }
ash::LoginStatus GetLoginStatus() { return tray()->login_; } void CreateDetailedMenu() {
ash::mojom::SystemTrayTestApiAsyncWaiter wait_for(tray_test_api_.get());
bool CreateDetailedMenu() { wait_for.ShowDetailedView(ash::mojom::TrayItem::kAccessibility);
tray()->ShowDetailedView(0);
return tray()->detailed_menu_ != nullptr;
}
ash::tray::AccessibilityDetailedView* GetDetailedMenu() {
return tray()->detailed_menu_;
} }
void CloseDetailMenu() { bool IsBubbleOpen() {
ASSERT_TRUE(tray()->detailed_menu_); ash::mojom::SystemTrayTestApiAsyncWaiter wait_for(tray_test_api_.get());
tray()->OnDetailedViewDestroyed(); bool is_open = false;
EXPECT_FALSE(tray()->detailed_menu_); wait_for.IsTrayBubbleOpen(&is_open);
return is_open;
} }
void ClickAutoclickOnDetailMenu() { void ClickAutoclickOnDetailMenu() {
ash::HoverHighlightView* view = tray()->detailed_menu_->autoclick_view_; ash::mojom::SystemTrayTestApiAsyncWaiter wait_for(tray_test_api_.get());
tray()->detailed_menu_->OnViewClicked(view); wait_for.ClickBubbleView(ash::VIEW_ID_ACCESSIBILITY_AUTOCLICK);
base::RunLoop().RunUntilIdle();
} }
bool IsAutoclickEnabledOnDetailMenu() const { bool IsAutoclickEnabledOnDetailMenu() const {
return tray()->detailed_menu_->autoclick_enabled_; ash::mojom::SystemTrayTestApiAsyncWaiter wait_for(tray_test_api_.get());
bool visible = false;
wait_for.IsBubbleViewVisible(ash::VIEW_ID_ACCESSIBILITY_AUTOCLICK_ENABLED,
false /* open_tray */, &visible);
return visible;
} }
// Disable animations so that tray icons hide immediately. // Disable animations so that tray icons hide immediately.
ui::ScopedAnimationDurationScaleMode disable_animations_; ui::ScopedAnimationDurationScaleMode disable_animations_;
policy::MockConfigurationPolicyProvider provider_; policy::MockConfigurationPolicyProvider provider_;
ash::mojom::SystemTrayTestApiPtr tray_test_api_;
}; };
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenu) { IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenu) {
// TODO(tetsui): Restore after AccessibilityManager is moved to ash.
// https://crbug.com/850014
if (ash::features::IsSystemTrayUnifiedEnabled())
return;
SetShowAccessibilityOptionsInSystemTrayMenu(false); SetShowAccessibilityOptionsInSystemTrayMenu(false);
// Confirms that the menu is hidden. // Confirms that the menu is hidden.
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
// Toggling spoken feedback changes the visibility of the menu. // Toggling spoken feedback changes the visibility of the menu.
EnableSpokenFeedback(true); EnableSpokenFeedback(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(false); EnableSpokenFeedback(false);
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
// Toggling high contrast changes the visibility of the menu. // Toggling high contrast changes the visibility of the menu.
EnableHighContrast(true); EnableHighContrast(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(false); EnableHighContrast(false);
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
// Toggling screen magnifier changes the visibility of the menu. // Toggling screen magnifier changes the visibility of the menu.
SetMagnifierEnabled(true); SetMagnifierEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetMagnifierEnabled(false); SetMagnifierEnabled(false);
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
// Toggling autoclick changes the visibility of the menu. // Toggling autoclick changes the visibility of the menu.
EnableAutoclick(true); EnableAutoclick(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableAutoclick(false); EnableAutoclick(false);
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
// Toggling virtual keyboard changes the visibility of the menu. // Toggling virtual keyboard changes the visibility of the menu.
EnableVirtualKeyboard(true); EnableVirtualKeyboard(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(false); EnableVirtualKeyboard(false);
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
// Toggling large mouse cursor changes the visibility of the menu. // Toggling large mouse cursor changes the visibility of the menu.
EnableLargeCursor(true); EnableLargeCursor(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(false); EnableLargeCursor(false);
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
// Toggling mono audio changes the visibility of the menu. // Toggling mono audio changes the visibility of the menu.
EnableMonoAudio(true); EnableMonoAudio(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(false); EnableMonoAudio(false);
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
// Toggling caret highlight changes the visibility of the menu. // Toggling caret highlight changes the visibility of the menu.
SetCaretHighlightEnabled(true); SetCaretHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(false); SetCaretHighlightEnabled(false);
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
// Toggling highlight mouse cursor changes the visibility of the menu. // Toggling highlight mouse cursor changes the visibility of the menu.
SetCursorHighlightEnabled(true); SetCursorHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(false); SetCursorHighlightEnabled(false);
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
// Toggling highlight keyboard focus changes the visibility of the menu. // Toggling highlight keyboard focus changes the visibility of the menu.
SetFocusHighlightEnabled(true); SetFocusHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(false); SetFocusHighlightEnabled(false);
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
// Toggling sticky keys changes the visibility of the menu. // Toggling sticky keys changes the visibility of the menu.
EnableStickyKeys(true); EnableStickyKeys(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(false); EnableStickyKeys(false);
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
// Toggling select-to-speak dragging changes the visibility of the menu. // Toggling select-to-speak dragging changes the visibility of the menu.
EnableSelectToSpeak(true); EnableSelectToSpeak(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(false); EnableSelectToSpeak(false);
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
// Enabling all accessibility features. // Enabling all accessibility features.
SetMagnifierEnabled(true); SetMagnifierEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(true); EnableHighContrast(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(true); EnableSpokenFeedback(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(true); EnableSelectToSpeak(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableAutoclick(true); EnableAutoclick(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(true); EnableVirtualKeyboard(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(true); EnableLargeCursor(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(true); EnableMonoAudio(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(true); SetCaretHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(true); SetCursorHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(true); SetFocusHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(true); EnableStickyKeys(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(false); EnableVirtualKeyboard(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableAutoclick(false); EnableAutoclick(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(false); EnableSpokenFeedback(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(false); EnableSelectToSpeak(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(false); EnableHighContrast(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetMagnifierEnabled(false); SetMagnifierEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(false); EnableLargeCursor(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(false); EnableMonoAudio(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(false); SetCaretHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(false); SetCursorHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(false); SetFocusHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(false); EnableStickyKeys(false);
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
} }
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowMenuOption) { IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowMenuOption) {
// TODO(tetsui): Restore after AccessibilityManager is moved to ash.
// https://crbug.com/850014
if (ash::features::IsSystemTrayUnifiedEnabled())
return;
SetShowAccessibilityOptionsInSystemTrayMenu(true); SetShowAccessibilityOptionsInSystemTrayMenu(true);
// Confirms that the menu is visible. // Confirms that the menu is visible.
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling spoken feedback. // The menu remains visible regardless of toggling spoken feedback.
EnableSpokenFeedback(true); EnableSpokenFeedback(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(false); EnableSpokenFeedback(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling high contrast. // The menu remains visible regardless of toggling high contrast.
EnableHighContrast(true); EnableHighContrast(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(false); EnableHighContrast(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling screen magnifier. // The menu remains visible regardless of toggling screen magnifier.
SetMagnifierEnabled(true); SetMagnifierEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetMagnifierEnabled(false); SetMagnifierEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling autoclick. // The menu remains visible regardless of toggling autoclick.
EnableAutoclick(true); EnableAutoclick(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableAutoclick(false); EnableAutoclick(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling on-screen keyboard. // The menu remains visible regardless of toggling on-screen keyboard.
EnableVirtualKeyboard(true); EnableVirtualKeyboard(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(false); EnableVirtualKeyboard(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling large mouse cursor. // The menu remains visible regardless of toggling large mouse cursor.
EnableLargeCursor(true); EnableLargeCursor(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(false); EnableLargeCursor(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling mono audio. // The menu remains visible regardless of toggling mono audio.
EnableMonoAudio(true); EnableMonoAudio(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(false); EnableMonoAudio(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling caret highlight. // The menu remains visible regardless of toggling caret highlight.
SetCaretHighlightEnabled(true); SetCaretHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(false); SetCaretHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling highlight mouse cursor. // The menu remains visible regardless of toggling highlight mouse cursor.
SetCursorHighlightEnabled(true); SetCursorHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(false); SetCursorHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling highlight keyboard focus. // The menu remains visible regardless of toggling highlight keyboard focus.
SetFocusHighlightEnabled(true); SetFocusHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(false); SetFocusHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of the toggling sticky keys. // The menu remains visible regardless of the toggling sticky keys.
EnableStickyKeys(true); EnableStickyKeys(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(false); EnableStickyKeys(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling select-to-speak. // The menu remains visible regardless of toggling select-to-speak.
EnableSelectToSpeak(true); EnableSelectToSpeak(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(false); EnableSelectToSpeak(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// Enabling all accessibility features. // Enabling all accessibility features.
SetMagnifierEnabled(true); SetMagnifierEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(true); EnableHighContrast(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(true); EnableSpokenFeedback(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(true); EnableSelectToSpeak(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableAutoclick(true); EnableAutoclick(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(true); EnableVirtualKeyboard(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(true); EnableLargeCursor(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(true); EnableMonoAudio(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(true); SetCaretHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(true); SetCursorHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(true); SetFocusHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(true); EnableStickyKeys(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(false); EnableVirtualKeyboard(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableAutoclick(false); EnableAutoclick(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(false); EnableSpokenFeedback(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(false); EnableSelectToSpeak(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(false); EnableHighContrast(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetMagnifierEnabled(false); SetMagnifierEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(false); EnableLargeCursor(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(false); EnableMonoAudio(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(false); SetCaretHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(false); SetCursorHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(false); SetFocusHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(false); EnableStickyKeys(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetShowAccessibilityOptionsInSystemTrayMenu(false); SetShowAccessibilityOptionsInSystemTrayMenu(false);
// Confirms that the menu is invisible. // Confirms that the menu is invisible.
EXPECT_FALSE(CanCreateMenuItem()); EXPECT_FALSE(IsMenuButtonVisible());
} }
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowOnLoginScreen) { IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) {
// TODO(tetsui): Restore after AccessibilityManager is moved to ash. // Enables high contrast mode.
// https://crbug.com/850014 EnableHighContrast(true);
if (ash::features::IsSystemTrayUnifiedEnabled()) EXPECT_TRUE(IsMenuButtonVisible());
return;
SetLoginStatus(ash::LoginStatus::NOT_LOGGED_IN); // Locks the screen.
SessionControllerClient::Get()->RequestLockScreen();
// Resets binding because UnifiedSystemTray is recreated.
BindTestApi();
EXPECT_TRUE(IsMenuButtonVisible());
// Disables high contrast mode.
EnableHighContrast(false);
// Confirms that the menu is still visible.
EXPECT_TRUE(IsMenuButtonVisible());
}
// Verify that the accessiblity system detailed menu remains open when an item
// is selected or deselected.
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, DetailMenuRemainsOpen) {
CreateDetailedMenu();
ClickAutoclickOnDetailMenu();
EXPECT_TRUE(IsAutoclickEnabledOnDetailMenu());
{
base::RunLoop run_loop;
run_loop.RunUntilIdle();
}
EXPECT_TRUE(IsBubbleOpen());
ClickAutoclickOnDetailMenu();
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
{
base::RunLoop run_loop;
run_loop.RunUntilIdle();
}
EXPECT_TRUE(IsBubbleOpen());
}
class TrayAccessibilityLoginTest : public TrayAccessibilityTest {
public:
TrayAccessibilityLoginTest() = default;
~TrayAccessibilityLoginTest() = default;
void SetUpCommandLine(base::CommandLine* command_line) override {
TrayAccessibilityTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kLoginManager);
command_line->AppendSwitch(switches::kForceLoginManagerInTests);
}
private:
DISALLOW_COPY_AND_ASSIGN(TrayAccessibilityLoginTest);
};
IN_PROC_BROWSER_TEST_P(TrayAccessibilityLoginTest,
ShowMenuWithShowOnLoginScreen) {
EXPECT_FALSE(user_manager::UserManager::Get()->IsUserLoggedIn());
// Confirms that the menu is visible. // Confirms that the menu is visible.
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling spoken feedback. // The menu remains visible regardless of toggling spoken feedback.
EnableSpokenFeedback(true); EnableSpokenFeedback(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(false); EnableSpokenFeedback(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling high contrast. // The menu remains visible regardless of toggling high contrast.
EnableHighContrast(true); EnableHighContrast(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(false); EnableHighContrast(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling screen magnifier. // The menu remains visible regardless of toggling screen magnifier.
SetMagnifierEnabled(true); SetMagnifierEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetMagnifierEnabled(false); SetMagnifierEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling on-screen keyboard. // The menu remains visible regardless of toggling on-screen keyboard.
EnableVirtualKeyboard(true); EnableVirtualKeyboard(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(false); EnableVirtualKeyboard(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling large mouse cursor. // The menu remains visible regardless of toggling large mouse cursor.
EnableLargeCursor(true); EnableLargeCursor(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(false); EnableLargeCursor(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling mono audio. // The menu remains visible regardless of toggling mono audio.
EnableMonoAudio(true); EnableMonoAudio(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(false); EnableMonoAudio(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling caret highlight. // The menu remains visible regardless of toggling caret highlight.
SetCaretHighlightEnabled(true); SetCaretHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(false); SetCaretHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling highlight mouse cursor. // The menu remains visible regardless of toggling highlight mouse cursor.
SetCursorHighlightEnabled(true); SetCursorHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(false); SetCursorHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling highlight keyboard focus. // The menu remains visible regardless of toggling highlight keyboard focus.
SetFocusHighlightEnabled(true); SetFocusHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(false); SetFocusHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling sticky keys. // The menu remains visible regardless of toggling sticky keys.
EnableStickyKeys(true); EnableStickyKeys(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(false); EnableStickyKeys(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
// Enabling all accessibility features. // Enabling all accessibility features.
SetMagnifierEnabled(true); SetMagnifierEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(true); EnableHighContrast(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(true); EnableSpokenFeedback(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(true); EnableVirtualKeyboard(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(true); EnableLargeCursor(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(true); EnableMonoAudio(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(true); SetCaretHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(true); SetCursorHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(true); SetFocusHighlightEnabled(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(true); EnableStickyKeys(true);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(false); EnableVirtualKeyboard(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(false); EnableSpokenFeedback(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(false); EnableHighContrast(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetMagnifierEnabled(false); SetMagnifierEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(false); EnableLargeCursor(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(false); EnableMonoAudio(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(false); SetCaretHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(false); SetCursorHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(false); SetFocusHighlightEnabled(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(false); EnableStickyKeys(false);
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetShowAccessibilityOptionsInSystemTrayMenu(true); SetShowAccessibilityOptionsInSystemTrayMenu(true);
// Confirms that the menu remains visible. // Confirms that the menu remains visible.
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
SetShowAccessibilityOptionsInSystemTrayMenu(false); SetShowAccessibilityOptionsInSystemTrayMenu(false);
// Confirms that the menu remains visible. // Confirms that the menu remains visible.
EXPECT_TRUE(CanCreateMenuItem()); EXPECT_TRUE(IsMenuButtonVisible());
}
// TODO: Move to ash_unittests.
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) {
// TODO(tetsui): Restore after AccessibilityManager is moved to ash.
// https://crbug.com/850014
if (ash::features::IsSystemTrayUnifiedEnabled())
return;
// Enables high contrast mode.
EnableHighContrast(true);
EXPECT_TRUE(CanCreateMenuItem());
// Locks the screen.
SetLoginStatus(ash::LoginStatus::LOCKED);
EXPECT_TRUE(CanCreateMenuItem());
// Disables high contrast mode.
EnableHighContrast(false);
// Confirms that the menu is still visible.
EXPECT_TRUE(CanCreateMenuItem());
}
// Verify that the accessiblity system detailed menu remains open when an item
// is selected or deselected.
// TODO: Move to ash_unittests.
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, DetailMenuRemainsOpen) {
// TODO(tetsui): Restore after AccessibilityManager is moved to ash.
// https://crbug.com/850014
if (ash::features::IsSystemTrayUnifiedEnabled())
return;
EXPECT_TRUE(CreateDetailedMenu());
ClickAutoclickOnDetailMenu();
EXPECT_TRUE(IsAutoclickEnabledOnDetailMenu());
{
base::RunLoop run_loop;
run_loop.RunUntilIdle();
}
EXPECT_TRUE(GetDetailedMenu());
ClickAutoclickOnDetailMenu();
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
{
base::RunLoop run_loop;
run_loop.RunUntilIdle();
}
EXPECT_TRUE(GetDetailedMenu());
} }
INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance, INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance,
TrayAccessibilityTest, TrayAccessibilityTest,
testing::Values(PREF_SERVICE, testing::Values(PREF_SERVICE,
POLICY)); POLICY));
INSTANTIATE_TEST_CASE_P(TrayAccessibilityLoginTestInstance,
TrayAccessibilityLoginTest,
testing::Values(PREF_SERVICE, POLICY));
} // namespace chromeos } // namespace chromeos
...@@ -75,13 +75,12 @@ IN_PROC_BROWSER_TEST_F(SystemTrayClientEnterpriseTest, TrayEnterprise) { ...@@ -75,13 +75,12 @@ IN_PROC_BROWSER_TEST_F(SystemTrayClientEnterpriseTest, TrayEnterprise) {
->GetConnector() ->GetConnector()
->BindInterface(ash::mojom::kServiceName, &tray_test_api); ->BindInterface(ash::mojom::kServiceName, &tray_test_api);
// Open the system tray menu.
ash::mojom::SystemTrayTestApiAsyncWaiter wait_for(tray_test_api.get()); ash::mojom::SystemTrayTestApiAsyncWaiter wait_for(tray_test_api.get());
wait_for.ShowBubble();
// Managed devices show an item in the menu. // Managed devices show an item in the menu.
bool view_visible = false; bool view_visible = false;
wait_for.IsBubbleViewVisible(ash::VIEW_ID_TRAY_ENTERPRISE, &view_visible); wait_for.IsBubbleViewVisible(ash::VIEW_ID_TRAY_ENTERPRISE,
true /* open_tray */, &view_visible);
EXPECT_TRUE(view_visible); EXPECT_TRUE(view_visible);
} }
......
...@@ -56,7 +56,7 @@ class SystemTrayTrayCastMediaRouterChromeOSTest : public InProcessBrowserTest { ...@@ -56,7 +56,7 @@ class SystemTrayTrayCastMediaRouterChromeOSTest : public InProcessBrowserTest {
bool IsViewDrawn(int view_id) { bool IsViewDrawn(int view_id) {
ash::mojom::SystemTrayTestApiAsyncWaiter wait_for(tray_test_api_.get()); ash::mojom::SystemTrayTestApiAsyncWaiter wait_for(tray_test_api_.get());
bool visible = false; bool visible = false;
wait_for.IsBubbleViewVisible(view_id, &visible); wait_for.IsBubbleViewVisible(view_id, false /* open_tray */, &visible);
return visible; return visible;
} }
......
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