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

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: Fix Win GN build. 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 *braille_controller_.GetDisplayState()); 254 *braille_controller_.GetDisplayState());
255 } 255 }
256 256
257 int default_autoclick_delay() const { return default_autoclick_delay_; } 257 int default_autoclick_delay() const { return default_autoclick_delay_; }
258 258
259 int default_autoclick_delay_; 259 int default_autoclick_delay_;
260 260
261 content::NotificationRegistrar registrar_; 261 content::NotificationRegistrar registrar_;
262 262
263 MockBrailleController braille_controller_; 263 MockBrailleController braille_controller_;
264
265 const AccountId test_account_id_ = AccountId::FromUserEmail(kTestUserName);
266
264 DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerTest); 267 DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerTest);
265 }; 268 };
266 269
267 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) { 270 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) {
268 // Confirms that a11y features are disabled on the login screen. 271 // Confirms that a11y features are disabled on the login screen.
269 EXPECT_FALSE(IsLargeCursorEnabled()); 272 EXPECT_FALSE(IsLargeCursorEnabled());
270 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 273 EXPECT_FALSE(IsSpokenFeedbackEnabled());
271 EXPECT_FALSE(IsHighContrastEnabled()); 274 EXPECT_FALSE(IsHighContrastEnabled());
272 EXPECT_FALSE(IsAutoclickEnabled()); 275 EXPECT_FALSE(IsAutoclickEnabled());
273 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 276 EXPECT_FALSE(IsVirtualKeyboardEnabled());
274 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 277 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
275 278
276 // Logs in. 279 // Logs in.
277 user_manager::UserManager::Get()->UserLoggedIn( 280 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
278 kTestUserName, kTestUserName, true); 281 kTestUserName, true);
279 282
280 // Confirms that the features still disabled just after login. 283 // Confirms that the features still disabled just after login.
281 EXPECT_FALSE(IsLargeCursorEnabled()); 284 EXPECT_FALSE(IsLargeCursorEnabled());
282 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 285 EXPECT_FALSE(IsSpokenFeedbackEnabled());
283 EXPECT_FALSE(IsHighContrastEnabled()); 286 EXPECT_FALSE(IsHighContrastEnabled());
284 EXPECT_FALSE(IsAutoclickEnabled()); 287 EXPECT_FALSE(IsAutoclickEnabled());
285 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 288 EXPECT_FALSE(IsVirtualKeyboardEnabled());
286 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 289 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
287 290
288 user_manager::UserManager::Get()->SessionStarted(); 291 user_manager::UserManager::Get()->SessionStarted();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 332 EXPECT_FALSE(IsSpokenFeedbackEnabled());
330 333
331 // Signal the accessibility manager that a braille display was connected. 334 // Signal the accessibility manager that a braille display was connected.
332 SetBrailleDisplayAvailability(true); 335 SetBrailleDisplayAvailability(true);
333 // Confirms that the spoken feedback is enabled. 336 // Confirms that the spoken feedback is enabled.
334 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 337 EXPECT_TRUE(IsSpokenFeedbackEnabled());
335 } 338 }
336 339
337 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) { 340 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) {
338 // Logs in. 341 // Logs in.
339 user_manager::UserManager::Get()->UserLoggedIn( 342 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
340 kTestUserName, kTestUserName, true); 343 kTestUserName, true);
341 user_manager::UserManager::Get()->SessionStarted(); 344 user_manager::UserManager::Get()->SessionStarted();
342 345
343 // Confirms that the features are disabled just after login. 346 // Confirms that the features are disabled just after login.
344 EXPECT_FALSE(IsLargeCursorEnabled()); 347 EXPECT_FALSE(IsLargeCursorEnabled());
345 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 348 EXPECT_FALSE(IsSpokenFeedbackEnabled());
346 EXPECT_FALSE(IsHighContrastEnabled()); 349 EXPECT_FALSE(IsHighContrastEnabled());
347 EXPECT_FALSE(IsAutoclickEnabled()); 350 EXPECT_FALSE(IsAutoclickEnabled());
348 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 351 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
349 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 352 EXPECT_FALSE(IsVirtualKeyboardEnabled());
350 353
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 392
390 SetAutoclickEnabledPref(false); 393 SetAutoclickEnabledPref(false);
391 EXPECT_FALSE(IsAutoclickEnabled()); 394 EXPECT_FALSE(IsAutoclickEnabled());
392 395
393 SetVirtualKeyboardEnabledPref(false); 396 SetVirtualKeyboardEnabledPref(false);
394 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 397 EXPECT_FALSE(IsVirtualKeyboardEnabled());
395 } 398 }
396 399
397 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) { 400 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) {
398 // Loads the profile of the user. 401 // Loads the profile of the user.
399 user_manager::UserManager::Get()->UserLoggedIn( 402 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
400 kTestUserName, kTestUserName, true); 403 kTestUserName, true);
401 404
402 // Sets the pref to enable large cursor before login. 405 // Sets the pref to enable large cursor before login.
403 SetLargeCursorEnabledPref(true); 406 SetLargeCursorEnabledPref(true);
404 EXPECT_FALSE(IsLargeCursorEnabled()); 407 EXPECT_FALSE(IsLargeCursorEnabled());
405 408
406 // Sets the pref to enable spoken feedback before login. 409 // Sets the pref to enable spoken feedback before login.
407 SetSpokenFeedbackEnabledPref(true); 410 SetSpokenFeedbackEnabledPref(true);
408 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 411 EXPECT_FALSE(IsSpokenFeedbackEnabled());
409 412
410 // Sets the pref to enable high contrast before login. 413 // Sets the pref to enable high contrast before login.
(...skipping 23 matching lines...) Expand all
434 EXPECT_TRUE(IsAutoclickEnabled()); 437 EXPECT_TRUE(IsAutoclickEnabled());
435 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 438 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
436 EXPECT_TRUE(IsVirtualKeyboardEnabled()); 439 EXPECT_TRUE(IsVirtualKeyboardEnabled());
437 } 440 }
438 441
439 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, 442 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest,
440 ChangingTypeInvokesNotification) { 443 ChangingTypeInvokesNotification) {
441 MockAccessibilityObserver observer; 444 MockAccessibilityObserver observer;
442 445
443 // Logs in. 446 // Logs in.
444 user_manager::UserManager::Get()->UserLoggedIn( 447 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
445 kTestUserName, kTestUserName, true); 448 kTestUserName, true);
446 user_manager::UserManager::Get()->SessionStarted(); 449 user_manager::UserManager::Get()->SessionStarted();
447 450
448 EXPECT_FALSE(observer.observed()); 451 EXPECT_FALSE(observer.observed());
449 observer.reset(); 452 observer.reset();
450 453
451 SetSpokenFeedbackEnabled(true); 454 SetSpokenFeedbackEnabled(true);
452 EXPECT_TRUE(observer.observed()); 455 EXPECT_TRUE(observer.observed());
453 EXPECT_TRUE(observer.observed_enabled()); 456 EXPECT_TRUE(observer.observed_enabled());
454 EXPECT_EQ(observer.observed_type(), 457 EXPECT_EQ(observer.observed_type(),
455 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); 458 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 EXPECT_EQ(observer.observed_type(), 497 EXPECT_EQ(observer.observed_type(),
495 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD); 498 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD);
496 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 499 EXPECT_FALSE(IsVirtualKeyboardEnabled());
497 } 500 }
498 501
499 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, 502 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest,
500 ChangingTypePrefInvokesNotification) { 503 ChangingTypePrefInvokesNotification) {
501 MockAccessibilityObserver observer; 504 MockAccessibilityObserver observer;
502 505
503 // Logs in. 506 // Logs in.
504 user_manager::UserManager::Get()->UserLoggedIn( 507 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
505 kTestUserName, kTestUserName, true); 508 kTestUserName, true);
506 user_manager::UserManager::Get()->SessionStarted(); 509 user_manager::UserManager::Get()->SessionStarted();
507 510
508 EXPECT_FALSE(observer.observed()); 511 EXPECT_FALSE(observer.observed());
509 observer.reset(); 512 observer.reset();
510 513
511 SetSpokenFeedbackEnabledPref(true); 514 SetSpokenFeedbackEnabledPref(true);
512 EXPECT_TRUE(observer.observed()); 515 EXPECT_TRUE(observer.observed());
513 EXPECT_TRUE(observer.observed_enabled()); 516 EXPECT_TRUE(observer.observed_enabled());
514 EXPECT_EQ(observer.observed_type(), 517 EXPECT_EQ(observer.observed_type(),
515 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); 518 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
(...skipping 70 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