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

Side by Side Diff: chrome/browser/chromeos/system/tray_accessibility_browsertest.cc

Issue 2942043002: cros: Tighten profile loading (Closed)
Patch Set: update SystemClock header Created 3 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/accessibility_types.h" 5 #include "ash/accessibility_types.h"
6 #include "ash/login_status.h" 6 #include "ash/login_status.h"
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 "ash/system/tray/system_tray.h" 9 #include "ash/system/tray/system_tray.h"
10 #include "ash/system/tray/system_tray_test_api.h" 10 #include "ash/system/tray/system_tray_test_api.h"
11 #include "ash/system/tray_accessibility.h" 11 #include "ash/system/tray_accessibility.h"
12 #include "ash/test/shell_test_api.h" 12 #include "ash/test/shell_test_api.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chrome_notification_types.h" 18 #include "chrome/browser/chrome_notification_types.h"
19 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 19 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
20 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 20 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
21 #include "chrome/browser/chromeos/login/helper.h" 21 #include "chrome/browser/chromeos/login/helper.h"
22 #include "chrome/browser/chromeos/login/startup_utils.h" 22 #include "chrome/browser/chromeos/login/startup_utils.h"
23 #include "chrome/browser/chromeos/profiles/profile_helper.h"
23 #include "chrome/browser/extensions/api/braille_display_private/mock_braille_con troller.h" 24 #include "chrome/browser/extensions/api/braille_display_private/mock_braille_con troller.h"
24 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/browser/ui/ash/session_controller_client.h" 27 #include "chrome/browser/ui/ash/session_controller_client.h"
27 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
29 #include "chrome/test/base/in_process_browser_test.h" 30 #include "chrome/test/base/in_process_browser_test.h"
30 #include "chrome/test/base/testing_profile.h" 31 #include "chrome/test/base/testing_profile.h"
31 #include "chromeos/chromeos_switches.h" 32 #include "chromeos/chromeos_switches.h"
32 #include "components/policy/core/browser/browser_policy_connector.h" 33 #include "components/policy/core/browser/browser_policy_connector.h"
(...skipping 24 matching lines...) Expand all
57 58
58 enum PrefSettingMechanism { 59 enum PrefSettingMechanism {
59 PREF_SERVICE, 60 PREF_SERVICE,
60 POLICY, 61 POLICY,
61 }; 62 };
62 63
63 void SetMagnifierEnabled(bool enabled) { 64 void SetMagnifierEnabled(bool enabled) {
64 MagnificationManager::Get()->SetMagnifierEnabled(enabled); 65 MagnificationManager::Get()->SetMagnifierEnabled(enabled);
65 } 66 }
66 67
68 // Simulates how UserSessionManager creates and starts a user session.
69 void CreateAndStartUserSession(const AccountId& account_id) {
70 using session_manager::SessionManager;
71
72 const std::string user_id_hash =
73 ProfileHelper::GetUserIdHashByUserIdForTesting(account_id.GetUserEmail());
74
75 SessionManager::Get()->CreateSession(account_id, user_id_hash);
76 ProfileHelper::GetProfileByUserIdHashForTest(user_id_hash);
77 SessionManager::Get()->SessionStarted();
78 }
79
67 class TrayAccessibilityTest 80 class TrayAccessibilityTest
68 : public InProcessBrowserTest, 81 : public InProcessBrowserTest,
69 public WithParamInterface<PrefSettingMechanism> { 82 public WithParamInterface<PrefSettingMechanism> {
70 protected: 83 protected:
71 TrayAccessibilityTest() {} 84 TrayAccessibilityTest() {}
72 virtual ~TrayAccessibilityTest() {} 85 virtual ~TrayAccessibilityTest() {}
73 86
74 // The profile which should be used by these tests. 87 // The profile which should be used by these tests.
75 Profile* GetProfile() { return ProfileManager::GetActiveUserProfile(); } 88 Profile* GetProfile() { return ProfileManager::GetActiveUserProfile(); }
76 89
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 *braille_controller_.GetDisplayState()); 358 *braille_controller_.GetDisplayState());
346 } 359 }
347 360
348 policy::MockConfigurationPolicyProvider provider_; 361 policy::MockConfigurationPolicyProvider provider_;
349 MockBrailleController braille_controller_; 362 MockBrailleController braille_controller_;
350 }; 363 };
351 364
352 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, LoginStatus) { 365 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, LoginStatus) {
353 EXPECT_EQ(ash::LoginStatus::NOT_LOGGED_IN, GetLoginStatus()); 366 EXPECT_EQ(ash::LoginStatus::NOT_LOGGED_IN, GetLoginStatus());
354 367
355 session_manager::SessionManager::Get()->CreateSession( 368 CreateAndStartUserSession(AccountId::FromUserEmail("owner@invalid.domain"));
356 AccountId::FromUserEmail("owner@invalid.domain"), "owner@invalid.domain");
357 session_manager::SessionManager::Get()->SessionStarted();
358 // Flush to ensure the session state reaches ash and updates login status. 369 // Flush to ensure the session state reaches ash and updates login status.
359 SessionControllerClient::FlushForTesting(); 370 SessionControllerClient::FlushForTesting();
360 371
361 EXPECT_EQ(ash::LoginStatus::USER, GetLoginStatus()); 372 EXPECT_EQ(ash::LoginStatus::USER, GetLoginStatus());
362 } 373 }
363 374
364 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowTrayIcon) { 375 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowTrayIcon) {
365 SetLoginStatus(ash::LoginStatus::NOT_LOGGED_IN); 376 SetLoginStatus(ash::LoginStatus::NOT_LOGGED_IN);
366 377
367 // Confirms that the icon is invisible before login. 378 // Confirms that the icon is invisible before login.
368 EXPECT_FALSE(IsTrayIconVisible()); 379 EXPECT_FALSE(IsTrayIconVisible());
369 380
370 session_manager::SessionManager::Get()->CreateSession( 381 CreateAndStartUserSession(AccountId::FromUserEmail("owner@invalid.domain"));
371 AccountId::FromUserEmail("owner@invalid.domain"), "owner@invalid.domain");
372 session_manager::SessionManager::Get()->SessionStarted();
373 382
374 // Confirms that the icon is invisible just after login. 383 // Confirms that the icon is invisible just after login.
375 EXPECT_FALSE(IsTrayIconVisible()); 384 EXPECT_FALSE(IsTrayIconVisible());
376 385
377 // Toggling spoken feedback changes the visibillity of the icon. 386 // Toggling spoken feedback changes the visibillity of the icon.
378 AccessibilityManager::Get()->EnableSpokenFeedback( 387 AccessibilityManager::Get()->EnableSpokenFeedback(
379 true, ash::A11Y_NOTIFICATION_NONE); 388 true, ash::A11Y_NOTIFICATION_NONE);
380 EXPECT_TRUE(IsTrayIconVisible()); 389 EXPECT_TRUE(IsTrayIconVisible());
381 AccessibilityManager::Get()->EnableSpokenFeedback( 390 AccessibilityManager::Get()->EnableSpokenFeedback(
382 false, ash::A11Y_NOTIFICATION_NONE); 391 false, ash::A11Y_NOTIFICATION_NONE);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 // the icon on the tray. 510 // the icon on the tray.
502 SetShowAccessibilityOptionsInSystemTrayMenu(true); 511 SetShowAccessibilityOptionsInSystemTrayMenu(true);
503 AccessibilityManager::Get()->EnableHighContrast(true); 512 AccessibilityManager::Get()->EnableHighContrast(true);
504 EXPECT_TRUE(IsTrayIconVisible()); 513 EXPECT_TRUE(IsTrayIconVisible());
505 AccessibilityManager::Get()->EnableHighContrast(false); 514 AccessibilityManager::Get()->EnableHighContrast(false);
506 EXPECT_FALSE(IsTrayIconVisible()); 515 EXPECT_FALSE(IsTrayIconVisible());
507 } 516 }
508 517
509 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenu) { 518 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenu) {
510 // Login 519 // Login
511 session_manager::SessionManager::Get()->CreateSession( 520 CreateAndStartUserSession(AccountId::FromUserEmail("owner@invalid.domain"));
512 AccountId::FromUserEmail("owner@invalid.domain"), "owner@invalid.domain");
513 session_manager::SessionManager::Get()->SessionStarted();
514 // Flush to ensure the session state reaches ash and updates login status. 521 // Flush to ensure the session state reaches ash and updates login status.
515 SessionControllerClient::FlushForTesting(); 522 SessionControllerClient::FlushForTesting();
516 523
517 SetShowAccessibilityOptionsInSystemTrayMenu(false); 524 SetShowAccessibilityOptionsInSystemTrayMenu(false);
518 525
519 // Confirms that the menu is hidden. 526 // Confirms that the menu is hidden.
520 EXPECT_FALSE(CanCreateMenuItem()); 527 EXPECT_FALSE(CanCreateMenuItem());
521 528
522 // Toggling spoken feedback changes the visibillity of the menu. 529 // Toggling spoken feedback changes the visibillity of the menu.
523 AccessibilityManager::Get()->EnableSpokenFeedback( 530 AccessibilityManager::Get()->EnableSpokenFeedback(
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 AccessibilityManager::Get()->SetFocusHighlightEnabled(false); 648 AccessibilityManager::Get()->SetFocusHighlightEnabled(false);
642 EXPECT_TRUE(CanCreateMenuItem()); 649 EXPECT_TRUE(CanCreateMenuItem());
643 AccessibilityManager::Get()->EnableStickyKeys(false); 650 AccessibilityManager::Get()->EnableStickyKeys(false);
644 EXPECT_TRUE(CanCreateMenuItem()); 651 EXPECT_TRUE(CanCreateMenuItem());
645 AccessibilityManager::Get()->EnableTapDragging(false); 652 AccessibilityManager::Get()->EnableTapDragging(false);
646 EXPECT_FALSE(CanCreateMenuItem()); 653 EXPECT_FALSE(CanCreateMenuItem());
647 } 654 }
648 655
649 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowMenuOption) { 656 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowMenuWithShowMenuOption) {
650 // Login 657 // Login
651 session_manager::SessionManager::Get()->CreateSession( 658 CreateAndStartUserSession(AccountId::FromUserEmail("owner@invalid.domain"));
652 AccountId::FromUserEmail("owner@invalid.domain"), "owner@invalid.domain");
653 session_manager::SessionManager::Get()->SessionStarted();
654 // Flush to ensure the session state reaches ash and updates login status. 659 // Flush to ensure the session state reaches ash and updates login status.
655 SessionControllerClient::FlushForTesting(); 660 SessionControllerClient::FlushForTesting();
656 661
657 SetShowAccessibilityOptionsInSystemTrayMenu(true); 662 SetShowAccessibilityOptionsInSystemTrayMenu(true);
658 663
659 // Confirms that the menu is visible. 664 // Confirms that the menu is visible.
660 EXPECT_TRUE(CanCreateMenuItem()); 665 EXPECT_TRUE(CanCreateMenuItem());
661 666
662 // The menu remains visible regardless of toggling spoken feedback. 667 // The menu remains visible regardless of toggling spoken feedback.
663 AccessibilityManager::Get()->EnableSpokenFeedback( 668 AccessibilityManager::Get()->EnableSpokenFeedback(
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 EXPECT_TRUE(IsLargeCursorMenuShownOnDetailMenu()); 1637 EXPECT_TRUE(IsLargeCursorMenuShownOnDetailMenu());
1633 EXPECT_TRUE(IsMonoAudioMenuShownOnDetailMenu()); 1638 EXPECT_TRUE(IsMonoAudioMenuShownOnDetailMenu());
1634 EXPECT_TRUE(IsCaretHighlightMenuShownOnDetailMenu()); 1639 EXPECT_TRUE(IsCaretHighlightMenuShownOnDetailMenu());
1635 EXPECT_TRUE(IsHighlightMouseCursorMenuShownOnDetailMenu()); 1640 EXPECT_TRUE(IsHighlightMouseCursorMenuShownOnDetailMenu());
1636 EXPECT_TRUE(IsHighlightKeyboardFocusMenuShownOnDetailMenu()); 1641 EXPECT_TRUE(IsHighlightKeyboardFocusMenuShownOnDetailMenu());
1637 EXPECT_TRUE(IsStickyKeysMenuShownOnDetailMenu()); 1642 EXPECT_TRUE(IsStickyKeysMenuShownOnDetailMenu());
1638 EXPECT_TRUE(IsTapDraggingMenuShownOnDetailMenu()); 1643 EXPECT_TRUE(IsTapDraggingMenuShownOnDetailMenu());
1639 CloseDetailMenu(); 1644 CloseDetailMenu();
1640 1645
1641 // Simulate login. 1646 // Simulate login.
1642 session_manager::SessionManager::Get()->CreateSession( 1647 CreateAndStartUserSession(AccountId::FromUserEmail("owner@invalid.domain"));
1643 AccountId::FromUserEmail("owner@invalid.domain"), "owner@invalid.domain");
1644 session_manager::SessionManager::Get()->SessionStarted();
1645 // Flush to ensure the session state reaches ash and updates login status. 1648 // Flush to ensure the session state reaches ash and updates login status.
1646 SessionControllerClient::FlushForTesting(); 1649 SessionControllerClient::FlushForTesting();
1647 EXPECT_TRUE(CreateDetailedMenu()); 1650 EXPECT_TRUE(CreateDetailedMenu());
1648 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu()); 1651 EXPECT_TRUE(IsSpokenFeedbackMenuShownOnDetailMenu());
1649 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu()); 1652 EXPECT_TRUE(IsHighContrastMenuShownOnDetailMenu());
1650 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu()); 1653 EXPECT_TRUE(IsScreenMagnifierMenuShownOnDetailMenu());
1651 EXPECT_TRUE(IsAutoclickMenuShownOnDetailMenu()); 1654 EXPECT_TRUE(IsAutoclickMenuShownOnDetailMenu());
1652 EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu()); 1655 EXPECT_TRUE(IsVirtualKeyboardMenuShownOnDetailMenu());
1653 EXPECT_TRUE(IsHelpAvailableOnDetailMenu()); 1656 EXPECT_TRUE(IsHelpAvailableOnDetailMenu());
1654 EXPECT_TRUE(IsSettingsAvailableOnDetailMenu()); 1657 EXPECT_TRUE(IsSettingsAvailableOnDetailMenu());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 EXPECT_TRUE(IsTapDraggingMenuShownOnDetailMenu()); 1708 EXPECT_TRUE(IsTapDraggingMenuShownOnDetailMenu());
1706 CloseDetailMenu(); 1709 CloseDetailMenu();
1707 } 1710 }
1708 1711
1709 INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance, 1712 INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance,
1710 TrayAccessibilityTest, 1713 TrayAccessibilityTest,
1711 testing::Values(PREF_SERVICE, 1714 testing::Values(PREF_SERVICE,
1712 POLICY)); 1715 POLICY));
1713 1716
1714 } // namespace chromeos 1717 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system/system_clock.cc ('k') | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698