| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "base/win/scoped_process_information.h" |
| 5 #include "base/win/windows_version.h" | 6 #include "base/win/windows_version.h" |
| 6 #include "sandbox/src/sandbox.h" | 7 #include "sandbox/src/sandbox.h" |
| 7 #include "sandbox/src/sandbox_factory.h" | 8 #include "sandbox/src/sandbox_factory.h" |
| 8 #include "sandbox/src/sandbox_utils.h" | 9 #include "sandbox/src/sandbox_utils.h" |
| 9 #include "sandbox/src/target_services.h" | 10 #include "sandbox/src/target_services.h" |
| 10 #include "sandbox/tests/common/controller.h" | 11 #include "sandbox/tests/common/controller.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 13 |
| 13 namespace sandbox { | 14 namespace sandbox { |
| 14 | 15 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 return ::GetLastError(); | 143 return ::GetLastError(); |
| 143 | 144 |
| 144 return SBOX_TEST_SUCCEEDED; | 145 return SBOX_TEST_SUCCEEDED; |
| 145 } | 146 } |
| 146 | 147 |
| 147 // Tests that we can call CreateProcess. | 148 // Tests that we can call CreateProcess. |
| 148 SBOX_TESTS_COMMAND int PolicyTargetTest_process(int argc, wchar_t **argv) { | 149 SBOX_TESTS_COMMAND int PolicyTargetTest_process(int argc, wchar_t **argv) { |
| 149 // Use default values to create a new process. | 150 // Use default values to create a new process. |
| 150 STARTUPINFO startup_info = {0}; | 151 STARTUPINFO startup_info = {0}; |
| 151 startup_info.cb = sizeof(startup_info); | 152 startup_info.cb = sizeof(startup_info); |
| 152 PROCESS_INFORMATION process_info; | 153 base::win::ScopedProcessInformation process_info; |
| 153 if (!::CreateProcessW(L"foo.exe", L"foo.exe", NULL, NULL, FALSE, 0, | 154 if (!::CreateProcessW(L"foo.exe", L"foo.exe", NULL, NULL, FALSE, 0, |
| 154 NULL, NULL, &startup_info, &process_info)) | 155 NULL, NULL, &startup_info, process_info.Receive())) |
| 155 return SBOX_TEST_SUCCEEDED; | 156 return SBOX_TEST_SUCCEEDED; |
| 156 return SBOX_TEST_FAILED; | 157 return SBOX_TEST_FAILED; |
| 157 } | 158 } |
| 158 | 159 |
| 159 TEST(PolicyTargetTest, SetInformationThread) { | 160 TEST(PolicyTargetTest, SetInformationThread) { |
| 160 TestRunner runner; | 161 TestRunner runner; |
| 161 if (base::win::GetVersion() >= base::win::VERSION_XP) { | 162 if (base::win::GetVersion() >= base::win::VERSION_XP) { |
| 162 runner.SetTestState(BEFORE_REVERT); | 163 runner.SetTestState(BEFORE_REVERT); |
| 163 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_token")); | 164 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_token")); |
| 164 } | 165 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 EXPECT_TRUE(::CloseHandle(target.hProcess)); | 332 EXPECT_TRUE(::CloseHandle(target.hProcess)); |
| 332 EXPECT_TRUE(::CloseHandle(target.hThread)); | 333 EXPECT_TRUE(::CloseHandle(target.hThread)); |
| 333 | 334 |
| 334 // Close the desktop handle. | 335 // Close the desktop handle. |
| 335 temp_policy = broker->CreatePolicy(); | 336 temp_policy = broker->CreatePolicy(); |
| 336 temp_policy->DestroyAlternateDesktop(); | 337 temp_policy->DestroyAlternateDesktop(); |
| 337 temp_policy->Release(); | 338 temp_policy->Release(); |
| 338 } | 339 } |
| 339 | 340 |
| 340 } // namespace sandbox | 341 } // namespace sandbox |
| OLD | NEW |