Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
|
jochen (gone - plz use gerrit)
2015/10/21 13:28:18
shouldn't this be 2015 and without the (c)?
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // These tests have been added to specifically tests issues arising from (A)LPC | |
| 6 // lock down. | |
| 7 | |
| 8 #include <algorithm> | |
| 9 #include <cctype> | |
| 10 | |
| 11 #include <windows.h> | |
| 12 #include <winioctl.h> | |
| 13 | |
| 14 #include "base/win/windows_version.h" | |
| 15 #include "sandbox/win/src/sandbox.h" | |
| 16 #include "sandbox/win/src/sandbox_factory.h" | |
| 17 #include "sandbox/win/src/sandbox_policy.h" | |
| 18 #include "sandbox/win/tests/common/controller.h" | |
| 19 #include "sandbox/win/tests/common/test_utils.h" | |
| 20 #include "testing/gtest/include/gtest/gtest.h" | |
| 21 | |
| 22 namespace sandbox { | |
| 23 | |
| 24 SBOX_TESTS_COMMAND int Lpc_GetUserDefaultLangID(int argc, wchar_t** argv) { | |
| 25 ::GetUserDefaultLangID(); | |
| 26 return SBOX_TEST_SUCCEEDED; | |
| 27 } | |
| 28 | |
| 29 TEST(LpcPolicyTest, GetUserDefaultLangID) { | |
| 30 TestRunner runner; | |
| 31 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"Lpc_GetUserDefaultLangID")); | |
| 32 } | |
| 33 | |
| 34 SBOX_TESTS_COMMAND int Lpc_GetUserDefaultLCID(int argc, wchar_t** argv) { | |
| 35 ::GetUserDefaultLCID(); | |
| 36 return SBOX_TEST_SUCCEEDED; | |
| 37 } | |
| 38 | |
| 39 TEST(LpcPolicyTest, GetUserDefaultLCID) { | |
| 40 TestRunner runner; | |
| 41 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"Lpc_GetUserDefaultLCID")); | |
| 42 } | |
| 43 | |
| 44 // GetUserDefaultLocaleName is not available on WIN XP. So we'll | |
| 45 // load it on-the-fly. | |
| 46 const wchar_t kKernel32DllName[] = L"kernel32.dll"; | |
| 47 typedef int(WINAPI* GetUserDefaultLocaleNameFunction)(LPWSTR lpLocaleName, | |
| 48 int cchLocaleName); | |
| 49 | |
| 50 SBOX_TESTS_COMMAND int Lpc_GetUserDefaultLocaleName(int argc, wchar_t** argv) { | |
| 51 static GetUserDefaultLocaleNameFunction GetUserDefaultLocaleName_func = NULL; | |
| 52 if (!GetUserDefaultLocaleName_func) { | |
| 53 // GetUserDefaultLocaleName is not available on WIN XP. So we'll | |
| 54 // load it on-the-fly. | |
| 55 HMODULE kernel32_dll = ::GetModuleHandle(kKernel32DllName); | |
| 56 if (!kernel32_dll) { | |
| 57 return SBOX_TEST_FAILED; | |
| 58 } | |
| 59 GetUserDefaultLocaleName_func = | |
| 60 reinterpret_cast<GetUserDefaultLocaleNameFunction>( | |
| 61 GetProcAddress(kernel32_dll, "GetUserDefaultLocaleName")); | |
| 62 if (!GetUserDefaultLocaleName_func) { | |
| 63 return SBOX_TEST_FAILED; | |
| 64 } | |
| 65 } | |
| 66 wchar_t localeName[LOCALE_NAME_MAX_LENGTH] = {0}; | |
| 67 int ret = GetUserDefaultLocaleName_func( | |
| 68 localeName, LOCALE_NAME_MAX_LENGTH * sizeof(wchar_t)); | |
| 69 if (!ret) { | |
| 70 return SBOX_TEST_FAILED; | |
| 71 } | |
| 72 if (!wcsnlen(localeName, LOCALE_NAME_MAX_LENGTH)) { | |
| 73 return SBOX_TEST_FAILED; | |
| 74 } | |
| 75 return SBOX_TEST_SUCCEEDED; | |
| 76 } | |
| 77 | |
| 78 TEST(LpcPolicyTest, GetUserDefaultLocaleName) { | |
| 79 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | |
| 80 TestRunner runner; | |
| 81 EXPECT_EQ(SBOX_TEST_SUCCEEDED, | |
| 82 runner.RunTest(L"Lpc_GetUserDefaultLocaleName")); | |
| 83 } | |
| 84 } | |
| 85 | |
| 86 } // namespace sandbox | |
| OLD | NEW |