| 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 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 const base::string16 constructed_app_id( | 972 const base::string16 constructed_app_id( |
| 973 ShellUtil::BuildAppModelId(components)); | 973 ShellUtil::BuildAppModelId(components)); |
| 974 ASSERT_LE(constructed_app_id.length(), installer::kMaxAppModelIdLength); | 974 ASSERT_LE(constructed_app_id.length(), installer::kMaxAppModelIdLength); |
| 975 ASSERT_EQ(L"Chrome.a_user_wer_64_characters.A_crazy_profilethat_is_possible", | 975 ASSERT_EQ(L"Chrome.a_user_wer_64_characters.A_crazy_profilethat_is_possible", |
| 976 constructed_app_id); | 976 constructed_app_id); |
| 977 } | 977 } |
| 978 | 978 |
| 979 TEST(ShellUtilTest, GetUserSpecificRegistrySuffix) { | 979 TEST(ShellUtilTest, GetUserSpecificRegistrySuffix) { |
| 980 base::string16 suffix; | 980 base::string16 suffix; |
| 981 ASSERT_TRUE(ShellUtil::GetUserSpecificRegistrySuffix(&suffix)); | 981 ASSERT_TRUE(ShellUtil::GetUserSpecificRegistrySuffix(&suffix)); |
| 982 ASSERT_TRUE(base::StartsWith(suffix, L".", true)); | 982 ASSERT_TRUE(base::StartsWith(suffix, L".", base::CompareCase::SENSITIVE)); |
| 983 ASSERT_EQ(27, suffix.length()); | 983 ASSERT_EQ(27, suffix.length()); |
| 984 ASSERT_TRUE(base::ContainsOnlyChars(suffix.substr(1), | 984 ASSERT_TRUE(base::ContainsOnlyChars(suffix.substr(1), |
| 985 L"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")); | 985 L"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")); |
| 986 } | 986 } |
| 987 | 987 |
| 988 TEST(ShellUtilTest, GetOldUserSpecificRegistrySuffix) { | 988 TEST(ShellUtilTest, GetOldUserSpecificRegistrySuffix) { |
| 989 base::string16 suffix; | 989 base::string16 suffix; |
| 990 ASSERT_TRUE(ShellUtil::GetOldUserSpecificRegistrySuffix(&suffix)); | 990 ASSERT_TRUE(ShellUtil::GetOldUserSpecificRegistrySuffix(&suffix)); |
| 991 ASSERT_TRUE(base::StartsWith(suffix, L".", true)); | 991 ASSERT_TRUE(base::StartsWith(suffix, L".", base::CompareCase::SENSITIVE)); |
| 992 | 992 |
| 993 wchar_t user_name[256]; | 993 wchar_t user_name[256]; |
| 994 DWORD size = arraysize(user_name); | 994 DWORD size = arraysize(user_name); |
| 995 ASSERT_NE(0, ::GetUserName(user_name, &size)); | 995 ASSERT_NE(0, ::GetUserName(user_name, &size)); |
| 996 ASSERT_GE(size, 1U); | 996 ASSERT_GE(size, 1U); |
| 997 ASSERT_STREQ(user_name, suffix.substr(1).c_str()); | 997 ASSERT_STREQ(user_name, suffix.substr(1).c_str()); |
| 998 } | 998 } |
| 999 | 999 |
| 1000 TEST(ShellUtilTest, ByteArrayToBase32) { | 1000 TEST(ShellUtilTest, ByteArrayToBase32) { |
| 1001 // Tests from http://tools.ietf.org/html/rfc4648#section-10. | 1001 // Tests from http://tools.ietf.org/html/rfc4648#section-10. |
| 1002 const unsigned char test_array[] = { 'f', 'o', 'o', 'b', 'a', 'r' }; | 1002 const unsigned char test_array[] = { 'f', 'o', 'o', 'b', 'a', 'r' }; |
| 1003 | 1003 |
| 1004 const base::string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", | 1004 const base::string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", |
| 1005 L"MZXW6YTB", L"MZXW6YTBOI"}; | 1005 L"MZXW6YTB", L"MZXW6YTBOI"}; |
| 1006 | 1006 |
| 1007 // Run the tests, with one more letter in the input every pass. | 1007 // Run the tests, with one more letter in the input every pass. |
| 1008 for (int i = 0; i < arraysize(expected); ++i) { | 1008 for (int i = 0; i < arraysize(expected); ++i) { |
| 1009 ASSERT_EQ(expected[i], | 1009 ASSERT_EQ(expected[i], |
| 1010 ShellUtil::ByteArrayToBase32(test_array, i)); | 1010 ShellUtil::ByteArrayToBase32(test_array, i)); |
| 1011 } | 1011 } |
| 1012 } | 1012 } |
| OLD | NEW |