OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/browser_process.h" |
| 7 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 8 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 9 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" |
| 10 #include "chrome/browser/chromeos/login/helper.h" |
| 11 #include "chrome/browser/chromeos/login/login_utils.h" |
| 12 #include "chrome/browser/chromeos/login/user_manager.h" |
| 13 #include "chrome/browser/chromeos/login/user_manager_impl.h" |
| 14 #include "chrome/browser/prefs/pref_service.h" |
| 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/test/base/testing_profile.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 |
| 23 namespace chromeos { |
| 24 |
| 25 class MagnificationManagerTest : public CrosInProcessBrowserTest { |
| 26 protected: |
| 27 MagnificationManagerTest() {} |
| 28 virtual ~MagnificationManagerTest() {} |
| 29 |
| 30 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 31 command_line->AppendSwitch(switches::kLoginManager); |
| 32 command_line->AppendSwitchASCII(switches::kLoginProfile, |
| 33 TestingProfile::kTestUserProfileDir); |
| 34 } |
| 35 |
| 36 Profile* profile() { |
| 37 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
| 38 DCHECK(profile); |
| 39 return profile; |
| 40 } |
| 41 |
| 42 PrefServiceBase* prefs() { |
| 43 return PrefServiceBase::FromBrowserContext(profile()); |
| 44 } |
| 45 |
| 46 void SetScreenManagnifierTypeToPref(accessibility::ScreenMagnifierType type) { |
| 47 prefs()->SetString(prefs::kScreenMagnifierType, |
| 48 ScreenMagnifierNameFromType(type)); |
| 49 } |
| 50 |
| 51 void CheckCurrentScreenMagnifierType( |
| 52 accessibility::ScreenMagnifierType type) { |
| 53 EXPECT_EQ(MagnificationManager::GetInstance()->GetScreenMagnifierType(), |
| 54 type); |
| 55 } |
| 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(MagnificationManagerTest); |
| 58 }; |
| 59 |
| 60 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, Login) { |
| 61 // Confirms that magnifier is enabled on the login screen. |
| 62 CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_FULL); |
| 63 |
| 64 // Logs in. |
| 65 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); |
| 66 UserManager::Get()->SessionStarted(); |
| 67 |
| 68 // Confirms that magnifier is disabled just after login. |
| 69 CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_OFF); |
| 70 |
| 71 // Enables magnifier. |
| 72 SetScreenManagnifierTypeToPref(accessibility::MAGNIFIER_FULL); |
| 73 |
| 74 // Confirms that magnifier is enabled. |
| 75 CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_FULL); |
| 76 } |
| 77 |
| 78 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, WorkingWithPref) { |
| 79 // Logs in |
| 80 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); |
| 81 UserManager::Get()->SessionStarted(); |
| 82 |
| 83 // Confirms that magnifier is disabled just after login. |
| 84 CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_OFF); |
| 85 |
| 86 // Sets the pref as true to enable magnifier. |
| 87 SetScreenManagnifierTypeToPref(accessibility::MAGNIFIER_FULL); |
| 88 |
| 89 // Confirms that magnifier is enabled. |
| 90 CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_FULL); |
| 91 |
| 92 // Sets the pref as false to disabled magnifier. |
| 93 SetScreenManagnifierTypeToPref(accessibility::MAGNIFIER_OFF); |
| 94 |
| 95 // Confirms that magnifier is disabled. |
| 96 CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_OFF); |
| 97 |
| 98 // Sets the pref as true to enable magnifier again. |
| 99 SetScreenManagnifierTypeToPref(accessibility::MAGNIFIER_FULL); |
| 100 |
| 101 // Confirms that magnifier is enabled. |
| 102 CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_FULL); |
| 103 } |
| 104 |
| 105 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ResumeSavedPref) { |
| 106 // Loads the profile of the user. |
| 107 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); |
| 108 |
| 109 // Sets the pref as true to enable magnifier before login. |
| 110 SetScreenManagnifierTypeToPref(accessibility::MAGNIFIER_FULL); |
| 111 |
| 112 // Logs in. |
| 113 UserManager::Get()->SessionStarted(); |
| 114 |
| 115 // Confirms that magnifier is enabled just after login. |
| 116 CheckCurrentScreenMagnifierType(accessibility::MAGNIFIER_FULL); |
| 117 } |
| 118 |
| 119 } // namespace chromeos |
OLD | NEW |