| 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" |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 19 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
| 20 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
| 20 #include "chrome/browser/chromeos/login/login_manager_test.h" | 21 #include "chrome/browser/chromeos/login/login_manager_test.h" |
| 21 #include "chrome/browser/chromeos/login/startup_utils.h" | 22 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 22 #include "chrome/browser/chromeos/login/user.h" | 23 #include "chrome/browser/chromeos/login/user.h" |
| 23 #include "chrome/browser/chromeos/login/user_manager.h" | 24 #include "chrome/browser/chromeos/login/user_manager.h" |
| 24 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 25 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
| 25 #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" |
| 26 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 27 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 27 #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" |
| 28 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
| 29 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 30 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 31 #include "chromeos/chromeos_paths.h" | 32 #include "chromeos/chromeos_paths.h" |
| 32 #include "chromeos/chromeos_switches.h" | 33 #include "chromeos/chromeos_switches.h" |
| 33 #include "chromeos/dbus/cryptohome_client.h" | 34 #include "chromeos/dbus/cryptohome_client.h" |
| 34 #include "chromeos/dbus/dbus_thread_manager.h" | 35 #include "chromeos/dbus/dbus_thread_manager.h" |
| 35 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 36 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
| 36 #include "chromeos/dbus/fake_session_manager_client.h" | 37 #include "chromeos/dbus/fake_session_manager_client.h" |
| 37 #include "chromeos/dbus/session_manager_client.h" | 38 #include "chromeos/dbus/session_manager_client.h" |
| 38 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 39 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 39 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 40 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 40 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 41 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
| 41 #include "components/policy/core/common/cloud/policy_builder.h" | 42 #include "components/policy/core/common/cloud/policy_builder.h" |
| 43 #include "content/public/test/browser_test_utils.h" |
| 42 #include "crypto/rsa_private_key.h" | 44 #include "crypto/rsa_private_key.h" |
| 43 #include "net/test/embedded_test_server/embedded_test_server.h" | 45 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 44 #include "policy/proto/cloud_policy.pb.h" | 46 #include "policy/proto/cloud_policy.pb.h" |
| 45 #include "testing/gtest/include/gtest/gtest.h" | 47 #include "testing/gtest/include/gtest/gtest.h" |
| 46 #include "third_party/skia/include/core/SkBitmap.h" | 48 #include "third_party/skia/include/core/SkBitmap.h" |
| 47 #include "third_party/skia/include/core/SkColor.h" | 49 #include "third_party/skia/include/core/SkColor.h" |
| 48 #include "ui/gfx/image/image_skia.h" | 50 #include "ui/gfx/image/image_skia.h" |
| 49 #include "url/gurl.h" | 51 #include "url/gurl.h" |
| 50 | 52 |
| 51 namespace chromeos { | 53 namespace chromeos { |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 GetUserWallpaperInfo(0, &info); | 322 GetUserWallpaperInfo(0, &info); |
| 321 ASSERT_EQ(User::DEFAULT, info.type); | 323 ASSERT_EQ(User::DEFAULT, info.type); |
| 322 ASSERT_EQ(original_background_color, GetAverageBackgroundColor()); | 324 ASSERT_EQ(original_background_color, GetAverageBackgroundColor()); |
| 323 | 325 |
| 324 // Check wallpaper change count to ensure that setting the second user's | 326 // Check wallpaper change count to ensure that setting the second user's |
| 325 // wallpaper didn't have any effect. | 327 // wallpaper didn't have any effect. |
| 326 ASSERT_EQ(4, wallpaper_change_count_); | 328 ASSERT_EQ(4, wallpaper_change_count_); |
| 327 } | 329 } |
| 328 | 330 |
| 329 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, | 331 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, |
| 332 PRE_PRE_PRE_WallpaperOnLoginScreen) { |
| 333 RegisterUser(kTestUsers[0]); |
| 334 RegisterUser(kTestUsers[1]); |
| 335 StartupUtils::MarkOobeCompleted(); |
| 336 } |
| 337 |
| 338 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, |
| 330 PRE_PRE_WallpaperOnLoginScreen) { | 339 PRE_PRE_WallpaperOnLoginScreen) { |
| 331 RegisterUser(kTestUsers[0]); | |
| 332 StartupUtils::MarkOobeCompleted(); | |
| 333 } | |
| 334 | |
| 335 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PRE_WallpaperOnLoginScreen) { | |
| 336 LoginUser(kTestUsers[0]); | 340 LoginUser(kTestUsers[0]); |
| 337 | 341 |
| 338 // Wait until default wallpaper has been loaded. | 342 // Wait until default wallpaper has been loaded. |
| 339 RunUntilWallpaperChangeCount(1); | 343 RunUntilWallpaperChangeCount(1); |
| 340 | 344 |
| 341 // Set wallpaper policy to red image. | 345 // Set wallpaper policy to red image. |
| 342 InjectPolicy(0, kRedImageFileName); | 346 InjectPolicy(0, kRedImageFileName); |
| 343 | 347 |
| 344 // Run until wallpaper has changed. | 348 // Run until wallpaper has changed. |
| 345 RunUntilWallpaperChangeCount(2); | 349 RunUntilWallpaperChangeCount(2); |
| 350 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
| 351 } |
| 352 |
| 353 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PRE_WallpaperOnLoginScreen) { |
| 354 LoginUser(kTestUsers[1]); |
| 355 |
| 356 // Wait until default wallpaper has been loaded. |
| 357 RunUntilWallpaperChangeCount(1); |
| 358 |
| 359 // Set wallpaper policy to green image. |
| 360 InjectPolicy(1, kGreenImageFileName); |
| 361 |
| 362 // Run until wallpaper has changed. |
| 363 RunUntilWallpaperChangeCount(2); |
| 364 ASSERT_EQ(kGreenImageColor, GetAverageBackgroundColor()); |
| 346 } | 365 } |
| 347 | 366 |
| 348 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, WallpaperOnLoginScreen) { | 367 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, WallpaperOnLoginScreen) { |
| 349 // Wait for active pod's wallpaper to be loaded. | 368 // Wait for active pod's wallpaper to be loaded. |
| 350 RunUntilWallpaperChangeCount(1); | 369 RunUntilWallpaperChangeCount(1); |
| 370 ASSERT_EQ(kGreenImageColor, GetAverageBackgroundColor()); |
| 371 |
| 372 // Select the second pod (belonging to user 1). |
| 373 ASSERT_TRUE(content::ExecuteScript( |
| 374 static_cast<chromeos::LoginDisplayHostImpl*>( |
| 375 chromeos::LoginDisplayHostImpl::default_host())->GetOobeUI()-> |
| 376 web_ui()->GetWebContents(), |
| 377 "document.getElementsByClassName('pod')[1].focus();")); |
| 378 RunUntilWallpaperChangeCount(2); |
| 351 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); | 379 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
| 352 } | 380 } |
| 353 | 381 |
| 382 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PRE_PRE_PersistOverLogout) { |
| 383 RegisterUser(kTestUsers[0]); |
| 384 StartupUtils::MarkOobeCompleted(); |
| 385 } |
| 386 |
| 387 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PRE_PersistOverLogout) { |
| 388 LoginUser(kTestUsers[0]); |
| 389 |
| 390 // Wait until default wallpaper has been loaded. |
| 391 RunUntilWallpaperChangeCount(1); |
| 392 |
| 393 // Set wallpaper policy to red image. |
| 394 InjectPolicy(0, kRedImageFileName); |
| 395 |
| 396 // Run until wallpaper has changed. |
| 397 RunUntilWallpaperChangeCount(2); |
| 398 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
| 399 } |
| 400 |
| 401 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PersistOverLogout) { |
| 402 LoginUser(kTestUsers[0]); |
| 403 |
| 404 // Wait until wallpaper has been loaded. |
| 405 RunUntilWallpaperChangeCount(1); |
| 406 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
| 407 } |
| 408 |
| 354 INSTANTIATE_TEST_CASE_P(WallpaperManagerPolicyTestInstantiation, | 409 INSTANTIATE_TEST_CASE_P(WallpaperManagerPolicyTestInstantiation, |
| 355 WallpaperManagerPolicyTest, testing::Bool()); | 410 WallpaperManagerPolicyTest, testing::Bool()); |
| 356 | 411 |
| 357 } // namespace chromeos | 412 } // namespace chromeos |
| OLD | NEW |