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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
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/chromeos/profiles/profile_helper.h" | 29 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
30 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
31 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 31 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
32 #include "chrome/common/chrome_paths.h" | 32 #include "chrome/common/chrome_paths.h" |
33 #include "chromeos/chromeos_paths.h" | 33 #include "chromeos/chromeos_paths.h" |
34 #include "chromeos/chromeos_switches.h" | 34 #include "chromeos/chromeos_switches.h" |
35 #include "chromeos/cryptohome/system_salt_getter.h" | |
36 #include "chromeos/dbus/cryptohome_client.h" | 35 #include "chromeos/dbus/cryptohome_client.h" |
37 #include "chromeos/dbus/dbus_thread_manager.h" | 36 #include "chromeos/dbus/dbus_thread_manager.h" |
38 #include "chromeos/dbus/fake_session_manager_client.h" | 37 #include "chromeos/dbus/fake_session_manager_client.h" |
39 #include "chromeos/dbus/session_manager_client.h" | 38 #include "chromeos/dbus/session_manager_client.h" |
40 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 39 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
41 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 40 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
42 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 41 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
43 #include "components/policy/core/common/cloud/policy_builder.h" | 42 #include "components/policy/core/common/cloud/policy_builder.h" |
44 #include "components/user_manager/user.h" | 43 #include "components/user_manager/user.h" |
45 #include "components/user_manager/user_manager.h" | 44 #include "components/user_manager/user_manager.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 const gfx::ImageSkiaRep& representation = image.GetRepresentation(1.); | 120 const gfx::ImageSkiaRep& representation = image.GetRepresentation(1.); |
122 if (representation.is_null()) { | 121 if (representation.is_null()) { |
123 ADD_FAILURE() << "No image representation."; | 122 ADD_FAILURE() << "No image representation."; |
124 return SkColorSetARGB(0, 0, 0, 0); | 123 return SkColorSetARGB(0, 0, 0, 0); |
125 } | 124 } |
126 | 125 |
127 const SkBitmap& bitmap = representation.sk_bitmap(); | 126 const SkBitmap& bitmap = representation.sk_bitmap(); |
128 return ComputeAverageColor(bitmap); | 127 return ComputeAverageColor(bitmap); |
129 } | 128 } |
130 | 129 |
131 // Initialize system salt to calculate wallpaper file names. | |
132 void SetSystemSalt() { | |
133 chromeos::SystemSaltGetter::Get()->SetRawSaltForTesting( | |
134 chromeos::SystemSaltGetter::RawSalt({1, 2, 3, 4, 5, 6, 7, 8})); | |
135 } | |
136 | |
137 } // namespace | 130 } // namespace |
138 | 131 |
139 class WallpaperManagerPolicyTest | 132 class WallpaperManagerPolicyTest |
140 : public LoginManagerTest, | 133 : public LoginManagerTest, |
141 public ash::DesktopBackgroundControllerObserver { | 134 public ash::DesktopBackgroundControllerObserver { |
142 protected: | 135 protected: |
143 WallpaperManagerPolicyTest() | 136 WallpaperManagerPolicyTest() |
144 : LoginManagerTest(true), | 137 : LoginManagerTest(true), |
145 wallpaper_change_count_(0), | 138 wallpaper_change_count_(0), |
146 fake_session_manager_client_(new FakeSessionManagerClient) { | 139 fake_session_manager_client_(new FakeSessionManagerClient) { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 RegisterUser(testUsers_[0].GetUserEmail()); | 288 RegisterUser(testUsers_[0].GetUserEmail()); |
296 RegisterUser(testUsers_[1].GetUserEmail()); | 289 RegisterUser(testUsers_[1].GetUserEmail()); |
297 StartupUtils::MarkOobeCompleted(); | 290 StartupUtils::MarkOobeCompleted(); |
298 } | 291 } |
299 | 292 |
300 // Verifies that the wallpaper can be set and re-set through policy and that | 293 // Verifies that the wallpaper can be set and re-set through policy and that |
301 // setting policy for a user that is not logged in doesn't affect the current | 294 // setting policy for a user that is not logged in doesn't affect the current |
302 // user. Also verifies that after the policy has been cleared, the wallpaper | 295 // user. Also verifies that after the policy has been cleared, the wallpaper |
303 // reverts to default. | 296 // reverts to default. |
304 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, SetResetClear) { | 297 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, SetResetClear) { |
305 SetSystemSalt(); | |
306 wallpaper::WallpaperInfo info; | 298 wallpaper::WallpaperInfo info; |
307 LoginUser(testUsers_[0].GetUserEmail()); | 299 LoginUser(testUsers_[0].GetUserEmail()); |
308 base::RunLoop().RunUntilIdle(); | 300 base::RunLoop().RunUntilIdle(); |
309 | 301 |
310 // First user: Wait until default wallpaper has been loaded (happens | 302 // First user: Wait until default wallpaper has been loaded (happens |
311 // automatically) and store color to recognize it later. | 303 // automatically) and store color to recognize it later. |
312 RunUntilWallpaperChangeCount(1); | 304 RunUntilWallpaperChangeCount(1); |
313 const SkColor original_background_color = GetAverageBackgroundColor(); | 305 const SkColor original_background_color = GetAverageBackgroundColor(); |
314 | 306 |
315 // Second user: Set wallpaper policy to blue image. This should not result in | 307 // Second user: Set wallpaper policy to blue image. This should not result in |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 381 |
390 // Select the second pod (belonging to user 1). | 382 // Select the second pod (belonging to user 1). |
391 ASSERT_TRUE(content::ExecuteScript( | 383 ASSERT_TRUE(content::ExecuteScript( |
392 LoginDisplayHost::default_host()->GetOobeUI()->web_ui()->GetWebContents(), | 384 LoginDisplayHost::default_host()->GetOobeUI()->web_ui()->GetWebContents(), |
393 "document.getElementsByClassName('pod')[1].focus();")); | 385 "document.getElementsByClassName('pod')[1].focus();")); |
394 RunUntilWallpaperChangeCount(2); | 386 RunUntilWallpaperChangeCount(2); |
395 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); | 387 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
396 } | 388 } |
397 | 389 |
398 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_PRE_PersistOverLogout) { | 390 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_PRE_PersistOverLogout) { |
399 SetSystemSalt(); | |
400 RegisterUser(testUsers_[0].GetUserEmail()); | 391 RegisterUser(testUsers_[0].GetUserEmail()); |
401 StartupUtils::MarkOobeCompleted(); | 392 StartupUtils::MarkOobeCompleted(); |
402 } | 393 } |
403 | 394 |
404 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_PersistOverLogout) { | 395 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_PersistOverLogout) { |
405 SetSystemSalt(); | |
406 LoginUser(testUsers_[0].GetUserEmail()); | 396 LoginUser(testUsers_[0].GetUserEmail()); |
407 | 397 |
408 // Wait until default wallpaper has been loaded. | 398 // Wait until default wallpaper has been loaded. |
409 RunUntilWallpaperChangeCount(1); | 399 RunUntilWallpaperChangeCount(1); |
410 | 400 |
411 // Set wallpaper policy to red image. | 401 // Set wallpaper policy to red image. |
412 InjectPolicy(0, kRedImageFileName); | 402 InjectPolicy(0, kRedImageFileName); |
413 | 403 |
414 // Run until wallpaper has changed. | 404 // Run until wallpaper has changed. |
415 RunUntilWallpaperChangeCount(2); | 405 RunUntilWallpaperChangeCount(2); |
416 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); | 406 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
417 } | 407 } |
418 | 408 |
419 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { | 409 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { |
420 LoginUser(testUsers_[0].GetUserEmail()); | 410 LoginUser(testUsers_[0].GetUserEmail()); |
421 | 411 |
422 // Wait until wallpaper has been loaded. | 412 // Wait until wallpaper has been loaded. |
423 RunUntilWallpaperChangeCount(1); | 413 RunUntilWallpaperChangeCount(1); |
424 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); | 414 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
425 } | 415 } |
426 | 416 |
427 } // namespace chromeos | 417 } // namespace chromeos |
OLD | NEW |