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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "ash/desktop_background/desktop_background_controller.h" | 8 #include "ash/desktop_background/desktop_background_controller.h" |
9 #include "ash/desktop_background/desktop_background_controller_observer.h" | 9 #include "ash/desktop_background/desktop_background_controller_observer.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base_test_u
til.h" | 24 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base_test_u
til.h" |
25 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 25 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
26 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 26 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
27 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 27 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
30 #include "chromeos/chromeos_paths.h" | 30 #include "chromeos/chromeos_paths.h" |
31 #include "chromeos/chromeos_switches.h" | 31 #include "chromeos/chromeos_switches.h" |
32 #include "chromeos/dbus/cryptohome_client.h" | 32 #include "chromeos/dbus/cryptohome_client.h" |
33 #include "chromeos/dbus/dbus_thread_manager.h" | 33 #include "chromeos/dbus/dbus_thread_manager.h" |
34 #include "chromeos/dbus/fake_dbus_thread_manager.h" | |
35 #include "chromeos/dbus/fake_session_manager_client.h" | 34 #include "chromeos/dbus/fake_session_manager_client.h" |
36 #include "chromeos/dbus/session_manager_client.h" | 35 #include "chromeos/dbus/session_manager_client.h" |
37 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 36 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
38 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 37 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
39 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 38 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
40 #include "components/policy/core/common/cloud/policy_builder.h" | 39 #include "components/policy/core/common/cloud/policy_builder.h" |
41 #include "components/user_manager/user.h" | 40 #include "components/user_manager/user.h" |
42 #include "components/user_manager/user_manager.h" | 41 #include "components/user_manager/user_manager.h" |
43 #include "content/public/test/browser_test_utils.h" | 42 #include "content/public/test/browser_test_utils.h" |
44 #include "crypto/rsa_private_key.h" | 43 #include "crypto/rsa_private_key.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 128 |
130 } // namespace | 129 } // namespace |
131 | 130 |
132 class WallpaperManagerPolicyTest | 131 class WallpaperManagerPolicyTest |
133 : public LoginManagerTest, | 132 : public LoginManagerTest, |
134 public ash::DesktopBackgroundControllerObserver { | 133 public ash::DesktopBackgroundControllerObserver { |
135 protected: | 134 protected: |
136 WallpaperManagerPolicyTest() | 135 WallpaperManagerPolicyTest() |
137 : LoginManagerTest(true), | 136 : LoginManagerTest(true), |
138 wallpaper_change_count_(0), | 137 wallpaper_change_count_(0), |
139 fake_dbus_thread_manager_(new FakeDBusThreadManager), | |
140 fake_session_manager_client_(new FakeSessionManagerClient) { | 138 fake_session_manager_client_(new FakeSessionManagerClient) { |
141 fake_dbus_thread_manager_->SetFakeClients(); | |
142 fake_dbus_thread_manager_->SetSessionManagerClient( | |
143 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); | |
144 } | 139 } |
145 | 140 |
146 scoped_ptr<policy::UserPolicyBuilder> GetUserPolicyBuilder( | 141 scoped_ptr<policy::UserPolicyBuilder> GetUserPolicyBuilder( |
147 const std::string& user_id) { | 142 const std::string& user_id) { |
148 scoped_ptr<policy::UserPolicyBuilder> | 143 scoped_ptr<policy::UserPolicyBuilder> |
149 user_policy_builder(new policy::UserPolicyBuilder()); | 144 user_policy_builder(new policy::UserPolicyBuilder()); |
150 base::FilePath user_keys_dir; | 145 base::FilePath user_keys_dir; |
151 EXPECT_TRUE(PathService::Get(DIR_USER_POLICY_KEYS, &user_keys_dir)); | 146 EXPECT_TRUE(PathService::Get(DIR_USER_POLICY_KEYS, &user_keys_dir)); |
152 const std::string sanitized_user_id = | 147 const std::string sanitized_user_id = |
153 CryptohomeClient::GetStubSanitizedUsername(user_id); | 148 CryptohomeClient::GetStubSanitizedUsername(user_id); |
154 const base::FilePath user_key_file = | 149 const base::FilePath user_key_file = |
155 user_keys_dir.AppendASCII(sanitized_user_id) | 150 user_keys_dir.AppendASCII(sanitized_user_id) |
156 .AppendASCII("policy.pub"); | 151 .AppendASCII("policy.pub"); |
157 std::vector<uint8> user_key_bits; | 152 std::vector<uint8> user_key_bits; |
158 EXPECT_TRUE(user_policy_builder->GetSigningKey()-> | 153 EXPECT_TRUE(user_policy_builder->GetSigningKey()-> |
159 ExportPublicKey(&user_key_bits)); | 154 ExportPublicKey(&user_key_bits)); |
160 EXPECT_TRUE(base::CreateDirectory(user_key_file.DirName())); | 155 EXPECT_TRUE(base::CreateDirectory(user_key_file.DirName())); |
161 EXPECT_EQ(base::WriteFile( | 156 EXPECT_EQ(base::WriteFile( |
162 user_key_file, | 157 user_key_file, |
163 reinterpret_cast<const char*>(user_key_bits.data()), | 158 reinterpret_cast<const char*>(user_key_bits.data()), |
164 user_key_bits.size()), | 159 user_key_bits.size()), |
165 static_cast<int>(user_key_bits.size())); | 160 static_cast<int>(user_key_bits.size())); |
166 user_policy_builder->policy_data().set_username(user_id); | 161 user_policy_builder->policy_data().set_username(user_id); |
167 return user_policy_builder.Pass(); | 162 return user_policy_builder.Pass(); |
168 } | 163 } |
169 | 164 |
170 // LoginManagerTest: | 165 // LoginManagerTest: |
171 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 166 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
172 DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager_); | 167 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( |
| 168 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); |
| 169 |
173 LoginManagerTest::SetUpInProcessBrowserTestFixture(); | 170 LoginManagerTest::SetUpInProcessBrowserTestFixture(); |
174 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); | 171 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); |
175 } | 172 } |
176 | 173 |
177 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 174 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
178 // Set the same switches as LoginManagerTest, except that kMultiProfiles is | 175 // Set the same switches as LoginManagerTest, except that kMultiProfiles is |
179 // only set when GetParam() is true and except that kLoginProfile is set | 176 // only set when GetParam() is true and except that kLoginProfile is set |
180 // when GetParam() is false. The latter seems to be required for the sane | 177 // when GetParam() is false. The latter seems to be required for the sane |
181 // start-up of user profiles. | 178 // start-up of user profiles. |
182 command_line->AppendSwitch(switches::kLoginManager); | 179 command_line->AppendSwitch(switches::kLoginManager); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 // Obtain WallpaperInfo for |user_number| from WallpaperManager. | 256 // Obtain WallpaperInfo for |user_number| from WallpaperManager. |
260 void GetUserWallpaperInfo(int user_number, WallpaperInfo* wallpaper_info) { | 257 void GetUserWallpaperInfo(int user_number, WallpaperInfo* wallpaper_info) { |
261 WallpaperManager::Get()-> | 258 WallpaperManager::Get()-> |
262 GetUserWallpaperInfo(kTestUsers[user_number], wallpaper_info); | 259 GetUserWallpaperInfo(kTestUsers[user_number], wallpaper_info); |
263 } | 260 } |
264 | 261 |
265 base::FilePath test_data_dir_; | 262 base::FilePath test_data_dir_; |
266 scoped_ptr<base::RunLoop> run_loop_; | 263 scoped_ptr<base::RunLoop> run_loop_; |
267 int wallpaper_change_count_; | 264 int wallpaper_change_count_; |
268 scoped_ptr<policy::UserPolicyBuilder> user_policy_builders_[2]; | 265 scoped_ptr<policy::UserPolicyBuilder> user_policy_builders_[2]; |
269 FakeDBusThreadManager* fake_dbus_thread_manager_; | |
270 FakeSessionManagerClient* fake_session_manager_client_; | 266 FakeSessionManagerClient* fake_session_manager_client_; |
271 | 267 |
272 private: | 268 private: |
273 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerPolicyTest); | 269 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerPolicyTest); |
274 }; | 270 }; |
275 | 271 |
276 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_SetResetClear) { | 272 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_SetResetClear) { |
277 RegisterUser(kTestUsers[0]); | 273 RegisterUser(kTestUsers[0]); |
278 RegisterUser(kTestUsers[1]); | 274 RegisterUser(kTestUsers[1]); |
279 StartupUtils::MarkOobeCompleted(); | 275 StartupUtils::MarkOobeCompleted(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 395 |
400 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { | 396 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { |
401 LoginUser(kTestUsers[0]); | 397 LoginUser(kTestUsers[0]); |
402 | 398 |
403 // Wait until wallpaper has been loaded. | 399 // Wait until wallpaper has been loaded. |
404 RunUntilWallpaperChangeCount(1); | 400 RunUntilWallpaperChangeCount(1); |
405 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); | 401 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
406 } | 402 } |
407 | 403 |
408 } // namespace chromeos | 404 } // namespace chromeos |
OLD | NEW |