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

Side by Side Diff: base/memory/discardable_memory_unittest.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/discardable_memory.h" 5 #include "base/memory/discardable_memory.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 memory->Unlock(); 76 memory->Unlock();
77 } 77 }
78 78
79 // Test delete a discardable memory while it is locked. 79 // Test delete a discardable memory while it is locked.
80 TEST_P(DiscardableMemoryTest, DeleteWhileLocked) { 80 TEST_P(DiscardableMemoryTest, DeleteWhileLocked) {
81 const scoped_ptr<DiscardableMemory> memory(CreateLockedMemory(kSize)); 81 const scoped_ptr<DiscardableMemory> memory(CreateLockedMemory(kSize));
82 ASSERT_TRUE(memory); 82 ASSERT_TRUE(memory);
83 } 83 }
84 84
85 // Test forced purging.
86 TEST_P(DiscardableMemoryTest, Purge) {
87 const scoped_ptr<DiscardableMemory> memory(CreateLockedMemory(kSize));
88 ASSERT_TRUE(memory);
89 memory->Unlock();
90
91 DiscardableMemory::PurgeForTesting();
92 EXPECT_EQ(DISCARDABLE_MEMORY_LOCK_STATUS_PURGED, memory->Lock());
93 }
94
95 #if !defined(NDEBUG) && !defined(OS_ANDROID) 85 #if !defined(NDEBUG) && !defined(OS_ANDROID)
96 // Death tests are not supported with Android APKs. 86 // Death tests are not supported with Android APKs.
97 TEST_P(DiscardableMemoryTest, UnlockedMemoryAccessCrashesInDebugMode) { 87 TEST_P(DiscardableMemoryTest, UnlockedMemoryAccessCrashesInDebugMode) {
98 const scoped_ptr<DiscardableMemory> memory(CreateLockedMemory(kSize)); 88 const scoped_ptr<DiscardableMemory> memory(CreateLockedMemory(kSize));
99 ASSERT_TRUE(memory); 89 ASSERT_TRUE(memory);
100 memory->Unlock(); 90 memory->Unlock();
101 ASSERT_DEATH_IF_SUPPORTED( 91 ASSERT_DEATH_IF_SUPPORTED(
102 { *static_cast<int*>(memory->Memory()) = 0xdeadbeef; }, ".*"); 92 { *static_cast<int*>(memory->Memory()) = 0xdeadbeef; }, ".*");
103 } 93 }
104 #endif 94 #endif
(...skipping 24 matching lines...) Expand all
129 return supported_types; 119 return supported_types;
130 } 120 }
131 121
132 INSTANTIATE_TEST_CASE_P( 122 INSTANTIATE_TEST_CASE_P(
133 DiscardableMemoryTests, 123 DiscardableMemoryTests,
134 DiscardableMemoryTest, 124 DiscardableMemoryTest,
135 ::testing::ValuesIn(GetSupportedDiscardableMemoryTypes())); 125 ::testing::ValuesIn(GetSupportedDiscardableMemoryTypes()));
136 126
137 } // namespace 127 } // namespace
138 } // namespace base 128 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_shmem_allocator.cc ('k') | base/memory/discardable_memory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698