OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "chrome/browser/cache_manager_host.h" | 8 #include "chrome/browser/cache_manager_host.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "webkit/glue/cache_manager.h" | 10 #include "webkit/glue/cache_manager.h" |
11 | 11 |
12 using base::Time; | 12 using base::Time; |
13 using base::TimeDelta; | 13 using base::TimeDelta; |
14 | 14 |
15 class CacheManagerHostTest : public testing::Test { | 15 class CacheManagerHostTest : public testing::Test { |
16 protected: | 16 protected: |
17 typedef CacheManagerHost::StatsMap StatsMap; | 17 typedef CacheManagerHost::StatsMap StatsMap; |
18 typedef CacheManagerHost::Allocation Allocation; | 18 typedef CacheManagerHost::Allocation Allocation; |
19 typedef CacheManagerHost::AllocationStrategy AllocationStrategy; | 19 typedef CacheManagerHost::AllocationStrategy AllocationStrategy; |
20 | 20 |
21 static const int kRendererID; | 21 static const int kRendererID; |
22 static const int kRendererID2; | 22 static const int kRendererID2; |
23 static const CacheManager::UsageStats kStats; | 23 static const CacheManager::UsageStats kStats; |
24 static const CacheManager::UsageStats kStats2; | 24 static const CacheManager::UsageStats kStats2; |
25 | 25 |
26 // Thunks to access protected members of CacheManagerHost | 26 // Thunks to access protected members of CacheManagerHost |
27 static std::map<int, CacheManagerHost::RendererInfo>& stats(CacheManagerHost*
h) { | 27 static std::map<int, CacheManagerHost::RendererInfo>& stats( |
| 28 CacheManagerHost* h) { |
28 return h->stats_; | 29 return h->stats_; |
29 } | 30 } |
30 | 31 |
31 static void SimulateInactivity(CacheManagerHost* h, int renderer_id) { | 32 static void SimulateInactivity(CacheManagerHost* h, int renderer_id) { |
32 stats(h)[renderer_id].access = Time::Now() - TimeDelta::FromMinutes( | 33 stats(h)[renderer_id].access = Time::Now() - TimeDelta::FromMinutes( |
33 CacheManagerHost::kRendererInactiveThresholdMinutes); | 34 CacheManagerHost::kRendererInactiveThresholdMinutes); |
34 h->FindInactiveRenderers(); | 35 h->FindInactiveRenderers(); |
35 } | 36 } |
36 | 37 |
37 static std::set<int>& active_renderers(CacheManagerHost* h) { | 38 static std::set<int>& active_renderers(CacheManagerHost* h) { |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 size_t expected_total_bytes = kExtraBytesToAllocate + | 307 size_t expected_total_bytes = kExtraBytesToAllocate + |
307 kStats.live_size + kStats.dead_size + | 308 kStats.live_size + kStats.dead_size + |
308 kStats2.live_size + kStats2.dead_size; | 309 kStats2.live_size + kStats2.dead_size; |
309 | 310 |
310 EXPECT_GE(expected_total_bytes, total_bytes); | 311 EXPECT_GE(expected_total_bytes, total_bytes); |
311 | 312 |
312 h->Remove(kRendererID); | 313 h->Remove(kRendererID); |
313 h->Remove(kRendererID2); | 314 h->Remove(kRendererID2); |
314 } | 315 } |
315 | 316 |
OLD | NEW |