| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" |
| 11 #include "chrome/browser/chromeos/login/login_manager_test.h" | 12 #include "chrome/browser/chromeos/login/login_manager_test.h" |
| 12 #include "chrome/browser/chromeos/login/startup_utils.h" | 13 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 13 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 14 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 14 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 15 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 15 #include "chrome/browser/chromeos/settings/cros_settings.h" | 16 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 16 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | 17 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
| 18 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/signin/signin_manager_factory.h" | 19 #include "chrome/browser/signin/signin_manager_factory.h" |
| 18 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_commands.h" | 21 #include "chrome/browser/ui/browser_commands.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 21 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| 23 #include "chromeos/settings/cros_settings_names.h" | 25 #include "chromeos/settings/cros_settings_names.h" |
| 24 #if defined(GOOGLE_CHROME_BUILD) | 26 #if defined(GOOGLE_CHROME_BUILD) |
| 25 #include "components/spellcheck/browser/pref_names.h" | 27 #include "components/spellcheck/browser/pref_names.h" |
| 26 #endif | 28 #endif |
| 27 #include "components/prefs/pref_service.h" | 29 #include "components/prefs/pref_service.h" |
| 28 #include "components/signin/core/browser/signin_manager.h" | 30 #include "components/signin/core/browser/signin_manager.h" |
| 29 #include "components/user_manager/user_manager.h" | 31 #include "components/user_manager/user_manager.h" |
| 32 #include "content/public/browser/notification_service.h" |
| 33 #include "content/public/browser/notification_source.h" |
| 30 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
| 31 #include "content/public/test/browser_test_utils.h" | 35 #include "content/public/test/browser_test_utils.h" |
| 32 #include "content/public/test/test_utils.h" | 36 #include "content/public/test/test_utils.h" |
| 33 | 37 |
| 34 namespace chromeos { | 38 namespace chromeos { |
| 35 | 39 |
| 36 namespace { | 40 namespace { |
| 37 | 41 |
| 38 // Because policy is not needed in this test it is better to use e-mails that | 42 // Because policy is not needed in this test it is better to use e-mails that |
| 39 // are definitely not enterprise. This lets us to avoid faking of policy fetch | 43 // are definitely not enterprise. This lets us to avoid faking of policy fetch |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 LoginManagerTest::SetUpOnMainThread(); | 111 LoginManagerTest::SetUpOnMainThread(); |
| 108 | 112 |
| 109 CrosSettings* settings = CrosSettings::Get(); | 113 CrosSettings* settings = CrosSettings::Get(); |
| 110 | 114 |
| 111 // Add the stub settings provider, moving the device settings provider | 115 // Add the stub settings provider, moving the device settings provider |
| 112 // behind it so our stub takes precedence. | 116 // behind it so our stub takes precedence. |
| 113 std::unique_ptr<CrosSettingsProvider> device_settings_provider = | 117 std::unique_ptr<CrosSettingsProvider> device_settings_provider = |
| 114 settings->RemoveSettingsProvider(settings->GetProvider(kDeviceOwner)); | 118 settings->RemoveSettingsProvider(settings->GetProvider(kDeviceOwner)); |
| 115 settings->AddSettingsProvider(std::move(stub_settings_provider_)); | 119 settings->AddSettingsProvider(std::move(stub_settings_provider_)); |
| 116 settings->AddSettingsProvider(std::move(device_settings_provider)); | 120 settings->AddSettingsProvider(std::move(device_settings_provider)); |
| 121 |
| 122 // Notify ChromeUserManager of ownership change. |
| 123 content::NotificationService::current()->Notify( |
| 124 chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, |
| 125 content::Source<SharedOptionsTest>(this), |
| 126 content::NotificationService::NoDetails()); |
| 117 } | 127 } |
| 118 | 128 |
| 119 void TearDownOnMainThread() override { | 129 void TearDownOnMainThread() override { |
| 120 CrosSettings* settings = CrosSettings::Get(); | 130 CrosSettings* settings = CrosSettings::Get(); |
| 121 settings->RemoveSettingsProvider(stub_settings_provider_ptr_); | 131 settings->RemoveSettingsProvider(stub_settings_provider_ptr_); |
| 122 LoginManagerTest::TearDownOnMainThread(); | 132 LoginManagerTest::TearDownOnMainThread(); |
| 123 } | 133 } |
| 124 | 134 |
| 125 protected: | 135 protected: |
| 126 void CheckOptionsUI(const user_manager::User* user, | 136 void CheckOptionsUI(const user_manager::User* user, |
| 127 bool is_owner, | 137 bool is_owner, |
| 128 bool is_primary) { | 138 bool is_primary) { |
| 139 ASSERT_NE(nullptr, user); |
| 129 Browser* browser = CreateBrowserForUser(user); | 140 Browser* browser = CreateBrowserForUser(user); |
| 130 content::WebContents* contents = | 141 content::WebContents* contents = |
| 131 browser->tab_strip_model()->GetActiveWebContents(); | 142 browser->tab_strip_model()->GetActiveWebContents(); |
| 132 | 143 |
| 133 for (size_t i = 0; i < sizeof(kPrefTests) / sizeof(kPrefTests[0]); i++) { | 144 for (size_t i = 0; i < sizeof(kPrefTests) / sizeof(kPrefTests[0]); i++) { |
| 134 bool disabled = !is_owner && kPrefTests[i].owner_only; | 145 bool disabled = !is_owner && kPrefTests[i].owner_only; |
| 135 if (strcmp(kPrefTests[i].pref_name, kSystemTimezone) == 0) { | 146 if (strcmp(kPrefTests[i].pref_name, kSystemTimezone) == 0) { |
| 136 disabled = ProfileHelper::Get() | 147 disabled = ProfileHelper::Get() |
| 137 ->GetProfileByUserUnsafe(user) | 148 ->GetProfileByUserUnsafe(user) |
| 138 ->GetPrefs() | 149 ->GetPrefs() |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 content::WaitForLoadStop(contents); | 458 content::WaitForLoadStop(contents); |
| 448 { | 459 { |
| 449 SCOPED_TRACE("Screen lock false for both users"); | 460 SCOPED_TRACE("Screen lock false for both users"); |
| 450 expected_value = false; | 461 expected_value = false; |
| 451 CheckBooleanPreference(contents, prefs::kEnableAutoScreenLock, disabled, | 462 CheckBooleanPreference(contents, prefs::kEnableAutoScreenLock, disabled, |
| 452 empty_controlled, expected_value); | 463 empty_controlled, expected_value); |
| 453 } | 464 } |
| 454 } | 465 } |
| 455 | 466 |
| 456 } // namespace chromeos | 467 } // namespace chromeos |
| OLD | NEW |