Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/browser/chromeos/accessibility/accessibility_manager_browsertest.cc

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Update after review. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 *braille_controller_.GetDisplayState()); 253 *braille_controller_.GetDisplayState());
254 } 254 }
255 255
256 int default_autoclick_delay() const { return default_autoclick_delay_; } 256 int default_autoclick_delay() const { return default_autoclick_delay_; }
257 257
258 int default_autoclick_delay_; 258 int default_autoclick_delay_;
259 259
260 content::NotificationRegistrar registrar_; 260 content::NotificationRegistrar registrar_;
261 261
262 MockBrailleController braille_controller_; 262 MockBrailleController braille_controller_;
263
264 const AccountId test_account_id_ = AccountId::FromUserEmail(kTestUserName);
265
263 DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerTest); 266 DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerTest);
264 }; 267 };
265 268
266 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) { 269 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) {
267 // Confirms that a11y features are disabled on the login screen. 270 // Confirms that a11y features are disabled on the login screen.
268 EXPECT_FALSE(IsLargeCursorEnabled()); 271 EXPECT_FALSE(IsLargeCursorEnabled());
269 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 272 EXPECT_FALSE(IsSpokenFeedbackEnabled());
270 EXPECT_FALSE(IsHighContrastEnabled()); 273 EXPECT_FALSE(IsHighContrastEnabled());
271 EXPECT_FALSE(IsAutoclickEnabled()); 274 EXPECT_FALSE(IsAutoclickEnabled());
272 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 275 EXPECT_FALSE(IsVirtualKeyboardEnabled());
273 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 276 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
274 277
275 // Logs in. 278 // Logs in.
276 user_manager::UserManager::Get()->UserLoggedIn( 279 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
277 kTestUserName, kTestUserName, true); 280 kTestUserName, true);
278 281
279 // Confirms that the features still disabled just after login. 282 // Confirms that the features still disabled just after login.
280 EXPECT_FALSE(IsLargeCursorEnabled()); 283 EXPECT_FALSE(IsLargeCursorEnabled());
281 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 284 EXPECT_FALSE(IsSpokenFeedbackEnabled());
282 EXPECT_FALSE(IsHighContrastEnabled()); 285 EXPECT_FALSE(IsHighContrastEnabled());
283 EXPECT_FALSE(IsAutoclickEnabled()); 286 EXPECT_FALSE(IsAutoclickEnabled());
284 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 287 EXPECT_FALSE(IsVirtualKeyboardEnabled());
285 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 288 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
286 289
287 user_manager::UserManager::Get()->SessionStarted(); 290 user_manager::UserManager::Get()->SessionStarted();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 331 EXPECT_FALSE(IsSpokenFeedbackEnabled());
329 332
330 // Signal the accessibility manager that a braille display was connected. 333 // Signal the accessibility manager that a braille display was connected.
331 SetBrailleDisplayAvailability(true); 334 SetBrailleDisplayAvailability(true);
332 // Confirms that the spoken feedback is enabled. 335 // Confirms that the spoken feedback is enabled.
333 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 336 EXPECT_TRUE(IsSpokenFeedbackEnabled());
334 } 337 }
335 338
336 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) { 339 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) {
337 // Logs in. 340 // Logs in.
338 user_manager::UserManager::Get()->UserLoggedIn( 341 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
339 kTestUserName, kTestUserName, true); 342 kTestUserName, true);
340 user_manager::UserManager::Get()->SessionStarted(); 343 user_manager::UserManager::Get()->SessionStarted();
341 344
342 // Confirms that the features are disabled just after login. 345 // Confirms that the features are disabled just after login.
343 EXPECT_FALSE(IsLargeCursorEnabled()); 346 EXPECT_FALSE(IsLargeCursorEnabled());
344 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 347 EXPECT_FALSE(IsSpokenFeedbackEnabled());
345 EXPECT_FALSE(IsHighContrastEnabled()); 348 EXPECT_FALSE(IsHighContrastEnabled());
346 EXPECT_FALSE(IsAutoclickEnabled()); 349 EXPECT_FALSE(IsAutoclickEnabled());
347 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 350 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
348 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 351 EXPECT_FALSE(IsVirtualKeyboardEnabled());
349 352
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 391
389 SetAutoclickEnabledPref(false); 392 SetAutoclickEnabledPref(false);
390 EXPECT_FALSE(IsAutoclickEnabled()); 393 EXPECT_FALSE(IsAutoclickEnabled());
391 394
392 SetVirtualKeyboardEnabledPref(false); 395 SetVirtualKeyboardEnabledPref(false);
393 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 396 EXPECT_FALSE(IsVirtualKeyboardEnabled());
394 } 397 }
395 398
396 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) { 399 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) {
397 // Loads the profile of the user. 400 // Loads the profile of the user.
398 user_manager::UserManager::Get()->UserLoggedIn( 401 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
399 kTestUserName, kTestUserName, true); 402 kTestUserName, true);
400 403
401 // Sets the pref to enable large cursor before login. 404 // Sets the pref to enable large cursor before login.
402 SetLargeCursorEnabledPref(true); 405 SetLargeCursorEnabledPref(true);
403 EXPECT_FALSE(IsLargeCursorEnabled()); 406 EXPECT_FALSE(IsLargeCursorEnabled());
404 407
405 // Sets the pref to enable spoken feedback before login. 408 // Sets the pref to enable spoken feedback before login.
406 SetSpokenFeedbackEnabledPref(true); 409 SetSpokenFeedbackEnabledPref(true);
407 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 410 EXPECT_FALSE(IsSpokenFeedbackEnabled());
408 411
409 // Sets the pref to enable high contrast before login. 412 // Sets the pref to enable high contrast before login.
(...skipping 23 matching lines...) Expand all
433 EXPECT_TRUE(IsAutoclickEnabled()); 436 EXPECT_TRUE(IsAutoclickEnabled());
434 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 437 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
435 EXPECT_TRUE(IsVirtualKeyboardEnabled()); 438 EXPECT_TRUE(IsVirtualKeyboardEnabled());
436 } 439 }
437 440
438 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, 441 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest,
439 ChangingTypeInvokesNotification) { 442 ChangingTypeInvokesNotification) {
440 MockAccessibilityObserver observer; 443 MockAccessibilityObserver observer;
441 444
442 // Logs in. 445 // Logs in.
443 user_manager::UserManager::Get()->UserLoggedIn( 446 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
444 kTestUserName, kTestUserName, true); 447 kTestUserName, true);
445 user_manager::UserManager::Get()->SessionStarted(); 448 user_manager::UserManager::Get()->SessionStarted();
446 449
447 EXPECT_FALSE(observer.observed()); 450 EXPECT_FALSE(observer.observed());
448 observer.reset(); 451 observer.reset();
449 452
450 SetSpokenFeedbackEnabled(true); 453 SetSpokenFeedbackEnabled(true);
451 EXPECT_TRUE(observer.observed()); 454 EXPECT_TRUE(observer.observed());
452 EXPECT_TRUE(observer.observed_enabled()); 455 EXPECT_TRUE(observer.observed_enabled());
453 EXPECT_EQ(observer.observed_type(), 456 EXPECT_EQ(observer.observed_type(),
454 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); 457 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 EXPECT_EQ(observer.observed_type(), 496 EXPECT_EQ(observer.observed_type(),
494 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD); 497 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD);
495 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 498 EXPECT_FALSE(IsVirtualKeyboardEnabled());
496 } 499 }
497 500
498 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, 501 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest,
499 ChangingTypePrefInvokesNotification) { 502 ChangingTypePrefInvokesNotification) {
500 MockAccessibilityObserver observer; 503 MockAccessibilityObserver observer;
501 504
502 // Logs in. 505 // Logs in.
503 user_manager::UserManager::Get()->UserLoggedIn( 506 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
504 kTestUserName, kTestUserName, true); 507 kTestUserName, true);
505 user_manager::UserManager::Get()->SessionStarted(); 508 user_manager::UserManager::Get()->SessionStarted();
506 509
507 EXPECT_FALSE(observer.observed()); 510 EXPECT_FALSE(observer.observed());
508 observer.reset(); 511 observer.reset();
509 512
510 SetSpokenFeedbackEnabledPref(true); 513 SetSpokenFeedbackEnabledPref(true);
511 EXPECT_TRUE(observer.observed()); 514 EXPECT_TRUE(observer.observed());
512 EXPECT_TRUE(observer.observed_enabled()); 515 EXPECT_TRUE(observer.observed_enabled());
513 EXPECT_EQ(observer.observed_type(), 516 EXPECT_EQ(observer.observed_type(),
514 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); 517 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 SetHighContrastEnabled(true); 589 SetHighContrastEnabled(true);
587 EXPECT_TRUE(IsHighContrastEnabled()); 590 EXPECT_TRUE(IsHighContrastEnabled());
588 // Enables autoclick. 591 // Enables autoclick.
589 SetAutoclickEnabled(true); 592 SetAutoclickEnabled(true);
590 EXPECT_TRUE(IsAutoclickEnabled()); 593 EXPECT_TRUE(IsAutoclickEnabled());
591 // Set autoclick delay. 594 // Set autoclick delay.
592 SetAutoclickDelay(kTestAutoclickDelayMs); 595 SetAutoclickDelay(kTestAutoclickDelayMs);
593 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 596 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
594 597
595 // Logs in. 598 // Logs in.
596 const char* user_name = GetParam(); 599 const AccountId account_id = AccountId::FromUserEmail(GetParam());
597 user_manager::UserManager::Get()->UserLoggedIn(user_name, user_name, true); 600 user_manager::UserManager::Get()->UserLoggedIn(
601 account_id, account_id.GetUserEmail(), true);
598 602
599 // Confirms that the features are still enabled just after login. 603 // Confirms that the features are still enabled just after login.
600 EXPECT_TRUE(IsLargeCursorEnabled()); 604 EXPECT_TRUE(IsLargeCursorEnabled());
601 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 605 EXPECT_TRUE(IsSpokenFeedbackEnabled());
602 EXPECT_TRUE(IsHighContrastEnabled()); 606 EXPECT_TRUE(IsHighContrastEnabled());
603 EXPECT_TRUE(IsAutoclickEnabled()); 607 EXPECT_TRUE(IsAutoclickEnabled());
604 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 608 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
605 609
606 user_manager::UserManager::Get()->SessionStarted(); 610 user_manager::UserManager::Get()->SessionStarted();
607 611
608 // Confirms that the features keep enabled after session starts. 612 // Confirms that the features keep enabled after session starts.
609 EXPECT_TRUE(IsLargeCursorEnabled()); 613 EXPECT_TRUE(IsLargeCursorEnabled());
610 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 614 EXPECT_TRUE(IsSpokenFeedbackEnabled());
611 EXPECT_TRUE(IsHighContrastEnabled()); 615 EXPECT_TRUE(IsHighContrastEnabled());
612 EXPECT_TRUE(IsAutoclickEnabled()); 616 EXPECT_TRUE(IsAutoclickEnabled());
613 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 617 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
614 618
615 // Confirms that the prefs have been copied to the user's profile. 619 // Confirms that the prefs have been copied to the user's profile.
616 EXPECT_TRUE(GetLargeCursorEnabledFromPref()); 620 EXPECT_TRUE(GetLargeCursorEnabledFromPref());
617 EXPECT_TRUE(GetSpokenFeedbackEnabledFromPref()); 621 EXPECT_TRUE(GetSpokenFeedbackEnabledFromPref());
618 EXPECT_TRUE(GetHighContrastEnabledFromPref()); 622 EXPECT_TRUE(GetHighContrastEnabledFromPref());
619 EXPECT_TRUE(GetAutoclickEnabledFromPref()); 623 EXPECT_TRUE(GetAutoclickEnabledFromPref());
620 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelayFromPref()); 624 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelayFromPref());
621 } 625 }
622 626
623 IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest, BrailleWhenLoggedIn) { 627 IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest, BrailleWhenLoggedIn) {
624 // Logs in. 628 // Logs in.
625 const char* user_name = GetParam(); 629 const AccountId account_id = AccountId::FromUserEmail(GetParam());
626 user_manager::UserManager::Get()->UserLoggedIn(user_name, user_name, true); 630 user_manager::UserManager::Get()->UserLoggedIn(
631 account_id, account_id.GetUserEmail(), true);
627 user_manager::UserManager::Get()->SessionStarted(); 632 user_manager::UserManager::Get()->SessionStarted();
628 // This object watches for IME preference changes and reflects those in 633 // This object watches for IME preference changes and reflects those in
629 // the IME framework state. 634 // the IME framework state.
630 chromeos::Preferences prefs; 635 chromeos::Preferences prefs;
631 prefs.InitUserPrefsForTesting( 636 prefs.InitUserPrefsForTesting(
632 PrefServiceSyncableFromProfile(GetProfile()), 637 PrefServiceSyncableFromProfile(GetProfile()),
633 user_manager::UserManager::Get()->GetActiveUser(), 638 user_manager::UserManager::Get()->GetActiveUser(),
634 UserSessionManager::GetInstance()->GetDefaultIMEState(GetProfile())); 639 UserSessionManager::GetInstance()->GetDefaultIMEState(GetProfile()));
635 640
636 // Make sure we start in the expected state. 641 // Make sure we start in the expected state.
(...skipping 24 matching lines...) Expand all
661 666
662 // Plugging in a display while spoken feedback is enabled should activate 667 // Plugging in a display while spoken feedback is enabled should activate
663 // the Braille IME. 668 // the Braille IME.
664 SetBrailleDisplayAvailability(true); 669 SetBrailleDisplayAvailability(true);
665 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 670 EXPECT_TRUE(IsSpokenFeedbackEnabled());
666 EXPECT_TRUE(IsBrailleImeActive()); 671 EXPECT_TRUE(IsBrailleImeActive());
667 } 672 }
668 673
669 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, AccessibilityMenuVisibility) { 674 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, AccessibilityMenuVisibility) {
670 // Log in. 675 // Log in.
671 user_manager::UserManager::Get()->UserLoggedIn( 676 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
672 kTestUserName, kTestUserName, true); 677 kTestUserName, true);
673 user_manager::UserManager::Get()->SessionStarted(); 678 user_manager::UserManager::Get()->SessionStarted();
674 679
675 // Confirms that the features are disabled. 680 // Confirms that the features are disabled.
676 EXPECT_FALSE(IsLargeCursorEnabled()); 681 EXPECT_FALSE(IsLargeCursorEnabled());
677 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 682 EXPECT_FALSE(IsSpokenFeedbackEnabled());
678 EXPECT_FALSE(IsHighContrastEnabled()); 683 EXPECT_FALSE(IsHighContrastEnabled());
679 EXPECT_FALSE(IsAutoclickEnabled()); 684 EXPECT_FALSE(IsAutoclickEnabled());
680 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 685 EXPECT_FALSE(ShouldShowAccessibilityMenu());
681 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 686 EXPECT_FALSE(IsVirtualKeyboardEnabled());
682 687
(...skipping 22 matching lines...) Expand all
705 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 710 EXPECT_FALSE(ShouldShowAccessibilityMenu());
706 711
707 // Check on-screen keyboard. 712 // Check on-screen keyboard.
708 SetVirtualKeyboardEnabled(true); 713 SetVirtualKeyboardEnabled(true);
709 EXPECT_TRUE(ShouldShowAccessibilityMenu()); 714 EXPECT_TRUE(ShouldShowAccessibilityMenu());
710 SetVirtualKeyboardEnabled(false); 715 SetVirtualKeyboardEnabled(false);
711 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 716 EXPECT_FALSE(ShouldShowAccessibilityMenu());
712 } 717 }
713 718
714 } // namespace chromeos 719 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698