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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
7 #include "ash/magnifier/magnification_controller.h"
9 #include "base/command_line.h"
10 #include "base/prefs/pref_service.h"
11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
14 #include "chrome/browser/chromeos/login/helper.h"
15 #include "chrome/browser/chromeos/login/login_utils.h"
16 #include "chrome/browser/chromeos/login/user_manager.h"
17 #include "chrome/browser/chromeos/login/user_manager_impl.h"
18 #include "chrome/browser/chromeos/profiles/profile_helper.h"
19 #include "chrome/browser/extensions/api/braille_display_private/stub_braille_controller.h"
20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_manager.h"
22 #include "chrome/common/pref_names.h"
23 #include "chrome/test/base/in_process_browser_test.h"
24 #include "chrome/test/base/testing_profile.h"
25 #include "chromeos/chromeos_switches.h"
26 #include "content/public/browser/notification_service.h"
27 #include "testing/gtest/include/gtest/gtest.h"
29 using extensions::api::braille_display_private::BrailleObserver;
30 using extensions::api::braille_display_private::DisplayState;
31 using extensions::api::braille_display_private::StubBrailleController;
37 const char kTestUserName[] = "owner@invalid.domain";
39 const int kTestAutoclickDelayMs = 2000;
41 // Test user name for locally managed user. The domain part must be matched
42 // with UserManager::kLocallyManagedUserDomain.
43 const char kTestLocallyManagedUserName[] = "test@locally-managed.localhost";
45 class MockAccessibilityObserver : public content::NotificationObserver {
47 MockAccessibilityObserver() : observed_(false),
48 observed_enabled_(false),
52 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK,
53 content::NotificationService::AllSources());
56 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE,
57 content::NotificationService::AllSources());
60 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD,
61 content::NotificationService::AllSources());
63 virtual ~MockAccessibilityObserver() {}
65 bool observed() const { return observed_; }
66 bool observed_enabled() const { return observed_enabled_; }
67 int observed_type() const { return observed_type_; }
69 void reset() { observed_ = false; }
72 // content::NotificationObserver implimentation:
73 virtual void Observe(int type,
74 const content::NotificationSource& source,
75 const content::NotificationDetails& details) OVERRIDE {
76 AccessibilityStatusEventDetails* accessibility_status =
77 content::Details<AccessibilityStatusEventDetails>(
79 ASSERT_FALSE(observed_);
82 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK:
84 observed_enabled_ = accessibility_status->enabled;
85 observed_type_ = type;
87 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE:
89 observed_enabled_ = accessibility_status->enabled;
90 observed_type_ = type;
92 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD:
94 observed_enabled_ = accessibility_status->enabled;
95 observed_type_ = type;
101 bool observed_enabled_;
104 content::NotificationRegistrar registrar_;
106 DISALLOW_COPY_AND_ASSIGN(MockAccessibilityObserver);
109 class MockBrailleController : public StubBrailleController {
112 MockBrailleController() : available_(false), observer_(NULL) {}
114 virtual scoped_ptr<DisplayState> GetDisplayState() OVERRIDE {
115 scoped_ptr<DisplayState> state(new DisplayState());
116 state->available = available_;
120 virtual void AddObserver(BrailleObserver* observer) OVERRIDE {
121 ASSERT_EQ(NULL, observer_);
122 observer_ = observer;
125 virtual void RemoveObserver(BrailleObserver* observer) OVERRIDE {
126 ASSERT_EQ(observer_, observer);
129 void SetAvailable(bool available) {
130 available_ = available;
133 BrailleObserver* GetObserver() {
139 BrailleObserver* observer_;
142 void SetLargeCursorEnabled(bool enabled) {
143 return AccessibilityManager::Get()->EnableLargeCursor(enabled);
146 bool IsLargeCursorEnabled() {
147 return AccessibilityManager::Get()->IsLargeCursorEnabled();
150 bool ShouldShowAccessibilityMenu() {
151 return AccessibilityManager::Get()->ShouldShowAccessibilityMenu();
154 void SetHighContrastEnabled(bool enabled) {
155 return AccessibilityManager::Get()->EnableHighContrast(enabled);
158 bool IsHighContrastEnabled() {
159 return AccessibilityManager::Get()->IsHighContrastEnabled();
162 void SetSpokenFeedbackEnabled(bool enabled) {
163 return AccessibilityManager::Get()->EnableSpokenFeedback(
164 enabled, ash::A11Y_NOTIFICATION_NONE);
167 bool IsSpokenFeedbackEnabled() {
168 return AccessibilityManager::Get()->IsSpokenFeedbackEnabled();
171 void SetAutoclickEnabled(bool enabled) {
172 return AccessibilityManager::Get()->EnableAutoclick(enabled);
175 bool IsAutoclickEnabled() {
176 return AccessibilityManager::Get()->IsAutoclickEnabled();
179 void SetAutoclickDelay(int delay_ms) {
180 return AccessibilityManager::Get()->SetAutoclickDelay(delay_ms);
183 int GetAutoclickDelay() {
184 return AccessibilityManager::Get()->GetAutoclickDelay();
187 void SetVirtualKeyboardEnabled(bool enabled) {
188 return AccessibilityManager::Get()->EnableVirtualKeyboard(enabled);
191 bool IsVirtualKeyboardEnabled() {
192 return AccessibilityManager::Get()->IsVirtualKeyboardEnabled();
195 Profile* GetProfile() {
196 Profile* profile = ProfileManager::GetActiveUserProfile();
201 PrefService* GetPrefs() {
202 return GetProfile()->GetPrefs();
205 void SetLargeCursorEnabledPref(bool enabled) {
206 GetPrefs()->SetBoolean(prefs::kLargeCursorEnabled, enabled);
209 void SetHighContrastEnabledPref(bool enabled) {
210 GetPrefs()->SetBoolean(prefs::kHighContrastEnabled, enabled);
213 void SetSpokenFeedbackEnabledPref(bool enabled) {
214 GetPrefs()->SetBoolean(prefs::kSpokenFeedbackEnabled, enabled);
217 void SetAutoclickEnabledPref(bool enabled) {
218 GetPrefs()->SetBoolean(prefs::kAutoclickEnabled, enabled);
221 void SetAutoclickDelayPref(int delay_ms) {
222 GetPrefs()->SetInteger(prefs::kAutoclickDelayMs, delay_ms);
225 void SetVirtualKeyboardEnabledPref(bool enabled) {
226 GetPrefs()->SetBoolean(prefs::kVirtualKeyboardEnabled, enabled);
229 bool GetLargeCursorEnabledFromPref() {
230 return GetPrefs()->GetBoolean(prefs::kLargeCursorEnabled);
233 bool GetHighContrastEnabledFromPref() {
234 return GetPrefs()->GetBoolean(prefs::kHighContrastEnabled);
237 bool GetSpokenFeedbackEnabledFromPref() {
238 return GetPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled);
241 bool GetAutoclickEnabledFromPref() {
242 return GetPrefs()->GetBoolean(prefs::kAutoclickEnabled);
245 int GetAutoclickDelayFromPref() {
246 return GetPrefs()->GetInteger(prefs::kAutoclickDelayMs);
249 } // anonymouse namespace
251 class AccessibilityManagerTest : public InProcessBrowserTest {
253 AccessibilityManagerTest() : default_autoclick_delay_(0) {}
254 virtual ~AccessibilityManagerTest() {}
256 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
257 command_line->AppendSwitch(chromeos::switches::kLoginManager);
258 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile,
259 TestingProfile::kTestUserProfileDir);
262 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
263 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_);
266 virtual void SetUpOnMainThread() OVERRIDE {
267 // Sets the login-screen profile.
268 AccessibilityManager::Get()->
269 SetProfileForTest(ProfileHelper::GetSigninProfile());
270 default_autoclick_delay_ = GetAutoclickDelay();
273 virtual void CleanUpOnMainThread() OVERRIDE {
274 AccessibilityManager::SetBrailleControllerForTest(NULL);
277 int default_autoclick_delay() const { return default_autoclick_delay_; }
279 int default_autoclick_delay_;
281 content::NotificationRegistrar registrar_;
283 MockBrailleController braille_controller_;
284 DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerTest);
287 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) {
288 // Confirms that a11y features are disabled on the login screen.
289 EXPECT_FALSE(IsLargeCursorEnabled());
290 EXPECT_FALSE(IsSpokenFeedbackEnabled());
291 EXPECT_FALSE(IsHighContrastEnabled());
292 EXPECT_FALSE(IsAutoclickEnabled());
293 EXPECT_FALSE(IsVirtualKeyboardEnabled());
294 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
297 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true);
299 // Confirms that the features still disabled just after login.
300 EXPECT_FALSE(IsLargeCursorEnabled());
301 EXPECT_FALSE(IsSpokenFeedbackEnabled());
302 EXPECT_FALSE(IsHighContrastEnabled());
303 EXPECT_FALSE(IsAutoclickEnabled());
304 EXPECT_FALSE(IsVirtualKeyboardEnabled());
305 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
307 UserManager::Get()->SessionStarted();
309 // Confirms that the features are still disabled just after login.
310 EXPECT_FALSE(IsLargeCursorEnabled());
311 EXPECT_FALSE(IsSpokenFeedbackEnabled());
312 EXPECT_FALSE(IsHighContrastEnabled());
313 EXPECT_FALSE(IsAutoclickEnabled());
314 EXPECT_FALSE(IsVirtualKeyboardEnabled());
315 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
317 // Enables large cursor.
318 SetLargeCursorEnabled(true);
319 // Confirms that large cursor is enabled.
320 EXPECT_TRUE(IsLargeCursorEnabled());
322 // Enables spoken feedback.
323 SetSpokenFeedbackEnabled(true);
324 // Confirms that the spoken feedback is enabled.
325 EXPECT_TRUE(IsSpokenFeedbackEnabled());
327 // Enables high contrast.
328 SetHighContrastEnabled(true);
329 // Confirms that high cotrast is enabled.
330 EXPECT_TRUE(IsHighContrastEnabled());
332 // Enables autoclick.
333 SetAutoclickEnabled(true);
334 // Confirms that autoclick is enabled.
335 EXPECT_TRUE(IsAutoclickEnabled());
337 // Test that autoclick delay is set properly.
338 SetAutoclickDelay(kTestAutoclickDelayMs);
339 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
341 // Enable on-screen keyboard
342 SetVirtualKeyboardEnabled(true);
343 // Confirm that the on-screen keyboard option is enabled.
344 EXPECT_TRUE(IsVirtualKeyboardEnabled());
347 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, BrailleOnLoginScreen) {
348 EXPECT_FALSE(IsSpokenFeedbackEnabled());
350 // Signal the accessibility manager that a braille display was connected.
351 braille_controller_.SetAvailable(true);
352 braille_controller_.GetObserver()->OnDisplayStateChanged(
353 *braille_controller_.GetDisplayState());
355 // Confirms that the spoken feedback is enabled.
356 EXPECT_TRUE(IsSpokenFeedbackEnabled());
359 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) {
361 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true);
362 UserManager::Get()->SessionStarted();
364 // Confirms that the features are disabled just after login.
365 EXPECT_FALSE(IsLargeCursorEnabled());
366 EXPECT_FALSE(IsSpokenFeedbackEnabled());
367 EXPECT_FALSE(IsHighContrastEnabled());
368 EXPECT_FALSE(IsAutoclickEnabled());
369 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
370 EXPECT_FALSE(IsVirtualKeyboardEnabled());
372 // Sets the pref as true to enable the large cursor.
373 SetLargeCursorEnabledPref(true);
374 // Confirms that the large cursor is enabled.
375 EXPECT_TRUE(IsLargeCursorEnabled());
377 // Sets the pref as true to enable the spoken feedback.
378 SetSpokenFeedbackEnabledPref(true);
379 // Confirms that the spoken feedback is enabled.
380 EXPECT_TRUE(IsSpokenFeedbackEnabled());
382 // Sets the pref as true to enable high contrast mode.
383 SetHighContrastEnabledPref(true);
384 // Confirms that the high contrast mode is enabled.
385 EXPECT_TRUE(IsHighContrastEnabled());
387 // Sets the pref as true to enable autoclick.
388 SetAutoclickEnabledPref(true);
389 // Confirms that autoclick is enabled.
390 EXPECT_TRUE(IsAutoclickEnabled());
392 // Set autoclick delay pref.
393 SetAutoclickDelayPref(kTestAutoclickDelayMs);
394 // Confirm that the correct value is set.
395 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
397 // Sets the on-screen keyboard pref.
398 SetVirtualKeyboardEnabledPref(true);
399 // Confirm that the on-screen keyboard option is enabled.
400 EXPECT_TRUE(IsVirtualKeyboardEnabled());
402 SetLargeCursorEnabledPref(false);
403 EXPECT_FALSE(IsLargeCursorEnabled());
405 SetSpokenFeedbackEnabledPref(false);
406 EXPECT_FALSE(IsSpokenFeedbackEnabled());
408 SetHighContrastEnabledPref(false);
409 EXPECT_FALSE(IsHighContrastEnabled());
411 SetAutoclickEnabledPref(false);
412 EXPECT_FALSE(IsAutoclickEnabled());
414 SetVirtualKeyboardEnabledPref(false);
415 EXPECT_FALSE(IsVirtualKeyboardEnabled());
418 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) {
419 // Loads the profile of the user.
420 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true);
422 // Sets the pref to enable large cursor before login.
423 SetLargeCursorEnabledPref(true);
424 EXPECT_FALSE(IsLargeCursorEnabled());
426 // Sets the pref to enable spoken feedback before login.
427 SetSpokenFeedbackEnabledPref(true);
428 EXPECT_FALSE(IsSpokenFeedbackEnabled());
430 // Sets the pref to enable high contrast before login.
431 SetHighContrastEnabledPref(true);
432 EXPECT_FALSE(IsHighContrastEnabled());
434 // Sets the pref to enable autoclick before login.
435 SetAutoclickEnabledPref(true);
436 EXPECT_FALSE(IsAutoclickEnabled());
438 // Sets the autoclick delay pref before login but the
439 // initial value should not change.
440 SetAutoclickDelayPref(kTestAutoclickDelayMs);
441 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
443 // Sets the pref to enable the on-screen keyboard before login.
444 SetVirtualKeyboardEnabledPref(true);
445 EXPECT_FALSE(IsVirtualKeyboardEnabled());
448 UserManager::Get()->SessionStarted();
450 // Confirms that features are enabled by restoring from pref just after login.
451 EXPECT_TRUE(IsLargeCursorEnabled());
452 EXPECT_TRUE(IsSpokenFeedbackEnabled());
453 EXPECT_TRUE(IsHighContrastEnabled());
454 EXPECT_TRUE(IsAutoclickEnabled());
455 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
456 EXPECT_TRUE(IsVirtualKeyboardEnabled());
459 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest,
460 ChangingTypeInvokesNotification) {
461 MockAccessibilityObserver observer;
464 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true);
465 UserManager::Get()->SessionStarted();
467 EXPECT_FALSE(observer.observed());
470 SetSpokenFeedbackEnabled(true);
471 EXPECT_TRUE(observer.observed());
472 EXPECT_TRUE(observer.observed_enabled());
473 EXPECT_EQ(observer.observed_type(),
474 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
475 EXPECT_TRUE(IsSpokenFeedbackEnabled());
478 SetSpokenFeedbackEnabled(false);
479 EXPECT_TRUE(observer.observed());
480 EXPECT_FALSE(observer.observed_enabled());
481 EXPECT_EQ(observer.observed_type(),
482 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
483 EXPECT_FALSE(IsSpokenFeedbackEnabled());
486 SetHighContrastEnabled(true);
487 EXPECT_TRUE(observer.observed());
488 EXPECT_TRUE(observer.observed_enabled());
489 EXPECT_EQ(observer.observed_type(),
490 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE);
491 EXPECT_TRUE(IsHighContrastEnabled());
494 SetHighContrastEnabled(false);
495 EXPECT_TRUE(observer.observed());
496 EXPECT_FALSE(observer.observed_enabled());
497 EXPECT_EQ(observer.observed_type(),
498 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE);
499 EXPECT_FALSE(IsHighContrastEnabled());
502 SetVirtualKeyboardEnabled(true);
503 EXPECT_TRUE(observer.observed());
504 EXPECT_TRUE(observer.observed_enabled());
505 EXPECT_EQ(observer.observed_type(),
506 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD);
507 EXPECT_TRUE(IsVirtualKeyboardEnabled());
510 SetVirtualKeyboardEnabled(false);
511 EXPECT_TRUE(observer.observed());
512 EXPECT_FALSE(observer.observed_enabled());
513 EXPECT_EQ(observer.observed_type(),
514 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD);
515 EXPECT_FALSE(IsVirtualKeyboardEnabled());
518 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest,
519 ChangingTypePrefInvokesNotification) {
520 MockAccessibilityObserver observer;
523 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true);
524 UserManager::Get()->SessionStarted();
526 EXPECT_FALSE(observer.observed());
529 SetSpokenFeedbackEnabledPref(true);
530 EXPECT_TRUE(observer.observed());
531 EXPECT_TRUE(observer.observed_enabled());
532 EXPECT_EQ(observer.observed_type(),
533 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
534 EXPECT_TRUE(IsSpokenFeedbackEnabled());
537 SetSpokenFeedbackEnabledPref(false);
538 EXPECT_TRUE(observer.observed());
539 EXPECT_FALSE(observer.observed_enabled());
540 EXPECT_EQ(observer.observed_type(),
541 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
542 EXPECT_FALSE(IsSpokenFeedbackEnabled());
545 SetHighContrastEnabledPref(true);
546 EXPECT_TRUE(observer.observed());
547 EXPECT_TRUE(observer.observed_enabled());
548 EXPECT_EQ(observer.observed_type(),
549 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE);
550 EXPECT_TRUE(IsHighContrastEnabled());
553 SetHighContrastEnabledPref(false);
554 EXPECT_TRUE(observer.observed());
555 EXPECT_FALSE(observer.observed_enabled());
556 EXPECT_EQ(observer.observed_type(),
557 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE);
558 EXPECT_FALSE(IsHighContrastEnabled());
561 SetVirtualKeyboardEnabledPref(true);
562 EXPECT_TRUE(observer.observed());
563 EXPECT_TRUE(observer.observed_enabled());
564 EXPECT_EQ(observer.observed_type(),
565 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD);
566 EXPECT_TRUE(IsVirtualKeyboardEnabled());
569 SetVirtualKeyboardEnabledPref(false);
570 EXPECT_TRUE(observer.observed());
571 EXPECT_FALSE(observer.observed_enabled());
572 EXPECT_EQ(observer.observed_type(),
573 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD);
574 EXPECT_FALSE(IsVirtualKeyboardEnabled());
577 class AccessibilityManagerUserTypeTest
578 : public AccessibilityManagerTest,
579 public ::testing::WithParamInterface<const char*> {
581 AccessibilityManagerUserTypeTest() {}
582 virtual ~AccessibilityManagerUserTypeTest() {}
584 DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerUserTypeTest);
587 // TODO(yoshiki): Enable a test for retail mode.
588 INSTANTIATE_TEST_CASE_P(
589 UserTypeInstantiation,
590 AccessibilityManagerUserTypeTest,
591 ::testing::Values(kTestUserName,
592 UserManager::kGuestUserName,
593 //UserManager::kRetailModeUserName,
594 kTestLocallyManagedUserName));
596 IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest,
597 EnableOnLoginScreenAndLogin) {
598 // Enables large cursor.
599 SetLargeCursorEnabled(true);
600 EXPECT_TRUE(IsLargeCursorEnabled());
601 // Enables spoken feedback.
602 SetSpokenFeedbackEnabled(true);
603 EXPECT_TRUE(IsSpokenFeedbackEnabled());
604 // Enables high contrast.
605 SetHighContrastEnabled(true);
606 EXPECT_TRUE(IsHighContrastEnabled());
607 // Enables autoclick.
608 SetAutoclickEnabled(true);
609 EXPECT_TRUE(IsAutoclickEnabled());
610 // Set autoclick delay.
611 SetAutoclickDelay(kTestAutoclickDelayMs);
612 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
615 const char* user_name = GetParam();
616 UserManager::Get()->UserLoggedIn(user_name, user_name, true);
618 // Confirms that the features are still enabled just after login.
619 EXPECT_TRUE(IsLargeCursorEnabled());
620 EXPECT_TRUE(IsSpokenFeedbackEnabled());
621 EXPECT_TRUE(IsHighContrastEnabled());
622 EXPECT_TRUE(IsAutoclickEnabled());
623 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
625 UserManager::Get()->SessionStarted();
627 // Confirms that the features keep enabled after session starts.
628 EXPECT_TRUE(IsLargeCursorEnabled());
629 EXPECT_TRUE(IsSpokenFeedbackEnabled());
630 EXPECT_TRUE(IsHighContrastEnabled());
631 EXPECT_TRUE(IsAutoclickEnabled());
632 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
634 // Confirms that the prefs have been copied to the user's profile.
635 EXPECT_TRUE(GetLargeCursorEnabledFromPref());
636 EXPECT_TRUE(GetSpokenFeedbackEnabledFromPref());
637 EXPECT_TRUE(GetHighContrastEnabledFromPref());
638 EXPECT_TRUE(GetAutoclickEnabledFromPref());
639 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelayFromPref());
642 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, AcessibilityMenuVisibility) {
644 UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true);
645 UserManager::Get()->SessionStarted();
647 // Confirms that the features are disabled.
648 EXPECT_FALSE(IsLargeCursorEnabled());
649 EXPECT_FALSE(IsSpokenFeedbackEnabled());
650 EXPECT_FALSE(IsHighContrastEnabled());
651 EXPECT_FALSE(IsAutoclickEnabled());
652 EXPECT_FALSE(ShouldShowAccessibilityMenu());
653 EXPECT_FALSE(IsVirtualKeyboardEnabled());
655 // Check large cursor.
656 SetLargeCursorEnabled(true);
657 EXPECT_TRUE(ShouldShowAccessibilityMenu());
658 SetLargeCursorEnabled(false);
659 EXPECT_FALSE(ShouldShowAccessibilityMenu());
661 // Check spoken feedback.
662 SetSpokenFeedbackEnabled(true);
663 EXPECT_TRUE(ShouldShowAccessibilityMenu());
664 SetSpokenFeedbackEnabled(false);
665 EXPECT_FALSE(ShouldShowAccessibilityMenu());
667 // Check high contrast.
668 SetHighContrastEnabled(true);
669 EXPECT_TRUE(ShouldShowAccessibilityMenu());
670 SetHighContrastEnabled(false);
671 EXPECT_FALSE(ShouldShowAccessibilityMenu());
674 SetAutoclickEnabled(true);
675 EXPECT_TRUE(ShouldShowAccessibilityMenu());
676 SetAutoclickEnabled(false);
677 EXPECT_FALSE(ShouldShowAccessibilityMenu());
679 // Check on-screen keyboard.
680 SetVirtualKeyboardEnabled(true);
681 EXPECT_TRUE(ShouldShowAccessibilityMenu());
682 SetVirtualKeyboardEnabled(false);
683 EXPECT_FALSE(ShouldShowAccessibilityMenu());
686 } // namespace chromeos