| 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 <map> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 38 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
| 39 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 39 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 40 #include "chrome/browser/profiles/profile.h" | 40 #include "chrome/browser/profiles/profile.h" |
| 41 #include "chrome/browser/profiles/profile_downloader.h" | 41 #include "chrome/browser/profiles/profile_downloader.h" |
| 42 #include "chrome/common/chrome_paths.h" | 42 #include "chrome/common/chrome_paths.h" |
| 43 #include "chrome/test/base/in_process_browser_test.h" | 43 #include "chrome/test/base/in_process_browser_test.h" |
| 44 #include "chrome/test/base/testing_browser_process.h" | 44 #include "chrome/test/base/testing_browser_process.h" |
| 45 #include "chromeos/chromeos_paths.h" | 45 #include "chromeos/chromeos_paths.h" |
| 46 #include "chromeos/dbus/cryptohome_client.h" | 46 #include "chromeos/dbus/cryptohome_client.h" |
| 47 #include "chromeos/dbus/dbus_thread_manager.h" | 47 #include "chromeos/dbus/dbus_thread_manager.h" |
| 48 #include "chromeos/dbus/fake_dbus_thread_manager.h" | |
| 49 #include "chromeos/dbus/fake_session_manager_client.h" | 48 #include "chromeos/dbus/fake_session_manager_client.h" |
| 50 #include "chromeos/dbus/session_manager_client.h" | 49 #include "chromeos/dbus/session_manager_client.h" |
| 51 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 50 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 52 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 51 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 53 #include "components/policy/core/common/cloud/policy_builder.h" | 52 #include "components/policy/core/common/cloud/policy_builder.h" |
| 54 #include "components/user_manager/user.h" | 53 #include "components/user_manager/user.h" |
| 55 #include "components/user_manager/user_image/default_user_images.h" | 54 #include "components/user_manager/user_image/default_user_images.h" |
| 56 #include "components/user_manager/user_image/user_image.h" | 55 #include "components/user_manager/user_image/user_image.h" |
| 57 #include "components/user_manager/user_manager.h" | 56 #include "components/user_manager/user_manager.h" |
| 58 #include "content/public/browser/notification_service.h" | 57 #include "content/public/browser/notification_service.h" |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 EXPECT_EQ(user_manager::kFirstDefaultImageIndex, user->image_index()); | 593 EXPECT_EQ(user_manager::kFirstDefaultImageIndex, user->image_index()); |
| 595 EXPECT_TRUE(test::AreImagesEqual(default_image, user->GetImage())); | 594 EXPECT_TRUE(test::AreImagesEqual(default_image, user->GetImage())); |
| 596 ExpectNewUserImageInfo( | 595 ExpectNewUserImageInfo( |
| 597 kTestUser1, user_manager::kFirstDefaultImageIndex, base::FilePath()); | 596 kTestUser1, user_manager::kFirstDefaultImageIndex, base::FilePath()); |
| 598 } | 597 } |
| 599 | 598 |
| 600 class UserImageManagerPolicyTest : public UserImageManagerTest, | 599 class UserImageManagerPolicyTest : public UserImageManagerTest, |
| 601 public policy::CloudPolicyStore::Observer { | 600 public policy::CloudPolicyStore::Observer { |
| 602 protected: | 601 protected: |
| 603 UserImageManagerPolicyTest() | 602 UserImageManagerPolicyTest() |
| 604 : fake_dbus_thread_manager_(new chromeos::FakeDBusThreadManager), | 603 : fake_session_manager_client_(new chromeos::FakeSessionManagerClient) { |
| 605 fake_session_manager_client_(new chromeos::FakeSessionManagerClient) { | |
| 606 fake_dbus_thread_manager_->SetFakeClients(); | |
| 607 fake_dbus_thread_manager_->SetSessionManagerClient( | |
| 608 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); | |
| 609 } | 604 } |
| 610 | 605 |
| 611 // UserImageManagerTest overrides: | 606 // UserImageManagerTest overrides: |
| 612 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 607 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 613 DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager_); | 608 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( |
| 609 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); |
| 614 UserImageManagerTest::SetUpInProcessBrowserTestFixture(); | 610 UserImageManagerTest::SetUpInProcessBrowserTestFixture(); |
| 615 } | 611 } |
| 616 | 612 |
| 617 virtual void SetUpOnMainThread() OVERRIDE { | 613 virtual void SetUpOnMainThread() OVERRIDE { |
| 618 UserImageManagerTest::SetUpOnMainThread(); | 614 UserImageManagerTest::SetUpOnMainThread(); |
| 619 | 615 |
| 620 base::FilePath user_keys_dir; | 616 base::FilePath user_keys_dir; |
| 621 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, | 617 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, |
| 622 &user_keys_dir)); | 618 &user_keys_dir)); |
| 623 const std::string sanitized_username = | 619 const std::string sanitized_username = |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 } | 657 } |
| 662 std::string policy; | 658 std::string policy; |
| 663 base::JSONWriter::Write(policy::test::ConstructExternalDataReference( | 659 base::JSONWriter::Write(policy::test::ConstructExternalDataReference( |
| 664 embedded_test_server()->GetURL(std::string("/") + relative_path).spec(), | 660 embedded_test_server()->GetURL(std::string("/") + relative_path).spec(), |
| 665 image_data).get(), | 661 image_data).get(), |
| 666 &policy); | 662 &policy); |
| 667 return policy; | 663 return policy; |
| 668 } | 664 } |
| 669 | 665 |
| 670 policy::UserPolicyBuilder user_policy_; | 666 policy::UserPolicyBuilder user_policy_; |
| 671 FakeDBusThreadManager* fake_dbus_thread_manager_; | |
| 672 FakeSessionManagerClient* fake_session_manager_client_; | 667 FakeSessionManagerClient* fake_session_manager_client_; |
| 673 | 668 |
| 674 scoped_ptr<gfx::ImageSkia> policy_image_; | 669 scoped_ptr<gfx::ImageSkia> policy_image_; |
| 675 | 670 |
| 676 private: | 671 private: |
| 677 DISALLOW_COPY_AND_ASSIGN(UserImageManagerPolicyTest); | 672 DISALLOW_COPY_AND_ASSIGN(UserImageManagerPolicyTest); |
| 678 }; | 673 }; |
| 679 | 674 |
| 680 IN_PROC_BROWSER_TEST_F(UserImageManagerPolicyTest, PRE_SetAndClear) { | 675 IN_PROC_BROWSER_TEST_F(UserImageManagerPolicyTest, PRE_SetAndClear) { |
| 681 RegisterUser(kTestUser1); | 676 RegisterUser(kTestUser1); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 | 885 |
| 891 saved_image = test::ImageLoader(GetUserImagePath(kTestUser1, "jpg")).Load(); | 886 saved_image = test::ImageLoader(GetUserImagePath(kTestUser1, "jpg")).Load(); |
| 892 ASSERT_TRUE(saved_image); | 887 ASSERT_TRUE(saved_image); |
| 893 | 888 |
| 894 // Check image dimensions. Images can't be compared since JPEG is lossy. | 889 // Check image dimensions. Images can't be compared since JPEG is lossy. |
| 895 EXPECT_EQ(policy_image_->width(), saved_image->width()); | 890 EXPECT_EQ(policy_image_->width(), saved_image->width()); |
| 896 EXPECT_EQ(policy_image_->height(), saved_image->height()); | 891 EXPECT_EQ(policy_image_->height(), saved_image->height()); |
| 897 } | 892 } |
| 898 | 893 |
| 899 } // namespace chromeos | 894 } // namespace chromeos |
| OLD | NEW |