| 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" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 settings->AddSettingsProvider(device_settings_provider_); | 103 settings->AddSettingsProvider(device_settings_provider_); |
| 104 } | 104 } |
| 105 | 105 |
| 106 virtual void CleanUpOnMainThread() OVERRIDE { | 106 virtual void CleanUpOnMainThread() OVERRIDE { |
| 107 CrosSettings* settings = CrosSettings::Get(); | 107 CrosSettings* settings = CrosSettings::Get(); |
| 108 settings->RemoveSettingsProvider(&stub_settings_provider_); | 108 settings->RemoveSettingsProvider(&stub_settings_provider_); |
| 109 LoginManagerTest::CleanUpOnMainThread(); | 109 LoginManagerTest::CleanUpOnMainThread(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 protected: | 112 protected: |
| 113 void CheckOptionsUI(const User* user, bool is_owner, bool is_primary) { | 113 void CheckOptionsUI(const user_manager::User* user, |
| 114 bool is_owner, |
| 115 bool is_primary) { |
| 114 Browser* browser = CreateBrowserForUser(user); | 116 Browser* browser = CreateBrowserForUser(user); |
| 115 content::WebContents* contents = | 117 content::WebContents* contents = |
| 116 browser->tab_strip_model()->GetActiveWebContents(); | 118 browser->tab_strip_model()->GetActiveWebContents(); |
| 117 | 119 |
| 118 for (size_t i = 0; i < sizeof(kPrefTests) / sizeof(kPrefTests[0]); i++) { | 120 for (size_t i = 0; i < sizeof(kPrefTests) / sizeof(kPrefTests[0]); i++) { |
| 119 CheckPreference(contents, | 121 CheckPreference(contents, |
| 120 kPrefTests[i].pref_name, | 122 kPrefTests[i].pref_name, |
| 121 !is_owner && kPrefTests[i].owner_only, | 123 !is_owner && kPrefTests[i].owner_only, |
| 122 !is_owner && kPrefTests[i].indicator ? "owner" : | 124 !is_owner && kPrefTests[i].indicator ? "owner" : |
| 123 std::string()); | 125 std::string()); |
| 124 } | 126 } |
| 125 CheckBanner(contents, is_primary); | 127 CheckBanner(contents, is_primary); |
| 126 CheckSharedSections(contents, is_primary); | 128 CheckSharedSections(contents, is_primary); |
| 127 CheckAccountsOverlay(contents, is_owner); | 129 CheckAccountsOverlay(contents, is_owner); |
| 128 } | 130 } |
| 129 | 131 |
| 130 // Creates a browser and navigates to the Settings page. | 132 // Creates a browser and navigates to the Settings page. |
| 131 Browser* CreateBrowserForUser(const User* user) { | 133 Browser* CreateBrowserForUser(const user_manager::User* user) { |
| 132 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user); | 134 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user); |
| 133 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, | 135 profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, |
| 134 user->email()); | 136 user->email()); |
| 135 | 137 |
| 136 ui_test_utils::BrowserAddedObserver observer; | 138 ui_test_utils::BrowserAddedObserver observer; |
| 137 Browser* browser = CreateBrowser(profile); | 139 Browser* browser = CreateBrowser(profile); |
| 138 observer.WaitForSingleNewBrowser(); | 140 observer.WaitForSingleNewBrowser(); |
| 139 | 141 |
| 140 ui_test_utils::NavigateToURL(browser, | 142 ui_test_utils::NavigateToURL(browser, |
| 141 GURL("chrome://settings-frame")); | 143 GURL("chrome://settings-frame")); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // (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 |
| 297 // other signed-in user has enabled this preference, the shared setting | 299 // other signed-in user has enabled this preference, the shared setting |
| 298 // indicator explains this.) | 300 // indicator explains this.) |
| 299 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, ScreenLockPreferencePrimary) { | 301 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, ScreenLockPreferencePrimary) { |
| 300 LoginUser(kTestOwner); | 302 LoginUser(kTestOwner); |
| 301 UserAddingScreen::Get()->Start(); | 303 UserAddingScreen::Get()->Start(); |
| 302 content::RunAllPendingInMessageLoop(); | 304 content::RunAllPendingInMessageLoop(); |
| 303 AddUser(kTestNonOwner); | 305 AddUser(kTestNonOwner); |
| 304 | 306 |
| 305 UserManager* manager = UserManager::Get(); | 307 UserManager* manager = UserManager::Get(); |
| 306 const User* user1 = manager->FindUser(kTestOwner); | 308 const user_manager::User* user1 = manager->FindUser(kTestOwner); |
| 307 const User* user2 = manager->FindUser(kTestNonOwner); | 309 const user_manager::User* user2 = manager->FindUser(kTestNonOwner); |
| 308 | 310 |
| 309 PrefService* prefs1 = | 311 PrefService* prefs1 = |
| 310 ProfileHelper::Get()->GetProfileByUser(user1)->GetPrefs(); | 312 ProfileHelper::Get()->GetProfileByUser(user1)->GetPrefs(); |
| 311 PrefService* prefs2 = | 313 PrefService* prefs2 = |
| 312 ProfileHelper::Get()->GetProfileByUser(user2)->GetPrefs(); | 314 ProfileHelper::Get()->GetProfileByUser(user2)->GetPrefs(); |
| 313 | 315 |
| 314 // 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 |
| 315 // 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 |
| 316 // but reloading the settings page is super slow on debug builds. | 318 // but reloading the settings page is super slow on debug builds. |
| 317 prefs1->SetBoolean(prefs::kEnableAutoScreenLock, false); | 319 prefs1->SetBoolean(prefs::kEnableAutoScreenLock, false); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 // (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 |
| 368 // other signed-in user has enabled this preference, the shared setting | 370 // other signed-in user has enabled this preference, the shared setting |
| 369 // indicator explains this.) | 371 // indicator explains this.) |
| 370 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, ScreenLockPreferenceSecondary) { | 372 IN_PROC_BROWSER_TEST_F(SharedOptionsTest, ScreenLockPreferenceSecondary) { |
| 371 LoginUser(kTestOwner); | 373 LoginUser(kTestOwner); |
| 372 UserAddingScreen::Get()->Start(); | 374 UserAddingScreen::Get()->Start(); |
| 373 content::RunAllPendingInMessageLoop(); | 375 content::RunAllPendingInMessageLoop(); |
| 374 AddUser(kTestNonOwner); | 376 AddUser(kTestNonOwner); |
| 375 | 377 |
| 376 UserManager* manager = UserManager::Get(); | 378 UserManager* manager = UserManager::Get(); |
| 377 const User* user1 = manager->FindUser(kTestOwner); | 379 const user_manager::User* user1 = manager->FindUser(kTestOwner); |
| 378 const User* user2 = manager->FindUser(kTestNonOwner); | 380 const user_manager::User* user2 = manager->FindUser(kTestNonOwner); |
| 379 | 381 |
| 380 PrefService* prefs1 = | 382 PrefService* prefs1 = |
| 381 ProfileHelper::Get()->GetProfileByUser(user1)->GetPrefs(); | 383 ProfileHelper::Get()->GetProfileByUser(user1)->GetPrefs(); |
| 382 PrefService* prefs2 = | 384 PrefService* prefs2 = |
| 383 ProfileHelper::Get()->GetProfileByUser(user2)->GetPrefs(); | 385 ProfileHelper::Get()->GetProfileByUser(user2)->GetPrefs(); |
| 384 | 386 |
| 385 // 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 |
| 386 // false. | 388 // false. |
| 387 prefs1->SetBoolean(prefs::kEnableAutoScreenLock, true); | 389 prefs1->SetBoolean(prefs::kEnableAutoScreenLock, true); |
| 388 prefs2->SetBoolean(prefs::kEnableAutoScreenLock, true); | 390 prefs2->SetBoolean(prefs::kEnableAutoScreenLock, true); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 content::WaitForLoadStop(contents); | 422 content::WaitForLoadStop(contents); |
| 421 { | 423 { |
| 422 SCOPED_TRACE("Screen lock false for both users"); | 424 SCOPED_TRACE("Screen lock false for both users"); |
| 423 expected_value = false; | 425 expected_value = false; |
| 424 CheckBooleanPreference(contents, prefs::kEnableAutoScreenLock, disabled, | 426 CheckBooleanPreference(contents, prefs::kEnableAutoScreenLock, disabled, |
| 425 empty_controlled, expected_value); | 427 empty_controlled, expected_value); |
| 426 } | 428 } |
| 427 } | 429 } |
| 428 | 430 |
| 429 } // namespace chromeos | 431 } // namespace chromeos |
| OLD | NEW |