| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/chromeos/login/login_manager_test.h" | 9 #include "chrome/browser/chromeos/login/login_manager_test.h" |
| 10 #include "chrome/browser/chromeos/login/startup_utils.h" | 10 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 11 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 11 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 12 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
| 13 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 12 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 14 #include "chrome/browser/chromeos/settings/cros_settings.h" | 13 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 15 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | 14 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
| 16 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
| 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 21 #include "chromeos/settings/cros_settings_names.h" | 20 #include "chromeos/settings/cros_settings_names.h" |
| 21 #include "components/user_manager/user_manager.h" |
| 22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
| 24 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
| 25 | 25 |
| 26 namespace chromeos { | 26 namespace chromeos { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 const char* kTestOwner = "test-owner@example.com"; | 30 const char* kTestOwner = "test-owner@example.com"; |
| 31 const char* kTestNonOwner = "test-user1@example.com"; | 31 const char* kTestNonOwner = "test-user1@example.com"; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 StartupUtils::MarkOobeCompleted(); | 266 StartupUtils::MarkOobeCompleted(); |
| 267 } | 267 } |
| 268 | 268 |
| 269 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, SharedOptions) { | 269 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, SharedOptions) { |
| 270 // Log in the owner first, then add a secondary user. | 270 // Log in the owner first, then add a secondary user. |
| 271 LoginUser(kTestOwner); | 271 LoginUser(kTestOwner); |
| 272 UserAddingScreen::Get()->Start(); | 272 UserAddingScreen::Get()->Start(); |
| 273 content::RunAllPendingInMessageLoop(); | 273 content::RunAllPendingInMessageLoop(); |
| 274 AddUser(kTestNonOwner); | 274 AddUser(kTestNonOwner); |
| 275 | 275 |
| 276 UserManager* manager = UserManager::Get(); | 276 user_manager::UserManager* manager = user_manager::UserManager::Get(); |
| 277 ASSERT_EQ(2u, manager->GetLoggedInUsers().size()); | 277 ASSERT_EQ(2u, manager->GetLoggedInUsers().size()); |
| 278 { | 278 { |
| 279 SCOPED_TRACE("Checking settings for owner, primary user."); | 279 SCOPED_TRACE("Checking settings for owner, primary user."); |
| 280 CheckOptionsUI(manager->FindUser(manager->GetOwnerEmail()), true, true); | 280 CheckOptionsUI(manager->FindUser(manager->GetOwnerEmail()), true, true); |
| 281 } | 281 } |
| 282 { | 282 { |
| 283 SCOPED_TRACE("Checking settings for non-owner, secondary user."); | 283 SCOPED_TRACE("Checking settings for non-owner, secondary user."); |
| 284 CheckOptionsUI(manager->FindUser(kTestNonOwner), false, false); | 284 CheckOptionsUI(manager->FindUser(kTestNonOwner), false, false); |
| 285 } | 285 } |
| 286 // TODO(michaelpg): Add tests for non-primary owner and primary non-owner | 286 // TODO(michaelpg): Add tests for non-primary owner and primary non-owner |
| (...skipping 10 matching lines...) Expand all Loading... |
| 297 // when the secondary user has enabled or disabled their preference. | 297 // when the secondary user has enabled or disabled their preference. |
| 298 // (The checkbox is unset if the current user's preference is false, but if any | 298 // (The checkbox is unset if the current user's preference is false, but if any |
| 299 // other signed-in user has enabled this preference, the shared setting | 299 // other signed-in user has enabled this preference, the shared setting |
| 300 // indicator explains this.) | 300 // indicator explains this.) |
| 301 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, ScreenLockPreferencePrimary) { | 301 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, ScreenLockPreferencePrimary) { |
| 302 LoginUser(kTestOwner); | 302 LoginUser(kTestOwner); |
| 303 UserAddingScreen::Get()->Start(); | 303 UserAddingScreen::Get()->Start(); |
| 304 content::RunAllPendingInMessageLoop(); | 304 content::RunAllPendingInMessageLoop(); |
| 305 AddUser(kTestNonOwner); | 305 AddUser(kTestNonOwner); |
| 306 | 306 |
| 307 UserManager* manager = UserManager::Get(); | 307 user_manager::UserManager* manager = user_manager::UserManager::Get(); |
| 308 const user_manager::User* user1 = manager->FindUser(kTestOwner); | 308 const user_manager::User* user1 = manager->FindUser(kTestOwner); |
| 309 const user_manager::User* user2 = manager->FindUser(kTestNonOwner); | 309 const user_manager::User* user2 = manager->FindUser(kTestNonOwner); |
| 310 | 310 |
| 311 PrefService* prefs1 = | 311 PrefService* prefs1 = |
| 312 ProfileHelper::Get()->GetProfileByUserUnsafe(user1)->GetPrefs(); | 312 ProfileHelper::Get()->GetProfileByUserUnsafe(user1)->GetPrefs(); |
| 313 PrefService* prefs2 = | 313 PrefService* prefs2 = |
| 314 ProfileHelper::Get()->GetProfileByUserUnsafe(user2)->GetPrefs(); | 314 ProfileHelper::Get()->GetProfileByUserUnsafe(user2)->GetPrefs(); |
| 315 | 315 |
| 316 // Set both users' preference to false, then change the secondary user's to | 316 // Set both users' preference to false, then change the secondary user's to |
| 317 // true. We'll do the opposite in the next test. Doesn't provide 100% coverage | 317 // true. We'll do the opposite in the next test. Doesn't provide 100% coverage |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 // when the primary user has enabled or disabled their preference. | 368 // when the primary user has enabled or disabled their preference. |
| 369 // (The checkbox is unset if the current user's preference is false, but if any | 369 // (The checkbox is unset if the current user's preference is false, but if any |
| 370 // other signed-in user has enabled this preference, the shared setting | 370 // other signed-in user has enabled this preference, the shared setting |
| 371 // indicator explains this.) | 371 // indicator explains this.) |
| 372 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, ScreenLockPreferenceSecondary) { | 372 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, ScreenLockPreferenceSecondary) { |
| 373 LoginUser(kTestOwner); | 373 LoginUser(kTestOwner); |
| 374 UserAddingScreen::Get()->Start(); | 374 UserAddingScreen::Get()->Start(); |
| 375 content::RunAllPendingInMessageLoop(); | 375 content::RunAllPendingInMessageLoop(); |
| 376 AddUser(kTestNonOwner); | 376 AddUser(kTestNonOwner); |
| 377 | 377 |
| 378 UserManager* manager = UserManager::Get(); | 378 user_manager::UserManager* manager = user_manager::UserManager::Get(); |
| 379 const user_manager::User* user1 = manager->FindUser(kTestOwner); | 379 const user_manager::User* user1 = manager->FindUser(kTestOwner); |
| 380 const user_manager::User* user2 = manager->FindUser(kTestNonOwner); | 380 const user_manager::User* user2 = manager->FindUser(kTestNonOwner); |
| 381 | 381 |
| 382 PrefService* prefs1 = | 382 PrefService* prefs1 = |
| 383 ProfileHelper::Get()->GetProfileByUserUnsafe(user1)->GetPrefs(); | 383 ProfileHelper::Get()->GetProfileByUserUnsafe(user1)->GetPrefs(); |
| 384 PrefService* prefs2 = | 384 PrefService* prefs2 = |
| 385 ProfileHelper::Get()->GetProfileByUserUnsafe(user2)->GetPrefs(); | 385 ProfileHelper::Get()->GetProfileByUserUnsafe(user2)->GetPrefs(); |
| 386 | 386 |
| 387 // Set both users' preference to true, then change the secondary user's to | 387 // Set both users' preference to true, then change the secondary user's to |
| 388 // false. | 388 // false. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 content::WaitForLoadStop(contents); | 422 content::WaitForLoadStop(contents); |
| 423 { | 423 { |
| 424 SCOPED_TRACE("Screen lock false for both users"); | 424 SCOPED_TRACE("Screen lock false for both users"); |
| 425 expected_value = false; | 425 expected_value = false; |
| 426 CheckBooleanPreference(contents, prefs::kEnableAutoScreenLock, disabled, | 426 CheckBooleanPreference(contents, prefs::kEnableAutoScreenLock, disabled, |
| 427 empty_controlled, expected_value); | 427 empty_controlled, expected_value); |
| 428 } | 428 } |
| 429 } | 429 } |
| 430 | 430 |
| 431 } // namespace chromeos | 431 } // namespace chromeos |
| OLD | NEW |