This source file includes following definitions.
- SetMagnifierEnabled
- GetProfile
- SetUpInProcessBrowserTestFixture
- SetUpCommandLine
- SetUpOnMainThread
- RunTestOnMainThreadLoop
- CleanUpOnMainThread
- SetShowAccessibilityOptionsInSystemTrayMenu
- tray
- tray
- IsTrayIconVisible
- CreateMenuItem
- DestroyMenuItem
- CanCreateMenuItem
- SetLoginStatus
- GetLoginStatus
- CreateDetailedMenu
- CloseDetailMenu
- ClickSpokenFeedbackOnDetailMenu
- ClickHighContrastOnDetailMenu
- ClickScreenMagnifierOnDetailMenu
- ClickAutoclickOnDetailMenu
- ClickVirtualKeyboardOnDetailMenu
- IsSpokenFeedbackEnabledOnDetailMenu
- IsHighContrastEnabledOnDetailMenu
- IsScreenMagnifierEnabledOnDetailMenu
- IsLargeCursorEnabledOnDetailMenu
- IsAutoclickEnabledOnDetailMenu
- IsVirtualKeyboardEnabledOnDetailMenu
- IsSpokenFeedbackMenuShownOnDetailMenu
- IsHighContrastMenuShownOnDetailMenu
- IsScreenMagnifierMenuShownOnDetailMenu
- IsLargeCursorMenuShownOnDetailMenu
- IsAutoclickMenuShownOnDetailMenu
- IsVirtualKeyboardMenuShownOnDetailMenu
- IsNotificationShown
- GetNotificationText
- SetBrailleConnected
- IN_PROC_BROWSER_TEST_P
- IN_PROC_BROWSER_TEST_P
- IN_PROC_BROWSER_TEST_P
- IN_PROC_BROWSER_TEST_P
- IN_PROC_BROWSER_TEST_P
- IN_PROC_BROWSER_TEST_P
- IN_PROC_BROWSER_TEST_P
- IN_PROC_BROWSER_TEST_P
- IN_PROC_BROWSER_TEST_P
- IN_PROC_BROWSER_TEST_P
#include "ash/magnifier/magnification_controller.h"
#include "ash/shell.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray_accessibility.h"
#include "ash/system/user/login_status.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/login_utils.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/user_manager_impl.h"
#include "chrome/browser/extensions/api/braille_display_private/mock_braille_controller.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/chromeos_switches.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/common/external_data_fetcher.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_types.h"
#include "content/public/test/test_utils.h"
#include "policy/policy_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/views/controls/label.h"
#include "ui/views/widget/widget.h"
using extensions::api::braille_display_private::BrailleObserver;
using extensions::api::braille_display_private::DisplayState;
using extensions::api::braille_display_private::MockBrailleController;
using testing::Return;
using testing::_;
using testing::WithParamInterface;
namespace chromeos {
enum PrefSettingMechanism {
PREF_SERVICE,
POLICY,
};
void SetMagnifierEnabled(bool enabled) {
MagnificationManager::Get()->SetMagnifierEnabled(enabled);
}
class TrayAccessibilityTest
: public InProcessBrowserTest,
public WithParamInterface<PrefSettingMechanism> {
protected:
TrayAccessibilityTest() {}
virtual ~TrayAccessibilityTest() {}
Profile* GetProfile() { return ProfileManager::GetActiveUserProfile(); }
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
EXPECT_CALL(provider_, IsInitializationComplete(_))
.WillRepeatedly(Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
AccessibilityManager::SetBrailleControllerForTest(&braille_controller_);
}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
command_line->AppendSwitch(switches::kLoginManager);
command_line->AppendSwitchASCII(switches::kLoginProfile,
TestingProfile::kTestUserProfileDir);
}
virtual void SetUpOnMainThread() OVERRIDE {
AccessibilityManager::Get()->SetProfileForTest(GetProfile());
MagnificationManager::Get()->SetProfileForTest(GetProfile());
}
virtual void RunTestOnMainThreadLoop() OVERRIDE {
StartupUtils::MarkOobeCompleted();
InProcessBrowserTest::RunTestOnMainThreadLoop();
}
virtual void CleanUpOnMainThread() OVERRIDE {
AccessibilityManager::SetBrailleControllerForTest(NULL);
}
void SetShowAccessibilityOptionsInSystemTrayMenu(bool value) {
if (GetParam() == PREF_SERVICE) {
PrefService* prefs = GetProfile()->GetPrefs();
prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, value);
} else if (GetParam() == POLICY) {
policy::PolicyMap policy_map;
policy_map.Set(policy::key::kShowAccessibilityOptionsInSystemTrayMenu,
policy::POLICY_LEVEL_MANDATORY,
policy::POLICY_SCOPE_USER,
base::Value::CreateBooleanValue(value),
NULL);
provider_.UpdateChromePolicy(policy_map);
base::RunLoop().RunUntilIdle();
} else {
FAIL() << "Unknown test parameterization";
}
}
ash::TrayAccessibility* tray() {
return ash::Shell::GetInstance()->GetPrimarySystemTray()->
GetTrayAccessibilityForTest();
}
const ash::TrayAccessibility* tray() const {
return ash::Shell::GetInstance()
->GetPrimarySystemTray()
->GetTrayAccessibilityForTest();
}
bool IsTrayIconVisible() const { return tray()->tray_icon_visible_; }
views::View* CreateMenuItem() {
return tray()->CreateDefaultView(GetLoginStatus());
}
void DestroyMenuItem() {
return tray()->DestroyDefaultView();
}
bool CanCreateMenuItem() {
views::View* menu_item_view = CreateMenuItem();
DestroyMenuItem();
return menu_item_view != NULL;
}
void SetLoginStatus(ash::user::LoginStatus status) {
tray()->UpdateAfterLoginStatusChange(status);
}
ash::user::LoginStatus GetLoginStatus() {
return tray()->login_;
}
bool CreateDetailedMenu() {
tray()->PopupDetailedView(0, false);
return tray()->detailed_menu_ != NULL;
}
void CloseDetailMenu() {
CHECK(tray()->detailed_menu_);
tray()->DestroyDetailedView();
tray()->detailed_menu_ = NULL;
}
void ClickSpokenFeedbackOnDetailMenu() {
views::View* button = tray()->detailed_menu_->spoken_feedback_view_;
ASSERT_TRUE(button);
tray()->detailed_menu_->OnViewClicked(button);
}
void ClickHighContrastOnDetailMenu() {
views::View* button = tray()->detailed_menu_->high_contrast_view_;
ASSERT_TRUE(button);
tray()->detailed_menu_->OnViewClicked(button);
}
void ClickScreenMagnifierOnDetailMenu() {
views::View* button = tray()->detailed_menu_->screen_magnifier_view_;
ASSERT_TRUE(button);
tray()->detailed_menu_->OnViewClicked(button);
}
void ClickAutoclickOnDetailMenu() {
views::View* button = tray()->detailed_menu_->autoclick_view_;
ASSERT_TRUE(button);
tray()->detailed_menu_->OnViewClicked(button);
}
void ClickVirtualKeyboardOnDetailMenu() {
views::View* button = tray()->detailed_menu_->virtual_keyboard_view_;
ASSERT_TRUE(button);
tray()->detailed_menu_->OnViewClicked(button);
}
bool IsSpokenFeedbackEnabledOnDetailMenu() const {
return tray()->detailed_menu_->spoken_feedback_enabled_;
}
bool IsHighContrastEnabledOnDetailMenu() const {
return tray()->detailed_menu_->high_contrast_enabled_;
}
bool IsScreenMagnifierEnabledOnDetailMenu() const {
return tray()->detailed_menu_->screen_magnifier_enabled_;
}
bool IsLargeCursorEnabledOnDetailMenu() const {
return tray()->detailed_menu_->large_cursor_enabled_;
}
bool IsAutoclickEnabledOnDetailMenu() const {
return tray()->detailed_menu_->autoclick_enabled_;
}
bool IsVirtualKeyboardEnabledOnDetailMenu() const {
return tray()->detailed_menu_->virtual_keyboard_enabled_;
}
bool IsSpokenFeedbackMenuShownOnDetailMenu() const {
return tray()->detailed_menu_->spoken_feedback_view_;
}
bool IsHighContrastMenuShownOnDetailMenu() const {
return tray()->detailed_menu_->high_contrast_view_;
}
bool IsScreenMagnifierMenuShownOnDetailMenu() const {
return tray()->detailed_menu_->screen_magnifier_view_;
}
bool IsLargeCursorMenuShownOnDetailMenu() const {
return tray()->detailed_menu_->large_cursor_view_;
}
bool IsAutoclickMenuShownOnDetailMenu() const {
return tray()->detailed_menu_->autoclick_view_;
}
bool IsVirtualKeyboardMenuShownOnDetailMenu() const {
return tray()->detailed_menu_->virtual_keyboard_view_;
}
bool IsNotificationShown() const {
return (tray()->detailed_popup_ &&
!tray()->detailed_popup_->GetWidget()->IsClosed());
}
base::string16 GetNotificationText() const {
if (IsNotificationShown())
return tray()->detailed_popup_->label_for_test()->text();
else
return base::string16();
}
void SetBrailleConnected(bool connected) {
braille_controller_.SetAvailable(connected);
braille_controller_.GetObserver()->OnDisplayStateChanged(
*braille_controller_.GetDisplayState());
}
policy::MockConfigurationPolicyProvider provider_;
MockBrailleController braille_controller_;
};
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, LoginStatus) {
EXPECT_EQ(ash::user::LOGGED_IN_NONE, GetLoginStatus());
UserManager::Get()->UserLoggedIn(
"owner@invalid.domain", "owner@invalid.domain", true);
UserManager::Get()->SessionStarted();
EXPECT_EQ(ash::user::LOGGED_IN_USER, GetLoginStatus());
}
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowTrayIcon) {
SetLoginStatus(ash::user::LOGGED_IN_NONE);
EXPECT_FALSE(IsTrayIconVisible());
UserManager::Get()->UserLoggedIn(
"owner@invalid.domain", "owner@invalid.domain", true);
UserManager::Get()->SessionStarted();
EXPECT_FALSE(IsTrayIconVisible());
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(IsTrayIconVisible());
AccessibilityManager::Get()->EnableSpokenFeedback(
false, ash::A11Y_NOTIFICATION_NONE);
EXPECT_FALSE(IsTrayIconVisible());
AccessibilityManager::Get()->EnableHighContrast(true);
EXPECT_TRUE(IsTrayIconVisible());
AccessibilityManager::Get()->EnableHighContrast(false);
EXPECT_FALSE(IsTrayIconVisible());
SetMagnifierEnabled(true);
EXPECT_TRUE(IsTrayIconVisible());
SetMagnifierEnabled(false);
EXPECT_FALSE(IsTrayIconVisible());
AccessibilityManager::Get()->EnableVirtualKeyboard(true);
EXPECT_TRUE(IsTrayIconVisible());
AccessibilityManager::Get()->EnableVirtualKeyboard(false);
EXPECT_FALSE(IsTrayIconVisible());
SetMagnifierEnabled(true);
EXPECT_TRUE(IsTrayIconVisible());
AccessibilityManager::Get()->EnableHighContrast(true);
EXPECT_TRUE(IsTrayIconVisible());
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(IsTrayIconVisible());
AccessibilityManager::Get()->EnableVirtualKeyboard(true);
EXPECT_TRUE(IsTrayIconVisible());
AccessibilityManager::Get()->EnableSpokenFeedback(
false, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(IsTrayIconVisible());
AccessibilityManager::Get()->EnableHighContrast(false);
EXPECT_TRUE(IsTrayIconVisible());
SetMagnifierEnabled(false);
EXPECT_TRUE(IsTrayIconVisible());
AccessibilityManager::Get()->EnableVirtualKeyboard(false);
EXPECT_FALSE(IsTrayIconVisible());
SetShowAccessibilityOptionsInSystemTrayMenu(true);
AccessibilityManager::Get()->EnableHighContrast(true);
EXPECT_TRUE(IsTrayIconVisible());
AccessibilityManager::Get()->EnableHighContrast(false);
EXPECT_FALSE(IsTrayIconVisible());
}
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenu) {
UserManager::Get()->UserLoggedIn(
"owner@invalid.domain", "owner@invalid.domain", true);
UserManager::Get()->SessionStarted();
SetShowAccessibilityOptionsInSystemTrayMenu(false);
EXPECT_FALSE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableSpokenFeedback(
false, ash::A11Y_NOTIFICATION_NONE);
EXPECT_FALSE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableHighContrast(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableHighContrast(false);
EXPECT_FALSE(CanCreateMenuItem());
SetMagnifierEnabled(true);
EXPECT_TRUE(CanCreateMenuItem());
SetMagnifierEnabled(false);
EXPECT_FALSE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableAutoclick(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableAutoclick(false);
EXPECT_FALSE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableVirtualKeyboard(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableVirtualKeyboard(false);
EXPECT_FALSE(CanCreateMenuItem());
SetMagnifierEnabled(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableHighContrast(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableAutoclick(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableVirtualKeyboard(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableVirtualKeyboard(false);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableAutoclick(false);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableSpokenFeedback(
false, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableHighContrast(false);
EXPECT_TRUE(CanCreateMenuItem());
SetMagnifierEnabled(false);
EXPECT_FALSE(CanCreateMenuItem());
}
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowMenuOption) {
UserManager::Get()->UserLoggedIn(
"owner@invalid.domain", "owner@invalid.domain", true);
UserManager::Get()->SessionStarted();
SetShowAccessibilityOptionsInSystemTrayMenu(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableSpokenFeedback(
false, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableHighContrast(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableHighContrast(false);
EXPECT_TRUE(CanCreateMenuItem());
SetMagnifierEnabled(true);
EXPECT_TRUE(CanCreateMenuItem());
SetMagnifierEnabled(false);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableAutoclick(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableAutoclick(false);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableVirtualKeyboard(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableVirtualKeyboard(false);
EXPECT_TRUE(CanCreateMenuItem());
SetMagnifierEnabled(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableHighContrast(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableAutoclick(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableVirtualKeyboard(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableVirtualKeyboard(false);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableAutoclick(false);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableSpokenFeedback(
false, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableHighContrast(false);
EXPECT_TRUE(CanCreateMenuItem());
SetMagnifierEnabled(false);
EXPECT_TRUE(CanCreateMenuItem());
SetShowAccessibilityOptionsInSystemTrayMenu(false);
EXPECT_FALSE(CanCreateMenuItem());
}
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowOnLoginScreen) {
SetLoginStatus(ash::user::LOGGED_IN_NONE);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableSpokenFeedback(
false, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableHighContrast(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableHighContrast(false);
EXPECT_TRUE(CanCreateMenuItem());
SetMagnifierEnabled(true);
EXPECT_TRUE(CanCreateMenuItem());
SetMagnifierEnabled(false);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableVirtualKeyboard(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableVirtualKeyboard(false);
EXPECT_TRUE(CanCreateMenuItem());
SetMagnifierEnabled(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableHighContrast(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableVirtualKeyboard(true);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableVirtualKeyboard(false);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableSpokenFeedback(
false, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableHighContrast(false);
EXPECT_TRUE(CanCreateMenuItem());
SetMagnifierEnabled(false);
EXPECT_TRUE(CanCreateMenuItem());
SetShowAccessibilityOptionsInSystemTrayMenu(true);
EXPECT_TRUE(CanCreateMenuItem());
SetShowAccessibilityOptionsInSystemTrayMenu(false);
EXPECT_TRUE(CanCreateMenuItem());
}
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowNotification) {
const base::string16 BRAILLE_CONNECTED =
base::ASCIIToUTF16("Braille display connected.");
const base::string16 CHROMEVOX_ENABLED = base::ASCIIToUTF16(
"ChromeVox (spoken feedback) is enabled.\nPress Ctrl+Alt+Z to disable.");
const base::string16 BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED(
BRAILLE_CONNECTED + base::ASCIIToUTF16(" ") + CHROMEVOX_ENABLED);
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_SHOW);
EXPECT_EQ(CHROMEVOX_ENABLED, GetNotificationText());
SetBrailleConnected(true);
EXPECT_EQ(BRAILLE_CONNECTED, GetNotificationText());
SetBrailleConnected(false);
EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
EXPECT_FALSE(IsNotificationShown());
AccessibilityManager::Get()->EnableSpokenFeedback(
false, ash::A11Y_NOTIFICATION_SHOW);
EXPECT_FALSE(IsNotificationShown());
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
SetBrailleConnected(true);
EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
EXPECT_EQ(BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED, GetNotificationText());
}
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) {
AccessibilityManager::Get()->EnableHighContrast(true);
EXPECT_TRUE(CanCreateMenuItem());
SetLoginStatus(ash::user::LOGGED_IN_LOCKED);
EXPECT_TRUE(CanCreateMenuItem());
AccessibilityManager::Get()->EnableHighContrast(false);
EXPECT_TRUE(CanCreateMenuItem());
}
#if defined(OS_CHROMEOS)
#define MAYBE_ClickDetailMenu DISABLED_ClickDetailMenu
#else
#define MAYBE_ClickDetailMenu ClickDetailMenu
#endif
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, MAYBE_ClickDetailMenu) {
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
EXPECT_TRUE(CreateDetailedMenu());
ClickSpokenFeedbackOnDetailMenu();
EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
EXPECT_TRUE(CreateDetailedMenu());
ClickSpokenFeedbackOnDetailMenu();
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
EXPECT_TRUE(CreateDetailedMenu());
ClickHighContrastOnDetailMenu();
EXPECT_TRUE(AccessibilityManager::Get()->IsHighContrastEnabled());
EXPECT_TRUE(CreateDetailedMenu());
ClickHighContrastOnDetailMenu();
EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
EXPECT_FALSE(AccessibilityManager::Get()->IsHighContrastEnabled());
EXPECT_FALSE(MagnificationManager::Get()->IsMagnifierEnabled());
EXPECT_TRUE(CreateDetailedMenu());
ClickScreenMagnifierOnDetailMenu();
EXPECT_TRUE(MagnificationManager::Get()->IsMagnifierEnabled());
EXPECT_TRUE(CreateDetailedMenu());
ClickScreenMagnifierOnDetailMenu();
EXPECT_FALSE(MagnificationManager::Get()->IsMagnifierEnabled());
EXPECT_FALSE(AccessibilityManager::Get()->IsAutoclickEnabled());
EXPECT_TRUE(CreateDetailedMenu());
ClickAutoclickOnDetailMenu();
EXPECT_TRUE(AccessibilityManager::Get()->IsAutoclickEnabled());
EXPECT_TRUE(CreateDetailedMenu());
ClickAutoclickOnDetailMenu();
EXPECT_FALSE(AccessibilityManager::Get()->IsAutoclickEnabled());
EXPECT_FALSE(AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
EXPECT_TRUE(CreateDetailedMenu());
ClickVirtualKeyboardOnDetailMenu();
EXPECT_TRUE(AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
EXPECT_TRUE(CreateDetailedMenu());
ClickVirtualKeyboardOnDetailMenu();
EXPECT_FALSE(AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
}
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, CheckMarksOnDetailMenu) {
SetLoginStatus(ash::user::LOGGED_IN_NONE);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_TRUE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
AccessibilityManager::Get()->EnableSpokenFeedback(
false, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
AccessibilityManager::Get()->EnableHighContrast(true);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_TRUE(IsHighContrastEnabledOnDetailMenu());
EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
AccessibilityManager::Get()->EnableHighContrast(false);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
SetMagnifierEnabled(true);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
EXPECT_TRUE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
SetMagnifierEnabled(false);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
AccessibilityManager::Get()->EnableLargeCursor(true);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_TRUE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
AccessibilityManager::Get()->EnableLargeCursor(false);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
AccessibilityManager::Get()->EnableVirtualKeyboard(true);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
EXPECT_TRUE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
AccessibilityManager::Get()->EnableVirtualKeyboard(false);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
AccessibilityManager::Get()->EnableHighContrast(true);
SetMagnifierEnabled(true);
AccessibilityManager::Get()->EnableLargeCursor(true);
AccessibilityManager::Get()->EnableVirtualKeyboard(true);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_TRUE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_TRUE(IsHighContrastEnabledOnDetailMenu());
EXPECT_TRUE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_TRUE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
EXPECT_TRUE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
AccessibilityManager::Get()->EnableSpokenFeedback(
false, ash::A11Y_NOTIFICATION_NONE);
AccessibilityManager::Get()->EnableHighContrast(false);
SetMagnifierEnabled(false);
AccessibilityManager::Get()->EnableLargeCursor(false);
AccessibilityManager::Get()->EnableVirtualKeyboard(false);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
SetLoginStatus(ash::user::LOGGED_IN_USER);
AccessibilityManager::Get()->EnableAutoclick(true);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_TRUE(IsAutoclickEnabledOnDetailMenu());
EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
AccessibilityManager::Get()->EnableAutoclick(false);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu());
EXPECT_FALSE(IsHighContrastEnabledOnDetailMenu());
EXPECT_FALSE(IsScreenMagnifierEnabledOnDetailMenu());
EXPECT_FALSE(IsLargeCursorEnabledOnDetailMenu());
EXPECT_FALSE(IsAutoclickEnabledOnDetailMenu());
EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
CloseDetailMenu();
}
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, CheckMenuVisibilityOnDetailMenu) {
SetLoginStatus(ash::user::LOGGED_IN_NONE);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
EXPECT_TRUE(IsLargeCursorMenuShownOnDetailMenu());
EXPECT_FALSE(IsAutoclickMenuShownOnDetailMenu());
EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
CloseDetailMenu();
SetLoginStatus(ash::user::LOGGED_IN_USER);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
EXPECT_FALSE(IsLargeCursorMenuShownOnDetailMenu());
EXPECT_TRUE(IsAutoclickMenuShownOnDetailMenu());
EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
CloseDetailMenu();
SetLoginStatus(ash::user::LOGGED_IN_LOCKED);
EXPECT_TRUE(CreateDetailedMenu());
EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
EXPECT_FALSE(IsLargeCursorMenuShownOnDetailMenu());
EXPECT_TRUE(IsAutoclickMenuShownOnDetailMenu());
EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
CloseDetailMenu();
}
INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance,
TrayAccessibilityTest,
testing::Values(PREF_SERVICE,
POLICY));
}