| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // These tests have been added to specifically tests issues arising from (A)LPC | 5 // These tests have been added to specifically tests issues arising from (A)LPC |
| 6 // lock down. | 6 // lock down. |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <cctype> | 9 #include <cctype> |
| 10 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 return SBOX_TEST_FAILED; | 121 return SBOX_TEST_FAILED; |
| 122 } | 122 } |
| 123 if (0 == wcsncmp(locale_name, expected_locale_name.c_str(), | 123 if (0 == wcsncmp(locale_name, expected_locale_name.c_str(), |
| 124 LOCALE_NAME_MAX_LENGTH)) { | 124 LOCALE_NAME_MAX_LENGTH)) { |
| 125 return SBOX_TEST_SUCCEEDED; | 125 return SBOX_TEST_SUCCEEDED; |
| 126 } | 126 } |
| 127 return SBOX_TEST_FAILED; | 127 return SBOX_TEST_FAILED; |
| 128 } | 128 } |
| 129 | 129 |
| 130 TEST(LpcPolicyTest, GetUserDefaultLocaleName) { | 130 TEST(LpcPolicyTest, GetUserDefaultLocaleName) { |
| 131 // GetUserDefaultLocaleName is not available before Vista. | |
| 132 if (base::win::GetVersion() < base::win::VERSION_VISTA) { | |
| 133 return; | |
| 134 } | |
| 135 static GetUserDefaultLocaleNameFunction GetUserDefaultLocaleName_func = NULL; | 131 static GetUserDefaultLocaleNameFunction GetUserDefaultLocaleName_func = NULL; |
| 136 if (!GetUserDefaultLocaleName_func) { | 132 if (!GetUserDefaultLocaleName_func) { |
| 137 // GetUserDefaultLocaleName is not available on WIN XP. So we'll | 133 // GetUserDefaultLocaleName is not available on WIN XP. So we'll |
| 138 // load it on-the-fly. | 134 // load it on-the-fly. |
| 139 HMODULE kernel32_dll = ::GetModuleHandle(kKernel32DllName); | 135 HMODULE kernel32_dll = ::GetModuleHandle(kKernel32DllName); |
| 140 EXPECT_NE(nullptr, kernel32_dll); | 136 EXPECT_NE(nullptr, kernel32_dll); |
| 141 GetUserDefaultLocaleName_func = | 137 GetUserDefaultLocaleName_func = |
| 142 reinterpret_cast<GetUserDefaultLocaleNameFunction>( | 138 reinterpret_cast<GetUserDefaultLocaleNameFunction>( |
| 143 GetProcAddress(kernel32_dll, "GetUserDefaultLocaleName")); | 139 GetProcAddress(kernel32_dll, "GetUserDefaultLocaleName")); |
| 144 EXPECT_NE(nullptr, GetUserDefaultLocaleName_func); | 140 EXPECT_NE(nullptr, GetUserDefaultLocaleName_func); |
| 145 } | 141 } |
| 146 wchar_t locale_name[LOCALE_NAME_MAX_LENGTH] = {0}; | 142 wchar_t locale_name[LOCALE_NAME_MAX_LENGTH] = {0}; |
| 147 EXPECT_NE(0, GetUserDefaultLocaleName_func( | 143 EXPECT_NE(0, GetUserDefaultLocaleName_func( |
| 148 locale_name, LOCALE_NAME_MAX_LENGTH * sizeof(wchar_t))); | 144 locale_name, LOCALE_NAME_MAX_LENGTH * sizeof(wchar_t))); |
| 149 EXPECT_NE(0U, wcsnlen(locale_name, LOCALE_NAME_MAX_LENGTH)); | 145 EXPECT_NE(0U, wcsnlen(locale_name, LOCALE_NAME_MAX_LENGTH)); |
| 150 std::wstring cmd = | 146 std::wstring cmd = |
| 151 L"Lpc_GetUserDefaultLocaleName " + std::wstring(locale_name); | 147 L"Lpc_GetUserDefaultLocaleName " + std::wstring(locale_name); |
| 152 TestRunner runner; | 148 TestRunner runner; |
| 153 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(cmd.c_str())); | 149 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(cmd.c_str())); |
| 154 } | 150 } |
| 155 | 151 |
| 156 } // namespace sandbox | 152 } // namespace sandbox |
| OLD | NEW |