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