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

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

Issue 2438063002: user_manager: Remove deps on session_manager (Closed)
Patch Set: fix nits in PS1 Created 4 years, 1 month 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/common/accessibility_types.h"
8 #include "ash/magnifier/magnification_controller.h" 8 #include "ash/magnifier/magnification_controller.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 14 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
15 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 15 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
16 #include "chrome/browser/chromeos/login/helper.h" 16 #include "chrome/browser/chromeos/login/helper.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_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
21 #include "chrome/test/base/in_process_browser_test.h" 21 #include "chrome/test/base/in_process_browser_test.h"
22 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
23 #include "chromeos/chromeos_switches.h" 23 #include "chromeos/chromeos_switches.h"
24 #include "components/prefs/pref_service.h" 24 #include "components/prefs/pref_service.h"
25 #include "components/session_manager/core/session_manager.h"
25 #include "components/user_manager/user_manager.h" 26 #include "components/user_manager/user_manager.h"
26 #include "components/user_prefs/user_prefs.h" 27 #include "components/user_prefs/user_prefs.h"
27 #include "content/public/browser/notification_details.h" 28 #include "content/public/browser/notification_details.h"
28 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
29 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
30 31
31 namespace chromeos { 32 namespace chromeos {
32 33
33 namespace { 34 namespace {
34 35
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 SetMagnifierEnabled(false); 188 SetMagnifierEnabled(false);
188 EXPECT_FALSE(IsMagnifierEnabled()); 189 EXPECT_FALSE(IsMagnifierEnabled());
189 190
190 // Logs in with existing profile. 191 // Logs in with existing profile.
191 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 192 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
192 kTestUserName, true); 193 kTestUserName, true);
193 194
194 // Confirms that magnifier is still disabled just after login. 195 // Confirms that magnifier is still disabled just after login.
195 EXPECT_FALSE(IsMagnifierEnabled()); 196 EXPECT_FALSE(IsMagnifierEnabled());
196 197
197 user_manager::UserManager::Get()->SessionStarted(); 198 session_manager::SessionManager::Get()->SessionStarted();
198 199
199 // Confirms that magnifier is still disabled just after session starts. 200 // Confirms that magnifier is still disabled just after session starts.
200 EXPECT_FALSE(IsMagnifierEnabled()); 201 EXPECT_FALSE(IsMagnifierEnabled());
201 202
202 // Enables magnifier. 203 // Enables magnifier.
203 SetMagnifierEnabled(true); 204 SetMagnifierEnabled(true);
204 // Confirms that magnifier is enabled. 205 // Confirms that magnifier is enabled.
205 EXPECT_TRUE(IsMagnifierEnabled()); 206 EXPECT_TRUE(IsMagnifierEnabled());
206 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); 207 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
207 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref()); 208 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref());
(...skipping 20 matching lines...) Expand all
228 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); 229 EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
229 230
230 // Logs in (but the session is not started yet). 231 // Logs in (but the session is not started yet).
231 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 232 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
232 kTestUserName, true); 233 kTestUserName, true);
233 234
234 // Confirms that magnifier is keeping enabled. 235 // Confirms that magnifier is keeping enabled.
235 EXPECT_TRUE(IsMagnifierEnabled()); 236 EXPECT_TRUE(IsMagnifierEnabled());
236 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); 237 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
237 238
238 user_manager::UserManager::Get()->SessionStarted(); 239 session_manager::SessionManager::Get()->SessionStarted();
239 240
240 // Confirms that magnifier is disabled just after session start. 241 // Confirms that magnifier is disabled just after session start.
241 EXPECT_FALSE(IsMagnifierEnabled()); 242 EXPECT_FALSE(IsMagnifierEnabled());
242 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref()); 243 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref());
243 } 244 }
244 245
245 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginOffToFull) { 246 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginOffToFull) {
246 // Create a new profile once, to run the test with non-new profile. 247 // Create a new profile once, to run the test with non-new profile.
247 PrepareNonNewProfile(test_account_id_); 248 PrepareNonNewProfile(test_account_id_);
248 249
249 // Sets prefs to explicitly enable the magnifier. 250 // Sets prefs to explicitly enable the magnifier.
250 SetScreenMagnifierEnabledPref(true); 251 SetScreenMagnifierEnabledPref(true);
251 SetScreenMagnifierTypePref(ash::MAGNIFIER_FULL); 252 SetScreenMagnifierTypePref(ash::MAGNIFIER_FULL);
252 SetFullScreenMagnifierScalePref(2.5); 253 SetFullScreenMagnifierScalePref(2.5);
253 } 254 }
254 255
255 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginOffToFull) { 256 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginOffToFull) {
256 // Disables magnifier on login screen. 257 // Disables magnifier on login screen.
257 SetMagnifierEnabled(false); 258 SetMagnifierEnabled(false);
258 EXPECT_FALSE(IsMagnifierEnabled()); 259 EXPECT_FALSE(IsMagnifierEnabled());
259 260
260 // Logs in (but the session is not started yet). 261 // Logs in (but the session is not started yet).
261 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 262 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
262 kTestUserName, true); 263 kTestUserName, true);
263 264
264 // Confirms that magnifier is keeping disabled. 265 // Confirms that magnifier is keeping disabled.
265 EXPECT_FALSE(IsMagnifierEnabled()); 266 EXPECT_FALSE(IsMagnifierEnabled());
266 267
267 user_manager::UserManager::Get()->SessionStarted(); 268 session_manager::SessionManager::Get()->SessionStarted();
268 269
269 // Confirms that the magnifier is enabled and configured according to the 270 // Confirms that the magnifier is enabled and configured according to the
270 // explicitly set prefs just after session start. 271 // explicitly set prefs just after session start.
271 EXPECT_TRUE(IsMagnifierEnabled()); 272 EXPECT_TRUE(IsMagnifierEnabled());
272 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); 273 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
273 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); 274 EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
274 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref()); 275 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref());
275 } 276 }
276 277
277 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginFullToFull) { 278 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginFullToFull) {
(...skipping 16 matching lines...) Expand all
294 EXPECT_EQ(3.0, GetFullScreenMagnifierScale()); 295 EXPECT_EQ(3.0, GetFullScreenMagnifierScale());
295 296
296 // Logs in (but the session is not started yet). 297 // Logs in (but the session is not started yet).
297 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 298 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
298 kTestUserName, true); 299 kTestUserName, true);
299 300
300 // Confirms that magnifier is keeping enabled. 301 // Confirms that magnifier is keeping enabled.
301 EXPECT_TRUE(IsMagnifierEnabled()); 302 EXPECT_TRUE(IsMagnifierEnabled());
302 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); 303 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
303 304
304 user_manager::UserManager::Get()->SessionStarted(); 305 session_manager::SessionManager::Get()->SessionStarted();
305 306
306 // Confirms that the magnifier is enabled and configured according to the 307 // Confirms that the magnifier is enabled and configured according to the
307 // explicitly set prefs just after session start. 308 // explicitly set prefs just after session start.
308 EXPECT_TRUE(IsMagnifierEnabled()); 309 EXPECT_TRUE(IsMagnifierEnabled());
309 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); 310 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
310 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); 311 EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
311 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref()); 312 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref());
312 } 313 }
313 314
314 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginFullToUnset) { 315 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginFullToUnset) {
315 // Creates a new profile once, to run the test with non-new profile. 316 // Creates a new profile once, to run the test with non-new profile.
316 PrepareNonNewProfile(test_account_id_); 317 PrepareNonNewProfile(test_account_id_);
317 } 318 }
318 319
319 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToUnset) { 320 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToUnset) {
320 // Enables full screen magnifier. 321 // Enables full screen magnifier.
321 SetMagnifierType(ash::MAGNIFIER_FULL); 322 SetMagnifierType(ash::MAGNIFIER_FULL);
322 SetMagnifierEnabled(true); 323 SetMagnifierEnabled(true);
323 EXPECT_TRUE(IsMagnifierEnabled()); 324 EXPECT_TRUE(IsMagnifierEnabled());
324 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); 325 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
325 326
326 // Logs in (but the session is not started yet). 327 // Logs in (but the session is not started yet).
327 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 328 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
328 kTestUserName, true); 329 kTestUserName, true);
329 330
330 // Confirms that magnifier is keeping enabled. 331 // Confirms that magnifier is keeping enabled.
331 EXPECT_TRUE(IsMagnifierEnabled()); 332 EXPECT_TRUE(IsMagnifierEnabled());
332 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); 333 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
333 334
334 user_manager::UserManager::Get()->SessionStarted(); 335 session_manager::SessionManager::Get()->SessionStarted();
335 336
336 // Confirms that magnifier is disabled. 337 // Confirms that magnifier is disabled.
337 EXPECT_FALSE(IsMagnifierEnabled()); 338 EXPECT_FALSE(IsMagnifierEnabled());
338 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref()); 339 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref());
339 } 340 }
340 341
341 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserOff) { 342 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserOff) {
342 // Confirms that magnifier is disabled on the login screen. 343 // Confirms that magnifier is disabled on the login screen.
343 EXPECT_FALSE(IsMagnifierEnabled()); 344 EXPECT_FALSE(IsMagnifierEnabled());
344 345
345 // Disables magnifier on login screen explicitly. 346 // Disables magnifier on login screen explicitly.
346 SetMagnifierEnabled(false); 347 SetMagnifierEnabled(false);
347 348
348 // Logs in (but the session is not started yet). 349 // Logs in (but the session is not started yet).
349 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 350 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
350 kTestUserName, true); 351 kTestUserName, true);
351 352
352 // Confirms that magnifier is keeping disabled. 353 // Confirms that magnifier is keeping disabled.
353 EXPECT_FALSE(IsMagnifierEnabled()); 354 EXPECT_FALSE(IsMagnifierEnabled());
354 355
355 user_manager::UserManager::Get()->SessionStarted(); 356 session_manager::SessionManager::Get()->SessionStarted();
356 357
357 // Confirms that magnifier is keeping disabled. 358 // Confirms that magnifier is keeping disabled.
358 EXPECT_FALSE(IsMagnifierEnabled()); 359 EXPECT_FALSE(IsMagnifierEnabled());
359 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref()); 360 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref());
360 } 361 }
361 362
362 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserFull) { 363 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserFull) {
363 // Enables magnifier on login screen. 364 // Enables magnifier on login screen.
364 SetMagnifierType(ash::MAGNIFIER_FULL); 365 SetMagnifierType(ash::MAGNIFIER_FULL);
365 SetMagnifierEnabled(true); 366 SetMagnifierEnabled(true);
366 SetFullScreenMagnifierScale(2.5); 367 SetFullScreenMagnifierScale(2.5);
367 EXPECT_TRUE(IsMagnifierEnabled()); 368 EXPECT_TRUE(IsMagnifierEnabled());
368 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); 369 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
369 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); 370 EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
370 371
371 // Logs in (but the session is not started yet). 372 // Logs in (but the session is not started yet).
372 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 373 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
373 kTestUserName, true); 374 kTestUserName, true);
374 375
375 // Confirms that magnifier is keeping enabled. 376 // Confirms that magnifier is keeping enabled.
376 EXPECT_TRUE(IsMagnifierEnabled()); 377 EXPECT_TRUE(IsMagnifierEnabled());
377 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); 378 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
378 379
379 user_manager::UserManager::Get()->SessionStarted(); 380 session_manager::SessionManager::Get()->SessionStarted();
380 381
381 // Confirms that magnifier keeps enabled. 382 // Confirms that magnifier keeps enabled.
382 EXPECT_TRUE(IsMagnifierEnabled()); 383 EXPECT_TRUE(IsMagnifierEnabled());
383 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); 384 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
384 EXPECT_EQ(2.5, GetFullScreenMagnifierScale()); 385 EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
385 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref()); 386 EXPECT_TRUE(GetScreenMagnifierEnabledFromPref());
386 } 387 }
387 388
388 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserUnset) { 389 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserUnset) {
389 // Confirms that magnifier is disabled on the login screen. 390 // Confirms that magnifier is disabled on the login screen.
390 EXPECT_FALSE(IsMagnifierEnabled()); 391 EXPECT_FALSE(IsMagnifierEnabled());
391 392
392 // Logs in (but the session is not started yet). 393 // Logs in (but the session is not started yet).
393 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 394 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
394 kTestUserName, true); 395 kTestUserName, true);
395 396
396 // Confirms that magnifier is keeping disabled. 397 // Confirms that magnifier is keeping disabled.
397 EXPECT_FALSE(IsMagnifierEnabled()); 398 EXPECT_FALSE(IsMagnifierEnabled());
398 399
399 user_manager::UserManager::Get()->SessionStarted(); 400 session_manager::SessionManager::Get()->SessionStarted();
400 401
401 // Confirms that magnifier is keeping disabled. 402 // Confirms that magnifier is keeping disabled.
402 EXPECT_FALSE(IsMagnifierEnabled()); 403 EXPECT_FALSE(IsMagnifierEnabled());
403 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref()); 404 EXPECT_FALSE(GetScreenMagnifierEnabledFromPref());
404 } 405 }
405 406
406 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ChangeMagnifierType) { 407 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ChangeMagnifierType) {
407 // Enables/disables full screen magnifier. 408 // Enables/disables full screen magnifier.
408 SetMagnifierEnabled(false); 409 SetMagnifierEnabled(false);
409 SetMagnifierType(ash::MAGNIFIER_FULL); 410 SetMagnifierType(ash::MAGNIFIER_FULL);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 458
458 SetMagnifierType(ash::MAGNIFIER_FULL); 459 SetMagnifierType(ash::MAGNIFIER_FULL);
459 EXPECT_FALSE(IsMagnifierEnabled()); 460 EXPECT_FALSE(IsMagnifierEnabled());
460 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); 461 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
461 } 462 }
462 463
463 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, TypePref) { 464 IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, TypePref) {
464 // Logs in 465 // Logs in
465 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_, 466 user_manager::UserManager::Get()->UserLoggedIn(test_account_id_,
466 kTestUserName, true); 467 kTestUserName, true);
467 user_manager::UserManager::Get()->SessionStarted(); 468 session_manager::SessionManager::Get()->SessionStarted();
468 469
469 // Confirms that magnifier is disabled just after login. 470 // Confirms that magnifier is disabled just after login.
470 EXPECT_FALSE(IsMagnifierEnabled()); 471 EXPECT_FALSE(IsMagnifierEnabled());
471 472
472 // Sets the pref as true to enable magnifier. 473 // Sets the pref as true to enable magnifier.
473 SetScreenMagnifierTypePref(ash::MAGNIFIER_FULL); 474 SetScreenMagnifierTypePref(ash::MAGNIFIER_FULL);
474 SetScreenMagnifierEnabledPref(true); 475 SetScreenMagnifierEnabledPref(true);
475 // Confirms that magnifier is enabled. 476 // Confirms that magnifier is enabled.
476 EXPECT_TRUE(IsMagnifierEnabled()); 477 EXPECT_TRUE(IsMagnifierEnabled());
477 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType()); 478 EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 observer.reset(); 548 observer.reset();
548 549
549 // Set full screen magnifier again, and confirm the observer is not called. 550 // Set full screen magnifier again, and confirm the observer is not called.
550 SetMagnifierType(ash::MAGNIFIER_FULL); 551 SetMagnifierType(ash::MAGNIFIER_FULL);
551 EXPECT_FALSE(observer.observed()); 552 EXPECT_FALSE(observer.observed());
552 EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL); 553 EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL);
553 observer.reset(); 554 observer.reset();
554 } 555 }
555 556
556 } // namespace chromeos 557 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698