Chromium Code Reviews| Index: sandbox/win/src/sandbox_nt_util_unittest.cc |
| diff --git a/sandbox/win/src/sandbox_nt_util_unittest.cc b/sandbox/win/src/sandbox_nt_util_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5d12b322f50cdd0e7dbc8be968adbca73880e790 |
| --- /dev/null |
| +++ b/sandbox/win/src/sandbox_nt_util_unittest.cc |
| @@ -0,0 +1,40 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <windows.h> |
| + |
| +#include "base/win/scoped_handle.h" |
| +#include "base/win/scoped_process_information.h" |
| +#include "sandbox/win/src/policy_broker.h" |
| +#include "sandbox/win/src/sandbox_nt_util.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace sandbox { |
| +namespace { |
| + |
| +TEST(SandboxNtUtil, IsSameProcess) { |
| + InitGlobalNt(); |
| + |
| + HANDLE current_process_pseudo = GetCurrentProcess(); |
| + EXPECT_TRUE(IsSameProcess(current_process_pseudo)); |
| + |
| + base::win::ScopedHandle current_process( |
| + OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, GetCurrentProcessId())); |
| + ASSERT_TRUE(current_process.IsValid()); |
|
Will Harris
2015/09/04 02:18:12
some are EXPECT_TRUE and some ASSERT_TRUE - normal
rickyz (no longer on Chrome)
2015/09/08 21:51:39
Discussed in person - I split the test up into sma
|
| + EXPECT_TRUE(IsSameProcess(current_process.Get())); |
| + |
| + STARTUPINFO si = {sizeof(si)}; |
| + PROCESS_INFORMATION pi = {}; |
| + wchar_t notepad[] = L"notepad"; |
| + ASSERT_TRUE(CreateProcessW(nullptr, notepad, nullptr, nullptr, FALSE, 0, |
| + nullptr, nullptr, &si, &pi)); |
| + base::win::ScopedProcessInformation process_info(pi); |
| + |
| + EXPECT_FALSE(IsSameProcess(process_info.process_handle())); |
| + |
| + EXPECT_TRUE(TerminateProcess(process_info.process_handle(), 0)); |
| +} |
| + |
| +} // namespace |
| +} // namespace sandbox |