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 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/chromeos/login/startup_utils.h" | 21 #include "chrome/browser/chromeos/login/startup_utils.h" |
22 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 22 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
23 #include "chrome/browser/chromeos/login/users/user.h" | 23 #include "chrome/browser/chromeos/login/users/user.h" |
24 #include "chrome/browser/chromeos/login/users/user_manager.h" | 24 #include "chrome/browser/chromeos/login/users/user_manager.h" |
25 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 25 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
26 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base_test_u
til.h" | 26 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base_test_u
til.h" |
27 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 27 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
28 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 28 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
29 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
31 #include "chrome/common/chrome_switches.h" | |
32 #include "chromeos/chromeos_paths.h" | 31 #include "chromeos/chromeos_paths.h" |
33 #include "chromeos/chromeos_switches.h" | 32 #include "chromeos/chromeos_switches.h" |
34 #include "chromeos/dbus/cryptohome_client.h" | 33 #include "chromeos/dbus/cryptohome_client.h" |
35 #include "chromeos/dbus/dbus_thread_manager.h" | 34 #include "chromeos/dbus/dbus_thread_manager.h" |
36 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 35 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
37 #include "chromeos/dbus/fake_session_manager_client.h" | 36 #include "chromeos/dbus/fake_session_manager_client.h" |
38 #include "chromeos/dbus/session_manager_client.h" | 37 #include "chromeos/dbus/session_manager_client.h" |
39 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 38 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
40 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 39 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
41 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 40 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 123 } |
125 | 124 |
126 const SkBitmap& bitmap = representation.sk_bitmap(); | 125 const SkBitmap& bitmap = representation.sk_bitmap(); |
127 return ComputeAverageColor(bitmap); | 126 return ComputeAverageColor(bitmap); |
128 } | 127 } |
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 public testing::WithParamInterface<bool> { | |
136 protected: | 134 protected: |
137 WallpaperManagerPolicyTest() | 135 WallpaperManagerPolicyTest() |
138 : LoginManagerTest(true), | 136 : LoginManagerTest(true), |
139 wallpaper_change_count_(0), | 137 wallpaper_change_count_(0), |
140 fake_dbus_thread_manager_(new FakeDBusThreadManager), | 138 fake_dbus_thread_manager_(new FakeDBusThreadManager), |
141 fake_session_manager_client_(new FakeSessionManagerClient) { | 139 fake_session_manager_client_(new FakeSessionManagerClient) { |
142 fake_dbus_thread_manager_->SetFakeClients(); | 140 fake_dbus_thread_manager_->SetFakeClients(); |
143 fake_dbus_thread_manager_->SetSessionManagerClient( | 141 fake_dbus_thread_manager_->SetSessionManagerClient( |
144 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); | 142 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); |
145 } | 143 } |
(...skipping 29 matching lines...) Expand all Loading... |
175 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); | 173 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); |
176 } | 174 } |
177 | 175 |
178 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 176 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
179 // Set the same switches as LoginManagerTest, except that kMultiProfiles is | 177 // Set the same switches as LoginManagerTest, except that kMultiProfiles is |
180 // only set when GetParam() is true and except that kLoginProfile is set | 178 // only set when GetParam() is true and except that kLoginProfile is set |
181 // when GetParam() is false. The latter seems to be required for the sane | 179 // when GetParam() is false. The latter seems to be required for the sane |
182 // start-up of user profiles. | 180 // start-up of user profiles. |
183 command_line->AppendSwitch(switches::kLoginManager); | 181 command_line->AppendSwitch(switches::kLoginManager); |
184 command_line->AppendSwitch(switches::kForceLoginManagerInTests); | 182 command_line->AppendSwitch(switches::kForceLoginManagerInTests); |
185 if (GetParam()) | |
186 command_line->AppendSwitch(::switches::kMultiProfiles); | |
187 else | |
188 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); | |
189 } | 183 } |
190 | 184 |
191 virtual void SetUpOnMainThread() OVERRIDE { | 185 virtual void SetUpOnMainThread() OVERRIDE { |
192 LoginManagerTest::SetUpOnMainThread(); | 186 LoginManagerTest::SetUpOnMainThread(); |
193 ash::Shell::GetInstance()-> | 187 ash::Shell::GetInstance()-> |
194 desktop_background_controller()->AddObserver(this); | 188 desktop_background_controller()->AddObserver(this); |
195 | 189 |
196 // Set up policy signing. | 190 // Set up policy signing. |
197 user_policy_builders_[0] = GetUserPolicyBuilder(kTestUsers[0]); | 191 user_policy_builders_[0] = GetUserPolicyBuilder(kTestUsers[0]); |
198 user_policy_builders_[1] = GetUserPolicyBuilder(kTestUsers[1]); | 192 user_policy_builders_[1] = GetUserPolicyBuilder(kTestUsers[1]); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 scoped_ptr<base::RunLoop> run_loop_; | 264 scoped_ptr<base::RunLoop> run_loop_; |
271 int wallpaper_change_count_; | 265 int wallpaper_change_count_; |
272 scoped_ptr<policy::UserPolicyBuilder> user_policy_builders_[2]; | 266 scoped_ptr<policy::UserPolicyBuilder> user_policy_builders_[2]; |
273 FakeDBusThreadManager* fake_dbus_thread_manager_; | 267 FakeDBusThreadManager* fake_dbus_thread_manager_; |
274 FakeSessionManagerClient* fake_session_manager_client_; | 268 FakeSessionManagerClient* fake_session_manager_client_; |
275 | 269 |
276 private: | 270 private: |
277 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerPolicyTest); | 271 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerPolicyTest); |
278 }; | 272 }; |
279 | 273 |
280 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PRE_SetResetClear) { | 274 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_SetResetClear) { |
281 RegisterUser(kTestUsers[0]); | 275 RegisterUser(kTestUsers[0]); |
282 RegisterUser(kTestUsers[1]); | 276 RegisterUser(kTestUsers[1]); |
283 StartupUtils::MarkOobeCompleted(); | 277 StartupUtils::MarkOobeCompleted(); |
284 } | 278 } |
285 | 279 |
286 // Verifies that the wallpaper can be set and re-set through policy and that | 280 // Verifies that the wallpaper can be set and re-set through policy and that |
287 // setting policy for a user that is not logged in doesn't affect the current | 281 // setting policy for a user that is not logged in doesn't affect the current |
288 // user. Also verifies that after the policy has been cleared, the wallpaper | 282 // user. Also verifies that after the policy has been cleared, the wallpaper |
289 // reverts to default. | 283 // reverts to default. |
290 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, SetResetClear) { | 284 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, SetResetClear) { |
291 WallpaperInfo info; | 285 WallpaperInfo info; |
292 LoginUser(kTestUsers[0]); | 286 LoginUser(kTestUsers[0]); |
293 base::RunLoop().RunUntilIdle(); | 287 base::RunLoop().RunUntilIdle(); |
294 | 288 |
295 // First user: Wait until default wallpaper has been loaded (happens | 289 // First user: Wait until default wallpaper has been loaded (happens |
296 // automatically) and store color to recognize it later. | 290 // automatically) and store color to recognize it later. |
297 RunUntilWallpaperChangeCount(1); | 291 RunUntilWallpaperChangeCount(1); |
298 const SkColor original_background_color = GetAverageBackgroundColor(); | 292 const SkColor original_background_color = GetAverageBackgroundColor(); |
299 | 293 |
300 // Second user: Set wallpaper policy to blue image. This should not result in | 294 // Second user: Set wallpaper policy to blue image. This should not result in |
(...skipping 20 matching lines...) Expand all Loading... |
321 RunUntilWallpaperChangeCount(4); | 315 RunUntilWallpaperChangeCount(4); |
322 GetUserWallpaperInfo(0, &info); | 316 GetUserWallpaperInfo(0, &info); |
323 ASSERT_EQ(User::DEFAULT, info.type); | 317 ASSERT_EQ(User::DEFAULT, info.type); |
324 ASSERT_EQ(original_background_color, GetAverageBackgroundColor()); | 318 ASSERT_EQ(original_background_color, GetAverageBackgroundColor()); |
325 | 319 |
326 // Check wallpaper change count to ensure that setting the second user's | 320 // Check wallpaper change count to ensure that setting the second user's |
327 // wallpaper didn't have any effect. | 321 // wallpaper didn't have any effect. |
328 ASSERT_EQ(4, wallpaper_change_count_); | 322 ASSERT_EQ(4, wallpaper_change_count_); |
329 } | 323 } |
330 | 324 |
331 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, | 325 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, |
332 PRE_PRE_PRE_WallpaperOnLoginScreen) { | 326 PRE_PRE_PRE_WallpaperOnLoginScreen) { |
333 RegisterUser(kTestUsers[0]); | 327 RegisterUser(kTestUsers[0]); |
334 RegisterUser(kTestUsers[1]); | 328 RegisterUser(kTestUsers[1]); |
335 StartupUtils::MarkOobeCompleted(); | 329 StartupUtils::MarkOobeCompleted(); |
336 } | 330 } |
337 | 331 |
338 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, | 332 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, |
339 PRE_PRE_WallpaperOnLoginScreen) { | 333 PRE_PRE_WallpaperOnLoginScreen) { |
340 LoginUser(kTestUsers[0]); | 334 LoginUser(kTestUsers[0]); |
341 | 335 |
342 // Wait until default wallpaper has been loaded. | 336 // Wait until default wallpaper has been loaded. |
343 RunUntilWallpaperChangeCount(1); | 337 RunUntilWallpaperChangeCount(1); |
344 | 338 |
345 // Set wallpaper policy to red image. | 339 // Set wallpaper policy to red image. |
346 InjectPolicy(0, kRedImageFileName); | 340 InjectPolicy(0, kRedImageFileName); |
347 | 341 |
348 // Run until wallpaper has changed. | 342 // Run until wallpaper has changed. |
349 RunUntilWallpaperChangeCount(2); | 343 RunUntilWallpaperChangeCount(2); |
350 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); | 344 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
351 } | 345 } |
352 | 346 |
353 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PRE_WallpaperOnLoginScreen) { | 347 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_WallpaperOnLoginScreen) { |
354 LoginUser(kTestUsers[1]); | 348 LoginUser(kTestUsers[1]); |
355 | 349 |
356 // Wait until default wallpaper has been loaded. | 350 // Wait until default wallpaper has been loaded. |
357 RunUntilWallpaperChangeCount(1); | 351 RunUntilWallpaperChangeCount(1); |
358 | 352 |
359 // Set wallpaper policy to green image. | 353 // Set wallpaper policy to green image. |
360 InjectPolicy(1, kGreenImageFileName); | 354 InjectPolicy(1, kGreenImageFileName); |
361 | 355 |
362 // Run until wallpaper has changed. | 356 // Run until wallpaper has changed. |
363 RunUntilWallpaperChangeCount(2); | 357 RunUntilWallpaperChangeCount(2); |
364 ASSERT_EQ(kGreenImageColor, GetAverageBackgroundColor()); | 358 ASSERT_EQ(kGreenImageColor, GetAverageBackgroundColor()); |
365 } | 359 } |
366 | 360 |
367 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, WallpaperOnLoginScreen) { | 361 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, WallpaperOnLoginScreen) { |
368 // Wait for active pod's wallpaper to be loaded. | 362 // Wait for active pod's wallpaper to be loaded. |
369 RunUntilWallpaperChangeCount(1); | 363 RunUntilWallpaperChangeCount(1); |
370 ASSERT_EQ(kGreenImageColor, GetAverageBackgroundColor()); | 364 ASSERT_EQ(kGreenImageColor, GetAverageBackgroundColor()); |
371 | 365 |
372 // Select the second pod (belonging to user 1). | 366 // Select the second pod (belonging to user 1). |
373 ASSERT_TRUE(content::ExecuteScript( | 367 ASSERT_TRUE(content::ExecuteScript( |
374 static_cast<chromeos::LoginDisplayHostImpl*>( | 368 static_cast<chromeos::LoginDisplayHostImpl*>( |
375 chromeos::LoginDisplayHostImpl::default_host())->GetOobeUI()-> | 369 chromeos::LoginDisplayHostImpl::default_host())->GetOobeUI()-> |
376 web_ui()->GetWebContents(), | 370 web_ui()->GetWebContents(), |
377 "document.getElementsByClassName('pod')[1].focus();")); | 371 "document.getElementsByClassName('pod')[1].focus();")); |
378 RunUntilWallpaperChangeCount(2); | 372 RunUntilWallpaperChangeCount(2); |
379 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); | 373 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
380 } | 374 } |
381 | 375 |
382 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PRE_PRE_PersistOverLogout) { | 376 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_PRE_PersistOverLogout) { |
383 RegisterUser(kTestUsers[0]); | 377 RegisterUser(kTestUsers[0]); |
384 StartupUtils::MarkOobeCompleted(); | 378 StartupUtils::MarkOobeCompleted(); |
385 } | 379 } |
386 | 380 |
387 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PRE_PersistOverLogout) { | 381 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_PersistOverLogout) { |
388 LoginUser(kTestUsers[0]); | 382 LoginUser(kTestUsers[0]); |
389 | 383 |
390 // Wait until default wallpaper has been loaded. | 384 // Wait until default wallpaper has been loaded. |
391 RunUntilWallpaperChangeCount(1); | 385 RunUntilWallpaperChangeCount(1); |
392 | 386 |
393 // Set wallpaper policy to red image. | 387 // Set wallpaper policy to red image. |
394 InjectPolicy(0, kRedImageFileName); | 388 InjectPolicy(0, kRedImageFileName); |
395 | 389 |
396 // Run until wallpaper has changed. | 390 // Run until wallpaper has changed. |
397 RunUntilWallpaperChangeCount(2); | 391 RunUntilWallpaperChangeCount(2); |
398 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); | 392 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
399 } | 393 } |
400 | 394 |
401 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PersistOverLogout) { | 395 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { |
402 LoginUser(kTestUsers[0]); | 396 LoginUser(kTestUsers[0]); |
403 | 397 |
404 // Wait until wallpaper has been loaded. | 398 // Wait until wallpaper has been loaded. |
405 RunUntilWallpaperChangeCount(1); | 399 RunUntilWallpaperChangeCount(1); |
406 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); | 400 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
407 } | 401 } |
408 | 402 |
409 INSTANTIATE_TEST_CASE_P(WallpaperManagerPolicyTestInstantiation, | |
410 WallpaperManagerPolicyTest, testing::Bool()); | |
411 | |
412 } // namespace chromeos | 403 } // namespace chromeos |
OLD | NEW |