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

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

Issue 2078393005: mash: Move accessibility_types.h from ui namespace to ash namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a11y
Patch Set: fix chromevox code generated from js Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "ash/common/accessibility_types.h"
7 #include "ash/magnifier/magnification_controller.h" 8 #include "ash/magnifier/magnification_controller.h"
8 #include "ash/shell.h" 9 #include "ash/shell.h"
9 #include "base/command_line.h" 10 #include "base/command_line.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 14 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
14 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 15 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
15 #include "chrome/browser/chromeos/login/helper.h" 16 #include "chrome/browser/chromeos/login/helper.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
(...skipping 13 matching lines...) Expand all
30 namespace chromeos { 31 namespace chromeos {
31 32
32 namespace { 33 namespace {
33 34
34 const char kTestUserName[] = "owner@invalid.domain"; 35 const char kTestUserName[] = "owner@invalid.domain";
35 36
36 void SetMagnifierEnabled(bool enabled) { 37 void SetMagnifierEnabled(bool enabled) {
37 MagnificationManager::Get()->SetMagnifierEnabled(enabled); 38 MagnificationManager::Get()->SetMagnifierEnabled(enabled);
38 } 39 }
39 40
40 void SetMagnifierType(ui::MagnifierType type) { 41 void SetMagnifierType(ash::MagnifierType type) {
41 MagnificationManager::Get()->SetMagnifierType(type); 42 MagnificationManager::Get()->SetMagnifierType(type);
42 } 43 }
43 44
44 void SetFullScreenMagnifierScale(double scale) { 45 void SetFullScreenMagnifierScale(double scale) {
45 ash::Shell::GetInstance()-> 46 ash::Shell::GetInstance()->
46 magnification_controller()->SetScale(scale, false); 47 magnification_controller()->SetScale(scale, false);
47 } 48 }
48 49
49 double GetFullScreenMagnifierScale() { 50 double GetFullScreenMagnifierScale() {
50 return ash::Shell::GetInstance()->magnification_controller()->GetScale(); 51 return ash::Shell::GetInstance()->magnification_controller()->GetScale();
51 } 52 }
52 53
53 void SetSavedFullScreenMagnifierScale(double scale) { 54 void SetSavedFullScreenMagnifierScale(double scale) {
54 MagnificationManager::Get()->SaveScreenMagnifierScale(scale); 55 MagnificationManager::Get()->SaveScreenMagnifierScale(scale);
55 } 56 }
56 57
57 double GetSavedFullScreenMagnifierScale() { 58 double GetSavedFullScreenMagnifierScale() {
58 return MagnificationManager::Get()->GetSavedScreenMagnifierScale(); 59 return MagnificationManager::Get()->GetSavedScreenMagnifierScale();
59 } 60 }
60 61
61 ui::MagnifierType GetMagnifierType() { 62 ash::MagnifierType GetMagnifierType() {
62 return MagnificationManager::Get()->GetMagnifierType(); 63 return MagnificationManager::Get()->GetMagnifierType();
63 } 64 }
64 65
65 bool IsMagnifierEnabled() { 66 bool IsMagnifierEnabled() {
66 return MagnificationManager::Get()->IsMagnifierEnabled(); 67 return MagnificationManager::Get()->IsMagnifierEnabled();
67 } 68 }
68 69
69 Profile* profile() { 70 Profile* profile() {
70 Profile* profile = ProfileManager::GetActiveUserProfile(); 71 Profile* profile = ProfileManager::GetActiveUserProfile();
71 DCHECK(profile); 72 DCHECK(profile);
72 return profile; 73 return profile;
73 } 74 }
74 75
75 PrefService* prefs() { 76 PrefService* prefs() {
76 return user_prefs::UserPrefs::Get(profile()); 77 return user_prefs::UserPrefs::Get(profile());
77 } 78 }
78 79
79 void SetScreenMagnifierEnabledPref(bool enabled) { 80 void SetScreenMagnifierEnabledPref(bool enabled) {
80 prefs()->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled, enabled); 81 prefs()->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled, enabled);
81 } 82 }
82 83
83 void SetScreenMagnifierTypePref(ui::MagnifierType type) { 84 void SetScreenMagnifierTypePref(ash::MagnifierType type) {
84 prefs()->SetInteger(prefs::kAccessibilityScreenMagnifierType, type); 85 prefs()->SetInteger(prefs::kAccessibilityScreenMagnifierType, type);
85 } 86 }
86 87
87 void SetFullScreenMagnifierScalePref(double scale) { 88 void SetFullScreenMagnifierScalePref(double scale) {
88 prefs()->SetDouble(prefs::kAccessibilityScreenMagnifierScale, scale); 89 prefs()->SetDouble(prefs::kAccessibilityScreenMagnifierScale, scale);
89 } 90 }
90 91
91 bool GetScreenMagnifierEnabledFromPref() { 92 bool GetScreenMagnifierEnabledFromPref() {
92 return prefs()->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled); 93 return prefs()->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled);
93 } 94 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 196
196 user_manager::UserManager::Get()->SessionStarted(); 197 user_manager::UserManager::Get()->SessionStarted();
197 198
198 // Confirms that magnifier is still disabled just after session starts. 199 // Confirms that magnifier is still disabled just after session starts.
199 EXPECT_FALSE(IsMagnifierEnabled()); 200 EXPECT_FALSE(IsMagnifierEnabled());
200 201
201 // Enables magnifier. 202 // Enables magnifier.
202 SetMagnifierEnabled(true); 203 SetMagnifierEnabled(true);
203 // Confirms that magnifier is enabled. 204 // Confirms that magnifier is enabled.
204 EXPECT_TRUE(IsMagnifierEnabled()); 205 EXPECT_TRUE(IsMagnifierEnabled());
205 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 206 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
206 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref()); 207 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref());
207 } 208 }
208 209
209 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginFullToOff) { 210 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginFullToOff) {
210 // Create a new profile once, to run the test with non-new profile. 211 // Create a new profile once, to run the test with non-new profile.
211 PrepareNonNewProfile(test_account_id_); 212 PrepareNonNewProfile(test_account_id_);
212 213
213 // Sets pref to explicitly disable the magnifier. 214 // Sets pref to explicitly disable the magnifier.
214 SetScreenMagnifierEnabledPref(false); 215 SetScreenMagnifierEnabledPref(false);
215 } 216 }
216 217
217 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToOff) { 218 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToOff) {
218 // Confirms that magnifier is disabled on the login screen. 219 // Confirms that magnifier is disabled on the login screen.
219 EXPECT_FALSE(IsMagnifierEnabled()); 220 EXPECT_FALSE(IsMagnifierEnabled());
220 221
221 // Enables magnifier on login screen. 222 // Enables magnifier on login screen.
222 SetMagnifierEnabled(true); 223 SetMagnifierEnabled(true);
223 SetMagnifierType(ui::MAGNIFIER_FULL); 224 SetMagnifierType(ash::MAGNIFIER_FULL);
224 SetFullScreenMagnifierScale(2.5); 225 SetFullScreenMagnifierScale(2.5);
225 EXPECT_TRUE(IsMagnifierEnabled()); 226 EXPECT_TRUE(IsMagnifierEnabled());
226 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 227 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
227 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); 228 EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
228 229
229 // Logs in (but the session is not started yet). 230 // Logs in (but the session is not started yet).
230 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 231 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
231 kTestUserName, true); 232 kTestUserName, true);
232 233
233 // Confirms that magnifier is keeping enabled. 234 // Confirms that magnifier is keeping enabled.
234 EXPECT_TRUE(IsMagnifierEnabled()); 235 EXPECT_TRUE(IsMagnifierEnabled());
235 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 236 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
236 237
237 user_manager::UserManager::Get()->SessionStarted(); 238 user_manager::UserManager::Get()->SessionStarted();
238 239
239 // Confirms that magnifier is disabled just after session start. 240 // Confirms that magnifier is disabled just after session start.
240 EXPECT_FALSE(IsMagnifierEnabled()); 241 EXPECT_FALSE(IsMagnifierEnabled());
241 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref()); 242 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref());
242 } 243 }
243 244
244 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginOffToFull) { 245 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginOffToFull) {
245 // Create a new profile once, to run the test with non-new profile. 246 // Create a new profile once, to run the test with non-new profile.
246 PrepareNonNewProfile(test_account_id_); 247 PrepareNonNewProfile(test_account_id_);
247 248
248 // Sets prefs to explicitly enable the magnifier. 249 // Sets prefs to explicitly enable the magnifier.
249 SetScreenMagnifierEnabledPref(true); 250 SetScreenMagnifierEnabledPref(true);
250 SetScreenMagnifierTypePref(ui::MAGNIFIER_FULL); 251 SetScreenMagnifierTypePref(ash::MAGNIFIER_FULL);
251 SetFullScreenMagnifierScalePref(2.5); 252 SetFullScreenMagnifierScalePref(2.5);
252 } 253 }
253 254
254 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginOffToFull) { 255 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginOffToFull) {
255 // Disables magnifier on login screen. 256 // Disables magnifier on login screen.
256 SetMagnifierEnabled(false); 257 SetMagnifierEnabled(false);
257 EXPECT_FALSE(IsMagnifierEnabled()); 258 EXPECT_FALSE(IsMagnifierEnabled());
258 259
259 // Logs in (but the session is not started yet). 260 // Logs in (but the session is not started yet).
260 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 261 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
261 kTestUserName, true); 262 kTestUserName, true);
262 263
263 // Confirms that magnifier is keeping disabled. 264 // Confirms that magnifier is keeping disabled.
264 EXPECT_FALSE(IsMagnifierEnabled()); 265 EXPECT_FALSE(IsMagnifierEnabled());
265 266
266 user_manager::UserManager::Get()->SessionStarted(); 267 user_manager::UserManager::Get()->SessionStarted();
267 268
268 // Confirms that the magnifier is enabled and configured according to the 269 // Confirms that the magnifier is enabled and configured according to the
269 // explicitly set prefs just after session start. 270 // explicitly set prefs just after session start.
270 EXPECT_TRUE(IsMagnifierEnabled()); 271 EXPECT_TRUE(IsMagnifierEnabled());
271 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 272 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
272 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); 273 EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
273 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref()); 274 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref());
274 } 275 }
275 276
276 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginFullToFull) { 277 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginFullToFull) {
277 // Create a new profile once, to run the test with non-new profile. 278 // Create a new profile once, to run the test with non-new profile.
278 PrepareNonNewProfile(test_account_id_); 279 PrepareNonNewProfile(test_account_id_);
279 280
280 // Sets prefs to explicitly enable the magnifier. 281 // Sets prefs to explicitly enable the magnifier.
281 SetScreenMagnifierEnabledPref(true); 282 SetScreenMagnifierEnabledPref(true);
282 SetScreenMagnifierTypePref(ui::MAGNIFIER_FULL); 283 SetScreenMagnifierTypePref(ash::MAGNIFIER_FULL);
283 SetFullScreenMagnifierScalePref(2.5); 284 SetFullScreenMagnifierScalePref(2.5);
284 } 285 }
285 286
286 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToFull) { 287 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToFull) {
287 // Enables magnifier on login screen. 288 // Enables magnifier on login screen.
288 SetMagnifierType(ui::MAGNIFIER_FULL); 289 SetMagnifierType(ash::MAGNIFIER_FULL);
289 SetMagnifierEnabled(true); 290 SetMagnifierEnabled(true);
290 SetFullScreenMagnifierScale(3.0); 291 SetFullScreenMagnifierScale(3.0);
291 EXPECT_TRUE(IsMagnifierEnabled()); 292 EXPECT_TRUE(IsMagnifierEnabled());
292 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 293 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
293 EXPECT_EQ(3.0, GetFullScreenMagnifierScale()); 294 EXPECT_EQ(3.0, GetFullScreenMagnifierScale());
294 295
295 // Logs in (but the session is not started yet). 296 // Logs in (but the session is not started yet).
296 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 297 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
297 kTestUserName, true); 298 kTestUserName, true);
298 299
299 // Confirms that magnifier is keeping enabled. 300 // Confirms that magnifier is keeping enabled.
300 EXPECT_TRUE(IsMagnifierEnabled()); 301 EXPECT_TRUE(IsMagnifierEnabled());
301 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 302 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
302 303
303 user_manager::UserManager::Get()->SessionStarted(); 304 user_manager::UserManager::Get()->SessionStarted();
304 305
305 // Confirms that the magnifier is enabled and configured according to the 306 // Confirms that the magnifier is enabled and configured according to the
306 // explicitly set prefs just after session start. 307 // explicitly set prefs just after session start.
307 EXPECT_TRUE(IsMagnifierEnabled()); 308 EXPECT_TRUE(IsMagnifierEnabled());
308 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 309 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
309 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); 310 EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
310 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref()); 311 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref());
311 } 312 }
312 313
313 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginFullToUnset) { 314 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginFullToUnset) {
314 // Creates a new profile once, to run the test with non-new profile. 315 // Creates a new profile once, to run the test with non-new profile.
315 PrepareNonNewProfile(test_account_id_); 316 PrepareNonNewProfile(test_account_id_);
316 } 317 }
317 318
318 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToUnset) { 319 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToUnset) {
319 // Enables full screen magnifier. 320 // Enables full screen magnifier.
320 SetMagnifierType(ui::MAGNIFIER_FULL); 321 SetMagnifierType(ash::MAGNIFIER_FULL);
321 SetMagnifierEnabled(true); 322 SetMagnifierEnabled(true);
322 EXPECT_TRUE(IsMagnifierEnabled()); 323 EXPECT_TRUE(IsMagnifierEnabled());
323 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 324 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
324 325
325 // Logs in (but the session is not started yet). 326 // Logs in (but the session is not started yet).
326 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 327 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
327 kTestUserName, true); 328 kTestUserName, true);
328 329
329 // Confirms that magnifier is keeping enabled. 330 // Confirms that magnifier is keeping enabled.
330 EXPECT_TRUE(IsMagnifierEnabled()); 331 EXPECT_TRUE(IsMagnifierEnabled());
331 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 332 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
332 333
333 user_manager::UserManager::Get()->SessionStarted(); 334 user_manager::UserManager::Get()->SessionStarted();
334 335
335 // Confirms that magnifier is disabled. 336 // Confirms that magnifier is disabled.
336 EXPECT_FALSE(IsMagnifierEnabled()); 337 EXPECT_FALSE(IsMagnifierEnabled());
337 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref()); 338 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref());
338 } 339 }
339 340
340 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserOff) { 341 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserOff) {
341 // Confirms that magnifier is disabled on the login screen. 342 // Confirms that magnifier is disabled on the login screen.
(...skipping 11 matching lines...) Expand all
353 354
354 user_manager::UserManager::Get()->SessionStarted(); 355 user_manager::UserManager::Get()->SessionStarted();
355 356
356 // Confirms that magnifier is keeping disabled. 357 // Confirms that magnifier is keeping disabled.
357 EXPECT_FALSE(IsMagnifierEnabled()); 358 EXPECT_FALSE(IsMagnifierEnabled());
358 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref()); 359 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref());
359 } 360 }
360 361
361 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserFull) { 362 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserFull) {
362 // Enables magnifier on login screen. 363 // Enables magnifier on login screen.
363 SetMagnifierType(ui::MAGNIFIER_FULL); 364 SetMagnifierType(ash::MAGNIFIER_FULL);
364 SetMagnifierEnabled(true); 365 SetMagnifierEnabled(true);
365 SetFullScreenMagnifierScale(2.5); 366 SetFullScreenMagnifierScale(2.5);
366 EXPECT_TRUE(IsMagnifierEnabled()); 367 EXPECT_TRUE(IsMagnifierEnabled());
367 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 368 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
368 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); 369 EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
369 370
370 // Logs in (but the session is not started yet). 371 // Logs in (but the session is not started yet).
371 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 372 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
372 kTestUserName, true); 373 kTestUserName, true);
373 374
374 // Confirms that magnifier is keeping enabled. 375 // Confirms that magnifier is keeping enabled.
375 EXPECT_TRUE(IsMagnifierEnabled()); 376 EXPECT_TRUE(IsMagnifierEnabled());
376 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 377 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
377 378
378 user_manager::UserManager::Get()->SessionStarted(); 379 user_manager::UserManager::Get()->SessionStarted();
379 380
380 // Confirms that magnifier keeps enabled. 381 // Confirms that magnifier keeps enabled.
381 EXPECT_TRUE(IsMagnifierEnabled()); 382 EXPECT_TRUE(IsMagnifierEnabled());
382 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 383 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
383 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); 384 EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
384 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref()); 385 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref());
385 } 386 }
386 387
387 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserUnset) { 388 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserUnset) {
388 // Confirms that magnifier is disabled on the login screen. 389 // Confirms that magnifier is disabled on the login screen.
389 EXPECT_FALSE(IsMagnifierEnabled()); 390 EXPECT_FALSE(IsMagnifierEnabled());
390 391
391 // Logs in (but the session is not started yet). 392 // Logs in (but the session is not started yet).
392 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 393 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
393 kTestUserName, true); 394 kTestUserName, true);
394 395
395 // Confirms that magnifier is keeping disabled. 396 // Confirms that magnifier is keeping disabled.
396 EXPECT_FALSE(IsMagnifierEnabled()); 397 EXPECT_FALSE(IsMagnifierEnabled());
397 398
398 user_manager::UserManager::Get()->SessionStarted(); 399 user_manager::UserManager::Get()->SessionStarted();
399 400
400 // Confirms that magnifier is keeping disabled. 401 // Confirms that magnifier is keeping disabled.
401 EXPECT_FALSE(IsMagnifierEnabled()); 402 EXPECT_FALSE(IsMagnifierEnabled());
402 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref()); 403 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref());
403 } 404 }
404 405
405 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ChangeMagnifierType) { 406 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ChangeMagnifierType) {
406 // Enables/disables full screen magnifier. 407 // Enables/disables full screen magnifier.
407 SetMagnifierEnabled(false); 408 SetMagnifierEnabled(false);
408 SetMagnifierType(ui::MAGNIFIER_FULL); 409 SetMagnifierType(ash::MAGNIFIER_FULL);
409 EXPECT_FALSE(IsMagnifierEnabled()); 410 EXPECT_FALSE(IsMagnifierEnabled());
410 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 411 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
411 412
412 SetMagnifierEnabled(true); 413 SetMagnifierEnabled(true);
413 EXPECT_TRUE(IsMagnifierEnabled()); 414 EXPECT_TRUE(IsMagnifierEnabled());
414 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 415 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
415 416
416 SetMagnifierEnabled(false); 417 SetMagnifierEnabled(false);
417 EXPECT_FALSE(IsMagnifierEnabled()); 418 EXPECT_FALSE(IsMagnifierEnabled());
418 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 419 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
419 420
420 // Enables/disables partial screen magnifier. 421 // Enables/disables partial screen magnifier.
421 SetMagnifierType(ui::MAGNIFIER_PARTIAL); 422 SetMagnifierType(ash::MAGNIFIER_PARTIAL);
422 EXPECT_FALSE(IsMagnifierEnabled()); 423 EXPECT_FALSE(IsMagnifierEnabled());
423 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 424 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
424 425
425 SetMagnifierEnabled(true); 426 SetMagnifierEnabled(true);
426 EXPECT_TRUE(IsMagnifierEnabled()); 427 EXPECT_TRUE(IsMagnifierEnabled());
427 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 428 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
428 429
429 SetMagnifierEnabled(false); 430 SetMagnifierEnabled(false);
430 EXPECT_FALSE(IsMagnifierEnabled()); 431 EXPECT_FALSE(IsMagnifierEnabled());
431 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 432 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
432 433
433 // Changes the magnifier type when the magnifier is enabled. 434 // Changes the magnifier type when the magnifier is enabled.
434 SetMagnifierType(ui::MAGNIFIER_FULL); 435 SetMagnifierType(ash::MAGNIFIER_FULL);
435 SetMagnifierEnabled(true); 436 SetMagnifierEnabled(true);
436 EXPECT_TRUE(IsMagnifierEnabled()); 437 EXPECT_TRUE(IsMagnifierEnabled());
437 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 438 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
438 439
439 SetMagnifierType(ui::MAGNIFIER_PARTIAL); 440 SetMagnifierType(ash::MAGNIFIER_PARTIAL);
440 EXPECT_TRUE(IsMagnifierEnabled()); 441 EXPECT_TRUE(IsMagnifierEnabled());
441 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 442 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
442 443
443 SetMagnifierType(ui::MAGNIFIER_FULL); 444 SetMagnifierType(ash::MAGNIFIER_FULL);
444 EXPECT_TRUE(IsMagnifierEnabled()); 445 EXPECT_TRUE(IsMagnifierEnabled());
445 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 446 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
446 447
447 // Changes the magnifier type when the magnifier is disabled. 448 // Changes the magnifier type when the magnifier is disabled.
448 SetMagnifierEnabled(false); 449 SetMagnifierEnabled(false);
449 SetMagnifierType(ui::MAGNIFIER_FULL); 450 SetMagnifierType(ash::MAGNIFIER_FULL);
450 EXPECT_FALSE(IsMagnifierEnabled()); 451 EXPECT_FALSE(IsMagnifierEnabled());
451 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 452 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
452 453
453 SetMagnifierType(ui::MAGNIFIER_PARTIAL); 454 SetMagnifierType(ash::MAGNIFIER_PARTIAL);
454 EXPECT_FALSE(IsMagnifierEnabled()); 455 EXPECT_FALSE(IsMagnifierEnabled());
455 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 456 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
456 457
457 SetMagnifierType(ui::MAGNIFIER_FULL); 458 SetMagnifierType(ash::MAGNIFIER_FULL);
458 EXPECT_FALSE(IsMagnifierEnabled()); 459 EXPECT_FALSE(IsMagnifierEnabled());
459 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 460 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
460 } 461 }
461 462
462 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, TypePref) { 463 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, TypePref) {
463 // Logs in 464 // Logs in
464 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 465 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
465 kTestUserName, true); 466 kTestUserName, true);
466 user_manager::UserManager::Get()->SessionStarted(); 467 user_manager::UserManager::Get()->SessionStarted();
467 468
468 // Confirms that magnifier is disabled just after login. 469 // Confirms that magnifier is disabled just after login.
469 EXPECT_FALSE(IsMagnifierEnabled()); 470 EXPECT_FALSE(IsMagnifierEnabled());
470 471
471 // Sets the pref as true to enable magnifier. 472 // Sets the pref as true to enable magnifier.
472 SetScreenMagnifierTypePref(ui::MAGNIFIER_FULL); 473 SetScreenMagnifierTypePref(ash::MAGNIFIER_FULL);
473 SetScreenMagnifierEnabledPref(true); 474 SetScreenMagnifierEnabledPref(true);
474 // Confirms that magnifier is enabled. 475 // Confirms that magnifier is enabled.
475 EXPECT_TRUE(IsMagnifierEnabled()); 476 EXPECT_TRUE(IsMagnifierEnabled());
476 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 477 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
477 } 478 }
478 479
479 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ScalePref) { 480 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ScalePref) {
480 SetMagnifierEnabled(false); 481 SetMagnifierEnabled(false);
481 EXPECT_FALSE(IsMagnifierEnabled()); 482 EXPECT_FALSE(IsMagnifierEnabled());
482 483
483 // Sets 2.5x to the pref. 484 // Sets 2.5x to the pref.
484 SetSavedFullScreenMagnifierScale(2.5); 485 SetSavedFullScreenMagnifierScale(2.5);
485 486
486 // Enables full screen magnifier. 487 // Enables full screen magnifier.
487 SetMagnifierType(ui::MAGNIFIER_FULL); 488 SetMagnifierType(ash::MAGNIFIER_FULL);
488 SetMagnifierEnabled(true); 489 SetMagnifierEnabled(true);
489 EXPECT_TRUE(IsMagnifierEnabled()); 490 EXPECT_TRUE(IsMagnifierEnabled());
490 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 491 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
491 492
492 // Confirms that 2.5x is restored. 493 // Confirms that 2.5x is restored.
493 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); 494 EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
494 495
495 // Sets the scale and confirms that the scale is saved to pref. 496 // Sets the scale and confirms that the scale is saved to pref.
496 SetFullScreenMagnifierScale(3.0); 497 SetFullScreenMagnifierScale(3.0);
497 EXPECT_EQ(3.0, GetSavedFullScreenMagnifierScale()); 498 EXPECT_EQ(3.0, GetSavedFullScreenMagnifierScale());
498 } 499 }
499 500
500 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, InvalidScalePref) { 501 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, InvalidScalePref) {
501 // TEST 1: Sets too small scale 502 // TEST 1: Sets too small scale
502 SetMagnifierEnabled(false); 503 SetMagnifierEnabled(false);
503 EXPECT_FALSE(IsMagnifierEnabled()); 504 EXPECT_FALSE(IsMagnifierEnabled());
504 505
505 // Sets too small value to the pref. 506 // Sets too small value to the pref.
506 SetSavedFullScreenMagnifierScale(0.5); 507 SetSavedFullScreenMagnifierScale(0.5);
507 508
508 // Enables full screen magnifier. 509 // Enables full screen magnifier.
509 SetMagnifierType(ui::MAGNIFIER_FULL); 510 SetMagnifierType(ash::MAGNIFIER_FULL);
510 SetMagnifierEnabled(true); 511 SetMagnifierEnabled(true);
511 EXPECT_TRUE(IsMagnifierEnabled()); 512 EXPECT_TRUE(IsMagnifierEnabled());
512 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 513 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
513 514
514 // Confirms that the actual scale is set to the minimum scale. 515 // Confirms that the actual scale is set to the minimum scale.
515 EXPECT_EQ(1.0, GetFullScreenMagnifierScale()); 516 EXPECT_EQ(1.0, GetFullScreenMagnifierScale());
516 517
517 // TEST 2: Sets too large scale 518 // TEST 2: Sets too large scale
518 SetMagnifierEnabled(false); 519 SetMagnifierEnabled(false);
519 EXPECT_FALSE(IsMagnifierEnabled()); 520 EXPECT_FALSE(IsMagnifierEnabled());
520 521
521 // Sets too large value to the pref. 522 // Sets too large value to the pref.
522 SetSavedFullScreenMagnifierScale(50.0); 523 SetSavedFullScreenMagnifierScale(50.0);
523 524
524 // Enables full screen magnifier. 525 // Enables full screen magnifier.
525 SetMagnifierEnabled(true); 526 SetMagnifierEnabled(true);
526 EXPECT_TRUE(IsMagnifierEnabled()); 527 EXPECT_TRUE(IsMagnifierEnabled());
527 EXPECT_EQ(ui::MAGNIFIER_FULL, GetMagnifierType()); 528 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
528 529
529 // Confirms that the actual scale is set to the maximum scale. 530 // Confirms that the actual scale is set to the maximum scale.
530 EXPECT_EQ(4.0, GetFullScreenMagnifierScale()); 531 EXPECT_EQ(4.0, GetFullScreenMagnifierScale());
531 } 532 }
532 533
533 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, 534 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest,
534 ChangingTypeInvokesNotification) { 535 ChangingTypeInvokesNotification) {
535 MockMagnificationObserver observer; 536 MockMagnificationObserver observer;
536 537
537 EXPECT_FALSE(observer.observed()); 538 EXPECT_FALSE(observer.observed());
538 539
539 // Set full screen magnifier, and confirm the observer is called. 540 // Set full screen magnifier, and confirm the observer is called.
540 SetMagnifierEnabled(true); 541 SetMagnifierEnabled(true);
541 SetMagnifierType(ui::MAGNIFIER_FULL); 542 SetMagnifierType(ash::MAGNIFIER_FULL);
542 EXPECT_TRUE(observer.observed()); 543 EXPECT_TRUE(observer.observed());
543 EXPECT_TRUE(observer.observed_enabled()); 544 EXPECT_TRUE(observer.observed_enabled());
544 EXPECT_EQ(observer.magnifier_type(), ui::MAGNIFIER_FULL); 545 EXPECT_EQ(observer.magnifier_type(), ash::MAGNIFIER_FULL);
545 EXPECT_EQ(GetMagnifierType(), ui::MAGNIFIER_FULL); 546 EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL);
546 observer.reset(); 547 observer.reset();
547 548
548 // Set full screen magnifier again, and confirm the observer is not called. 549 // Set full screen magnifier again, and confirm the observer is not called.
549 SetMagnifierType(ui::MAGNIFIER_FULL); 550 SetMagnifierType(ash::MAGNIFIER_FULL);
550 EXPECT_FALSE(observer.observed()); 551 EXPECT_FALSE(observer.observed());
551 EXPECT_EQ(GetMagnifierType(), ui::MAGNIFIER_FULL); 552 EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL);
552 observer.reset(); 553 observer.reset();
553 } 554 }
554 555
555 } // namespace chromeos 556 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698