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

Side by Side Diff: chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc

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

Powered by Google App Engine
This is Rietveld 408576698