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