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/session/user_session_manager.h"
16 #include "chrome/browser/chromeos/preferences.h"
17 #include "chrome/browser/chromeos/profiles/profile_helper.h"
18 #include "chrome/browser/extensions/api/braille_display_private/mock_braille_controller.h"
19 #include "chrome/browser/prefs/pref_service_syncable.h"
20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_manager.h"
22 #include "chrome/common/extensions/extension_constants.h"
23 #include "chrome/common/pref_names.h"
24 #include "chrome/test/base/in_process_browser_test.h"
25 #include "chrome/test/base/testing_profile.h"
26 #include "chromeos/chromeos_switches.h"
27 #include "chromeos/login/user_names.h"
28 #include "components/user_manager/user_manager.h"
29 #include "content/public/browser/notification_service.h"
30 #include "content/public/test/test_utils.h"
31 #include "testing/gtest/include/gtest/gtest.h"
32 #include "ui/base/ime/chromeos/component_extension_ime_manager.h"
33 #include "ui/base/ime/chromeos/input_method_manager.h"
35 using chromeos::input_method::InputMethodManager
;
36 using chromeos::input_method::InputMethodUtil
;
37 using chromeos::input_method::InputMethodDescriptors
;
38 using content::BrowserThread
;
39 using extensions::api::braille_display_private::BrailleObserver
;
40 using extensions::api::braille_display_private::DisplayState
;
41 using extensions::api::braille_display_private::KeyEvent
;
42 using extensions::api::braille_display_private::MockBrailleController
;
48 const char kTestUserName
[] = "owner@invalid.domain";
50 const int kTestAutoclickDelayMs
= 2000;
52 // Test user name for supervised user. The domain part must be matched with
53 // chromeos::login::kSupervisedUserDomain.
54 const char kTestSupervisedUserName
[] = "test@locally-managed.localhost";
56 class MockAccessibilityObserver
{
58 MockAccessibilityObserver() : observed_(false),
59 observed_enabled_(false),
62 AccessibilityManager
* accessibility_manager
= AccessibilityManager::Get();
63 CHECK(accessibility_manager
);
64 accessibility_subscription_
= accessibility_manager
->RegisterCallback(
65 base::Bind(&MockAccessibilityObserver::OnAccessibilityStatusChanged
,
66 base::Unretained(this)));
69 virtual ~MockAccessibilityObserver() {}
71 bool observed() const { return observed_
; }
72 bool observed_enabled() const { return observed_enabled_
; }
73 int observed_type() const { return observed_type_
; }
75 void reset() { observed_
= false; }
78 void OnAccessibilityStatusChanged(
79 const AccessibilityStatusEventDetails
& details
) {
80 if (details
.notification_type
!= ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER
) {
81 observed_type_
= details
.notification_type
;
82 observed_enabled_
= details
.enabled
;
88 bool observed_enabled_
;
91 scoped_ptr
<AccessibilityStatusSubscription
> accessibility_subscription_
;
93 DISALLOW_COPY_AND_ASSIGN(MockAccessibilityObserver
);
96 void SetLargeCursorEnabled(bool enabled
) {
97 return AccessibilityManager::Get()->EnableLargeCursor(enabled
);
100 bool IsLargeCursorEnabled() {
101 return AccessibilityManager::Get()->IsLargeCursorEnabled();
104 bool ShouldShowAccessibilityMenu() {
105 return AccessibilityManager::Get()->ShouldShowAccessibilityMenu();
108 void SetHighContrastEnabled(bool enabled
) {
109 return AccessibilityManager::Get()->EnableHighContrast(enabled
);
112 bool IsHighContrastEnabled() {
113 return AccessibilityManager::Get()->IsHighContrastEnabled();
116 void SetSpokenFeedbackEnabled(bool enabled
) {
117 return AccessibilityManager::Get()->EnableSpokenFeedback(
118 enabled
, ui::A11Y_NOTIFICATION_NONE
);
121 bool IsSpokenFeedbackEnabled() {
122 return AccessibilityManager::Get()->IsSpokenFeedbackEnabled();
125 void SetAutoclickEnabled(bool enabled
) {
126 return AccessibilityManager::Get()->EnableAutoclick(enabled
);
129 bool IsAutoclickEnabled() {
130 return AccessibilityManager::Get()->IsAutoclickEnabled();
133 void SetAutoclickDelay(int delay_ms
) {
134 return AccessibilityManager::Get()->SetAutoclickDelay(delay_ms
);
137 int GetAutoclickDelay() {
138 return AccessibilityManager::Get()->GetAutoclickDelay();
141 void SetVirtualKeyboardEnabled(bool enabled
) {
142 return AccessibilityManager::Get()->EnableVirtualKeyboard(enabled
);
145 bool IsVirtualKeyboardEnabled() {
146 return AccessibilityManager::Get()->IsVirtualKeyboardEnabled();
149 Profile
* GetProfile() {
150 Profile
* profile
= ProfileManager::GetActiveUserProfile();
155 PrefService
* GetPrefs() {
156 return GetProfile()->GetPrefs();
159 void SetLargeCursorEnabledPref(bool enabled
) {
160 GetPrefs()->SetBoolean(prefs::kAccessibilityLargeCursorEnabled
, enabled
);
163 void SetHighContrastEnabledPref(bool enabled
) {
164 GetPrefs()->SetBoolean(prefs::kAccessibilityHighContrastEnabled
, enabled
);
167 void SetSpokenFeedbackEnabledPref(bool enabled
) {
168 GetPrefs()->SetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled
, enabled
);
171 void SetAutoclickEnabledPref(bool enabled
) {
172 GetPrefs()->SetBoolean(prefs::kAccessibilityAutoclickEnabled
, enabled
);
175 void SetAutoclickDelayPref(int delay_ms
) {
176 GetPrefs()->SetInteger(prefs::kAccessibilityAutoclickDelayMs
, delay_ms
);
179 void SetVirtualKeyboardEnabledPref(bool enabled
) {
180 GetPrefs()->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled
, enabled
);
183 bool GetLargeCursorEnabledFromPref() {
184 return GetPrefs()->GetBoolean(prefs::kAccessibilityLargeCursorEnabled
);
187 bool GetHighContrastEnabledFromPref() {
188 return GetPrefs()->GetBoolean(prefs::kAccessibilityHighContrastEnabled
);
191 bool GetSpokenFeedbackEnabledFromPref() {
192 return GetPrefs()->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled
);
195 bool GetAutoclickEnabledFromPref() {
196 return GetPrefs()->GetBoolean(prefs::kAccessibilityAutoclickEnabled
);
199 int GetAutoclickDelayFromPref() {
200 return GetPrefs()->GetInteger(prefs::kAccessibilityAutoclickDelayMs
);
203 bool IsBrailleImeActive() {
204 InputMethodManager
* imm
= InputMethodManager::Get();
205 scoped_ptr
<InputMethodDescriptors
> descriptors
=
206 imm
->GetActiveIMEState()->GetActiveInputMethods();
207 for (InputMethodDescriptors::const_iterator i
= descriptors
->begin();
208 i
!= descriptors
->end();
210 if (i
->id() == extension_misc::kBrailleImeEngineId
)
216 bool IsBrailleImeCurrent() {
217 InputMethodManager
* imm
= InputMethodManager::Get();
218 return imm
->GetActiveIMEState()->GetCurrentInputMethod().id() ==
219 extension_misc::kBrailleImeEngineId
;
221 } // anonymous namespace
223 class AccessibilityManagerTest
: public InProcessBrowserTest
{
225 AccessibilityManagerTest() : default_autoclick_delay_(0) {}
226 ~AccessibilityManagerTest() override
{}
228 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
229 command_line
->AppendSwitch(chromeos::switches::kLoginManager
);
230 command_line
->AppendSwitchASCII(chromeos::switches::kLoginProfile
,
231 TestingProfile::kTestUserProfileDir
);
234 void SetUpInProcessBrowserTestFixture() override
{
235 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_
);
238 void SetUpOnMainThread() override
{
239 // Sets the login-screen profile.
240 AccessibilityManager::Get()->
241 SetProfileForTest(ProfileHelper::GetSigninProfile());
242 default_autoclick_delay_
= GetAutoclickDelay();
245 void TearDownOnMainThread() override
{
246 AccessibilityManager::SetBrailleControllerForTest(NULL
);
249 void SetBrailleDisplayAvailability(bool available
) {
250 braille_controller_
.SetAvailable(available
);
251 braille_controller_
.GetObserver()->OnBrailleDisplayStateChanged(
252 *braille_controller_
.GetDisplayState());
255 int default_autoclick_delay() const { return default_autoclick_delay_
; }
257 int default_autoclick_delay_
;
259 content::NotificationRegistrar registrar_
;
261 MockBrailleController braille_controller_
;
262 DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerTest
);
265 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest
, Login
) {
266 // Confirms that a11y features are disabled on the login screen.
267 EXPECT_FALSE(IsLargeCursorEnabled());
268 EXPECT_FALSE(IsSpokenFeedbackEnabled());
269 EXPECT_FALSE(IsHighContrastEnabled());
270 EXPECT_FALSE(IsAutoclickEnabled());
271 EXPECT_FALSE(IsVirtualKeyboardEnabled());
272 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
275 user_manager::UserManager::Get()->UserLoggedIn(
276 kTestUserName
, kTestUserName
, true);
278 // Confirms that the features still disabled just after login.
279 EXPECT_FALSE(IsLargeCursorEnabled());
280 EXPECT_FALSE(IsSpokenFeedbackEnabled());
281 EXPECT_FALSE(IsHighContrastEnabled());
282 EXPECT_FALSE(IsAutoclickEnabled());
283 EXPECT_FALSE(IsVirtualKeyboardEnabled());
284 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
286 user_manager::UserManager::Get()->SessionStarted();
288 // Confirms that the features are still disabled just after login.
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());
296 // Enables large cursor.
297 SetLargeCursorEnabled(true);
298 // Confirms that large cursor is enabled.
299 EXPECT_TRUE(IsLargeCursorEnabled());
301 // Enables spoken feedback.
302 SetSpokenFeedbackEnabled(true);
303 // Confirms that the spoken feedback is enabled.
304 EXPECT_TRUE(IsSpokenFeedbackEnabled());
306 // Enables high contrast.
307 SetHighContrastEnabled(true);
308 // Confirms that high cotrast is enabled.
309 EXPECT_TRUE(IsHighContrastEnabled());
311 // Enables autoclick.
312 SetAutoclickEnabled(true);
313 // Confirms that autoclick is enabled.
314 EXPECT_TRUE(IsAutoclickEnabled());
316 // Test that autoclick delay is set properly.
317 SetAutoclickDelay(kTestAutoclickDelayMs
);
318 EXPECT_EQ(kTestAutoclickDelayMs
, GetAutoclickDelay());
320 // Enable on-screen keyboard
321 SetVirtualKeyboardEnabled(true);
322 // Confirm that the on-screen keyboard option is enabled.
323 EXPECT_TRUE(IsVirtualKeyboardEnabled());
326 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest
, BrailleOnLoginScreen
) {
327 EXPECT_FALSE(IsSpokenFeedbackEnabled());
329 // Signal the accessibility manager that a braille display was connected.
330 SetBrailleDisplayAvailability(true);
331 // Confirms that the spoken feedback is enabled.
332 EXPECT_TRUE(IsSpokenFeedbackEnabled());
335 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest
, TypePref
) {
337 user_manager::UserManager::Get()->UserLoggedIn(
338 kTestUserName
, kTestUserName
, true);
339 user_manager::UserManager::Get()->SessionStarted();
341 // Confirms that the features are disabled just after login.
342 EXPECT_FALSE(IsLargeCursorEnabled());
343 EXPECT_FALSE(IsSpokenFeedbackEnabled());
344 EXPECT_FALSE(IsHighContrastEnabled());
345 EXPECT_FALSE(IsAutoclickEnabled());
346 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
347 EXPECT_FALSE(IsVirtualKeyboardEnabled());
349 // Sets the pref as true to enable the large cursor.
350 SetLargeCursorEnabledPref(true);
351 // Confirms that the large cursor is enabled.
352 EXPECT_TRUE(IsLargeCursorEnabled());
354 // Sets the pref as true to enable the spoken feedback.
355 SetSpokenFeedbackEnabledPref(true);
356 // Confirms that the spoken feedback is enabled.
357 EXPECT_TRUE(IsSpokenFeedbackEnabled());
359 // Sets the pref as true to enable high contrast mode.
360 SetHighContrastEnabledPref(true);
361 // Confirms that the high contrast mode is enabled.
362 EXPECT_TRUE(IsHighContrastEnabled());
364 // Sets the pref as true to enable autoclick.
365 SetAutoclickEnabledPref(true);
366 // Confirms that autoclick is enabled.
367 EXPECT_TRUE(IsAutoclickEnabled());
369 // Set autoclick delay pref.
370 SetAutoclickDelayPref(kTestAutoclickDelayMs
);
371 // Confirm that the correct value is set.
372 EXPECT_EQ(kTestAutoclickDelayMs
, GetAutoclickDelay());
374 // Sets the on-screen keyboard pref.
375 SetVirtualKeyboardEnabledPref(true);
376 // Confirm that the on-screen keyboard option is enabled.
377 EXPECT_TRUE(IsVirtualKeyboardEnabled());
379 SetLargeCursorEnabledPref(false);
380 EXPECT_FALSE(IsLargeCursorEnabled());
382 SetSpokenFeedbackEnabledPref(false);
383 EXPECT_FALSE(IsSpokenFeedbackEnabled());
385 SetHighContrastEnabledPref(false);
386 EXPECT_FALSE(IsHighContrastEnabled());
388 SetAutoclickEnabledPref(false);
389 EXPECT_FALSE(IsAutoclickEnabled());
391 SetVirtualKeyboardEnabledPref(false);
392 EXPECT_FALSE(IsVirtualKeyboardEnabled());
395 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest
, ResumeSavedPref
) {
396 // Loads the profile of the user.
397 user_manager::UserManager::Get()->UserLoggedIn(
398 kTestUserName
, kTestUserName
, true);
400 // Sets the pref to enable large cursor before login.
401 SetLargeCursorEnabledPref(true);
402 EXPECT_FALSE(IsLargeCursorEnabled());
404 // Sets the pref to enable spoken feedback before login.
405 SetSpokenFeedbackEnabledPref(true);
406 EXPECT_FALSE(IsSpokenFeedbackEnabled());
408 // Sets the pref to enable high contrast before login.
409 SetHighContrastEnabledPref(true);
410 EXPECT_FALSE(IsHighContrastEnabled());
412 // Sets the pref to enable autoclick before login.
413 SetAutoclickEnabledPref(true);
414 EXPECT_FALSE(IsAutoclickEnabled());
416 // Sets the autoclick delay pref before login but the
417 // initial value should not change.
418 SetAutoclickDelayPref(kTestAutoclickDelayMs
);
419 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
421 // Sets the pref to enable the on-screen keyboard before login.
422 SetVirtualKeyboardEnabledPref(true);
423 EXPECT_FALSE(IsVirtualKeyboardEnabled());
426 user_manager::UserManager::Get()->SessionStarted();
428 // Confirms that features are enabled by restoring from pref just after login.
429 EXPECT_TRUE(IsLargeCursorEnabled());
430 EXPECT_TRUE(IsSpokenFeedbackEnabled());
431 EXPECT_TRUE(IsHighContrastEnabled());
432 EXPECT_TRUE(IsAutoclickEnabled());
433 EXPECT_EQ(kTestAutoclickDelayMs
, GetAutoclickDelay());
434 EXPECT_TRUE(IsVirtualKeyboardEnabled());
437 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest
,
438 ChangingTypeInvokesNotification
) {
439 MockAccessibilityObserver observer
;
442 user_manager::UserManager::Get()->UserLoggedIn(
443 kTestUserName
, kTestUserName
, true);
444 user_manager::UserManager::Get()->SessionStarted();
446 EXPECT_FALSE(observer
.observed());
449 SetSpokenFeedbackEnabled(true);
450 EXPECT_TRUE(observer
.observed());
451 EXPECT_TRUE(observer
.observed_enabled());
452 EXPECT_EQ(observer
.observed_type(),
453 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK
);
454 EXPECT_TRUE(IsSpokenFeedbackEnabled());
457 SetSpokenFeedbackEnabled(false);
458 EXPECT_TRUE(observer
.observed());
459 EXPECT_FALSE(observer
.observed_enabled());
460 EXPECT_EQ(observer
.observed_type(),
461 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK
);
462 EXPECT_FALSE(IsSpokenFeedbackEnabled());
465 SetHighContrastEnabled(true);
466 EXPECT_TRUE(observer
.observed());
467 EXPECT_TRUE(observer
.observed_enabled());
468 EXPECT_EQ(observer
.observed_type(),
469 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE
);
470 EXPECT_TRUE(IsHighContrastEnabled());
473 SetHighContrastEnabled(false);
474 EXPECT_TRUE(observer
.observed());
475 EXPECT_FALSE(observer
.observed_enabled());
476 EXPECT_EQ(observer
.observed_type(),
477 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE
);
478 EXPECT_FALSE(IsHighContrastEnabled());
481 SetVirtualKeyboardEnabled(true);
482 EXPECT_TRUE(observer
.observed());
483 EXPECT_TRUE(observer
.observed_enabled());
484 EXPECT_EQ(observer
.observed_type(),
485 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD
);
486 EXPECT_TRUE(IsVirtualKeyboardEnabled());
489 SetVirtualKeyboardEnabled(false);
490 EXPECT_TRUE(observer
.observed());
491 EXPECT_FALSE(observer
.observed_enabled());
492 EXPECT_EQ(observer
.observed_type(),
493 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD
);
494 EXPECT_FALSE(IsVirtualKeyboardEnabled());
497 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest
,
498 ChangingTypePrefInvokesNotification
) {
499 MockAccessibilityObserver observer
;
502 user_manager::UserManager::Get()->UserLoggedIn(
503 kTestUserName
, kTestUserName
, true);
504 user_manager::UserManager::Get()->SessionStarted();
506 EXPECT_FALSE(observer
.observed());
509 SetSpokenFeedbackEnabledPref(true);
510 EXPECT_TRUE(observer
.observed());
511 EXPECT_TRUE(observer
.observed_enabled());
512 EXPECT_EQ(observer
.observed_type(),
513 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK
);
514 EXPECT_TRUE(IsSpokenFeedbackEnabled());
517 SetSpokenFeedbackEnabledPref(false);
518 EXPECT_TRUE(observer
.observed());
519 EXPECT_FALSE(observer
.observed_enabled());
520 EXPECT_EQ(observer
.observed_type(),
521 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK
);
522 EXPECT_FALSE(IsSpokenFeedbackEnabled());
525 SetHighContrastEnabledPref(true);
526 EXPECT_TRUE(observer
.observed());
527 EXPECT_TRUE(observer
.observed_enabled());
528 EXPECT_EQ(observer
.observed_type(),
529 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE
);
530 EXPECT_TRUE(IsHighContrastEnabled());
533 SetHighContrastEnabledPref(false);
534 EXPECT_TRUE(observer
.observed());
535 EXPECT_FALSE(observer
.observed_enabled());
536 EXPECT_EQ(observer
.observed_type(),
537 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE
);
538 EXPECT_FALSE(IsHighContrastEnabled());
541 SetVirtualKeyboardEnabledPref(true);
542 EXPECT_TRUE(observer
.observed());
543 EXPECT_TRUE(observer
.observed_enabled());
544 EXPECT_EQ(observer
.observed_type(),
545 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD
);
546 EXPECT_TRUE(IsVirtualKeyboardEnabled());
549 SetVirtualKeyboardEnabledPref(false);
550 EXPECT_TRUE(observer
.observed());
551 EXPECT_FALSE(observer
.observed_enabled());
552 EXPECT_EQ(observer
.observed_type(),
553 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD
);
554 EXPECT_FALSE(IsVirtualKeyboardEnabled());
557 class AccessibilityManagerUserTypeTest
558 : public AccessibilityManagerTest
,
559 public ::testing::WithParamInterface
<const char*> {
561 AccessibilityManagerUserTypeTest() {}
562 virtual ~AccessibilityManagerUserTypeTest() {}
564 DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerUserTypeTest
);
567 // TODO(yoshiki): Enable a test for retail mode.
568 INSTANTIATE_TEST_CASE_P(
569 UserTypeInstantiation
,
570 AccessibilityManagerUserTypeTest
,
571 ::testing::Values(kTestUserName
,
572 chromeos::login::kGuestUserName
,
573 // chromeos::login::kRetailModeUserName,
574 kTestSupervisedUserName
));
576 IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest
,
577 EnableOnLoginScreenAndLogin
) {
578 // Enables large cursor.
579 SetLargeCursorEnabled(true);
580 EXPECT_TRUE(IsLargeCursorEnabled());
581 // Enables spoken feedback.
582 SetSpokenFeedbackEnabled(true);
583 EXPECT_TRUE(IsSpokenFeedbackEnabled());
584 // Enables high contrast.
585 SetHighContrastEnabled(true);
586 EXPECT_TRUE(IsHighContrastEnabled());
587 // Enables autoclick.
588 SetAutoclickEnabled(true);
589 EXPECT_TRUE(IsAutoclickEnabled());
590 // Set autoclick delay.
591 SetAutoclickDelay(kTestAutoclickDelayMs
);
592 EXPECT_EQ(kTestAutoclickDelayMs
, GetAutoclickDelay());
595 const char* user_name
= GetParam();
596 user_manager::UserManager::Get()->UserLoggedIn(user_name
, user_name
, true);
598 // Confirms that the features are still enabled just after login.
599 EXPECT_TRUE(IsLargeCursorEnabled());
600 EXPECT_TRUE(IsSpokenFeedbackEnabled());
601 EXPECT_TRUE(IsHighContrastEnabled());
602 EXPECT_TRUE(IsAutoclickEnabled());
603 EXPECT_EQ(kTestAutoclickDelayMs
, GetAutoclickDelay());
605 user_manager::UserManager::Get()->SessionStarted();
607 // Confirms that the features keep enabled after session starts.
608 EXPECT_TRUE(IsLargeCursorEnabled());
609 EXPECT_TRUE(IsSpokenFeedbackEnabled());
610 EXPECT_TRUE(IsHighContrastEnabled());
611 EXPECT_TRUE(IsAutoclickEnabled());
612 EXPECT_EQ(kTestAutoclickDelayMs
, GetAutoclickDelay());
614 // Confirms that the prefs have been copied to the user's profile.
615 EXPECT_TRUE(GetLargeCursorEnabledFromPref());
616 EXPECT_TRUE(GetSpokenFeedbackEnabledFromPref());
617 EXPECT_TRUE(GetHighContrastEnabledFromPref());
618 EXPECT_TRUE(GetAutoclickEnabledFromPref());
619 EXPECT_EQ(kTestAutoclickDelayMs
, GetAutoclickDelayFromPref());
622 IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest
, BrailleWhenLoggedIn
) {
624 const char* user_name
= GetParam();
625 user_manager::UserManager::Get()->UserLoggedIn(user_name
, user_name
, true);
626 user_manager::UserManager::Get()->SessionStarted();
627 // This object watches for IME preference changes and reflects those in
628 // the IME framework state.
629 chromeos::Preferences prefs
;
630 prefs
.InitUserPrefsForTesting(
631 PrefServiceSyncable::FromProfile(GetProfile()),
632 user_manager::UserManager::Get()->GetActiveUser(),
633 UserSessionManager::GetInstance()->GetDefaultIMEState(GetProfile()));
635 // Make sure we start in the expected state.
636 EXPECT_FALSE(IsBrailleImeActive());
637 EXPECT_FALSE(IsSpokenFeedbackEnabled());
639 // Signal the accessibility manager that a braille display was connected.
640 SetBrailleDisplayAvailability(true);
642 // Now, both spoken feedback and the Braille IME should be enabled.
643 EXPECT_TRUE(IsSpokenFeedbackEnabled());
644 EXPECT_TRUE(IsBrailleImeActive());
646 // Send a braille dots key event and make sure that the braille IME is
649 event
.command
= extensions::api::braille_display_private::KEY_COMMAND_DOTS
;
650 event
.braille_dots
.reset(new int(0));
651 braille_controller_
.GetObserver()->OnBrailleKeyEvent(event
);
652 EXPECT_TRUE(IsBrailleImeCurrent());
654 // Unplug the display. Spolken feedback remains on, but the Braille IME
655 // should get deactivated.
656 SetBrailleDisplayAvailability(false);
657 EXPECT_TRUE(IsSpokenFeedbackEnabled());
658 EXPECT_FALSE(IsBrailleImeActive());
659 EXPECT_FALSE(IsBrailleImeCurrent());
661 // Plugging in a display while spoken feedback is enabled should activate
663 SetBrailleDisplayAvailability(true);
664 EXPECT_TRUE(IsSpokenFeedbackEnabled());
665 EXPECT_TRUE(IsBrailleImeActive());
668 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest
, AccessibilityMenuVisibility
) {
670 user_manager::UserManager::Get()->UserLoggedIn(
671 kTestUserName
, kTestUserName
, true);
672 user_manager::UserManager::Get()->SessionStarted();
674 // Confirms that the features are disabled.
675 EXPECT_FALSE(IsLargeCursorEnabled());
676 EXPECT_FALSE(IsSpokenFeedbackEnabled());
677 EXPECT_FALSE(IsHighContrastEnabled());
678 EXPECT_FALSE(IsAutoclickEnabled());
679 EXPECT_FALSE(ShouldShowAccessibilityMenu());
680 EXPECT_FALSE(IsVirtualKeyboardEnabled());
682 // Check large cursor.
683 SetLargeCursorEnabled(true);
684 EXPECT_TRUE(ShouldShowAccessibilityMenu());
685 SetLargeCursorEnabled(false);
686 EXPECT_FALSE(ShouldShowAccessibilityMenu());
688 // Check spoken feedback.
689 SetSpokenFeedbackEnabled(true);
690 EXPECT_TRUE(ShouldShowAccessibilityMenu());
691 SetSpokenFeedbackEnabled(false);
692 EXPECT_FALSE(ShouldShowAccessibilityMenu());
694 // Check high contrast.
695 SetHighContrastEnabled(true);
696 EXPECT_TRUE(ShouldShowAccessibilityMenu());
697 SetHighContrastEnabled(false);
698 EXPECT_FALSE(ShouldShowAccessibilityMenu());
701 SetAutoclickEnabled(true);
702 EXPECT_TRUE(ShouldShowAccessibilityMenu());
703 SetAutoclickEnabled(false);
704 EXPECT_FALSE(ShouldShowAccessibilityMenu());
706 // Check on-screen keyboard.
707 SetVirtualKeyboardEnabled(true);
708 EXPECT_TRUE(ShouldShowAccessibilityMenu());
709 SetVirtualKeyboardEnabled(false);
710 EXPECT_FALSE(ShouldShowAccessibilityMenu());
713 } // namespace chromeos