Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Unified Diff: base/memory/discardable_memory_unittest.cc

Issue 17106004: Add discardable memory emulation for non-android/mac platforms (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix MemoryAfterUnlock test Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/memory/discardable_memory_unittest.cc
diff --git a/base/memory/discardable_memory_unittest.cc b/base/memory/discardable_memory_unittest.cc
index d3c9c45cd8cdaee17adbf8a7b53ebbb4310bae5c..eb730f19f18e8482fde972598c99378f2c30447a 100644
--- a/base/memory/discardable_memory_unittest.cc
+++ b/base/memory/discardable_memory_unittest.cc
@@ -7,13 +7,22 @@
namespace base {
-#if defined(OS_ANDROID) || defined(OS_MACOSX)
const size_t kSize = 1024;
+TEST(DiscardableMemoryTest, SupportedNatively) {
+#if defined(DISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY)
+ ASSERT_TRUE(DiscardableMemory::SupportedNatively());
+#else
+ // If we ever have a platform that decides at runtime if it can support
+ // discardable memory natively, then we'll have to add a 'never supported
+ // natively' define for this case. At present, if it's not always supported
+ // natively, it's never supported.
+ ASSERT_FALSE(DiscardableMemory::SupportedNatively());
+#endif
+}
+
// Test Lock() and Unlock() functionalities.
TEST(DiscardableMemoryTest, LockAndUnLock) {
- ASSERT_TRUE(DiscardableMemory::Supported());
-
const scoped_ptr<DiscardableMemory> memory(
DiscardableMemory::CreateLockedMemory(kSize));
ASSERT_TRUE(memory);
@@ -32,17 +41,14 @@ TEST(DiscardableMemoryTest, LockAndUnLock) {
// Test delete a discardable memory while it is locked.
TEST(DiscardableMemoryTest, DeleteWhileLocked) {
- ASSERT_TRUE(DiscardableMemory::Supported());
-
const scoped_ptr<DiscardableMemory> memory(
DiscardableMemory::CreateLockedMemory(kSize));
ASSERT_TRUE(memory);
}
-#if defined(OS_MACOSX)
+#if !defined(OS_ANDROID)
// Test forced purging.
TEST(DiscardableMemoryTest, Purge) {
- ASSERT_TRUE(DiscardableMemory::Supported());
ASSERT_TRUE(DiscardableMemory::PurgeForTestingSupported());
const scoped_ptr<DiscardableMemory> memory(
@@ -53,7 +59,7 @@ TEST(DiscardableMemoryTest, Purge) {
DiscardableMemory::PurgeForTesting();
EXPECT_EQ(DISCARDABLE_MEMORY_PURGED, memory->Lock());
}
-#endif // OS_MACOSX
+#endif // !OS_ANDROID
#if !defined(NDEBUG) && !defined(OS_ANDROID)
// Death tests are not supported with Android APKs.
@@ -67,6 +73,4 @@ TEST(DiscardableMemoryTest, UnlockedMemoryAccessCrashesInDebugMode) {
}
#endif
-#endif // OS_*
-
}

Powered by Google App Engine
This is Rietveld 408576698