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

Side by Side Diff: components/web_cache/browser/web_cache_manager_unittest.cc

Issue 2799253002: Switch from TestBrowserThread to TestBrowserThreadBundle in components. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « components/feedback/feedback_uploader_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/message_loop/message_loop.h"
10 #include "components/web_cache/browser/web_cache_manager.h" 9 #include "components/web_cache/browser/web_cache_manager.h"
11 #include "content/public/test/test_browser_thread.h" 10 #include "content/public/test/test_browser_thread_bundle.h"
12 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
13 12
14 using base::Time; 13 using base::Time;
15 using base::TimeDelta; 14 using base::TimeDelta;
16 using content::BrowserThread;
17
18 namespace web_cache { 15 namespace web_cache {
19 16
20 class WebCacheManagerTest : public testing::Test { 17 class WebCacheManagerTest : public testing::Test {
21 protected: 18 protected:
22 typedef WebCacheManager::StatsMap StatsMap; 19 typedef WebCacheManager::StatsMap StatsMap;
23 typedef WebCacheManager::Allocation Allocation; 20 typedef WebCacheManager::Allocation Allocation;
24 typedef WebCacheManager::AllocationStrategy AllocationStrategy; 21 typedef WebCacheManager::AllocationStrategy AllocationStrategy;
25 22
26 static const int kRendererID; 23 static const int kRendererID;
27 static const int kRendererID2; 24 static const int kRendererID2;
28 static const WebCacheManager::RendererInfo kStats; 25 static const WebCacheManager::RendererInfo kStats;
29 static const WebCacheManager::RendererInfo kStats2; 26 static const WebCacheManager::RendererInfo kStats2;
30 27
31 WebCacheManagerTest() 28 WebCacheManagerTest() = default;
32 : ui_thread_(BrowserThread::UI, &message_loop_) {
33 }
34 29
35 // Thunks to access protected members of WebCacheManager 30 // Thunks to access protected members of WebCacheManager
36 static std::map<int, WebCacheManager::RendererInfo>& stats( 31 static std::map<int, WebCacheManager::RendererInfo>& stats(
37 WebCacheManager* h) { 32 WebCacheManager* h) {
38 return h->stats_; 33 return h->stats_;
39 } 34 }
40 35
41 static void SimulateInactivity(WebCacheManager* h, int renderer_id) { 36 static void SimulateInactivity(WebCacheManager* h, int renderer_id) {
42 stats(h)[renderer_id].access = Time::Now() - TimeDelta::FromMinutes( 37 stats(h)[renderer_id].access = Time::Now() - TimeDelta::FromMinutes(
43 WebCacheManager::kRendererInactiveThresholdMinutes); 38 WebCacheManager::kRendererInactiveThresholdMinutes);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 enum { 87 enum {
93 DIVIDE_EVENLY = WebCacheManager::DIVIDE_EVENLY, 88 DIVIDE_EVENLY = WebCacheManager::DIVIDE_EVENLY,
94 KEEP_CURRENT_WITH_HEADROOM = WebCacheManager::KEEP_CURRENT_WITH_HEADROOM, 89 KEEP_CURRENT_WITH_HEADROOM = WebCacheManager::KEEP_CURRENT_WITH_HEADROOM,
95 KEEP_CURRENT = WebCacheManager::KEEP_CURRENT, 90 KEEP_CURRENT = WebCacheManager::KEEP_CURRENT,
96 }; 91 };
97 92
98 WebCacheManager* manager() { return &manager_; } 93 WebCacheManager* manager() { return &manager_; }
99 94
100 private: 95 private:
101 WebCacheManager manager_; 96 WebCacheManager manager_;
102 base::MessageLoop message_loop_; 97 content::TestBrowserThreadBundle test_browser_thread_bundle_;
103 content::TestBrowserThread ui_thread_;
104 }; 98 };
105 99
106 // static 100 // static
107 const int WebCacheManagerTest::kRendererID = 146; 101 const int WebCacheManagerTest::kRendererID = 146;
108 102
109 // static 103 // static
110 const int WebCacheManagerTest::kRendererID2 = 245; 104 const int WebCacheManagerTest::kRendererID2 = 245;
111 105
112 // static 106 // static
113 const WebCacheManager::RendererInfo WebCacheManagerTest::kStats = { 107 const WebCacheManager::RendererInfo WebCacheManagerTest::kStats = {
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 manager()->ReviseAllocationStrategy(); 431 manager()->ReviseAllocationStrategy();
438 432
439 manager()->Remove(kRendererID); 433 manager()->Remove(kRendererID);
440 manager()->ReviseAllocationStrategy(); 434 manager()->ReviseAllocationStrategy();
441 435
442 manager()->ObserveActivity(kRendererID); 436 manager()->ObserveActivity(kRendererID);
443 manager()->ReviseAllocationStrategy(); 437 manager()->ReviseAllocationStrategy();
444 } 438 }
445 439
446 } // namespace web_cache 440 } // namespace web_cache
OLDNEW
« no previous file with comments | « components/feedback/feedback_uploader_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698