| 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 <cstdlib> | 5 #include <cstdlib> |
| 6 #include <cstring> | 6 #include <cstring> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" | 16 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" |
| 17 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 17 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 18 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 18 #include "chrome/browser/chromeos/settings/cros_settings.h" | 19 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 19 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 20 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 20 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | 21 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
| 21 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
| 22 #include "chrome/test/base/scoped_testing_local_state.h" | 23 #include "chrome/test/base/scoped_testing_local_state.h" |
| 23 #include "chrome/test/base/testing_browser_process.h" | 24 #include "chrome/test/base/testing_browser_process.h" |
| 24 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
| 25 #include "chromeos/chromeos_switches.h" | 26 #include "chromeos/chromeos_switches.h" |
| 26 #include "chromeos/dbus/dbus_thread_manager.h" | 27 #include "chromeos/dbus/dbus_thread_manager.h" |
| 27 #include "chromeos/settings/cros_settings_names.h" | 28 #include "chromeos/settings/cros_settings_names.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 local_state_.reset( | 76 local_state_.reset( |
| 76 new ScopedTestingLocalState(TestingBrowserProcess::GetGlobal())); | 77 new ScopedTestingLocalState(TestingBrowserProcess::GetGlobal())); |
| 77 | 78 |
| 78 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 79 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 79 TestingBrowserProcess::GetGlobal()->SetProfileManager( | 80 TestingBrowserProcess::GetGlobal()->SetProfileManager( |
| 80 new UnittestProfileManager(temp_dir_.path())); | 81 new UnittestProfileManager(temp_dir_.path())); |
| 81 | 82 |
| 82 chromeos::DBusThreadManager::Initialize(); | 83 chromeos::DBusThreadManager::Initialize(); |
| 83 | 84 |
| 84 ResetUserManager(); | 85 ResetUserManager(); |
| 86 WallpaperManager::Initialize(); |
| 85 } | 87 } |
| 86 | 88 |
| 87 void TearDown() override { | 89 void TearDown() override { |
| 88 // Unregister the in-memory local settings instance. | 90 // Unregister the in-memory local settings instance. |
| 89 local_state_.reset(); | 91 local_state_.reset(); |
| 90 | 92 |
| 91 // Restore the real DeviceSettingsProvider. | 93 // Restore the real DeviceSettingsProvider. |
| 92 EXPECT_TRUE( | 94 EXPECT_TRUE( |
| 93 cros_settings_->RemoveSettingsProvider(&stub_settings_provider_)); | 95 cros_settings_->RemoveSettingsProvider(&stub_settings_provider_)); |
| 94 cros_settings_->AddSettingsProvider(device_settings_provider_); | 96 cros_settings_->AddSettingsProvider(device_settings_provider_); |
| 95 | 97 |
| 96 // Shut down the DeviceSettingsService. | 98 // Shut down the DeviceSettingsService. |
| 97 DeviceSettingsService::Get()->UnsetSessionManager(); | 99 DeviceSettingsService::Get()->UnsetSessionManager(); |
| 98 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); | 100 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); |
| 99 | 101 |
| 100 base::RunLoop().RunUntilIdle(); | 102 base::RunLoop().RunUntilIdle(); |
| 101 chromeos::DBusThreadManager::Shutdown(); | 103 chromeos::DBusThreadManager::Shutdown(); |
| 104 WallpaperManager::Shutdown(); |
| 102 } | 105 } |
| 103 | 106 |
| 104 ChromeUserManagerImpl* GetChromeUserManager() const { | 107 ChromeUserManagerImpl* GetChromeUserManager() const { |
| 105 return static_cast<ChromeUserManagerImpl*>( | 108 return static_cast<ChromeUserManagerImpl*>( |
| 106 user_manager::UserManager::Get()); | 109 user_manager::UserManager::Get()); |
| 107 } | 110 } |
| 108 | 111 |
| 109 bool GetUserManagerEphemeralUsersEnabled() const { | 112 bool GetUserManagerEphemeralUsersEnabled() const { |
| 110 return GetChromeUserManager()->GetEphemeralUsersEnabled(); | 113 return GetChromeUserManager()->GetEphemeralUsersEnabled(); |
| 111 } | 114 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 "user0@invalid.domain", "user0@invalid.domain", false); | 217 "user0@invalid.domain", "user0@invalid.domain", false); |
| 215 ResetUserManager(); | 218 ResetUserManager(); |
| 216 | 219 |
| 217 const user_manager::UserList* users = | 220 const user_manager::UserList* users = |
| 218 &user_manager::UserManager::Get()->GetUsers(); | 221 &user_manager::UserManager::Get()->GetUsers(); |
| 219 EXPECT_EQ(1U, users->size()); | 222 EXPECT_EQ(1U, users->size()); |
| 220 EXPECT_EQ((*users)[0]->email(), "owner@invalid.domain"); | 223 EXPECT_EQ((*users)[0]->email(), "owner@invalid.domain"); |
| 221 } | 224 } |
| 222 | 225 |
| 223 } // namespace chromeos | 226 } // namespace chromeos |
| OLD | NEW |