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

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: Rebased. Created 5 years, 2 months 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 bool IsBrailleImeCurrent() { 217 bool IsBrailleImeCurrent() {
218 InputMethodManager* imm = InputMethodManager::Get(); 218 InputMethodManager* imm = InputMethodManager::Get();
219 return imm->GetActiveIMEState()->GetCurrentInputMethod().id() == 219 return imm->GetActiveIMEState()->GetCurrentInputMethod().id() ==
220 extension_misc::kBrailleImeEngineId; 220 extension_misc::kBrailleImeEngineId;
221 } 221 }
222 } // anonymous namespace 222 } // anonymous namespace
223 223
224 class AccessibilityManagerTest : public InProcessBrowserTest { 224 class AccessibilityManagerTest : public InProcessBrowserTest {
225 protected: 225 protected:
226 AccessibilityManagerTest() : default_autoclick_delay_(0) {} 226 AccessibilityManagerTest()
227 : default_autoclick_delay_(0),
228 test_account_id_(AccountId::FromUserEmail(kTestUserName)) {}
227 ~AccessibilityManagerTest() override {} 229 ~AccessibilityManagerTest() override {}
228 230
229 void SetUpCommandLine(base::CommandLine* command_line) override { 231 void SetUpCommandLine(base::CommandLine* command_line) override {
230 command_line->AppendSwitch(chromeos::switches::kLoginManager); 232 command_line->AppendSwitch(chromeos::switches::kLoginManager);
231 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, 233 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile,
232 TestingProfile::kTestUserProfileDir); 234 TestingProfile::kTestUserProfileDir);
233 } 235 }
234 236
235 void SetUpInProcessBrowserTestFixture() override { 237 void SetUpInProcessBrowserTestFixture() override {
236 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_); 238 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_);
(...skipping 16 matching lines...) Expand all
253 *braille_controller_.GetDisplayState()); 255 *braille_controller_.GetDisplayState());
254 } 256 }
255 257
256 int default_autoclick_delay() const { return default_autoclick_delay_; } 258 int default_autoclick_delay() const { return default_autoclick_delay_; }
257 259
258 int default_autoclick_delay_; 260 int default_autoclick_delay_;
259 261
260 content::NotificationRegistrar registrar_; 262 content::NotificationRegistrar registrar_;
261 263
262 MockBrailleController braille_controller_; 264 MockBrailleController braille_controller_;
265
266 const AccountId test_account_id_;
achuithb 2015/10/23 00:08:49 AccountId test_account_id_ = AccountId::FromUserEm
Alexander Alekseev 2015/10/23 09:11:21 Done.
267
263 DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerTest); 268 DISALLOW_COPY_AND_ASSIGN(AccessibilityManagerTest);
264 }; 269 };
265 270
266 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) { 271 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, Login) {
267 // Confirms that a11y features are disabled on the login screen. 272 // Confirms that a11y features are disabled on the login screen.
268 EXPECT_FALSE(IsLargeCursorEnabled()); 273 EXPECT_FALSE(IsLargeCursorEnabled());
269 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 274 EXPECT_FALSE(IsSpokenFeedbackEnabled());
270 EXPECT_FALSE(IsHighContrastEnabled()); 275 EXPECT_FALSE(IsHighContrastEnabled());
271 EXPECT_FALSE(IsAutoclickEnabled()); 276 EXPECT_FALSE(IsAutoclickEnabled());
272 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 277 EXPECT_FALSE(IsVirtualKeyboardEnabled());
273 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 278 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
274 279
275 // Logs in. 280 // Logs in.
276 user_manager::UserManager::Get()->UserLoggedIn( 281 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
277 kTestUserName, kTestUserName, true); 282 kTestUserName, true);
278 283
279 // Confirms that the features still disabled just after login. 284 // Confirms that the features still disabled just after login.
280 EXPECT_FALSE(IsLargeCursorEnabled()); 285 EXPECT_FALSE(IsLargeCursorEnabled());
281 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 286 EXPECT_FALSE(IsSpokenFeedbackEnabled());
282 EXPECT_FALSE(IsHighContrastEnabled()); 287 EXPECT_FALSE(IsHighContrastEnabled());
283 EXPECT_FALSE(IsAutoclickEnabled()); 288 EXPECT_FALSE(IsAutoclickEnabled());
284 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 289 EXPECT_FALSE(IsVirtualKeyboardEnabled());
285 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 290 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
286 291
287 user_manager::UserManager::Get()->SessionStarted(); 292 user_manager::UserManager::Get()->SessionStarted();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 333 EXPECT_FALSE(IsSpokenFeedbackEnabled());
329 334
330 // Signal the accessibility manager that a braille display was connected. 335 // Signal the accessibility manager that a braille display was connected.
331 SetBrailleDisplayAvailability(true); 336 SetBrailleDisplayAvailability(true);
332 // Confirms that the spoken feedback is enabled. 337 // Confirms that the spoken feedback is enabled.
333 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 338 EXPECT_TRUE(IsSpokenFeedbackEnabled());
334 } 339 }
335 340
336 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) { 341 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, TypePref) {
337 // Logs in. 342 // Logs in.
338 user_manager::UserManager::Get()->UserLoggedIn( 343 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
339 kTestUserName, kTestUserName, true); 344 kTestUserName, true);
340 user_manager::UserManager::Get()->SessionStarted(); 345 user_manager::UserManager::Get()->SessionStarted();
341 346
342 // Confirms that the features are disabled just after login. 347 // Confirms that the features are disabled just after login.
343 EXPECT_FALSE(IsLargeCursorEnabled()); 348 EXPECT_FALSE(IsLargeCursorEnabled());
344 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 349 EXPECT_FALSE(IsSpokenFeedbackEnabled());
345 EXPECT_FALSE(IsHighContrastEnabled()); 350 EXPECT_FALSE(IsHighContrastEnabled());
346 EXPECT_FALSE(IsAutoclickEnabled()); 351 EXPECT_FALSE(IsAutoclickEnabled());
347 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay()); 352 EXPECT_EQ(default_autoclick_delay(), GetAutoclickDelay());
348 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 353 EXPECT_FALSE(IsVirtualKeyboardEnabled());
349 354
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 393
389 SetAutoclickEnabledPref(false); 394 SetAutoclickEnabledPref(false);
390 EXPECT_FALSE(IsAutoclickEnabled()); 395 EXPECT_FALSE(IsAutoclickEnabled());
391 396
392 SetVirtualKeyboardEnabledPref(false); 397 SetVirtualKeyboardEnabledPref(false);
393 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 398 EXPECT_FALSE(IsVirtualKeyboardEnabled());
394 } 399 }
395 400
396 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) { 401 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, ResumeSavedPref) {
397 // Loads the profile of the user. 402 // Loads the profile of the user.
398 user_manager::UserManager::Get()->UserLoggedIn( 403 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
399 kTestUserName, kTestUserName, true); 404 kTestUserName, true);
400 405
401 // Sets the pref to enable large cursor before login. 406 // Sets the pref to enable large cursor before login.
402 SetLargeCursorEnabledPref(true); 407 SetLargeCursorEnabledPref(true);
403 EXPECT_FALSE(IsLargeCursorEnabled()); 408 EXPECT_FALSE(IsLargeCursorEnabled());
404 409
405 // Sets the pref to enable spoken feedback before login. 410 // Sets the pref to enable spoken feedback before login.
406 SetSpokenFeedbackEnabledPref(true); 411 SetSpokenFeedbackEnabledPref(true);
407 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 412 EXPECT_FALSE(IsSpokenFeedbackEnabled());
408 413
409 // Sets the pref to enable high contrast before login. 414 // Sets the pref to enable high contrast before login.
(...skipping 23 matching lines...) Expand all
433 EXPECT_TRUE(IsAutoclickEnabled()); 438 EXPECT_TRUE(IsAutoclickEnabled());
434 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 439 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
435 EXPECT_TRUE(IsVirtualKeyboardEnabled()); 440 EXPECT_TRUE(IsVirtualKeyboardEnabled());
436 } 441 }
437 442
438 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, 443 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest,
439 ChangingTypeInvokesNotification) { 444 ChangingTypeInvokesNotification) {
440 MockAccessibilityObserver observer; 445 MockAccessibilityObserver observer;
441 446
442 // Logs in. 447 // Logs in.
443 user_manager::UserManager::Get()->UserLoggedIn( 448 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
444 kTestUserName, kTestUserName, true); 449 kTestUserName, true);
445 user_manager::UserManager::Get()->SessionStarted(); 450 user_manager::UserManager::Get()->SessionStarted();
446 451
447 EXPECT_FALSE(observer.observed()); 452 EXPECT_FALSE(observer.observed());
448 observer.reset(); 453 observer.reset();
449 454
450 SetSpokenFeedbackEnabled(true); 455 SetSpokenFeedbackEnabled(true);
451 EXPECT_TRUE(observer.observed()); 456 EXPECT_TRUE(observer.observed());
452 EXPECT_TRUE(observer.observed_enabled()); 457 EXPECT_TRUE(observer.observed_enabled());
453 EXPECT_EQ(observer.observed_type(), 458 EXPECT_EQ(observer.observed_type(),
454 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); 459 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 EXPECT_EQ(observer.observed_type(), 498 EXPECT_EQ(observer.observed_type(),
494 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD); 499 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD);
495 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 500 EXPECT_FALSE(IsVirtualKeyboardEnabled());
496 } 501 }
497 502
498 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, 503 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest,
499 ChangingTypePrefInvokesNotification) { 504 ChangingTypePrefInvokesNotification) {
500 MockAccessibilityObserver observer; 505 MockAccessibilityObserver observer;
501 506
502 // Logs in. 507 // Logs in.
503 user_manager::UserManager::Get()->UserLoggedIn( 508 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
504 kTestUserName, kTestUserName, true); 509 kTestUserName, true);
505 user_manager::UserManager::Get()->SessionStarted(); 510 user_manager::UserManager::Get()->SessionStarted();
506 511
507 EXPECT_FALSE(observer.observed()); 512 EXPECT_FALSE(observer.observed());
508 observer.reset(); 513 observer.reset();
509 514
510 SetSpokenFeedbackEnabledPref(true); 515 SetSpokenFeedbackEnabledPref(true);
511 EXPECT_TRUE(observer.observed()); 516 EXPECT_TRUE(observer.observed());
512 EXPECT_TRUE(observer.observed_enabled()); 517 EXPECT_TRUE(observer.observed_enabled());
513 EXPECT_EQ(observer.observed_type(), 518 EXPECT_EQ(observer.observed_type(),
514 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK); 519 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 SetHighContrastEnabled(true); 591 SetHighContrastEnabled(true);
587 EXPECT_TRUE(IsHighContrastEnabled()); 592 EXPECT_TRUE(IsHighContrastEnabled());
588 // Enables autoclick. 593 // Enables autoclick.
589 SetAutoclickEnabled(true); 594 SetAutoclickEnabled(true);
590 EXPECT_TRUE(IsAutoclickEnabled()); 595 EXPECT_TRUE(IsAutoclickEnabled());
591 // Set autoclick delay. 596 // Set autoclick delay.
592 SetAutoclickDelay(kTestAutoclickDelayMs); 597 SetAutoclickDelay(kTestAutoclickDelayMs);
593 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 598 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
594 599
595 // Logs in. 600 // Logs in.
596 const char* user_name = GetParam(); 601 const AccountId user_id = AccountId::FromUserEmail(GetParam());
achuithb 2015/10/23 00:08:49 account_id?
Alexander Alekseev 2015/10/23 09:11:21 Done.
597 user_manager::UserManager::Get()->UserLoggedIn(user_name, user_name, true); 602 user_manager::UserManager::Get()->UserLoggedIn(user_id,
603 user_id.GetUserEmail(), true);
598 604
599 // Confirms that the features are still enabled just after login. 605 // Confirms that the features are still enabled just after login.
600 EXPECT_TRUE(IsLargeCursorEnabled()); 606 EXPECT_TRUE(IsLargeCursorEnabled());
601 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 607 EXPECT_TRUE(IsSpokenFeedbackEnabled());
602 EXPECT_TRUE(IsHighContrastEnabled()); 608 EXPECT_TRUE(IsHighContrastEnabled());
603 EXPECT_TRUE(IsAutoclickEnabled()); 609 EXPECT_TRUE(IsAutoclickEnabled());
604 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 610 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
605 611
606 user_manager::UserManager::Get()->SessionStarted(); 612 user_manager::UserManager::Get()->SessionStarted();
607 613
608 // Confirms that the features keep enabled after session starts. 614 // Confirms that the features keep enabled after session starts.
609 EXPECT_TRUE(IsLargeCursorEnabled()); 615 EXPECT_TRUE(IsLargeCursorEnabled());
610 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 616 EXPECT_TRUE(IsSpokenFeedbackEnabled());
611 EXPECT_TRUE(IsHighContrastEnabled()); 617 EXPECT_TRUE(IsHighContrastEnabled());
612 EXPECT_TRUE(IsAutoclickEnabled()); 618 EXPECT_TRUE(IsAutoclickEnabled());
613 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay()); 619 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelay());
614 620
615 // Confirms that the prefs have been copied to the user's profile. 621 // Confirms that the prefs have been copied to the user's profile.
616 EXPECT_TRUE(GetLargeCursorEnabledFromPref()); 622 EXPECT_TRUE(GetLargeCursorEnabledFromPref());
617 EXPECT_TRUE(GetSpokenFeedbackEnabledFromPref()); 623 EXPECT_TRUE(GetSpokenFeedbackEnabledFromPref());
618 EXPECT_TRUE(GetHighContrastEnabledFromPref()); 624 EXPECT_TRUE(GetHighContrastEnabledFromPref());
619 EXPECT_TRUE(GetAutoclickEnabledFromPref()); 625 EXPECT_TRUE(GetAutoclickEnabledFromPref());
620 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelayFromPref()); 626 EXPECT_EQ(kTestAutoclickDelayMs, GetAutoclickDelayFromPref());
621 } 627 }
622 628
623 IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest, BrailleWhenLoggedIn) { 629 IN_PROC_BROWSER_TEST_P(AccessibilityManagerUserTypeTest, BrailleWhenLoggedIn) {
624 // Logs in. 630 // Logs in.
625 const char* user_name = GetParam(); 631 const AccountId user_id = AccountId::FromUserEmail(GetParam());
achuithb 2015/10/23 00:08:49 account_id?
Alexander Alekseev 2015/10/23 09:11:21 Done.
626 user_manager::UserManager::Get()->UserLoggedIn(user_name, user_name, true); 632 user_manager::UserManager::Get()->UserLoggedIn(user_id,
633 user_id.GetUserEmail(), true);
627 user_manager::UserManager::Get()->SessionStarted(); 634 user_manager::UserManager::Get()->SessionStarted();
628 // This object watches for IME preference changes and reflects those in 635 // This object watches for IME preference changes and reflects those in
629 // the IME framework state. 636 // the IME framework state.
630 chromeos::Preferences prefs; 637 chromeos::Preferences prefs;
631 prefs.InitUserPrefsForTesting( 638 prefs.InitUserPrefsForTesting(
632 PrefServiceSyncableFromProfile(GetProfile()), 639 PrefServiceSyncableFromProfile(GetProfile()),
633 user_manager::UserManager::Get()->GetActiveUser(), 640 user_manager::UserManager::Get()->GetActiveUser(),
634 UserSessionManager::GetInstance()->GetDefaultIMEState(GetProfile())); 641 UserSessionManager::GetInstance()->GetDefaultIMEState(GetProfile()));
635 642
636 // Make sure we start in the expected state. 643 // Make sure we start in the expected state.
(...skipping 24 matching lines...) Expand all
661 668
662 // Plugging in a display while spoken feedback is enabled should activate 669 // Plugging in a display while spoken feedback is enabled should activate
663 // the Braille IME. 670 // the Braille IME.
664 SetBrailleDisplayAvailability(true); 671 SetBrailleDisplayAvailability(true);
665 EXPECT_TRUE(IsSpokenFeedbackEnabled()); 672 EXPECT_TRUE(IsSpokenFeedbackEnabled());
666 EXPECT_TRUE(IsBrailleImeActive()); 673 EXPECT_TRUE(IsBrailleImeActive());
667 } 674 }
668 675
669 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, AccessibilityMenuVisibility) { 676 IN_PROC_BROWSER_TEST_F(AccessibilityManagerTest, AccessibilityMenuVisibility) {
670 // Log in. 677 // Log in.
671 user_manager::UserManager::Get()->UserLoggedIn( 678 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
672 kTestUserName, kTestUserName, true); 679 kTestUserName, true);
673 user_manager::UserManager::Get()->SessionStarted(); 680 user_manager::UserManager::Get()->SessionStarted();
674 681
675 // Confirms that the features are disabled. 682 // Confirms that the features are disabled.
676 EXPECT_FALSE(IsLargeCursorEnabled()); 683 EXPECT_FALSE(IsLargeCursorEnabled());
677 EXPECT_FALSE(IsSpokenFeedbackEnabled()); 684 EXPECT_FALSE(IsSpokenFeedbackEnabled());
678 EXPECT_FALSE(IsHighContrastEnabled()); 685 EXPECT_FALSE(IsHighContrastEnabled());
679 EXPECT_FALSE(IsAutoclickEnabled()); 686 EXPECT_FALSE(IsAutoclickEnabled());
680 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 687 EXPECT_FALSE(ShouldShowAccessibilityMenu());
681 EXPECT_FALSE(IsVirtualKeyboardEnabled()); 688 EXPECT_FALSE(IsVirtualKeyboardEnabled());
682 689
(...skipping 22 matching lines...) Expand all
705 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 712 EXPECT_FALSE(ShouldShowAccessibilityMenu());
706 713
707 // Check on-screen keyboard. 714 // Check on-screen keyboard.
708 SetVirtualKeyboardEnabled(true); 715 SetVirtualKeyboardEnabled(true);
709 EXPECT_TRUE(ShouldShowAccessibilityMenu()); 716 EXPECT_TRUE(ShouldShowAccessibilityMenu());
710 SetVirtualKeyboardEnabled(false); 717 SetVirtualKeyboardEnabled(false);
711 EXPECT_FALSE(ShouldShowAccessibilityMenu()); 718 EXPECT_FALSE(ShouldShowAccessibilityMenu());
712 } 719 }
713 720
714 } // namespace chromeos 721 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698