Chromium Code Reviews| 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 #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/debug/alias.h" | 10 #include "base/debug/alias.h" |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 EXPECT_TRUE(process.SetProcessBackgrounded(false)); | 373 EXPECT_TRUE(process.SetProcessBackgrounded(false)); |
| 374 EXPECT_FALSE(process.IsProcessBackgrounded()); | 374 EXPECT_FALSE(process.IsProcessBackgrounded()); |
| 375 #else | 375 #else |
| 376 process.SetProcessBackgrounded(true); | 376 process.SetProcessBackgrounded(true); |
| 377 process.SetProcessBackgrounded(false); | 377 process.SetProcessBackgrounded(false); |
| 378 #endif | 378 #endif |
| 379 int new_priority = process.GetPriority(); | 379 int new_priority = process.GetPriority(); |
| 380 EXPECT_EQ(old_priority, new_priority); | 380 EXPECT_EQ(old_priority, new_priority); |
| 381 } | 381 } |
| 382 | 382 |
| 383 #if defined(OS_LINUX) || defined(OS_ANDROID) | |
| 384 TEST_F(ProcessUtilTest, GetSystemMemoryInfo) { | |
| 385 base::SystemMemoryInfoKB info1; | |
|
jar (doing other things)
2013/02/14 02:26:11
nit: how about using the name |info|.
I assume yo
| |
| 386 EXPECT_TRUE(base::GetSystemMemoryInfo(&info1)); | |
| 387 | |
| 388 // Ensure each field received a value. | |
| 389 EXPECT_GT(info1.total, 0); | |
| 390 EXPECT_GT(info1.free, 0); | |
| 391 EXPECT_GT(info1.buffers, 0); | |
| 392 EXPECT_GT(info1.cached, 0); | |
| 393 EXPECT_GT(info1.active_anon, 0); | |
| 394 EXPECT_GT(info1.inactive_anon, 0); | |
| 395 EXPECT_GT(info1.active_file, 0); | |
| 396 EXPECT_GT(info1.inactive_file, 0); | |
| 397 | |
| 398 // All the values should be less than the total amount of memory. | |
| 399 EXPECT_LT(info1.free, info1.total); | |
| 400 EXPECT_LT(info1.buffers, info1.total); | |
| 401 EXPECT_LT(info1.cached, info1.total); | |
| 402 EXPECT_LT(info1.active_anon, info1.total); | |
| 403 EXPECT_LT(info1.inactive_anon, info1.total); | |
| 404 EXPECT_LT(info1.active_file, info1.total); | |
| 405 EXPECT_LT(info1.inactive_file, info1.total); | |
| 406 | |
| 407 #if defined(OS_CHROMEOS) | |
| 408 // Chrome OS exposes shmem. | |
| 409 EXPECT_GT(info1.shmem, 0); | |
| 410 EXPECT_LT(info1.shmem, info1.total); | |
| 411 // Chrome unit tests are not run on actual Chrome OS hardware, so gem_objects | |
| 412 // and gem_size cannot be tested here. | |
| 413 #endif | |
| 414 } | |
| 415 #endif // defined(OS_LINUX) || defined(OS_ANDROID) | |
| 416 | |
| 383 // TODO(estade): if possible, port these 2 tests. | 417 // TODO(estade): if possible, port these 2 tests. |
| 384 #if defined(OS_WIN) | 418 #if defined(OS_WIN) |
| 385 TEST_F(ProcessUtilTest, EnableLFH) { | 419 TEST_F(ProcessUtilTest, EnableLFH) { |
| 386 ASSERT_TRUE(base::EnableLowFragmentationHeap()); | 420 ASSERT_TRUE(base::EnableLowFragmentationHeap()); |
| 387 if (IsDebuggerPresent()) { | 421 if (IsDebuggerPresent()) { |
| 388 // Under these conditions, LFH can't be enabled. There's no point to test | 422 // Under these conditions, LFH can't be enabled. There's no point to test |
| 389 // anything. | 423 // anything. |
| 390 const char* no_debug_env = getenv("_NO_DEBUG_HEAP"); | 424 const char* no_debug_env = getenv("_NO_DEBUG_HEAP"); |
| 391 if (!no_debug_env || strcmp(no_debug_env, "1")) | 425 if (!no_debug_env || strcmp(no_debug_env, "1")) |
| 392 return; | 426 return; |
| (...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1235 SetUpInDeathAssert(); | 1269 SetUpInDeathAssert(); |
| 1236 while ((value_ = base::AllocatePsychoticallyBigObjCObject())) {} | 1270 while ((value_ = base::AllocatePsychoticallyBigObjCObject())) {} |
| 1237 }, ""); | 1271 }, ""); |
| 1238 } | 1272 } |
| 1239 | 1273 |
| 1240 #endif // !ARCH_CPU_64_BITS | 1274 #endif // !ARCH_CPU_64_BITS |
| 1241 #endif // OS_MACOSX | 1275 #endif // OS_MACOSX |
| 1242 | 1276 |
| 1243 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && | 1277 #endif // !defined(OS_ANDROID) && !defined(OS_OPENBSD) && |
| 1244 // !defined(OS_WIN) && !defined(ADDRESS_SANITIZER) | 1278 // !defined(OS_WIN) && !defined(ADDRESS_SANITIZER) |
| OLD | NEW |