| OLD | NEW |
| 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/magnifier/magnification_controller.h" | 5 #include "ash/magnifier/magnification_controller.h" |
| 6 #include "ash/shell.h" | 6 #include "ash/shell.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 9 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 10 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 10 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 11 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" | 11 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" |
| 12 #include "chrome/browser/chromeos/login/helper.h" | 12 #include "chrome/browser/chromeos/login/helper.h" |
| 13 #include "chrome/browser/chromeos/login/login_utils.h" | 13 #include "chrome/browser/chromeos/login/login_utils.h" |
| 14 #include "chrome/browser/chromeos/login/user_manager.h" | 14 #include "chrome/browser/chromeos/login/user_manager.h" |
| 15 #include "chrome/browser/chromeos/login/user_manager_impl.h" | 15 #include "chrome/browser/chromeos/login/user_manager_impl.h" |
| 16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 24 |
| 25 namespace chromeos { | 25 namespace chromeos { |
| 26 | 26 |
| 27 namespace { |
| 28 |
| 29 void SetMagnifierEnabled(bool enabled) { |
| 30 MagnificationManager::Get()->SetMagnifierEnabled(enabled); |
| 31 } |
| 32 |
| 33 void SetMagnifierType(ash::MagnifierType type) { |
| 34 MagnificationManager::Get()->SetMagnifierType(type); |
| 35 } |
| 36 |
| 37 void SetFullScreenMagnifierScale(double scale) { |
| 38 ash::Shell::GetInstance()-> |
| 39 magnification_controller()->SetScale(scale, false); |
| 40 } |
| 41 |
| 42 double GetFullScreenMagnifierScale() { |
| 43 return ash::Shell::GetInstance()->magnification_controller()->GetScale(); |
| 44 } |
| 45 |
| 46 void SetSavedFullScreenMagnifierScale(double scale) { |
| 47 MagnificationManager::Get()->SaveScreenMagnifierScale(scale); |
| 48 } |
| 49 |
| 50 double GetSavedFullScreenMagnifierScale() { |
| 51 return MagnificationManager::Get()->GetSavedScreenMagnifierScale(); |
| 52 } |
| 53 |
| 54 ash::MagnifierType GetMagnifierType() { |
| 55 return MagnificationManager::Get()->GetMagnifierType(); |
| 56 } |
| 57 |
| 58 bool IsMagnifierEnabled() { |
| 59 return MagnificationManager::Get()->IsMagnifierEnabled(); |
| 60 } |
| 61 |
| 62 Profile* profile() { |
| 63 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
| 64 DCHECK(profile); |
| 65 return profile; |
| 66 } |
| 67 |
| 68 PrefServiceBase* prefs() { |
| 69 return PrefServiceBase::FromBrowserContext(profile()); |
| 70 } |
| 71 |
| 72 void EnableScreenManagnifierToPref(bool enabled) { |
| 73 prefs()->SetBoolean(prefs::kScreenMagnifierEnabled, enabled); |
| 74 } |
| 75 |
| 76 void SetScreenManagnifierTypeToPref(ash::MagnifierType type) { |
| 77 prefs()->SetInteger(prefs::kScreenMagnifierType, type); |
| 78 } |
| 79 |
| 80 } // anonymouse namespace |
| 81 |
| 27 class MagnificationManagerTest : public CrosInProcessBrowserTest, | 82 class MagnificationManagerTest : public CrosInProcessBrowserTest, |
| 28 public content::NotificationObserver { | 83 public content::NotificationObserver { |
| 29 protected: | 84 protected: |
| 30 MagnificationManagerTest() : observed_(false), | 85 MagnificationManagerTest() : observed_(false), |
| 31 observed_type_(ash::MAGNIFIER_OFF) {} | 86 observed_enabled_(false), |
| 87 observed_type_(ash::kDefaultMagnifierType) {} |
| 32 virtual ~MagnificationManagerTest() {} | 88 virtual ~MagnificationManagerTest() {} |
| 33 | 89 |
| 34 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 90 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 35 command_line->AppendSwitch(switches::kLoginManager); | 91 command_line->AppendSwitch(switches::kLoginManager); |
| 36 command_line->AppendSwitchASCII(switches::kLoginProfile, | 92 command_line->AppendSwitchASCII(switches::kLoginProfile, |
| 37 TestingProfile::kTestUserProfileDir); | 93 TestingProfile::kTestUserProfileDir); |
| 38 } | 94 } |
| 39 | 95 |
| 40 Profile* profile() { | |
| 41 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); | |
| 42 DCHECK(profile); | |
| 43 return profile; | |
| 44 } | |
| 45 | |
| 46 PrefServiceBase* prefs() { | |
| 47 return PrefServiceBase::FromBrowserContext(profile()); | |
| 48 } | |
| 49 | |
| 50 virtual void SetUpOnMainThread() OVERRIDE { | 96 virtual void SetUpOnMainThread() OVERRIDE { |
| 51 registrar_.Add( | 97 registrar_.Add( |
| 52 this, | 98 this, |
| 53 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER, | 99 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER, |
| 54 content::NotificationService::AllSources()); | 100 content::NotificationService::AllSources()); |
| 55 } | 101 } |
| 56 | 102 |
| 57 void SetScreenManagnifierType(ash::MagnifierType type) { | |
| 58 MagnificationManager::Get()->SetMagnifier(type); | |
| 59 } | |
| 60 | |
| 61 void SetScreenManagnifierTypeToPref(ash::MagnifierType type) { | |
| 62 prefs()->SetBoolean(prefs::kScreenMagnifierEnabled, | |
| 63 (type != ash::MAGNIFIER_OFF) ? true : false); | |
| 64 } | |
| 65 | |
| 66 void SetFullScreenMagnifierScale(double scale) { | |
| 67 ash::Shell::GetInstance()-> | |
| 68 magnification_controller()->SetScale(scale, false); | |
| 69 } | |
| 70 | |
| 71 double GetFullScreenMagnifierScale() { | |
| 72 return ash::Shell::GetInstance()->magnification_controller()->GetScale(); | |
| 73 } | |
| 74 | |
| 75 void SetSavedFullScreenMagnifierScale(double scale) { | |
| 76 MagnificationManager::Get()->SaveScreenMagnifierScale(scale); | |
| 77 } | |
| 78 | |
| 79 double GetSavedFullScreenMagnifierScale() { | |
| 80 return MagnificationManager::Get()->GetSavedScreenMagnifierScale(); | |
| 81 } | |
| 82 | |
| 83 void CheckCurrentMagnifierType( | |
| 84 ash::MagnifierType type) { | |
| 85 EXPECT_EQ(MagnificationManager::Get()->GetMagnifierType(), type); | |
| 86 } | |
| 87 | |
| 88 // content::NotificationObserver implementation. | 103 // content::NotificationObserver implementation. |
| 89 virtual void Observe(int type, | 104 virtual void Observe(int type, |
| 90 const content::NotificationSource& source, | 105 const content::NotificationSource& source, |
| 91 const content::NotificationDetails& details) OVERRIDE { | 106 const content::NotificationDetails& details) OVERRIDE { |
| 92 switch (type) { | 107 switch (type) { |
| 93 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER: { | 108 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER: { |
| 94 accessibility::AccessibilityStatusEventDetails* accessibility_status = | 109 accessibility::AccessibilityStatusEventDetails* accessibility_status = |
| 95 content::Details<accessibility::AccessibilityStatusEventDetails>( | 110 content::Details<accessibility::AccessibilityStatusEventDetails>( |
| 96 details).ptr(); | 111 details).ptr(); |
| 97 | 112 |
| 98 observed_ = true; | 113 observed_ = true; |
| 99 observed_type_ = accessibility_status->enabled ? ash::MAGNIFIER_FULL : | 114 observed_enabled_ = accessibility_status->enabled; |
| 100 ash::MAGNIFIER_OFF; | 115 observed_type_ = accessibility_status->magnifier_type; |
| 101 break; | 116 break; |
| 102 } | 117 } |
| 103 } | 118 } |
| 104 } | 119 } |
| 105 | 120 |
| 106 bool observed_; | 121 bool observed_; |
| 122 bool observed_enabled_; |
| 107 ash::MagnifierType observed_type_; | 123 ash::MagnifierType observed_type_; |
| 108 content::NotificationRegistrar registrar_; | 124 content::NotificationRegistrar registrar_; |
| 109 DISALLOW_COPY_AND_ASSIGN(MagnificationManagerTest); | 125 DISALLOW_COPY_AND_ASSIGN(MagnificationManagerTest); |
| 110 }; | 126 }; |
| 111 | 127 |
| 112 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginOffToOff) { | 128 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginOffToOff) { |
| 113 // Confirms that magnifier is disabled on the login screen. | 129 // Confirms that magnifier is disabled on the login screen. |
| 114 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 130 EXPECT_FALSE(IsMagnifierEnabled()); |
| 115 | 131 |
| 116 // Logs in. | 132 // Logs in. |
| 117 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); | 133 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); |
| 118 | 134 |
| 119 // Confirms that magnifier is still disabled just after login. | 135 // Confirms that magnifier is still disabled just after login. |
| 120 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 136 EXPECT_FALSE(IsMagnifierEnabled()); |
| 121 | 137 |
| 122 UserManager::Get()->SessionStarted(); | 138 UserManager::Get()->SessionStarted(); |
| 123 | 139 |
| 124 // Confirms that magnifier is still disabled just after login. | 140 // Confirms that magnifier is still disabled just after login. |
| 125 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 141 EXPECT_FALSE(IsMagnifierEnabled()); |
| 126 | 142 |
| 127 // Enables magnifier. | 143 // Enables magnifier. |
| 128 SetScreenManagnifierType(ash::MAGNIFIER_FULL); | 144 SetMagnifierEnabled(true); |
| 129 // Confirms that magnifier is enabled. | 145 // Confirms that magnifier is enabled. |
| 130 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 146 EXPECT_TRUE(IsMagnifierEnabled()); |
| 147 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 131 } | 148 } |
| 132 | 149 |
| 133 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToOff) { | 150 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToOff) { |
| 134 // Confirms that magnifier is disabled on the login screen. | 151 // Confirms that magnifier is disabled on the login screen. |
| 135 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 152 EXPECT_FALSE(IsMagnifierEnabled()); |
| 136 | 153 |
| 137 // Enables magnifier on login scren. | 154 // Enables magnifier on login scren. |
| 138 SetScreenManagnifierType(ash::MAGNIFIER_FULL); | 155 SetMagnifierEnabled(true); |
| 139 | 156 |
| 140 // Logs in (but the session is not started yet). | 157 // Logs in (but the session is not started yet). |
| 141 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); | 158 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); |
| 142 // Confirms that magnifier is keeping enabled. | 159 // Confirms that magnifier is keeping enabled. |
| 143 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 160 EXPECT_TRUE(IsMagnifierEnabled()); |
| 161 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 144 | 162 |
| 145 UserManager::Get()->SessionStarted(); | 163 UserManager::Get()->SessionStarted(); |
| 146 | 164 |
| 147 // Confirms that magnifier is disabled just after login. | 165 // Confirms that magnifier is disabled just after login. |
| 148 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 166 EXPECT_FALSE(IsMagnifierEnabled()); |
| 149 } | 167 } |
| 150 | 168 |
| 151 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginOffToFull) { | 169 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginOffToFull) { |
| 152 // Changes to full screen magnifier again and confirms that. | 170 // Changes to full screen magnifier again and confirms that. |
| 153 SetScreenManagnifierType(ash::MAGNIFIER_OFF); | 171 SetMagnifierEnabled(false); |
| 154 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 172 EXPECT_FALSE(IsMagnifierEnabled()); |
| 155 | 173 |
| 156 // Logs in (but the session is not started yet). | 174 // Logs in (but the session is not started yet). |
| 157 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); | 175 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); |
| 158 | 176 |
| 159 // Confirms that magnifier is keeping disabled. | 177 // Confirms that magnifier is keeping disabled. |
| 160 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 178 EXPECT_FALSE(IsMagnifierEnabled()); |
| 161 // Enable magnifier on the pref. | 179 // Enable magnifier on the pref. |
| 180 EnableScreenManagnifierToPref(true); |
| 162 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_FULL); | 181 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_FULL); |
| 163 SetSavedFullScreenMagnifierScale(2.5); | 182 SetSavedFullScreenMagnifierScale(2.5); |
| 164 | 183 |
| 165 UserManager::Get()->SessionStarted(); | 184 UserManager::Get()->SessionStarted(); |
| 166 | 185 |
| 167 // Confirms that the prefs are successfully loaded. | 186 // Confirms that the prefs are successfully loaded. |
| 168 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 187 EXPECT_TRUE(IsMagnifierEnabled()); |
| 188 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 169 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); | 189 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); |
| 170 } | 190 } |
| 171 | 191 |
| 192 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginOffToPartial) { |
| 193 // Changes to full screen magnifier again and confirms that. |
| 194 SetMagnifierEnabled(false); |
| 195 EXPECT_FALSE(IsMagnifierEnabled()); |
| 196 |
| 197 // Logs in (but the session is not started yet). |
| 198 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); |
| 199 |
| 200 // Confirms that magnifier is keeping disabled. |
| 201 EXPECT_FALSE(IsMagnifierEnabled()); |
| 202 // Enable magnifier on the pref. |
| 203 EnableScreenManagnifierToPref(true); |
| 204 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_PARTIAL); |
| 205 |
| 206 UserManager::Get()->SessionStarted(); |
| 207 |
| 208 // Confirms that the prefs are successfully loaded. |
| 209 EXPECT_TRUE(IsMagnifierEnabled()); |
| 210 EXPECT_EQ(ash::MAGNIFIER_PARTIAL, GetMagnifierType()); |
| 211 |
| 212 // Full screen magnifier scale is 1.0x since it's 'partial' magnifier. |
| 213 EXPECT_EQ(1.0, GetFullScreenMagnifierScale()); |
| 214 } |
| 215 |
| 172 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToFull) { | 216 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToFull) { |
| 173 // Changes to full screen magnifier again and confirms that. | 217 // Changes to full screen magnifier again and confirms that. |
| 174 SetScreenManagnifierType(ash::MAGNIFIER_FULL); | 218 SetMagnifierType(ash::MAGNIFIER_FULL); |
| 175 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 219 SetMagnifierEnabled(true); |
| 220 EXPECT_TRUE(IsMagnifierEnabled()); |
| 221 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 176 | 222 |
| 177 // Logs in (but the session is not started yet). | 223 // Logs in (but the session is not started yet). |
| 178 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); | 224 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); |
| 179 | 225 |
| 180 // Confirms that magnifier is keeping enabled. | 226 // Confirms that magnifier is keeping enabled. |
| 181 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 227 EXPECT_TRUE(IsMagnifierEnabled()); |
| 182 // Enable magnifier on the pref. | 228 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 229 // Enable magnifier on the pref. |
| 230 EnableScreenManagnifierToPref(true); |
| 183 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_FULL); | 231 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_FULL); |
| 184 SetSavedFullScreenMagnifierScale(2.5); | 232 SetSavedFullScreenMagnifierScale(2.5); |
| 185 | 233 |
| 186 UserManager::Get()->SessionStarted(); | 234 UserManager::Get()->SessionStarted(); |
| 187 | 235 |
| 188 // Confirms that the prefs are successfully loaded. | 236 // Confirms that the prefs are successfully loaded. |
| 189 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 237 EXPECT_TRUE(IsMagnifierEnabled()); |
| 238 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 190 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); | 239 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); |
| 191 } | 240 } |
| 192 | 241 |
| 242 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToPartial) { |
| 243 // Changes to full screen magnifier again and confirms that. |
| 244 SetMagnifierType(ash::MAGNIFIER_FULL); |
| 245 SetMagnifierEnabled(true); |
| 246 EXPECT_TRUE(IsMagnifierEnabled()); |
| 247 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 248 |
| 249 // Logs in (but the session is not started yet). |
| 250 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); |
| 251 |
| 252 // Confirms that magnifier is keeping enabled. |
| 253 EXPECT_TRUE(IsMagnifierEnabled()); |
| 254 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 255 // Enable magnifier on the pref. |
| 256 EnableScreenManagnifierToPref(true); |
| 257 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_PARTIAL); |
| 258 |
| 259 UserManager::Get()->SessionStarted(); |
| 260 |
| 261 // Confirms that the prefs are successfully loaded. |
| 262 EXPECT_TRUE(IsMagnifierEnabled()); |
| 263 EXPECT_EQ(ash::MAGNIFIER_PARTIAL, GetMagnifierType()); |
| 264 |
| 265 // Full screen magnifier scale is 1.0x since it's 'partial' magnifier. |
| 266 EXPECT_EQ(1.0, GetFullScreenMagnifierScale()); |
| 267 } |
| 268 |
| 193 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ChangeMagnifierType) { | 269 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ChangeMagnifierType) { |
| 194 // Changes to full screen magnifier and confirms that. | 270 // Enables/disables full screen magnifier. |
| 195 SetScreenManagnifierType(ash::MAGNIFIER_FULL); | 271 SetMagnifierEnabled(false); |
| 196 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 272 SetMagnifierType(ash::MAGNIFIER_FULL); |
| 197 | 273 EXPECT_FALSE(IsMagnifierEnabled()); |
| 198 // Changes to partial screen magnifier and confirms that. | 274 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 199 SetScreenManagnifierType(ash::MAGNIFIER_PARTIAL); | 275 |
| 200 CheckCurrentMagnifierType(ash::MAGNIFIER_PARTIAL); | 276 SetMagnifierEnabled(true); |
| 201 | 277 EXPECT_TRUE(IsMagnifierEnabled()); |
| 202 // Disable magnifier and confirms that. | 278 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 203 SetScreenManagnifierType(ash::MAGNIFIER_OFF); | 279 |
| 204 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 280 SetMagnifierEnabled(false); |
| 205 | 281 EXPECT_FALSE(IsMagnifierEnabled()); |
| 206 // Changes to full screen magnifier again and confirms that. | 282 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 207 SetScreenManagnifierType(ash::MAGNIFIER_FULL); | 283 |
| 208 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 284 // Enables/disables partial screen magnifier. |
| 209 | 285 SetMagnifierType(ash::MAGNIFIER_PARTIAL); |
| 210 // Logs in | 286 EXPECT_FALSE(IsMagnifierEnabled()); |
| 211 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); | 287 EXPECT_EQ(ash::MAGNIFIER_PARTIAL, GetMagnifierType()); |
| 212 UserManager::Get()->SessionStarted(); | 288 |
| 213 | 289 SetMagnifierEnabled(true); |
| 214 // Changes to full screen magnifier and confirms that. | 290 EXPECT_TRUE(IsMagnifierEnabled()); |
| 215 SetScreenManagnifierType(ash::MAGNIFIER_FULL); | 291 EXPECT_EQ(ash::MAGNIFIER_PARTIAL, GetMagnifierType()); |
| 216 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 292 |
| 217 | 293 SetMagnifierEnabled(false); |
| 218 // Changes to partial screen magnifier and confirms that. | 294 EXPECT_FALSE(IsMagnifierEnabled()); |
| 219 SetScreenManagnifierType(ash::MAGNIFIER_PARTIAL); | 295 EXPECT_EQ(ash::MAGNIFIER_PARTIAL, GetMagnifierType()); |
| 220 CheckCurrentMagnifierType(ash::MAGNIFIER_PARTIAL); | 296 |
| 221 | 297 // Changes the magnifier type when the magnifier is enabled. |
| 222 // Disable magnifier and confirms that. | 298 SetMagnifierType(ash::MAGNIFIER_FULL); |
| 223 SetScreenManagnifierType(ash::MAGNIFIER_OFF); | 299 SetMagnifierEnabled(true); |
| 224 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 300 EXPECT_TRUE(IsMagnifierEnabled()); |
| 225 | 301 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 226 // Changes to full screen magnifier again and confirms that. | 302 |
| 227 SetScreenManagnifierType(ash::MAGNIFIER_FULL); | 303 SetMagnifierType(ash::MAGNIFIER_PARTIAL); |
| 228 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 304 EXPECT_TRUE(IsMagnifierEnabled()); |
| 305 EXPECT_EQ(ash::MAGNIFIER_PARTIAL, GetMagnifierType()); |
| 306 |
| 307 SetMagnifierType(ash::MAGNIFIER_FULL); |
| 308 EXPECT_TRUE(IsMagnifierEnabled()); |
| 309 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 310 |
| 311 // Changes the magnifier type when the magnifier is disabled. |
| 312 SetMagnifierEnabled(false); |
| 313 SetMagnifierType(ash::MAGNIFIER_FULL); |
| 314 EXPECT_FALSE(IsMagnifierEnabled()); |
| 315 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 316 |
| 317 SetMagnifierType(ash::MAGNIFIER_PARTIAL); |
| 318 EXPECT_FALSE(IsMagnifierEnabled()); |
| 319 EXPECT_EQ(ash::MAGNIFIER_PARTIAL, GetMagnifierType()); |
| 320 |
| 321 SetMagnifierType(ash::MAGNIFIER_FULL); |
| 322 EXPECT_FALSE(IsMagnifierEnabled()); |
| 323 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 229 } | 324 } |
| 230 | 325 |
| 231 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, TypePref) { | 326 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, TypePref) { |
| 232 // Logs in | 327 // Logs in |
| 233 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); | 328 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); |
| 234 UserManager::Get()->SessionStarted(); | 329 UserManager::Get()->SessionStarted(); |
| 235 | 330 |
| 236 // Confirms that magnifier is disabled just after login. | 331 // Confirms that magnifier is disabled just after login. |
| 237 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 332 EXPECT_FALSE(IsMagnifierEnabled()); |
| 238 | 333 |
| 239 // Sets the pref as true to enable magnifier. | 334 // Sets the pref as true to enable magnifier. |
| 240 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_FULL); | 335 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_FULL); |
| 336 EnableScreenManagnifierToPref(true); |
| 241 // Confirms that magnifier is enabled. | 337 // Confirms that magnifier is enabled. |
| 242 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 338 EXPECT_TRUE(IsMagnifierEnabled()); |
| 339 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 340 |
| 341 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_PARTIAL); |
| 342 EXPECT_TRUE(IsMagnifierEnabled()); |
| 343 EXPECT_EQ(ash::MAGNIFIER_PARTIAL, GetMagnifierType()); |
| 243 | 344 |
| 244 // Sets the pref as false to disabled magnifier. | 345 // Sets the pref as false to disabled magnifier. |
| 245 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_OFF); | 346 EnableScreenManagnifierToPref(false); |
| 246 // Confirms that magnifier is disabled. | 347 // Confirms that magnifier is disabled. |
| 247 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 348 EXPECT_FALSE(IsMagnifierEnabled()); |
| 248 | 349 |
| 249 // Sets the pref as true to enable magnifier again. | 350 // Sets the pref as true to enable magnifier again. |
| 250 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_FULL); | 351 EnableScreenManagnifierToPref(true); |
| 251 // Confirms that magnifier is enabled. | 352 // Confirms that magnifier is enabled. |
| 252 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 353 EXPECT_TRUE(IsMagnifierEnabled()); |
| 354 EXPECT_EQ(ash::MAGNIFIER_PARTIAL, GetMagnifierType()); |
| 253 } | 355 } |
| 254 | 356 |
| 255 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ResumeSavedTypePref) { | 357 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ResumeSavedTypeFullPref) { |
| 256 // Loads the profile of the user. | 358 // Loads the profile of the user. |
| 257 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); | 359 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); |
| 258 | 360 |
| 259 // Sets the pref as true to enable magnifier before login. | 361 // Sets the pref as true to enable magnifier before login. |
| 362 EnableScreenManagnifierToPref(true); |
| 260 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_FULL); | 363 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_FULL); |
| 261 | 364 |
| 262 // Logs in. | 365 // Logs in. |
| 263 UserManager::Get()->SessionStarted(); | 366 UserManager::Get()->SessionStarted(); |
| 264 | 367 |
| 265 // Confirms that magnifier is enabled just after login. | 368 // Confirms that magnifier is enabled just after login. |
| 266 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 369 EXPECT_TRUE(IsMagnifierEnabled()); |
| 370 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 371 } |
| 372 |
| 373 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ResumeSavedTypePartialPref) { |
| 374 // Loads the profile of the user. |
| 375 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); |
| 376 |
| 377 // Sets the pref as true to enable magnifier before login. |
| 378 EnableScreenManagnifierToPref(true); |
| 379 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_PARTIAL); |
| 380 |
| 381 // Logs in. |
| 382 UserManager::Get()->SessionStarted(); |
| 383 |
| 384 // Confirms that magnifier is enabled just after login. |
| 385 EXPECT_TRUE(IsMagnifierEnabled()); |
| 386 EXPECT_EQ(ash::MAGNIFIER_PARTIAL, GetMagnifierType()); |
| 267 } | 387 } |
| 268 | 388 |
| 269 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ScalePref) { | 389 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ScalePref) { |
| 270 SetScreenManagnifierType(ash::MAGNIFIER_OFF); | 390 SetMagnifierEnabled(false); |
| 271 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 391 EXPECT_FALSE(IsMagnifierEnabled()); |
| 272 | 392 |
| 273 // Sets 2.5x to the pref. | 393 // Sets 2.5x to the pref. |
| 274 SetSavedFullScreenMagnifierScale(2.5); | 394 SetSavedFullScreenMagnifierScale(2.5); |
| 275 | 395 |
| 276 // Enables full screen magnifier. | 396 // Enables full screen magnifier. |
| 277 SetScreenManagnifierType(ash::MAGNIFIER_FULL); | 397 SetMagnifierType(ash::MAGNIFIER_FULL); |
| 278 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 398 SetMagnifierEnabled(true); |
| 399 EXPECT_TRUE(IsMagnifierEnabled()); |
| 400 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 279 | 401 |
| 280 // Confirms that 2.5x is restored. | 402 // Confirms that 2.5x is restored. |
| 281 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); | 403 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); |
| 282 | 404 |
| 283 // Sets the scale and confirms that the scale is saved to pref. | 405 // Sets the scale and confirms that the scale is saved to pref. |
| 284 SetFullScreenMagnifierScale(3.0); | 406 SetFullScreenMagnifierScale(3.0); |
| 285 EXPECT_EQ(3.0, GetSavedFullScreenMagnifierScale()); | 407 EXPECT_EQ(3.0, GetSavedFullScreenMagnifierScale()); |
| 286 } | 408 } |
| 287 | 409 |
| 288 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, InvalidScalePref) { | 410 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, InvalidScalePref) { |
| 289 // TEST 1: too small scale | 411 // TEST 1: Sets too small scale |
| 290 SetScreenManagnifierType(ash::MAGNIFIER_OFF); | 412 SetMagnifierEnabled(false); |
| 291 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 413 EXPECT_FALSE(IsMagnifierEnabled()); |
| 292 | 414 |
| 293 // Sets too small value to the pref. | 415 // Sets too small value to the pref. |
| 294 SetSavedFullScreenMagnifierScale(0.5); | 416 SetSavedFullScreenMagnifierScale(0.5); |
| 295 | 417 |
| 296 // Enables full screen magnifier. | 418 // Enables full screen magnifier. |
| 297 SetScreenManagnifierType(ash::MAGNIFIER_FULL); | 419 SetMagnifierType(ash::MAGNIFIER_FULL); |
| 298 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 420 SetMagnifierEnabled(true); |
| 421 EXPECT_TRUE(IsMagnifierEnabled()); |
| 422 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 299 | 423 |
| 300 // Confirms that the actual scale is set to the minimum scale. | 424 // Confirms that the actual scale is set to the minimum scale. |
| 301 EXPECT_EQ(1.0, GetFullScreenMagnifierScale()); | 425 EXPECT_EQ(1.0, GetFullScreenMagnifierScale()); |
| 302 | 426 |
| 303 // TEST 2: too large scale | 427 // TEST 2: Sets too large scale |
| 304 SetScreenManagnifierType(ash::MAGNIFIER_OFF); | 428 SetMagnifierEnabled(false); |
| 305 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 429 EXPECT_FALSE(IsMagnifierEnabled()); |
| 306 | 430 |
| 307 // Sets too large value to the pref. | 431 // Sets too large value to the pref. |
| 308 SetSavedFullScreenMagnifierScale(50.0); | 432 SetSavedFullScreenMagnifierScale(50.0); |
| 309 | 433 |
| 310 // Enables full screen magnifier. | 434 // Enables full screen magnifier. |
| 311 SetScreenManagnifierType(ash::MAGNIFIER_FULL); | 435 SetMagnifierEnabled(true); |
| 312 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 436 EXPECT_TRUE(IsMagnifierEnabled()); |
| 437 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); |
| 313 | 438 |
| 314 // Confirms that the actual scale is set to the maximum scale. | 439 // Confirms that the actual scale is set to the maximum scale. |
| 315 EXPECT_EQ(4.0, GetFullScreenMagnifierScale()); | 440 EXPECT_EQ(4.0, GetFullScreenMagnifierScale()); |
| 316 } | 441 } |
| 317 | 442 |
| 318 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, | 443 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, |
| 319 ChangingTypeInvokesNotification) { | 444 ChangingTypeInvokesNotification) { |
| 320 // Logs in | 445 // Logs in |
| 321 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); | 446 UserManager::Get()->UserLoggedIn("owner@invalid.domain", true); |
| 322 UserManager::Get()->SessionStarted(); | 447 UserManager::Get()->SessionStarted(); |
| 323 | 448 |
| 324 // Before the test, sets to full magnifier. | 449 // Enable magnifier (without type) |
| 325 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_FULL); | 450 EnableScreenManagnifierToPref(true); |
| 326 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 451 EXPECT_TRUE(observed_); |
| 327 | 452 |
| 328 // Disables magnifier and confirms observer is invoked. | 453 // Disables magnifier and confirms observer is invoked. |
| 329 observed_ = false; | 454 observed_ = false; |
| 330 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_OFF); | 455 SetMagnifierEnabled(false); |
| 331 EXPECT_TRUE(observed_); | 456 EXPECT_TRUE(observed_); |
| 332 EXPECT_EQ(observed_type_, ash::MAGNIFIER_OFF); | 457 |
| 333 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 458 // Disables magnifier again and confirms observer is not invoked. |
| 459 observed_ = false; |
| 460 SetMagnifierEnabled(false); |
| 461 EXPECT_FALSE(observed_); |
| 334 | 462 |
| 335 // Enables full screen magnifier and confirms observer is invoked. | 463 // Enables full screen magnifier and confirms observer is invoked. |
| 336 observed_ = false; | 464 observed_ = false; |
| 337 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_FULL); | 465 SetMagnifierType(ash::MAGNIFIER_FULL); |
| 466 SetMagnifierEnabled(true); |
| 338 EXPECT_TRUE(observed_); | 467 EXPECT_TRUE(observed_); |
| 339 EXPECT_EQ(observed_type_, ash::MAGNIFIER_FULL); | 468 |
| 340 CheckCurrentMagnifierType(ash::MAGNIFIER_FULL); | 469 // Enables full screen magnifier again and confirms observer is invoked. |
| 470 observed_ = false; |
| 471 SetMagnifierEnabled(true); |
| 472 EXPECT_TRUE(observed_); |
| 473 EXPECT_TRUE(observed_enabled_); |
| 474 EXPECT_EQ(ash::MAGNIFIER_FULL, observed_type_); |
| 475 |
| 476 // Switches to partial screen magnifier and confirms observer is invoked. |
| 477 observed_ = false; |
| 478 SetMagnifierType(ash::MAGNIFIER_PARTIAL); |
| 479 EXPECT_TRUE(observed_); |
| 480 EXPECT_TRUE(observed_enabled_); |
| 481 EXPECT_EQ(ash::MAGNIFIER_PARTIAL, observed_type_); |
| 482 |
| 483 // Switches to partial screen magnifier and confirms observer is invoked. |
| 484 observed_ = false; |
| 485 SetMagnifierType(ash::MAGNIFIER_FULL); |
| 486 EXPECT_TRUE(observed_); |
| 487 EXPECT_TRUE(observed_enabled_); |
| 488 EXPECT_EQ(ash::MAGNIFIER_FULL, observed_type_); |
| 341 | 489 |
| 342 // Disables magnifier again and confirms observer is invoked. | 490 // Disables magnifier again and confirms observer is invoked. |
| 343 observed_ = false; | 491 observed_ = false; |
| 344 SetScreenManagnifierTypeToPref(ash::MAGNIFIER_OFF); | 492 SetMagnifierEnabled(false); |
| 345 EXPECT_TRUE(observed_); | 493 EXPECT_TRUE(observed_); |
| 346 EXPECT_EQ(observed_type_, ash::MAGNIFIER_OFF); | 494 EXPECT_FALSE(observed_enabled_); |
| 347 CheckCurrentMagnifierType(ash::MAGNIFIER_OFF); | 495 EXPECT_FALSE(IsMagnifierEnabled()); |
| 348 } | 496 } |
| 349 | 497 |
| 350 } // namespace chromeos | 498 } // namespace chromeos |
| OLD | NEW |