| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 5 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 6 | 6 |
| 7 #include "ash/magnifier/magnification_controller.h" | 7 #include "ash/magnifier/magnification_controller.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 13 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 14 #include "chrome/browser/chromeos/login/helper.h" | 14 #include "chrome/browser/chromeos/login/helper.h" |
| 15 #include "chrome/browser/chromeos/login/login_utils.h" | 15 #include "chrome/browser/chromeos/login/login_utils.h" |
| 16 #include "chrome/browser/chromeos/login/user_manager.h" | 16 #include "chrome/browser/chromeos/login/user_manager.h" |
| 17 #include "chrome/browser/chromeos/login/user_manager_impl.h" | 17 #include "chrome/browser/chromeos/login/user_manager_impl.h" |
| 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 19 #include "chrome/browser/extensions/api/braille_display_private/stub_braille_con
troller.h" | 19 #include "chrome/browser/extensions/api/braille_display_private/stub_braille_con
troller.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 23 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
| 24 #include "chrome/test/base/testing_browser_process.h" |
| 24 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
| 25 #include "chromeos/chromeos_switches.h" | 26 #include "chromeos/chromeos_switches.h" |
| 26 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 29 |
| 29 using extensions::api::braille_display_private::BrailleObserver; | 30 using extensions::api::braille_display_private::BrailleObserver; |
| 30 using extensions::api::braille_display_private::DisplayState; | 31 using extensions::api::braille_display_private::DisplayState; |
| 31 using extensions::api::braille_display_private::StubBrailleController; | 32 using extensions::api::braille_display_private::StubBrailleController; |
| 32 | 33 |
| 33 namespace chromeos { | 34 namespace chromeos { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 Profile* GetProfile() { | 179 Profile* GetProfile() { |
| 179 Profile* profile = ProfileManager::GetActiveUserProfile(); | 180 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 180 DCHECK(profile); | 181 DCHECK(profile); |
| 181 return profile; | 182 return profile; |
| 182 } | 183 } |
| 183 | 184 |
| 184 PrefService* GetPrefs() { | 185 PrefService* GetPrefs() { |
| 185 return GetProfile()->GetPrefs(); | 186 return GetProfile()->GetPrefs(); |
| 186 } | 187 } |
| 187 | 188 |
| 189 PrefService* GetGlobalPrefs() { |
| 190 return TestingBrowserProcess::GetGlobal()->local_state(); |
| 191 } |
| 192 |
| 188 void SetLargeCursorEnabledPref(bool enabled) { | 193 void SetLargeCursorEnabledPref(bool enabled) { |
| 189 GetPrefs()->SetBoolean(prefs::kLargeCursorEnabled, enabled); | 194 GetPrefs()->SetBoolean(prefs::kLargeCursorEnabled, enabled); |
| 190 } | 195 } |
| 191 | 196 |
| 192 void SetHighContrastEnabledPref(bool enabled) { | 197 void SetHighContrastEnabledPref(bool enabled) { |
| 193 GetPrefs()->SetBoolean(prefs::kHighContrastEnabled, enabled); | 198 GetPrefs()->SetBoolean(prefs::kHighContrastEnabled, enabled); |
| 194 } | 199 } |
| 195 | 200 |
| 196 void SetSpokenFeedbackEnabledPref(bool enabled) { | 201 void SetSpokenFeedbackEnabledPref(bool enabled) { |
| 197 GetPrefs()->SetBoolean(prefs::kSpokenFeedbackEnabled, enabled); | 202 GetGlobalPrefs()->SetBoolean(prefs::kSpokenFeedbackEnabled, enabled); |
| 198 } | 203 } |
| 199 | 204 |
| 200 void SetAutoclickEnabledPref(bool enabled) { | 205 void SetAutoclickEnabledPref(bool enabled) { |
| 201 GetPrefs()->SetBoolean(prefs::kAutoclickEnabled, enabled); | 206 GetPrefs()->SetBoolean(prefs::kAutoclickEnabled, enabled); |
| 202 } | 207 } |
| 203 | 208 |
| 204 void SetAutoclickDelayPref(int delay_ms) { | 209 void SetAutoclickDelayPref(int delay_ms) { |
| 205 GetPrefs()->SetInteger(prefs::kAutoclickDelayMs, delay_ms); | 210 GetPrefs()->SetInteger(prefs::kAutoclickDelayMs, delay_ms); |
| 206 } | 211 } |
| 207 | 212 |
| 208 bool GetLargeCursorEnabledFromPref() { | 213 bool GetLargeCursorEnabledFromPref() { |
| 209 return GetPrefs()->GetBoolean(prefs::kLargeCursorEnabled); | 214 return GetPrefs()->GetBoolean(prefs::kLargeCursorEnabled); |
| 210 } | 215 } |
| 211 | 216 |
| 212 bool GetHighContrastEnabledFromPref() { | 217 bool GetHighContrastEnabledFromPref() { |
| 213 return GetPrefs()->GetBoolean(prefs::kHighContrastEnabled); | 218 return GetPrefs()->GetBoolean(prefs::kHighContrastEnabled); |
| 214 } | 219 } |
| 215 | 220 |
| 216 bool GetSpokenFeedbackEnabledFromPref() { | 221 bool GetSpokenFeedbackEnabledFromPref() { |
| 217 return GetPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled); | 222 return GetGlobalPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled); |
| 218 } | 223 } |
| 219 | 224 |
| 220 bool GetAutoclickEnabledFromPref() { | 225 bool GetAutoclickEnabledFromPref() { |
| 221 return GetPrefs()->GetBoolean(prefs::kAutoclickEnabled); | 226 return GetPrefs()->GetBoolean(prefs::kAutoclickEnabled); |
| 222 } | 227 } |
| 223 | 228 |
| 224 int GetAutoclickDelayFromPref() { | 229 int GetAutoclickDelayFromPref() { |
| 225 return GetPrefs()->GetInteger(prefs::kAutoclickDelayMs); | 230 return GetPrefs()->GetInteger(prefs::kAutoclickDelayMs); |
| 226 } | 231 } |
| 227 | 232 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 } | 383 } |
| 379 | 384 |
| 380 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) { | 385 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) { |
| 381 // Loads the profile of the user. | 386 // Loads the profile of the user. |
| 382 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true); | 387 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true); |
| 383 | 388 |
| 384 // Sets the pref to enable large cursor before login. | 389 // Sets the pref to enable large cursor before login. |
| 385 SetLargeCursorEnabledPref(true); | 390 SetLargeCursorEnabledPref(true); |
| 386 EXPECT_FALSE(IsLargeCursorEnabled()); | 391 EXPECT_FALSE(IsLargeCursorEnabled()); |
| 387 | 392 |
| 388 // Sets the pref to enable spoken feedback before login. | |
| 389 SetSpokenFeedbackEnabledPref(true); | |
| 390 EXPECT_FALSE(IsSpokenFeedbackEnabled()); | |
| 391 | |
| 392 // Sets the pref to enable high contrast before login. | 393 // Sets the pref to enable high contrast before login. |
| 393 SetHighContrastEnabledPref(true); | 394 SetHighContrastEnabledPref(true); |
| 394 EXPECT_FALSE(IsHighContrastEnabled()); | 395 EXPECT_FALSE(IsHighContrastEnabled()); |
| 395 | 396 |
| 396 // Sets the pref to enable autoclick before login. | 397 // Sets the pref to enable autoclick before login. |
| 397 SetAutoclickEnabledPref(true); | 398 SetAutoclickEnabledPref(true); |
| 398 EXPECT_FALSE(IsAutoclickEnabled()); | 399 EXPECT_FALSE(IsAutoclickEnabled()); |
| 399 | 400 |
| 400 // Sets the autoclick delay pref before login but the | 401 // Sets the autoclick delay pref before login but the |
| 401 // initial value should not change. | 402 // initial value should not change. |
| 402 SetAutoclickDelayPref(kTestAutoclickDelayMs); | 403 SetAutoclickDelayPref(kTestAutoclickDelayMs); |
| 403 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); | 404 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); |
| 404 | 405 |
| 406 // Sets the pref to enable spoken feedback before login. |
| 407 SetSpokenFeedbackEnabledPref(true); |
| 408 // Spoken feedback is enabled since it it the system-wide setting. |
| 409 EXPECT_TRUE(IsSpokenFeedbackEnabled()); |
| 410 |
| 405 // Logs in. | 411 // Logs in. |
| 406 UserManager::Get()->SessionStarted(); | 412 UserManager::Get()->SessionStarted(); |
| 407 | 413 |
| 408 // Confirms that features are enabled by restring from pref just after login. | 414 // Confirms that features are enabled by restring from pref just after login. |
| 409 EXPECT_TRUE(IsLargeCursorEnabled()); | 415 EXPECT_TRUE(IsLargeCursorEnabled()); |
| 410 EXPECT_TRUE(IsSpokenFeedbackEnabled()); | |
| 411 EXPECT_TRUE(IsHighContrastEnabled()); | 416 EXPECT_TRUE(IsHighContrastEnabled()); |
| 412 EXPECT_TRUE(IsAutoclickEnabled()); | 417 EXPECT_TRUE(IsAutoclickEnabled()); |
| 413 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); | 418 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); |
| 419 |
| 420 // Spoken feedback is still enabled since it it the system-wide setting. |
| 421 EXPECT_TRUE(IsSpokenFeedbackEnabled()); |
| 414 } | 422 } |
| 415 | 423 |
| 416 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, | 424 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, |
| 417 ChangingTypeInvokesNotification) { | 425 ChangingTypeInvokesNotification) { |
| 418 MockAccessibilityObserver observer; | 426 MockAccessibilityObserver observer; |
| 419 | 427 |
| 420 // Logs in. | 428 // Logs in. |
| 421 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true); | 429 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true); |
| 422 UserManager::Get()->SessionStarted(); | 430 UserManager::Get()->SessionStarted(); |
| 423 | 431 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 EXPECT_FALSE(ShouldShowAccessibilityMenu()); | 603 EXPECT_FALSE(ShouldShowAccessibilityMenu()); |
| 596 | 604 |
| 597 // Check autoclick. | 605 // Check autoclick. |
| 598 SetAutoclickEnabled(true); | 606 SetAutoclickEnabled(true); |
| 599 EXPECT_TRUE(ShouldShowAccessibilityMenu()); | 607 EXPECT_TRUE(ShouldShowAccessibilityMenu()); |
| 600 SetAutoclickEnabled(false); | 608 SetAutoclickEnabled(false); |
| 601 EXPECT_FALSE(ShouldShowAccessibilityMenu()); | 609 EXPECT_FALSE(ShouldShowAccessibilityMenu()); |
| 602 } | 610 } |
| 603 | 611 |
| 604 } // namespace chromeos | 612 } // namespace chromeos |
| OLD | NEW |