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

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

Issue 458343003: Revert of base: Introduce an explicit call for reducing emulated discardable memory usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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 "base/run_loop.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 #if defined(OS_ANDROID) 12 #if defined(OS_ANDROID)
12 #include <limits> 13 #include <limits>
13 #endif 14 #endif
14 15
15 namespace base { 16 namespace base {
16 namespace { 17 namespace {
17 18
18 class DiscardableMemoryTest 19 class DiscardableMemoryTest
19 : public testing::TestWithParam<DiscardableMemoryType> { 20 : public testing::TestWithParam<DiscardableMemoryType> {
20 public: 21 public:
21 DiscardableMemoryTest() {} 22 DiscardableMemoryTest() : message_loop_(MessageLoop::TYPE_IO) {
23 // Register memory pressure listeners now that we have a message loop.
24 DiscardableMemory::RegisterMemoryPressureListeners();
25 }
22 virtual ~DiscardableMemoryTest() { 26 virtual ~DiscardableMemoryTest() {
27 DiscardableMemory::UnregisterMemoryPressureListeners();
23 } 28 }
24 29
25 protected: 30 protected:
26 scoped_ptr<DiscardableMemory> CreateLockedMemory(size_t size) { 31 scoped_ptr<DiscardableMemory> CreateLockedMemory(size_t size) {
27 return DiscardableMemory::CreateLockedMemoryWithType( 32 return DiscardableMemory::CreateLockedMemoryWithType(
28 GetParam(), size).Pass(); 33 GetParam(), size).Pass();
29 } 34 }
35
36 private:
37 MessageLoop message_loop_;
30 }; 38 };
31 39
32 const size_t kSize = 1024; 40 const size_t kSize = 1024;
33 41
34 TEST_P(DiscardableMemoryTest, IsNamed) { 42 TEST_P(DiscardableMemoryTest, IsNamed) {
35 std::string type_name(DiscardableMemory::GetTypeName(GetParam())); 43 std::string type_name(DiscardableMemory::GetTypeName(GetParam()));
36 EXPECT_NE("unknown", type_name); 44 EXPECT_NE("unknown", type_name);
37 EXPECT_EQ(GetParam(), DiscardableMemory::GetNamedType(type_name)); 45 EXPECT_EQ(GetParam(), DiscardableMemory::GetNamedType(type_name));
38 } 46 }
39 47
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return supported_types; 118 return supported_types;
111 } 119 }
112 120
113 INSTANTIATE_TEST_CASE_P( 121 INSTANTIATE_TEST_CASE_P(
114 DiscardableMemoryTests, 122 DiscardableMemoryTests,
115 DiscardableMemoryTest, 123 DiscardableMemoryTest,
116 ::testing::ValuesIn(GetSupportedDiscardableMemoryTypes())); 124 ::testing::ValuesIn(GetSupportedDiscardableMemoryTypes()));
117 125
118 } // namespace 126 } // namespace
119 } // namespace base 127 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_manager_unittest.cc ('k') | base/memory/discardable_memory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698