OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 { | 83 { |
84 // Save the global memory cache to restore it upon teardown. | 84 // Save the global memory cache to restore it upon teardown. |
85 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create()
); | 85 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create()
); |
86 } | 86 } |
87 | 87 |
88 virtual void TearDown() | 88 virtual void TearDown() |
89 { | 89 { |
90 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); | 90 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); |
91 } | 91 } |
92 | 92 |
93 OwnPtrWillBePersistent<MemoryCache> m_globalMemoryCache; | 93 Persistent<MemoryCache> m_globalMemoryCache; |
94 }; | 94 }; |
95 | 95 |
96 // Verifies that setters and getters for cache capacities work correcty. | 96 // Verifies that setters and getters for cache capacities work correcty. |
97 TEST_F(MemoryCacheTest, CapacityAccounting) | 97 TEST_F(MemoryCacheTest, CapacityAccounting) |
98 { | 98 { |
99 const size_t sizeMax = ~static_cast<size_t>(0); | 99 const size_t sizeMax = ~static_cast<size_t>(0); |
100 const size_t totalCapacity = sizeMax / 4; | 100 const size_t totalCapacity = sizeMax / 4; |
101 const size_t minDeadCapacity = sizeMax / 16; | 101 const size_t minDeadCapacity = sizeMax / 16; |
102 const size_t maxDeadCapacity = sizeMax / 8; | 102 const size_t maxDeadCapacity = sizeMax / 8; |
103 memoryCache()->setCapacities(minDeadCapacity, maxDeadCapacity, totalCapacity
); | 103 memoryCache()->setCapacities(minDeadCapacity, maxDeadCapacity, totalCapacity
); |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 573 |
574 WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = memoryCache()->re
sourcesForURL(url); | 574 WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = memoryCache()->re
sourcesForURL(url); |
575 EXPECT_EQ(2u, resources.size()); | 575 EXPECT_EQ(2u, resources.size()); |
576 | 576 |
577 memoryCache()->evictResources(); | 577 memoryCache()->evictResources(); |
578 EXPECT_FALSE(memoryCache()->contains(resource1.get())); | 578 EXPECT_FALSE(memoryCache()->contains(resource1.get())); |
579 EXPECT_FALSE(memoryCache()->contains(resource3.get())); | 579 EXPECT_FALSE(memoryCache()->contains(resource3.get())); |
580 } | 580 } |
581 | 581 |
582 } // namespace | 582 } // namespace |
OLD | NEW |