Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1425)

Unified Diff: sandbox/win/src/lpc_policy_test.cc

Issue 1419483002: Windows sbox: Warmup locales before sandbox lockdown (and tests) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: return true instead of 0 Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/win/sandbox_win.gypi ('k') | sandbox/win/src/sandbox_policy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/win/src/lpc_policy_test.cc
diff --git a/sandbox/win/src/lpc_policy_test.cc b/sandbox/win/src/lpc_policy_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7308f96181bf56f869769f8081c830a9a2617b65
--- /dev/null
+++ b/sandbox/win/src/lpc_policy_test.cc
@@ -0,0 +1,86 @@
+// 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)?
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// These tests have been added to specifically tests issues arising from (A)LPC
+// lock down.
+
+#include <algorithm>
+#include <cctype>
+
+#include <windows.h>
+#include <winioctl.h>
+
+#include "base/win/windows_version.h"
+#include "sandbox/win/src/sandbox.h"
+#include "sandbox/win/src/sandbox_factory.h"
+#include "sandbox/win/src/sandbox_policy.h"
+#include "sandbox/win/tests/common/controller.h"
+#include "sandbox/win/tests/common/test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace sandbox {
+
+SBOX_TESTS_COMMAND int Lpc_GetUserDefaultLangID(int argc, wchar_t** argv) {
+ ::GetUserDefaultLangID();
+ return SBOX_TEST_SUCCEEDED;
+}
+
+TEST(LpcPolicyTest, GetUserDefaultLangID) {
+ TestRunner runner;
+ EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"Lpc_GetUserDefaultLangID"));
+}
+
+SBOX_TESTS_COMMAND int Lpc_GetUserDefaultLCID(int argc, wchar_t** argv) {
+ ::GetUserDefaultLCID();
+ return SBOX_TEST_SUCCEEDED;
+}
+
+TEST(LpcPolicyTest, GetUserDefaultLCID) {
+ TestRunner runner;
+ EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"Lpc_GetUserDefaultLCID"));
+}
+
+// GetUserDefaultLocaleName is not available on WIN XP. So we'll
+// load it on-the-fly.
+const wchar_t kKernel32DllName[] = L"kernel32.dll";
+typedef int(WINAPI* GetUserDefaultLocaleNameFunction)(LPWSTR lpLocaleName,
+ int cchLocaleName);
+
+SBOX_TESTS_COMMAND int Lpc_GetUserDefaultLocaleName(int argc, wchar_t** argv) {
+ static GetUserDefaultLocaleNameFunction GetUserDefaultLocaleName_func = NULL;
+ if (!GetUserDefaultLocaleName_func) {
+ // GetUserDefaultLocaleName is not available on WIN XP. So we'll
+ // load it on-the-fly.
+ HMODULE kernel32_dll = ::GetModuleHandle(kKernel32DllName);
+ if (!kernel32_dll) {
+ return SBOX_TEST_FAILED;
+ }
+ GetUserDefaultLocaleName_func =
+ reinterpret_cast<GetUserDefaultLocaleNameFunction>(
+ GetProcAddress(kernel32_dll, "GetUserDefaultLocaleName"));
+ if (!GetUserDefaultLocaleName_func) {
+ return SBOX_TEST_FAILED;
+ }
+ }
+ wchar_t localeName[LOCALE_NAME_MAX_LENGTH] = {0};
+ int ret = GetUserDefaultLocaleName_func(
+ localeName, LOCALE_NAME_MAX_LENGTH * sizeof(wchar_t));
+ if (!ret) {
+ return SBOX_TEST_FAILED;
+ }
+ if (!wcsnlen(localeName, LOCALE_NAME_MAX_LENGTH)) {
+ return SBOX_TEST_FAILED;
+ }
+ return SBOX_TEST_SUCCEEDED;
+}
+
+TEST(LpcPolicyTest, GetUserDefaultLocaleName) {
+ if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
+ TestRunner runner;
+ EXPECT_EQ(SBOX_TEST_SUCCEEDED,
+ runner.RunTest(L"Lpc_GetUserDefaultLocaleName"));
+ }
+}
+
+} // namespace sandbox
« no previous file with comments | « sandbox/win/sandbox_win.gypi ('k') | sandbox/win/src/sandbox_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698