OLD | NEW |
---|---|
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. |
Peter Kasting
2010/10/14 20:30:45
Nit: Remove 2006
| |
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_util.h" | 5 #include "base/win/windows_version.h" |
6 #include "sandbox/src/sandbox.h" | 6 #include "sandbox/src/sandbox.h" |
7 #include "sandbox/src/sandbox_factory.h" | 7 #include "sandbox/src/sandbox_factory.h" |
8 #include "sandbox/src/sandbox_utils.h" | 8 #include "sandbox/src/sandbox_utils.h" |
9 #include "sandbox/src/target_services.h" | 9 #include "sandbox/src/target_services.h" |
10 #include "sandbox/tests/common/controller.h" | 10 #include "sandbox/tests/common/controller.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace sandbox { | 13 namespace sandbox { |
14 | 14 |
15 #define BINDNTDLL(name) \ | 15 #define BINDNTDLL(name) \ |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 startup_info.cb = sizeof(startup_info); | 151 startup_info.cb = sizeof(startup_info); |
152 PROCESS_INFORMATION process_info; | 152 PROCESS_INFORMATION process_info; |
153 if (!::CreateProcessW(L"foo.exe", L"foo.exe", NULL, NULL, FALSE, 0, | 153 if (!::CreateProcessW(L"foo.exe", L"foo.exe", NULL, NULL, FALSE, 0, |
154 NULL, NULL, &startup_info, &process_info)) | 154 NULL, NULL, &startup_info, &process_info)) |
155 return SBOX_TEST_SUCCEEDED; | 155 return SBOX_TEST_SUCCEEDED; |
156 return SBOX_TEST_FAILED; | 156 return SBOX_TEST_FAILED; |
157 } | 157 } |
158 | 158 |
159 TEST(PolicyTargetTest, SetInformationThread) { | 159 TEST(PolicyTargetTest, SetInformationThread) { |
160 TestRunner runner; | 160 TestRunner runner; |
161 if (win_util::GetWinVersion() >= win_util::WINVERSION_XP) { | 161 if (base::win::GetVersion() >= base::win::VERSION_XP) { |
162 runner.SetTestState(BEFORE_REVERT); | 162 runner.SetTestState(BEFORE_REVERT); |
163 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_token")); | 163 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_token")); |
164 } | 164 } |
165 | 165 |
166 runner.SetTestState(AFTER_REVERT); | 166 runner.SetTestState(AFTER_REVERT); |
167 EXPECT_EQ(ERROR_NO_TOKEN, runner.RunTest(L"PolicyTargetTest_token")); | 167 EXPECT_EQ(ERROR_NO_TOKEN, runner.RunTest(L"PolicyTargetTest_token")); |
168 | 168 |
169 runner.SetTestState(EVERY_STATE); | 169 runner.SetTestState(EVERY_STATE); |
170 if (win_util::GetWinVersion() >= win_util::WINVERSION_XP) | 170 if (base::win::GetVersion() >= base::win::VERSION_XP) |
171 EXPECT_EQ(SBOX_TEST_FAILED, runner.RunTest(L"PolicyTargetTest_steal")); | 171 EXPECT_EQ(SBOX_TEST_FAILED, runner.RunTest(L"PolicyTargetTest_steal")); |
172 } | 172 } |
173 | 173 |
174 TEST(PolicyTargetTest, OpenThreadToken) { | 174 TEST(PolicyTargetTest, OpenThreadToken) { |
175 TestRunner runner; | 175 TestRunner runner; |
176 if (win_util::GetWinVersion() >= win_util::WINVERSION_XP) { | 176 if (base::win::GetVersion() >= base::win::VERSION_XP) { |
177 runner.SetTestState(BEFORE_REVERT); | 177 runner.SetTestState(BEFORE_REVERT); |
178 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_token2")); | 178 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_token2")); |
179 } | 179 } |
180 | 180 |
181 runner.SetTestState(AFTER_REVERT); | 181 runner.SetTestState(AFTER_REVERT); |
182 EXPECT_EQ(ERROR_NO_TOKEN, runner.RunTest(L"PolicyTargetTest_token2")); | 182 EXPECT_EQ(ERROR_NO_TOKEN, runner.RunTest(L"PolicyTargetTest_token2")); |
183 } | 183 } |
184 | 184 |
185 TEST(PolicyTargetTest, OpenThreadTokenEx) { | 185 TEST(PolicyTargetTest, OpenThreadTokenEx) { |
186 TestRunner runner; | 186 TestRunner runner; |
187 if (win_util::GetWinVersion() < win_util::WINVERSION_XP) | 187 if (base::win::GetVersion() < base::win::VERSION_XP) |
188 return; | 188 return; |
189 | 189 |
190 runner.SetTestState(BEFORE_REVERT); | 190 runner.SetTestState(BEFORE_REVERT); |
191 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_token3")); | 191 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_token3")); |
192 | 192 |
193 runner.SetTestState(AFTER_REVERT); | 193 runner.SetTestState(AFTER_REVERT); |
194 EXPECT_EQ(ERROR_NO_TOKEN, runner.RunTest(L"PolicyTargetTest_token3")); | 194 EXPECT_EQ(ERROR_NO_TOKEN, runner.RunTest(L"PolicyTargetTest_token3")); |
195 } | 195 } |
196 | 196 |
197 TEST(PolicyTargetTest, OpenThread) { | 197 TEST(PolicyTargetTest, OpenThread) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 EXPECT_TRUE(::CloseHandle(target.hProcess)); | 331 EXPECT_TRUE(::CloseHandle(target.hProcess)); |
332 EXPECT_TRUE(::CloseHandle(target.hThread)); | 332 EXPECT_TRUE(::CloseHandle(target.hThread)); |
333 | 333 |
334 // Close the desktop handle. | 334 // Close the desktop handle. |
335 temp_policy = broker->CreatePolicy(); | 335 temp_policy = broker->CreatePolicy(); |
336 temp_policy->DestroyAlternateDesktop(); | 336 temp_policy->DestroyAlternateDesktop(); |
337 temp_policy->Release(); | 337 temp_policy->Release(); |
338 } | 338 } |
339 | 339 |
340 } // namespace sandbox | 340 } // namespace sandbox |
OLD | NEW |