| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/shared_memory.h" | 5 #include "base/memory/shared_memory.h" |
| 6 #include "base/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" |
| 7 #include "base/strings/string_piece.h" | 7 #include "base/strings/string_piece.h" |
| 8 #include "base/win/scoped_process_information.h" | 8 #include "base/win/scoped_process_information.h" |
| 9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
| 10 #include "sandbox/win/src/sandbox.h" | 10 #include "sandbox/win/src/sandbox.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_thread2")) << | 207 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_thread2")) << |
| 208 "Creates a new thread and opens it"; | 208 "Creates a new thread and opens it"; |
| 209 } | 209 } |
| 210 | 210 |
| 211 TEST(PolicyTargetTest, OpenProcess) { | 211 TEST(PolicyTargetTest, OpenProcess) { |
| 212 TestRunner runner; | 212 TestRunner runner; |
| 213 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_process")) << | 213 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_process")) << |
| 214 "Opens a process"; | 214 "Opens a process"; |
| 215 } | 215 } |
| 216 | 216 |
| 217 TEST(PolicyTargetTest, PolicyBaseNoJobLifetime) { |
| 218 TestRunner runner(JOB_NONE, USER_RESTRICTED_SAME_ACCESS, USER_LOCKDOWN); |
| 219 runner.SetReleasePolicyInRun(true); |
| 220 // TargetPolicy and its SharedMemIPCServer should continue to exist until |
| 221 // the child process dies. |
| 222 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_thread")) |
| 223 << "Opens the current thread"; |
| 224 } |
| 225 |
| 217 // Launches the app in the sandbox and ask it to wait in an | 226 // Launches the app in the sandbox and ask it to wait in an |
| 218 // infinite loop. Waits for 2 seconds and then check if the | 227 // infinite loop. Waits for 2 seconds and then check if the |
| 219 // desktop associated with the app thread is not the same as the | 228 // desktop associated with the app thread is not the same as the |
| 220 // current desktop. | 229 // current desktop. |
| 221 TEST(PolicyTargetTest, DesktopPolicy) { | 230 TEST(PolicyTargetTest, DesktopPolicy) { |
| 222 BrokerServices* broker = GetBroker(); | 231 BrokerServices* broker = GetBroker(); |
| 223 | 232 |
| 224 // Precreate the desktop. | 233 // Precreate the desktop. |
| 225 TargetPolicy* temp_policy = broker->CreatePolicy(); | 234 TargetPolicy* temp_policy = broker->CreatePolicy(); |
| 226 temp_policy->CreateAlternateDesktop(false); | 235 temp_policy->CreateAlternateDesktop(false); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 | 416 |
| 408 EXPECT_EQ(static_cast<DWORD>(WAIT_TIMEOUT), | 417 EXPECT_EQ(static_cast<DWORD>(WAIT_TIMEOUT), |
| 409 ::WaitForSingleObject(target.process_handle(), 2000)); | 418 ::WaitForSingleObject(target.process_handle(), 2000)); |
| 410 | 419 |
| 411 EXPECT_TRUE(::TerminateProcess(target.process_handle(), 0)); | 420 EXPECT_TRUE(::TerminateProcess(target.process_handle(), 0)); |
| 412 | 421 |
| 413 ::WaitForSingleObject(target.process_handle(), INFINITE); | 422 ::WaitForSingleObject(target.process_handle(), INFINITE); |
| 414 } | 423 } |
| 415 | 424 |
| 416 } // namespace sandbox | 425 } // namespace sandbox |
| OLD | NEW |