accessibility_manager_browsertest.cc revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
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.
4
5#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
6
7#include "ash/magnifier/magnification_controller.h"
8#include "ash/shell.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"
28
29using extensions::api::braille_display_private::BrailleObserver;
30using extensions::api::braille_display_private::DisplayState;
31using extensions::api::braille_display_private::StubBrailleController;
32
33namespace chromeos {
34
35namespace {
36
37const char kTestUserName[] = "owner@invalid.domain";
38
39const int kTestAutoclickDelayMs = 2000;
40
41// Test user name for locally managed user. The domain part must be matched
42// with UserManager::kLocallyManagedUserDomain.
43const char kTestLocallyManagedUserName[] = "test@locally-managed.localhost";
44
45class MockAccessibilityObserver {
46 public:
47  MockAccessibilityObserver() : observed_(false),
48                                observed_enabled_(false),
49                                observed_type_(-1)
50  {
51    AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
52    CHECK(accessibility_manager);
53    accessibility_subscription_ = accessibility_manager->RegisterCallback(
54        base::Bind(&MockAccessibilityObserver::OnAccessibilityStatusChanged,
55                   base::Unretained(this)));
56  }
57
58  virtual ~MockAccessibilityObserver() {}
59
60  bool observed() const { return observed_; }
61  bool observed_enabled() const { return observed_enabled_; }
62  int observed_type() const { return observed_type_; }
63
64  void reset() { observed_ = false; }
65
66 private:
67  void OnAccessibilityStatusChanged(
68      const AccessibilityStatusEventDetails& details) {
69    if (details.notification_type != ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER) {
70      observed_type_ = details.notification_type;
71      observed_enabled_ = details.enabled;
72      observed_ = true;
73    }
74  }
75
76  bool observed_;
77  bool observed_enabled_;
78  int observed_type_;
79
80  scoped_ptr<AccessibilityStatusSubscription> accessibility_subscription_;
81
82  DISALLOW_COPY_AND_ASSIGN(MockAccessibilityObserver);
83};
84
85class MockBrailleController : public StubBrailleController {
86 public:
87
88  MockBrailleController() : available_(false), observer_(NULL) {}
89
90  virtual scoped_ptr<DisplayState> GetDisplayState() OVERRIDE {
91    scoped_ptr<DisplayState> state(new DisplayState());
92    state->available = available_;
93    return state.Pass();
94  }
95
96  virtual void AddObserver(BrailleObserver* observer) OVERRIDE {
97    ASSERT_EQ(NULL, observer_);
98    observer_ = observer;
99  }
100
101  virtual void RemoveObserver(BrailleObserver* observer) OVERRIDE {
102    ASSERT_EQ(observer_, observer);
103  }
104
105  void SetAvailable(bool available) {
106    available_ = available;
107  }
108
109  BrailleObserver* GetObserver() {
110    return observer_;
111  }
112
113 private:
114  bool available_;
115  BrailleObserver* observer_;
116};
117
118void SetLargeCursorEnabled(bool enabled) {
119  return AccessibilityManager::Get()->EnableLargeCursor(enabled);
120}
121
122bool IsLargeCursorEnabled() {
123  return AccessibilityManager::Get()->IsLargeCursorEnabled();
124}
125
126bool ShouldShowAccessibilityMenu() {
127  return AccessibilityManager::Get()->ShouldShowAccessibilityMenu();
128}
129
130void SetHighContrastEnabled(bool enabled) {
131  return AccessibilityManager::Get()->EnableHighContrast(enabled);
132}
133
134bool IsHighContrastEnabled() {
135  return AccessibilityManager::Get()->IsHighContrastEnabled();
136}
137
138void SetSpokenFeedbackEnabled(bool enabled) {
139  return AccessibilityManager::Get()->EnableSpokenFeedback(
140      enabled, ash::A11Y_NOTIFICATION_NONE);
141}
142
143bool IsSpokenFeedbackEnabled() {
144  return AccessibilityManager::Get()->IsSpokenFeedbackEnabled();
145}
146
147void SetAutoclickEnabled(bool enabled) {
148  return AccessibilityManager::Get()->EnableAutoclick(enabled);
149}
150
151bool IsAutoclickEnabled() {
152  return AccessibilityManager::Get()->IsAutoclickEnabled();
153}
154
155void SetAutoclickDelay(int delay_ms) {
156  return AccessibilityManager::Get()->SetAutoclickDelay(delay_ms);
157}
158
159int GetAutoclickDelay() {
160  return AccessibilityManager::Get()->GetAutoclickDelay();
161}
162
163void SetVirtualKeyboardEnabled(bool enabled) {
164  return AccessibilityManager::Get()->EnableVirtualKeyboard(enabled);
165}
166
167bool IsVirtualKeyboardEnabled() {
168  return AccessibilityManager::Get()->IsVirtualKeyboardEnabled();
169}
170
171Profile* GetProfile() {
172  Profile* profile = ProfileManager::GetActiveUserProfile();
173  DCHECK(profile);
174  return profile;
175}
176
177PrefService* GetPrefs() {
178  return GetProfile()->GetPrefs();
179}
180
181void SetLargeCursorEnabledPref(bool enabled) {
182  GetPrefs()->SetBoolean(prefs::kLargeCursorEnabled, enabled);
183}
184
185void SetHighContrastEnabledPref(bool enabled) {
186  GetPrefs()->SetBoolean(prefs::kHighContrastEnabled, enabled);
187}
188
189void SetSpokenFeedbackEnabledPref(bool enabled) {
190  GetPrefs()->SetBoolean(prefs::kSpokenFeedbackEnabled, enabled);
191}
192
193void SetAutoclickEnabledPref(bool enabled) {
194  GetPrefs()->SetBoolean(prefs::kAutoclickEnabled, enabled);
195}
196
197void SetAutoclickDelayPref(int delay_ms) {
198  GetPrefs()->SetInteger(prefs::kAutoclickDelayMs, delay_ms);
199}
200
201void SetVirtualKeyboardEnabledPref(bool enabled) {
202  GetPrefs()->SetBoolean(prefs::kVirtualKeyboardEnabled, enabled);
203}
204
205bool GetLargeCursorEnabledFromPref() {
206  return GetPrefs()->GetBoolean(prefs::kLargeCursorEnabled);
207}
208
209bool GetHighContrastEnabledFromPref() {
210  return GetPrefs()->GetBoolean(prefs::kHighContrastEnabled);
211}
212
213bool GetSpokenFeedbackEnabledFromPref() {
214  return GetPrefs()->GetBoolean(prefs::kSpokenFeedbackEnabled);
215}
216
217bool GetAutoclickEnabledFromPref() {
218  return GetPrefs()->GetBoolean(prefs::kAutoclickEnabled);
219}
220
221int GetAutoclickDelayFromPref() {
222  return GetPrefs()->GetInteger(prefs::kAutoclickDelayMs);
223}
224
225}  // anonymouse namespace
226
227class AccessibilityManagerTest : public InProcessBrowserTest {
228 protected:
229  AccessibilityManagerTest() : default_autoclick_delay_(0) {}
230  virtual ~AccessibilityManagerTest() {}
231
232  virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
233    command_line->AppendSwitch(chromeos::switches::kLoginManager);
234    command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile,
235                                    TestingProfile::kTestUserProfileDir);
236  }
237
238  virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
239    AccessibilityManager::SetBrailleControllerForTest(&braille_controller_);
240  }
241
242  virtual void SetUpOnMainThread() OVERRIDE {
243    // Sets the login-screen profile.
244    AccessibilityManager::Get()->
245        SetProfileForTest(ProfileHelper::GetSigninProfile());
246    default_autoclick_delay_ = GetAutoclickDelay();
247  }
248
249  virtual void CleanUpOnMainThread() OVERRIDE {
250    AccessibilityManager::SetBrailleControllerForTest(NULL);
251  }
252
253  int default_autoclick_delay() const { return default_autoclick_delay_; }
254
255  int default_autoclick_delay_;
256
257  content::NotificationRegistrar registrar_;
258
259  MockBrailleController braille_controller_;
260  DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerTest);
261};
262
263IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) {
264  // Confirms that a11y features are disabled on the login screen.
265  EXPECT_FALSE(IsLargeCursorEnabled());
266  EXPECT_FALSE(IsSpokenFeedbackEnabled());
267  EXPECT_FALSE(IsHighContrastEnabled());
268  EXPECT_FALSE(IsAutoclickEnabled());
269  EXPECT_FALSE(IsVirtualKeyboardEnabled());
270  EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
271
272  // Logs in.
273  UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true);
274
275  // Confirms that the features still disabled just after login.
276  EXPECT_FALSE(IsLargeCursorEnabled());
277  EXPECT_FALSE(IsSpokenFeedbackEnabled());
278  EXPECT_FALSE(IsHighContrastEnabled());
279  EXPECT_FALSE(IsAutoclickEnabled());
280  EXPECT_FALSE(IsVirtualKeyboardEnabled());
281  EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
282
283  UserManager::Get()->SessionStarted();
284
285  // Confirms that the features are still disabled just after login.
286  EXPECT_FALSE(IsLargeCursorEnabled());
287  EXPECT_FALSE(IsSpokenFeedbackEnabled());
288  EXPECT_FALSE(IsHighContrastEnabled());
289  EXPECT_FALSE(IsAutoclickEnabled());
290  EXPECT_FALSE(IsVirtualKeyboardEnabled());
291  EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
292
293  // Enables large cursor.
294  SetLargeCursorEnabled(true);
295  // Confirms that large cursor is enabled.
296  EXPECT_TRUE(IsLargeCursorEnabled());
297
298  // Enables spoken feedback.
299  SetSpokenFeedbackEnabled(true);
300  // Confirms that the spoken feedback is enabled.
301  EXPECT_TRUE(IsSpokenFeedbackEnabled());
302
303  // Enables high contrast.
304  SetHighContrastEnabled(true);
305  // Confirms that high cotrast is enabled.
306  EXPECT_TRUE(IsHighContrastEnabled());
307
308  // Enables autoclick.
309  SetAutoclickEnabled(true);
310  // Confirms that autoclick is enabled.
311  EXPECT_TRUE(IsAutoclickEnabled());
312
313  // Test that autoclick delay is set properly.
314  SetAutoclickDelay(kTestAutoclickDelayMs);
315  EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
316
317  // Enable on-screen keyboard
318  SetVirtualKeyboardEnabled(true);
319  // Confirm that the on-screen keyboard option is enabled.
320  EXPECT_TRUE(IsVirtualKeyboardEnabled());
321}
322
323IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, BrailleOnLoginScreen) {
324  EXPECT_FALSE(IsSpokenFeedbackEnabled());
325
326  // Signal the accessibility manager that a braille display was connected.
327  braille_controller_.SetAvailable(true);
328  braille_controller_.GetObserver()->OnDisplayStateChanged(
329      *braille_controller_.GetDisplayState());
330
331  // Confirms that the spoken feedback is enabled.
332  EXPECT_TRUE(IsSpokenFeedbackEnabled());
333}
334
335IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) {
336  // Logs in.
337  UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true);
338  UserManager::Get()->SessionStarted();
339
340  // Confirms that the features are disabled just after login.
341  EXPECT_FALSE(IsLargeCursorEnabled());
342  EXPECT_FALSE(IsSpokenFeedbackEnabled());
343  EXPECT_FALSE(IsHighContrastEnabled());
344  EXPECT_FALSE(IsAutoclickEnabled());
345  EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
346  EXPECT_FALSE(IsVirtualKeyboardEnabled());
347
348  // Sets the pref as true to enable the large cursor.
349  SetLargeCursorEnabledPref(true);
350  // Confirms that the large cursor is enabled.
351  EXPECT_TRUE(IsLargeCursorEnabled());
352
353  // Sets the pref as true to enable the spoken feedback.
354  SetSpokenFeedbackEnabledPref(true);
355  // Confirms that the spoken feedback is enabled.
356  EXPECT_TRUE(IsSpokenFeedbackEnabled());
357
358  // Sets the pref as true to enable high contrast mode.
359  SetHighContrastEnabledPref(true);
360  // Confirms that the high contrast mode is enabled.
361  EXPECT_TRUE(IsHighContrastEnabled());
362
363  // Sets the pref as true to enable autoclick.
364  SetAutoclickEnabledPref(true);
365  // Confirms that autoclick is enabled.
366  EXPECT_TRUE(IsAutoclickEnabled());
367
368  // Set autoclick delay pref.
369  SetAutoclickDelayPref(kTestAutoclickDelayMs);
370  // Confirm that the correct value is set.
371  EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
372
373  // Sets the on-screen keyboard pref.
374  SetVirtualKeyboardEnabledPref(true);
375  // Confirm that the on-screen keyboard option is enabled.
376  EXPECT_TRUE(IsVirtualKeyboardEnabled());
377
378  SetLargeCursorEnabledPref(false);
379  EXPECT_FALSE(IsLargeCursorEnabled());
380
381  SetSpokenFeedbackEnabledPref(false);
382  EXPECT_FALSE(IsSpokenFeedbackEnabled());
383
384  SetHighContrastEnabledPref(false);
385  EXPECT_FALSE(IsHighContrastEnabled());
386
387  SetAutoclickEnabledPref(false);
388  EXPECT_FALSE(IsAutoclickEnabled());
389
390  SetVirtualKeyboardEnabledPref(false);
391  EXPECT_FALSE(IsVirtualKeyboardEnabled());
392}
393
394IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) {
395  // Loads the profile of the user.
396  UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true);
397
398  // Sets the pref to enable large cursor before login.
399  SetLargeCursorEnabledPref(true);
400  EXPECT_FALSE(IsLargeCursorEnabled());
401
402  // Sets the pref to enable spoken feedback before login.
403  SetSpokenFeedbackEnabledPref(true);
404  EXPECT_FALSE(IsSpokenFeedbackEnabled());
405
406  // Sets the pref to enable high contrast before login.
407  SetHighContrastEnabledPref(true);
408  EXPECT_FALSE(IsHighContrastEnabled());
409
410  // Sets the pref to enable autoclick before login.
411  SetAutoclickEnabledPref(true);
412  EXPECT_FALSE(IsAutoclickEnabled());
413
414  // Sets the autoclick delay pref before login but the
415  // initial value should not change.
416  SetAutoclickDelayPref(kTestAutoclickDelayMs);
417  EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
418
419  // Sets the pref to enable the on-screen keyboard before login.
420  SetVirtualKeyboardEnabledPref(true);
421  EXPECT_FALSE(IsVirtualKeyboardEnabled());
422
423  // Logs in.
424  UserManager::Get()->SessionStarted();
425
426  // Confirms that features are enabled by restoring from pref just after login.
427  EXPECT_TRUE(IsLargeCursorEnabled());
428  EXPECT_TRUE(IsSpokenFeedbackEnabled());
429  EXPECT_TRUE(IsHighContrastEnabled());
430  EXPECT_TRUE(IsAutoclickEnabled());
431  EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
432  EXPECT_TRUE(IsVirtualKeyboardEnabled());
433}
434
435IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest,
436                       ChangingTypeInvokesNotification) {
437  MockAccessibilityObserver observer;
438
439  // Logs in.
440  UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true);
441  UserManager::Get()->SessionStarted();
442
443  EXPECT_FALSE(observer.observed());
444  observer.reset();
445
446  SetSpokenFeedbackEnabled(true);
447  EXPECT_TRUE(observer.observed());
448  EXPECT_TRUE(observer.observed_enabled());
449  EXPECT_EQ(observer.observed_type(),
450            ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
451  EXPECT_TRUE(IsSpokenFeedbackEnabled());
452
453  observer.reset();
454  SetSpokenFeedbackEnabled(false);
455  EXPECT_TRUE(observer.observed());
456  EXPECT_FALSE(observer.observed_enabled());
457  EXPECT_EQ(observer.observed_type(),
458            ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
459  EXPECT_FALSE(IsSpokenFeedbackEnabled());
460
461  observer.reset();
462  SetHighContrastEnabled(true);
463  EXPECT_TRUE(observer.observed());
464  EXPECT_TRUE(observer.observed_enabled());
465  EXPECT_EQ(observer.observed_type(),
466            ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE);
467  EXPECT_TRUE(IsHighContrastEnabled());
468
469  observer.reset();
470  SetHighContrastEnabled(false);
471  EXPECT_TRUE(observer.observed());
472  EXPECT_FALSE(observer.observed_enabled());
473  EXPECT_EQ(observer.observed_type(),
474            ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE);
475  EXPECT_FALSE(IsHighContrastEnabled());
476
477  observer.reset();
478  SetVirtualKeyboardEnabled(true);
479  EXPECT_TRUE(observer.observed());
480  EXPECT_TRUE(observer.observed_enabled());
481  EXPECT_EQ(observer.observed_type(),
482            ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD);
483  EXPECT_TRUE(IsVirtualKeyboardEnabled());
484
485  observer.reset();
486  SetVirtualKeyboardEnabled(false);
487  EXPECT_TRUE(observer.observed());
488  EXPECT_FALSE(observer.observed_enabled());
489  EXPECT_EQ(observer.observed_type(),
490            ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD);
491  EXPECT_FALSE(IsVirtualKeyboardEnabled());
492}
493
494IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest,
495                       ChangingTypePrefInvokesNotification) {
496  MockAccessibilityObserver observer;
497
498  // Logs in.
499  UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true);
500  UserManager::Get()->SessionStarted();
501
502  EXPECT_FALSE(observer.observed());
503  observer.reset();
504
505  SetSpokenFeedbackEnabledPref(true);
506  EXPECT_TRUE(observer.observed());
507  EXPECT_TRUE(observer.observed_enabled());
508  EXPECT_EQ(observer.observed_type(),
509            ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
510  EXPECT_TRUE(IsSpokenFeedbackEnabled());
511
512  observer.reset();
513  SetSpokenFeedbackEnabledPref(false);
514  EXPECT_TRUE(observer.observed());
515  EXPECT_FALSE(observer.observed_enabled());
516  EXPECT_EQ(observer.observed_type(),
517            ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
518  EXPECT_FALSE(IsSpokenFeedbackEnabled());
519
520  observer.reset();
521  SetHighContrastEnabledPref(true);
522  EXPECT_TRUE(observer.observed());
523  EXPECT_TRUE(observer.observed_enabled());
524  EXPECT_EQ(observer.observed_type(),
525            ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE);
526  EXPECT_TRUE(IsHighContrastEnabled());
527
528  observer.reset();
529  SetHighContrastEnabledPref(false);
530  EXPECT_TRUE(observer.observed());
531  EXPECT_FALSE(observer.observed_enabled());
532  EXPECT_EQ(observer.observed_type(),
533            ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE);
534  EXPECT_FALSE(IsHighContrastEnabled());
535
536  observer.reset();
537  SetVirtualKeyboardEnabledPref(true);
538  EXPECT_TRUE(observer.observed());
539  EXPECT_TRUE(observer.observed_enabled());
540  EXPECT_EQ(observer.observed_type(),
541            ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD);
542  EXPECT_TRUE(IsVirtualKeyboardEnabled());
543
544  observer.reset();
545  SetVirtualKeyboardEnabledPref(false);
546  EXPECT_TRUE(observer.observed());
547  EXPECT_FALSE(observer.observed_enabled());
548  EXPECT_EQ(observer.observed_type(),
549            ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD);
550  EXPECT_FALSE(IsVirtualKeyboardEnabled());
551}
552
553class AccessibilityManagerUserTypeTest
554    : public AccessibilityManagerTest,
555      public ::testing::WithParamInterface<const char*> {
556 protected:
557  AccessibilityManagerUserTypeTest() {}
558  virtual ~AccessibilityManagerUserTypeTest() {}
559
560  DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerUserTypeTest);
561};
562
563// TODO(yoshiki): Enable a test for retail mode.
564INSTANTIATE_TEST_CASE_P(
565    UserTypeInstantiation,
566    AccessibilityManagerUserTypeTest,
567    ::testing::Values(kTestUserName,
568                      UserManager::kGuestUserName,
569                      //UserManager::kRetailModeUserName,
570                      kTestLocallyManagedUserName));
571
572IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest,
573                       EnableOnLoginScreenAndLogin) {
574  // Enables large cursor.
575  SetLargeCursorEnabled(true);
576  EXPECT_TRUE(IsLargeCursorEnabled());
577  // Enables spoken feedback.
578  SetSpokenFeedbackEnabled(true);
579  EXPECT_TRUE(IsSpokenFeedbackEnabled());
580  // Enables high contrast.
581  SetHighContrastEnabled(true);
582  EXPECT_TRUE(IsHighContrastEnabled());
583  // Enables autoclick.
584  SetAutoclickEnabled(true);
585  EXPECT_TRUE(IsAutoclickEnabled());
586  // Set autoclick delay.
587  SetAutoclickDelay(kTestAutoclickDelayMs);
588  EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
589
590  // Logs in.
591  const char* user_name = GetParam();
592  UserManager::Get()->UserLoggedIn(user_name, user_name, true);
593
594  // Confirms that the features are still enabled just after login.
595  EXPECT_TRUE(IsLargeCursorEnabled());
596  EXPECT_TRUE(IsSpokenFeedbackEnabled());
597  EXPECT_TRUE(IsHighContrastEnabled());
598  EXPECT_TRUE(IsAutoclickEnabled());
599  EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
600
601  UserManager::Get()->SessionStarted();
602
603  // Confirms that the features keep enabled after session starts.
604  EXPECT_TRUE(IsLargeCursorEnabled());
605  EXPECT_TRUE(IsSpokenFeedbackEnabled());
606  EXPECT_TRUE(IsHighContrastEnabled());
607  EXPECT_TRUE(IsAutoclickEnabled());
608  EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
609
610  // Confirms that the prefs have been copied to the user's profile.
611  EXPECT_TRUE(GetLargeCursorEnabledFromPref());
612  EXPECT_TRUE(GetSpokenFeedbackEnabledFromPref());
613  EXPECT_TRUE(GetHighContrastEnabledFromPref());
614  EXPECT_TRUE(GetAutoclickEnabledFromPref());
615  EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelayFromPref());
616}
617
618IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, AcessibilityMenuVisibility) {
619  // Log in.
620  UserManager::Get()->UserLoggedIn(kTestUserName, kTestUserName, true);
621  UserManager::Get()->SessionStarted();
622
623  // Confirms that the features are disabled.
624  EXPECT_FALSE(IsLargeCursorEnabled());
625  EXPECT_FALSE(IsSpokenFeedbackEnabled());
626  EXPECT_FALSE(IsHighContrastEnabled());
627  EXPECT_FALSE(IsAutoclickEnabled());
628  EXPECT_FALSE(ShouldShowAccessibilityMenu());
629  EXPECT_FALSE(IsVirtualKeyboardEnabled());
630
631  // Check large cursor.
632  SetLargeCursorEnabled(true);
633  EXPECT_TRUE(ShouldShowAccessibilityMenu());
634  SetLargeCursorEnabled(false);
635  EXPECT_FALSE(ShouldShowAccessibilityMenu());
636
637  // Check spoken feedback.
638  SetSpokenFeedbackEnabled(true);
639  EXPECT_TRUE(ShouldShowAccessibilityMenu());
640  SetSpokenFeedbackEnabled(false);
641  EXPECT_FALSE(ShouldShowAccessibilityMenu());
642
643  // Check high contrast.
644  SetHighContrastEnabled(true);
645  EXPECT_TRUE(ShouldShowAccessibilityMenu());
646  SetHighContrastEnabled(false);
647  EXPECT_FALSE(ShouldShowAccessibilityMenu());
648
649  // Check autoclick.
650  SetAutoclickEnabled(true);
651  EXPECT_TRUE(ShouldShowAccessibilityMenu());
652  SetAutoclickEnabled(false);
653  EXPECT_FALSE(ShouldShowAccessibilityMenu());
654
655  // Check on-screen keyboard.
656  SetVirtualKeyboardEnabled(true);
657  EXPECT_TRUE(ShouldShowAccessibilityMenu());
658  SetVirtualKeyboardEnabled(false);
659  EXPECT_FALSE(ShouldShowAccessibilityMenu());
660}
661
662}  // namespace chromeos
663