| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 } // namespace | 97 } // namespace |
| 98 | 98 |
| 99 class UserImageManagerTest : public LoginManagerTest, | 99 class UserImageManagerTest : public LoginManagerTest, |
| 100 public user_manager::UserManager::Observer { | 100 public user_manager::UserManager::Observer { |
| 101 protected: | 101 protected: |
| 102 UserImageManagerTest() : LoginManagerTest(true) { | 102 UserImageManagerTest() : LoginManagerTest(true) { |
| 103 } | 103 } |
| 104 | 104 |
| 105 // LoginManagerTest overrides: | 105 // LoginManagerTest overrides: |
| 106 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 106 virtual void SetUpInProcessBrowserTestFixture() override { |
| 107 LoginManagerTest::SetUpInProcessBrowserTestFixture(); | 107 LoginManagerTest::SetUpInProcessBrowserTestFixture(); |
| 108 | 108 |
| 109 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); | 109 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); |
| 110 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_)); | 110 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 virtual void SetUpOnMainThread() OVERRIDE { | 113 virtual void SetUpOnMainThread() override { |
| 114 LoginManagerTest::SetUpOnMainThread(); | 114 LoginManagerTest::SetUpOnMainThread(); |
| 115 local_state_ = g_browser_process->local_state(); | 115 local_state_ = g_browser_process->local_state(); |
| 116 user_manager::UserManager::Get()->AddObserver(this); | 116 user_manager::UserManager::Get()->AddObserver(this); |
| 117 } | 117 } |
| 118 | 118 |
| 119 virtual void TearDownOnMainThread() OVERRIDE { | 119 virtual void TearDownOnMainThread() override { |
| 120 user_manager::UserManager::Get()->RemoveObserver(this); | 120 user_manager::UserManager::Get()->RemoveObserver(this); |
| 121 LoginManagerTest::TearDownOnMainThread(); | 121 LoginManagerTest::TearDownOnMainThread(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 // UserManager::Observer overrides: | 124 // UserManager::Observer overrides: |
| 125 virtual void LocalStateChanged( | 125 virtual void LocalStateChanged( |
| 126 user_manager::UserManager* user_manager) OVERRIDE { | 126 user_manager::UserManager* user_manager) override { |
| 127 if (run_loop_) | 127 if (run_loop_) |
| 128 run_loop_->Quit(); | 128 run_loop_->Quit(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 // Logs in |username|. | 131 // Logs in |username|. |
| 132 void LogIn(const std::string& username) { | 132 void LogIn(const std::string& username) { |
| 133 user_manager::UserManager::Get()->UserLoggedIn(username, username, false); | 133 user_manager::UserManager::Get()->UserLoggedIn(username, username, false); |
| 134 } | 134 } |
| 135 | 135 |
| 136 // Stores old (pre-migration) user image info. | 136 // Stores old (pre-migration) user image info. |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 } | 597 } |
| 598 | 598 |
| 599 class UserImageManagerPolicyTest : public UserImageManagerTest, | 599 class UserImageManagerPolicyTest : public UserImageManagerTest, |
| 600 public policy::CloudPolicyStore::Observer { | 600 public policy::CloudPolicyStore::Observer { |
| 601 protected: | 601 protected: |
| 602 UserImageManagerPolicyTest() | 602 UserImageManagerPolicyTest() |
| 603 : fake_session_manager_client_(new chromeos::FakeSessionManagerClient) { | 603 : fake_session_manager_client_(new chromeos::FakeSessionManagerClient) { |
| 604 } | 604 } |
| 605 | 605 |
| 606 // UserImageManagerTest overrides: | 606 // UserImageManagerTest overrides: |
| 607 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 607 virtual void SetUpInProcessBrowserTestFixture() override { |
| 608 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( | 608 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( |
| 609 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); | 609 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); |
| 610 UserImageManagerTest::SetUpInProcessBrowserTestFixture(); | 610 UserImageManagerTest::SetUpInProcessBrowserTestFixture(); |
| 611 } | 611 } |
| 612 | 612 |
| 613 virtual void SetUpOnMainThread() OVERRIDE { | 613 virtual void SetUpOnMainThread() override { |
| 614 UserImageManagerTest::SetUpOnMainThread(); | 614 UserImageManagerTest::SetUpOnMainThread(); |
| 615 | 615 |
| 616 base::FilePath user_keys_dir; | 616 base::FilePath user_keys_dir; |
| 617 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, | 617 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, |
| 618 &user_keys_dir)); | 618 &user_keys_dir)); |
| 619 const std::string sanitized_username = | 619 const std::string sanitized_username = |
| 620 chromeos::CryptohomeClient::GetStubSanitizedUsername(kTestUser1); | 620 chromeos::CryptohomeClient::GetStubSanitizedUsername(kTestUser1); |
| 621 const base::FilePath user_key_file = | 621 const base::FilePath user_key_file = |
| 622 user_keys_dir.AppendASCII(sanitized_username) | 622 user_keys_dir.AppendASCII(sanitized_username) |
| 623 .AppendASCII("policy.pub"); | 623 .AppendASCII("policy.pub"); |
| 624 std::vector<uint8> user_key_bits; | 624 std::vector<uint8> user_key_bits; |
| 625 ASSERT_TRUE(user_policy_.GetSigningKey()->ExportPublicKey(&user_key_bits)); | 625 ASSERT_TRUE(user_policy_.GetSigningKey()->ExportPublicKey(&user_key_bits)); |
| 626 ASSERT_TRUE(base::CreateDirectory(user_key_file.DirName())); | 626 ASSERT_TRUE(base::CreateDirectory(user_key_file.DirName())); |
| 627 ASSERT_EQ(base::WriteFile( | 627 ASSERT_EQ(base::WriteFile( |
| 628 user_key_file, | 628 user_key_file, |
| 629 reinterpret_cast<const char*>(user_key_bits.data()), | 629 reinterpret_cast<const char*>(user_key_bits.data()), |
| 630 user_key_bits.size()), | 630 user_key_bits.size()), |
| 631 static_cast<int>(user_key_bits.size())); | 631 static_cast<int>(user_key_bits.size())); |
| 632 user_policy_.policy_data().set_username(kTestUser1); | 632 user_policy_.policy_data().set_username(kTestUser1); |
| 633 | 633 |
| 634 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 634 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 635 | 635 |
| 636 policy_image_ = test::ImageLoader(test_data_dir_.Append( | 636 policy_image_ = test::ImageLoader(test_data_dir_.Append( |
| 637 test::kUserAvatarImage2RelativePath)).Load(); | 637 test::kUserAvatarImage2RelativePath)).Load(); |
| 638 ASSERT_TRUE(policy_image_); | 638 ASSERT_TRUE(policy_image_); |
| 639 } | 639 } |
| 640 | 640 |
| 641 // policy::CloudPolicyStore::Observer overrides: | 641 // policy::CloudPolicyStore::Observer overrides: |
| 642 virtual void OnStoreLoaded(policy::CloudPolicyStore* store) OVERRIDE { | 642 virtual void OnStoreLoaded(policy::CloudPolicyStore* store) override { |
| 643 if (run_loop_) | 643 if (run_loop_) |
| 644 run_loop_->Quit(); | 644 run_loop_->Quit(); |
| 645 } | 645 } |
| 646 | 646 |
| 647 virtual void OnStoreError(policy::CloudPolicyStore* store) OVERRIDE { | 647 virtual void OnStoreError(policy::CloudPolicyStore* store) override { |
| 648 if (run_loop_) | 648 if (run_loop_) |
| 649 run_loop_->Quit(); | 649 run_loop_->Quit(); |
| 650 } | 650 } |
| 651 | 651 |
| 652 std::string ConstructPolicy(const std::string& relative_path) { | 652 std::string ConstructPolicy(const std::string& relative_path) { |
| 653 std::string image_data; | 653 std::string image_data; |
| 654 if (!base::ReadFileToString(test_data_dir_.Append(relative_path), | 654 if (!base::ReadFileToString(test_data_dir_.Append(relative_path), |
| 655 &image_data)) { | 655 &image_data)) { |
| 656 ADD_FAILURE(); | 656 ADD_FAILURE(); |
| 657 } | 657 } |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 | 885 |
| 886 saved_image = test::ImageLoader(GetUserImagePath(kTestUser1, "jpg")).Load(); | 886 saved_image = test::ImageLoader(GetUserImagePath(kTestUser1, "jpg")).Load(); |
| 887 ASSERT_TRUE(saved_image); | 887 ASSERT_TRUE(saved_image); |
| 888 | 888 |
| 889 // 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. |
| 890 EXPECT_EQ(policy_image_->width(), saved_image->width()); | 890 EXPECT_EQ(policy_image_->width(), saved_image->width()); |
| 891 EXPECT_EQ(policy_image_->height(), saved_image->height()); | 891 EXPECT_EQ(policy_image_->height(), saved_image->height()); |
| 892 } | 892 } |
| 893 | 893 |
| 894 } // namespace chromeos | 894 } // namespace chromeos |
| OLD | NEW |