| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/installer/util/shell_util.h" | 5 #include "chrome/installer/util/shell_util.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/base_paths_win.h" | 10 #include "base/base_paths_win.h" |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 ShellUtil::BuildAppModelId(components)); | 1016 ShellUtil::BuildAppModelId(components)); |
| 1017 ASSERT_LE(constructed_app_id.length(), installer::kMaxAppModelIdLength); | 1017 ASSERT_LE(constructed_app_id.length(), installer::kMaxAppModelIdLength); |
| 1018 ASSERT_EQ(L"Chrome.a_user_wer_64_characters.A_crazy_profilethat_is_possible", | 1018 ASSERT_EQ(L"Chrome.a_user_wer_64_characters.A_crazy_profilethat_is_possible", |
| 1019 constructed_app_id); | 1019 constructed_app_id); |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 TEST(ShellUtilTest, GetUserSpecificRegistrySuffix) { | 1022 TEST(ShellUtilTest, GetUserSpecificRegistrySuffix) { |
| 1023 base::string16 suffix; | 1023 base::string16 suffix; |
| 1024 ASSERT_TRUE(ShellUtil::GetUserSpecificRegistrySuffix(&suffix)); | 1024 ASSERT_TRUE(ShellUtil::GetUserSpecificRegistrySuffix(&suffix)); |
| 1025 ASSERT_TRUE(base::StartsWith(suffix, L".", base::CompareCase::SENSITIVE)); | 1025 ASSERT_TRUE(base::StartsWith(suffix, L".", base::CompareCase::SENSITIVE)); |
| 1026 ASSERT_EQ(27, suffix.length()); | 1026 ASSERT_EQ(27u, suffix.length()); |
| 1027 ASSERT_TRUE(base::ContainsOnlyChars(suffix.substr(1), | 1027 ASSERT_TRUE(base::ContainsOnlyChars(suffix.substr(1), |
| 1028 L"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")); | 1028 L"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")); |
| 1029 } | 1029 } |
| 1030 | 1030 |
| 1031 TEST(ShellUtilTest, GetOldUserSpecificRegistrySuffix) { | 1031 TEST(ShellUtilTest, GetOldUserSpecificRegistrySuffix) { |
| 1032 base::string16 suffix; | 1032 base::string16 suffix; |
| 1033 ASSERT_TRUE(ShellUtil::GetOldUserSpecificRegistrySuffix(&suffix)); | 1033 ASSERT_TRUE(ShellUtil::GetOldUserSpecificRegistrySuffix(&suffix)); |
| 1034 ASSERT_TRUE(base::StartsWith(suffix, L".", base::CompareCase::SENSITIVE)); | 1034 ASSERT_TRUE(base::StartsWith(suffix, L".", base::CompareCase::SENSITIVE)); |
| 1035 | 1035 |
| 1036 wchar_t user_name[256]; | 1036 wchar_t user_name[256]; |
| 1037 DWORD size = arraysize(user_name); | 1037 DWORD size = arraysize(user_name); |
| 1038 ASSERT_NE(0, ::GetUserName(user_name, &size)); | 1038 ASSERT_NE(0, ::GetUserName(user_name, &size)); |
| 1039 ASSERT_GE(size, 1U); | 1039 ASSERT_GE(size, 1U); |
| 1040 ASSERT_STREQ(user_name, suffix.substr(1).c_str()); | 1040 ASSERT_STREQ(user_name, suffix.substr(1).c_str()); |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 TEST(ShellUtilTest, ByteArrayToBase32) { | 1043 TEST(ShellUtilTest, ByteArrayToBase32) { |
| 1044 // Tests from http://tools.ietf.org/html/rfc4648#section-10. | 1044 // Tests from http://tools.ietf.org/html/rfc4648#section-10. |
| 1045 const unsigned char test_array[] = { 'f', 'o', 'o', 'b', 'a', 'r' }; | 1045 const unsigned char test_array[] = { 'f', 'o', 'o', 'b', 'a', 'r' }; |
| 1046 | 1046 |
| 1047 const base::string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", | 1047 const base::string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", |
| 1048 L"MZXW6YTB", L"MZXW6YTBOI"}; | 1048 L"MZXW6YTB", L"MZXW6YTBOI"}; |
| 1049 | 1049 |
| 1050 // Run the tests, with one more letter in the input every pass. | 1050 // Run the tests, with one more letter in the input every pass. |
| 1051 for (int i = 0; i < arraysize(expected); ++i) { | 1051 for (size_t i = 0; i < arraysize(expected); ++i) { |
| 1052 ASSERT_EQ(expected[i], | 1052 ASSERT_EQ(expected[i], |
| 1053 ShellUtil::ByteArrayToBase32(test_array, i)); | 1053 ShellUtil::ByteArrayToBase32(test_array, i)); |
| 1054 } | 1054 } |
| 1055 } | 1055 } |
| OLD | NEW |