Index: chrome/browser/chromeos/system/tray_accessibility_browsertest.cc |
diff --git a/chrome/browser/chromeos/system/tray_accessibility_browsertest.cc b/chrome/browser/chromeos/system/tray_accessibility_browsertest.cc |
index d70ab70bb9b6dc9cecacccdb935c2bbdb6067397..98d553574e15c9454ad1d33279eec7c8c548305b 100644 |
--- a/chrome/browser/chromeos/system/tray_accessibility_browsertest.cc |
+++ b/chrome/browser/chromeos/system/tray_accessibility_browsertest.cc |
@@ -18,6 +18,10 @@ |
#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/policy/browser_policy_connector.h" |
+#include "chrome/browser/policy/mock_configuration_policy_provider.h" |
+#include "chrome/browser/policy/policy_map.h" |
+#include "chrome/browser/policy/policy_types.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/common/chrome_notification_types.h" |
@@ -26,20 +30,40 @@ |
#include "chrome/test/base/testing_profile.h" |
#include "chromeos/chromeos_switches.h" |
#include "content/public/test/test_utils.h" |
+#include "policy/policy_constants.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "ui/views/widget/widget.h" |
+using testing::AnyNumber; |
+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 CrosInProcessBrowserTest { |
+class TrayAccessibilityTest |
+ : public CrosInProcessBrowserTest, |
+ public WithParamInterface<PrefSettingMechanism> { |
protected: |
TrayAccessibilityTest() {} |
virtual ~TrayAccessibilityTest() {} |
+ virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
+ EXPECT_CALL(provider_, IsInitializationComplete(_)) |
+ .WillRepeatedly(Return(true)); |
+ EXPECT_CALL(provider_, RegisterPolicyDomain(_)).Times(AnyNumber()); |
+ policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); |
+ } |
+ |
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
command_line->AppendSwitch(switches::kLoginManager); |
command_line->AppendSwitchASCII(switches::kLoginProfile, |
@@ -52,6 +76,24 @@ class TrayAccessibilityTest : public CrosInProcessBrowserTest { |
CrosInProcessBrowserTest::RunTestOnMainThreadLoop(); |
} |
+ void SetShowAccessibilityOptionsInSystemTrayMenu(bool value) { |
+ if (GetParam() == PREF_SERVICE) { |
+ Profile* profile = ProfileManager::GetDefaultProfile(); |
+ PrefService* prefs = profile->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)); |
+ provider_.UpdateChromePolicy(policy_map); |
+ base::RunLoop().RunUntilIdle(); |
+ } else { |
+ FAIL() << "Unknown test parameterization"; |
+ } |
+ } |
+ |
ash::internal::TrayAccessibility* tray() { |
return ash::Shell::GetInstance()->GetPrimarySystemTray()-> |
GetTrayAccessibilityForTest(); |
@@ -122,9 +164,11 @@ class TrayAccessibilityTest : public CrosInProcessBrowserTest { |
bool IsScreenMagnifierEnabledOnDetailMenu() { |
return tray()->detailed_menu_->screen_magnifier_enabled_; |
} |
+ |
+ policy::MockConfigurationPolicyProvider provider_; |
}; |
-IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, LoginStatus) { |
+IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, LoginStatus) { |
EXPECT_EQ(ash::user::LOGGED_IN_NONE, GetLoginStatus()); |
UserManager::Get()->UserLoggedIn( |
@@ -134,7 +178,7 @@ IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, LoginStatus) { |
EXPECT_EQ(ash::user::LOGGED_IN_USER, GetLoginStatus()); |
} |
-IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowTrayIcon) { |
+IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowTrayIcon) { |
SetLoginStatus(ash::user::LOGGED_IN_NONE); |
// Confirms that the icon is invisible before login. |
@@ -147,19 +191,19 @@ IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowTrayIcon) { |
// Confirms that the icon is invisible just after login. |
EXPECT_FALSE(IsTrayIconVisible()); |
- // Toggling spoken feedback changes the visibillity of the icon. |
+ // Toggling spoken feedback changes the visibility of the icon. |
accessibility::EnableSpokenFeedback(true, NULL, ash::A11Y_NOTIFICATION_NONE); |
EXPECT_TRUE(IsTrayIconVisible()); |
accessibility::EnableSpokenFeedback(false, NULL, ash::A11Y_NOTIFICATION_NONE); |
EXPECT_FALSE(IsTrayIconVisible()); |
- // Toggling high contrast the visibillity of the icon. |
+ // Toggling high contrast the visibility of the icon. |
accessibility::EnableHighContrast(true); |
EXPECT_TRUE(IsTrayIconVisible()); |
accessibility::EnableHighContrast(false); |
EXPECT_FALSE(IsTrayIconVisible()); |
- // Toggling magnifier the visibillity of the icon. |
+ // Toggling magnifier the visibility of the icon. |
SetMagnifierEnabled(true); |
EXPECT_TRUE(IsTrayIconVisible()); |
SetMagnifierEnabled(false); |
@@ -181,44 +225,37 @@ IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowTrayIcon) { |
// Confirms that prefs::kShouldAlwaysShowAccessibilityMenu doesn't affect |
// the icon on the tray. |
- Profile* profile = ProfileManager::GetDefaultProfile(); |
- PrefService* prefs = profile->GetPrefs(); |
- prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, true); |
- prefs->CommitPendingWrite(); |
+ SetShowAccessibilityOptionsInSystemTrayMenu(true); |
accessibility::EnableHighContrast(true); |
EXPECT_TRUE(IsTrayIconVisible()); |
accessibility::EnableHighContrast(false); |
EXPECT_FALSE(IsTrayIconVisible()); |
} |
-IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowMenu) { |
+IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenu) { |
// Login |
UserManager::Get()->UserLoggedIn( |
"owner@invalid.domain", "owner@invalid.domain", true); |
UserManager::Get()->SessionStarted(); |
- // Sets prefs::kShouldAlwaysShowAccessibilityMenu = false. |
- Profile* profile = ProfileManager::GetDefaultProfile(); |
- PrefService* prefs = profile->GetPrefs(); |
- prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, false); |
- prefs->CommitPendingWrite(); |
+ SetShowAccessibilityOptionsInSystemTrayMenu(false); |
// Confirms that the menu is hidden. |
EXPECT_FALSE(CanCreateMenuItem()); |
- // Toggling spoken feedback changes the visibillity of the menu. |
+ // Toggling spoken feedback changes the visibility of the menu. |
accessibility::EnableSpokenFeedback(true, NULL, ash::A11Y_NOTIFICATION_NONE); |
EXPECT_TRUE(CanCreateMenuItem()); |
accessibility::EnableSpokenFeedback(false, NULL, ash::A11Y_NOTIFICATION_NONE); |
EXPECT_FALSE(CanCreateMenuItem()); |
- // Toggling high contrast changes the visibillity of the menu. |
+ // Toggling high contrast changes the visibility of the menu. |
accessibility::EnableHighContrast(true); |
EXPECT_TRUE(CanCreateMenuItem()); |
accessibility::EnableHighContrast(false); |
EXPECT_FALSE(CanCreateMenuItem()); |
- // Toggling screen magnifier changes the visibillity of the menu. |
+ // Toggling screen magnifier changes the visibility of the menu. |
SetMagnifierEnabled(true); |
EXPECT_TRUE(CanCreateMenuItem()); |
SetMagnifierEnabled(false); |
@@ -239,17 +276,13 @@ IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowMenu) { |
EXPECT_FALSE(CanCreateMenuItem()); |
} |
-IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowMenuWithShowMenuOption) { |
+IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowMenuOption) { |
// Login |
UserManager::Get()->UserLoggedIn( |
"owner@invalid.domain", "owner@invalid.domain", true); |
UserManager::Get()->SessionStarted(); |
- // Sets prefs::kShouldAlwaysShowAccessibilityMenu = true. |
- Profile* profile = ProfileManager::GetDefaultProfile(); |
- PrefService* prefs = profile->GetPrefs(); |
- prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, true); |
- prefs->CommitPendingWrite(); |
+ SetShowAccessibilityOptionsInSystemTrayMenu(true); |
// Confirms that the menu is visible. |
EXPECT_TRUE(CanCreateMenuItem()); |
@@ -286,14 +319,13 @@ IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowMenuWithShowMenuOption) { |
SetMagnifierEnabled(false); |
EXPECT_TRUE(CanCreateMenuItem()); |
- // Sets prefs::kShouldAlwaysShowAccessibilityMenu = true. |
- prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, false); |
+ SetShowAccessibilityOptionsInSystemTrayMenu(false); |
// Confirms that the menu is invisible. |
EXPECT_FALSE(CanCreateMenuItem()); |
} |
-IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowMenuWithShowOnLoginScreen) { |
+IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowOnLoginScreen) { |
SetLoginStatus(ash::user::LOGGED_IN_NONE); |
// Confirms that the menu is visible. |
@@ -331,24 +363,18 @@ IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, ShowMenuWithShowOnLoginScreen) { |
SetMagnifierEnabled(false); |
EXPECT_TRUE(CanCreateMenuItem()); |
- // Sets prefs::kShouldAlwaysShowAccessibilityMenu = true. |
- Profile* profile = ProfileManager::GetDefaultProfile(); |
- PrefService* prefs = profile->GetPrefs(); |
- prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, true); |
- prefs->CommitPendingWrite(); |
+ SetShowAccessibilityOptionsInSystemTrayMenu(true); |
// Confirms that the menu is keeping visible. |
EXPECT_TRUE(CanCreateMenuItem()); |
- // Sets prefs::kShouldAlwaysShowAccessibilityMenu = false. |
- prefs->SetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu, false); |
- prefs->CommitPendingWrite(); |
+ SetShowAccessibilityOptionsInSystemTrayMenu(false); |
// Confirms that the menu is keeping visible. |
EXPECT_TRUE(CanCreateMenuItem()); |
} |
-IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) { |
+IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) { |
// Enables high contrast mode. |
accessibility::EnableHighContrast(true); |
EXPECT_TRUE(CanCreateMenuItem()); |
@@ -370,7 +396,7 @@ IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) { |
#define MAYBE_ClickDetailMenu ClickDetailMenu |
#endif |
-IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, MAYBE_ClickDetailMenu) { |
+IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, MAYBE_ClickDetailMenu) { |
// Confirms that the check item toggles the spoken feedback. |
EXPECT_FALSE(accessibility::IsSpokenFeedbackEnabled()); |
@@ -406,7 +432,7 @@ IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, MAYBE_ClickDetailMenu) { |
EXPECT_FALSE(MagnificationManager::Get()->IsMagnifierEnabled()); |
} |
-IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, CheckMarksOnDetailMenu) { |
+IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, CheckMarksOnDetailMenu) { |
// At first, all of the check is unchecked. |
EXPECT_TRUE(CreateDetailedMenu()); |
EXPECT_FALSE(IsSpokenFeedbackEnabledOnDetailMenu()); |
@@ -483,4 +509,9 @@ IN_PROC_BROWSER_TEST_F(TrayAccessibilityTest, CheckMarksOnDetailMenu) { |
CloseDetailMenu(); |
} |
+INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance, |
+ TrayAccessibilityTest, |
+ testing::Values(PREF_SERVICE, |
+ POLICY)); |
+ |
} // namespace chromeos |