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> |
| 6 |
5 #include <map> | 7 #include <map> |
6 #include <string> | 8 #include <string> |
7 #include <vector> | 9 #include <vector> |
8 | 10 |
9 #include "base/basictypes.h" | |
10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
12 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
13 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
| 15 #include "base/macros.h" |
14 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
15 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
16 #include "base/memory/ref_counted_memory.h" | 18 #include "base/memory/ref_counted_memory.h" |
17 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
18 #include "base/path_service.h" | 20 #include "base/path_service.h" |
19 #include "base/prefs/pref_change_registrar.h" | 21 #include "base/prefs/pref_change_registrar.h" |
20 #include "base/prefs/pref_service.h" | 22 #include "base/prefs/pref_service.h" |
21 #include "base/prefs/scoped_user_pref_update.h" | 23 #include "base/prefs/scoped_user_pref_update.h" |
22 #include "base/run_loop.h" | 24 #include "base/run_loop.h" |
23 #include "base/thread_task_runner_handle.h" | 25 #include "base/thread_task_runner_handle.h" |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 | 650 |
649 base::FilePath user_keys_dir; | 651 base::FilePath user_keys_dir; |
650 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, | 652 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, |
651 &user_keys_dir)); | 653 &user_keys_dir)); |
652 const std::string sanitized_username = | 654 const std::string sanitized_username = |
653 chromeos::CryptohomeClient::GetStubSanitizedUsername( | 655 chromeos::CryptohomeClient::GetStubSanitizedUsername( |
654 enterprise_account_id_.GetUserEmail()); | 656 enterprise_account_id_.GetUserEmail()); |
655 const base::FilePath user_key_file = | 657 const base::FilePath user_key_file = |
656 user_keys_dir.AppendASCII(sanitized_username) | 658 user_keys_dir.AppendASCII(sanitized_username) |
657 .AppendASCII("policy.pub"); | 659 .AppendASCII("policy.pub"); |
658 std::vector<uint8> user_key_bits; | 660 std::vector<uint8_t> user_key_bits; |
659 ASSERT_TRUE(user_policy_.GetSigningKey()->ExportPublicKey(&user_key_bits)); | 661 ASSERT_TRUE(user_policy_.GetSigningKey()->ExportPublicKey(&user_key_bits)); |
660 ASSERT_TRUE(base::CreateDirectory(user_key_file.DirName())); | 662 ASSERT_TRUE(base::CreateDirectory(user_key_file.DirName())); |
661 ASSERT_EQ(base::WriteFile( | 663 ASSERT_EQ(base::WriteFile( |
662 user_key_file, | 664 user_key_file, |
663 reinterpret_cast<const char*>(user_key_bits.data()), | 665 reinterpret_cast<const char*>(user_key_bits.data()), |
664 user_key_bits.size()), | 666 user_key_bits.size()), |
665 static_cast<int>(user_key_bits.size())); | 667 static_cast<int>(user_key_bits.size())); |
666 user_policy_.policy_data().set_username( | 668 user_policy_.policy_data().set_username( |
667 enterprise_account_id_.GetUserEmail()); | 669 enterprise_account_id_.GetUserEmail()); |
668 | 670 |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 saved_image = | 926 saved_image = |
925 test::ImageLoader(GetUserImagePath(enterprise_account_id_, "jpg")).Load(); | 927 test::ImageLoader(GetUserImagePath(enterprise_account_id_, "jpg")).Load(); |
926 ASSERT_TRUE(saved_image); | 928 ASSERT_TRUE(saved_image); |
927 | 929 |
928 // Check image dimensions. Images can't be compared since JPEG is lossy. | 930 // Check image dimensions. Images can't be compared since JPEG is lossy. |
929 EXPECT_EQ(policy_image_->width(), saved_image->width()); | 931 EXPECT_EQ(policy_image_->width(), saved_image->width()); |
930 EXPECT_EQ(policy_image_->height(), saved_image->height()); | 932 EXPECT_EQ(policy_image_->height(), saved_image->height()); |
931 } | 933 } |
932 | 934 |
933 } // namespace chromeos | 935 } // namespace chromeos |
OLD | NEW |