Mandoline: support IME for HTMLWidgetRootLocal & HTMLWidgetLocalRoot.
[chromium-blink-merge.git] / sandbox / win / src / sandbox_nt_util_unittest.cc
blob0fbea6680247323a351574b8f9dfdb31f00c7685
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
3 // found in the LICENSE file.
5 #include <windows.h>
7 #include "base/win/scoped_handle.h"
8 #include "base/win/scoped_process_information.h"
9 #include "sandbox/win/src/policy_broker.h"
10 #include "sandbox/win/src/sandbox_nt_util.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 namespace sandbox {
14 namespace {
16 TEST(SandboxNtUtil, IsSameProcessPseudoHandle) {
17 InitGlobalNt();
19 HANDLE current_process_pseudo = GetCurrentProcess();
20 EXPECT_TRUE(IsSameProcess(current_process_pseudo));
23 TEST(SandboxNtUtil, IsSameProcessNonPseudoHandle) {
24 InitGlobalNt();
26 base::win::ScopedHandle current_process(
27 OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, GetCurrentProcessId()));
28 ASSERT_TRUE(current_process.IsValid());
29 EXPECT_TRUE(IsSameProcess(current_process.Get()));
32 TEST(SandboxNtUtil, IsSameProcessDifferentProcess) {
33 InitGlobalNt();
35 STARTUPINFO si = {sizeof(si)};
36 PROCESS_INFORMATION pi = {};
37 wchar_t notepad[] = L"notepad";
38 ASSERT_TRUE(CreateProcessW(nullptr, notepad, nullptr, nullptr, FALSE, 0,
39 nullptr, nullptr, &si, &pi));
40 base::win::ScopedProcessInformation process_info(pi);
42 EXPECT_FALSE(IsSameProcess(process_info.process_handle()));
43 EXPECT_TRUE(TerminateProcess(process_info.process_handle(), 0));
46 } // namespace
47 } // namespace sandbox