OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #define _CRT_SECURE_NO_WARNINGS | 5 #define _CRT_SECURE_NO_WARNINGS |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/eintr_wrapper.h" | 10 #include "base/eintr_wrapper.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } | 253 } |
254 | 254 |
255 // Ensure that the priority of a process is restored correctly after | 255 // Ensure that the priority of a process is restored correctly after |
256 // backgrounding and restoring. | 256 // backgrounding and restoring. |
257 // Note: a platform may not be willing or able to lower the priority of | 257 // Note: a platform may not be willing or able to lower the priority of |
258 // a process. The calls to SetProcessBackground should be noops then. | 258 // a process. The calls to SetProcessBackground should be noops then. |
259 TEST_F(ProcessUtilTest, SetProcessBackgrounded) { | 259 TEST_F(ProcessUtilTest, SetProcessBackgrounded) { |
260 base::ProcessHandle handle = this->SpawnChild("SimpleChildProcess", false); | 260 base::ProcessHandle handle = this->SpawnChild("SimpleChildProcess", false); |
261 base::Process process(handle); | 261 base::Process process(handle); |
262 int old_priority = process.GetPriority(); | 262 int old_priority = process.GetPriority(); |
263 process.SetProcessBackgrounded(true); | 263 if (process.SetProcessBackgrounded(true)) { |
264 process.SetProcessBackgrounded(false); | 264 EXPECT_TRUE(process.IsProcessBackgrounded()); |
| 265 EXPECT_TRUE(process.SetProcessBackgrounded(false)); |
| 266 EXPECT_FALSE(process.IsProcessBackgrounded()); |
| 267 } |
| 268 int new_priority = process.GetPriority(); |
| 269 EXPECT_EQ(old_priority, new_priority); |
| 270 } |
| 271 |
| 272 // Same as SetProcessBackgrounded but to this very process. It uses |
| 273 // a different code path at least for Windows. |
| 274 TEST_F(ProcessUtilTest, SetProcessBackgroundedSelf) { |
| 275 base::Process process(base::Process::Current().handle()); |
| 276 int old_priority = process.GetPriority(); |
| 277 if (process.SetProcessBackgrounded(true)) { |
| 278 EXPECT_TRUE(process.IsProcessBackgrounded()); |
| 279 EXPECT_TRUE(process.SetProcessBackgrounded(false)); |
| 280 EXPECT_FALSE(process.IsProcessBackgrounded()); |
| 281 } |
265 int new_priority = process.GetPriority(); | 282 int new_priority = process.GetPriority(); |
266 EXPECT_EQ(old_priority, new_priority); | 283 EXPECT_EQ(old_priority, new_priority); |
267 } | 284 } |
268 | 285 |
269 // TODO(estade): if possible, port these 2 tests. | 286 // TODO(estade): if possible, port these 2 tests. |
270 #if defined(OS_WIN) | 287 #if defined(OS_WIN) |
271 TEST_F(ProcessUtilTest, EnableLFH) { | 288 TEST_F(ProcessUtilTest, EnableLFH) { |
272 ASSERT_TRUE(base::EnableLowFragmentationHeap()); | 289 ASSERT_TRUE(base::EnableLowFragmentationHeap()); |
273 if (IsDebuggerPresent()) { | 290 if (IsDebuggerPresent()) { |
274 // Under these conditions, LFH can't be enabled. There's no point to test | 291 // Under these conditions, LFH can't be enabled. There's no point to test |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 ASSERT_DEATH({ | 938 ASSERT_DEATH({ |
922 SetUpInDeathAssert(); | 939 SetUpInDeathAssert(); |
923 while ((value_ = base::AllocatePsychoticallyBigObjCObject())) {} | 940 while ((value_ = base::AllocatePsychoticallyBigObjCObject())) {} |
924 }, ""); | 941 }, ""); |
925 } | 942 } |
926 | 943 |
927 #endif // !ARCH_CPU_64_BITS | 944 #endif // !ARCH_CPU_64_BITS |
928 #endif // OS_MACOSX | 945 #endif // OS_MACOSX |
929 | 946 |
930 #endif // !defined(OS_WIN) | 947 #endif // !defined(OS_WIN) |
OLD | NEW |