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

Side by Side Diff: chrome/test/base/testing_browser_process.cc

Issue 11418005: Get a minimal unit_tests target building and running for iOS (Closed) Base URL: http://git.chromium.org/chromium/src.git@chrome-gyp-ios-support
Patch Set: Better ifdefing in chrome_paths Created 8 years, 1 month 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 | « chrome/test/base/testing_browser_process.h ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/test/base/testing_browser_process.h" 5 #include "chrome/test/base/testing_browser_process.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/notifications/notification_ui_manager.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/prerender/prerender_tracker.h"
11 #include "chrome/browser/printing/background_printing_manager.h"
12 #include "chrome/browser/printing/print_preview_tab_controller.h"
13 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
15 #include "chrome/browser/thumbnails/render_widget_snapshot_taker.h"
16 #include "chrome/browser/ui/bookmarks/bookmark_prompt_controller.h" 11 #include "chrome/browser/ui/bookmarks/bookmark_prompt_controller.h"
17 #include "content/public/browser/notification_service.h" 12 #include "content/public/browser/notification_service.h"
18 #include "net/url_request/url_request_context_getter.h" 13 #include "net/url_request/url_request_context_getter.h"
19 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
20 15
16 #if !defined(OS_IOS)
17 #include "chrome/browser/notifications/notification_ui_manager.h"
18 #include "chrome/browser/prerender/prerender_tracker.h"
19 #include "chrome/browser/printing/background_printing_manager.h"
20 #include "chrome/browser/printing/print_preview_tab_controller.h"
21 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
22 #include "chrome/browser/thumbnails/render_widget_snapshot_taker.h"
23 #include "content/public/browser/notification_service.h"
24 #endif
25
21 #if defined(ENABLE_CONFIGURATION_POLICY) 26 #if defined(ENABLE_CONFIGURATION_POLICY)
22 #include "chrome/browser/policy/browser_policy_connector.h" 27 #include "chrome/browser/policy/browser_policy_connector.h"
23 #else 28 #else
24 #include "chrome/browser/policy/policy_service_stub.h" 29 #include "chrome/browser/policy/policy_service_stub.h"
25 #endif // defined(ENABLE_CONFIGURATION_POLICY) 30 #endif // defined(ENABLE_CONFIGURATION_POLICY)
26 31
27 TestingBrowserProcess::TestingBrowserProcess() 32 TestingBrowserProcess::TestingBrowserProcess()
28 : notification_service_(content::NotificationService::Create()), 33 : notification_service_(content::NotificationService::Create()),
29 module_ref_count_(0), 34 module_ref_count_(0),
30 app_locale_("en"), 35 app_locale_("en"),
31 local_state_(NULL), 36 local_state_(NULL),
37 #if !defined(OS_IOS)
32 render_widget_snapshot_taker_(new RenderWidgetSnapshotTaker), 38 render_widget_snapshot_taker_(new RenderWidgetSnapshotTaker),
39 #endif
33 io_thread_(NULL), 40 io_thread_(NULL),
34 system_request_context_(NULL) { 41 system_request_context_(NULL) {
35 } 42 }
36 43
37 TestingBrowserProcess::~TestingBrowserProcess() { 44 TestingBrowserProcess::~TestingBrowserProcess() {
38 EXPECT_FALSE(local_state_); 45 EXPECT_FALSE(local_state_);
39 #if defined(ENABLE_CONFIGURATION_POLICY) 46 #if defined(ENABLE_CONFIGURATION_POLICY)
40 if (browser_policy_connector_) 47 if (browser_policy_connector_)
41 browser_policy_connector_->Shutdown(); 48 browser_policy_connector_->Shutdown();
42 #endif 49 #endif
(...skipping 11 matching lines...) Expand all
54 61
55 IOThread* TestingBrowserProcess::io_thread() { 62 IOThread* TestingBrowserProcess::io_thread() {
56 return io_thread_; 63 return io_thread_;
57 } 64 }
58 65
59 WatchDogThread* TestingBrowserProcess::watchdog_thread() { 66 WatchDogThread* TestingBrowserProcess::watchdog_thread() {
60 return NULL; 67 return NULL;
61 } 68 }
62 69
63 ProfileManager* TestingBrowserProcess::profile_manager() { 70 ProfileManager* TestingBrowserProcess::profile_manager() {
71 #if defined(OS_IOS)
72 NOTIMPLEMENTED();
73 return NULL;
74 #else
64 return profile_manager_.get(); 75 return profile_manager_.get();
76 #endif
65 } 77 }
66 78
67 void TestingBrowserProcess::SetProfileManager(ProfileManager* profile_manager) { 79 void TestingBrowserProcess::SetProfileManager(ProfileManager* profile_manager) {
80 #if !defined(OS_IOS)
68 profile_manager_.reset(profile_manager); 81 profile_manager_.reset(profile_manager);
82 #endif
69 } 83 }
70 84
71 PrefService* TestingBrowserProcess::local_state() { 85 PrefService* TestingBrowserProcess::local_state() {
72 return local_state_; 86 return local_state_;
73 } 87 }
74 88
75 chrome_variations::VariationsService* 89 chrome_variations::VariationsService*
76 TestingBrowserProcess::variations_service() { 90 TestingBrowserProcess::variations_service() {
77 return NULL; 91 return NULL;
78 } 92 }
79 93
80 policy::BrowserPolicyConnector* 94 policy::BrowserPolicyConnector*
81 TestingBrowserProcess::browser_policy_connector() { 95 TestingBrowserProcess::browser_policy_connector() {
82 #if defined(ENABLE_CONFIGURATION_POLICY) 96 #if defined(ENABLE_CONFIGURATION_POLICY)
83 if (!browser_policy_connector_) 97 if (!browser_policy_connector_)
84 browser_policy_connector_.reset(new policy::BrowserPolicyConnector()); 98 browser_policy_connector_.reset(new policy::BrowserPolicyConnector());
85 return browser_policy_connector_.get(); 99 return browser_policy_connector_.get();
86 #else 100 #else
87 return NULL; 101 return NULL;
88 #endif 102 #endif
89 } 103 }
90 104
91 policy::PolicyService* TestingBrowserProcess::policy_service() { 105 policy::PolicyService* TestingBrowserProcess::policy_service() {
92 #if defined(ENABLE_CONFIGURATION_POLICY) 106 #if defined(OS_IOS)
107 NOTIMPLEMENTED();
108 return NULL;
109 #elif defined(ENABLE_CONFIGURATION_POLICY)
93 return browser_policy_connector()->GetPolicyService(); 110 return browser_policy_connector()->GetPolicyService();
94 #else 111 #else
95 if (!policy_service_) 112 if (!policy_service_)
96 policy_service_.reset(new policy::PolicyServiceStub()); 113 policy_service_.reset(new policy::PolicyServiceStub());
97 return policy_service_.get(); 114 return policy_service_.get();
98 #endif 115 #endif
99 } 116 }
100 117
101 IconManager* TestingBrowserProcess::icon_manager() { 118 IconManager* TestingBrowserProcess::icon_manager() {
102 return NULL; 119 return NULL;
103 } 120 }
104 121
105 RenderWidgetSnapshotTaker* 122 RenderWidgetSnapshotTaker*
106 TestingBrowserProcess::GetRenderWidgetSnapshotTaker() { 123 TestingBrowserProcess::GetRenderWidgetSnapshotTaker() {
124 #if defined(OS_IOS)
125 NOTREACHED();
126 return NULL;
127 #else
107 return render_widget_snapshot_taker_.get(); 128 return render_widget_snapshot_taker_.get();
129 #endif
108 } 130 }
109 131
110 BackgroundModeManager* TestingBrowserProcess::background_mode_manager() { 132 BackgroundModeManager* TestingBrowserProcess::background_mode_manager() {
111 return NULL; 133 return NULL;
112 } 134 }
113 135
114 StatusTray* TestingBrowserProcess::status_tray() { 136 StatusTray* TestingBrowserProcess::status_tray() {
115 return NULL; 137 return NULL;
116 } 138 }
117 139
118 SafeBrowsingService* TestingBrowserProcess::safe_browsing_service() { 140 SafeBrowsingService* TestingBrowserProcess::safe_browsing_service() {
141 #if defined(OS_IOS)
142 NOTIMPLEMENTED();
143 return NULL;
144 #else
119 return sb_service_.get(); 145 return sb_service_.get();
146 #endif
120 } 147 }
121 148
122 safe_browsing::ClientSideDetectionService* 149 safe_browsing::ClientSideDetectionService*
123 TestingBrowserProcess::safe_browsing_detection_service() { 150 TestingBrowserProcess::safe_browsing_detection_service() {
124 return NULL; 151 return NULL;
125 } 152 }
126 153
127 net::URLRequestContextGetter* TestingBrowserProcess::system_request_context() { 154 net::URLRequestContextGetter* TestingBrowserProcess::system_request_context() {
128 return system_request_context_; 155 return system_request_context_;
129 } 156 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 251
225 DownloadRequestLimiter* TestingBrowserProcess::download_request_limiter() { 252 DownloadRequestLimiter* TestingBrowserProcess::download_request_limiter() {
226 return NULL; 253 return NULL;
227 } 254 }
228 255
229 ChromeNetLog* TestingBrowserProcess::net_log() { 256 ChromeNetLog* TestingBrowserProcess::net_log() {
230 return NULL; 257 return NULL;
231 } 258 }
232 259
233 prerender::PrerenderTracker* TestingBrowserProcess::prerender_tracker() { 260 prerender::PrerenderTracker* TestingBrowserProcess::prerender_tracker() {
261 #if defined(OS_IOS)
262 NOTIMPLEMENTED();
263 return NULL;
264 #else
234 if (!prerender_tracker_.get()) 265 if (!prerender_tracker_.get())
235 prerender_tracker_.reset(new prerender::PrerenderTracker()); 266 prerender_tracker_.reset(new prerender::PrerenderTracker());
236 return prerender_tracker_.get(); 267 return prerender_tracker_.get();
268 #endif
237 } 269 }
238 270
239 ComponentUpdateService* TestingBrowserProcess::component_updater() { 271 ComponentUpdateService* TestingBrowserProcess::component_updater() {
240 return NULL; 272 return NULL;
241 } 273 }
242 274
243 CRLSetFetcher* TestingBrowserProcess::crl_set_fetcher() { 275 CRLSetFetcher* TestingBrowserProcess::crl_set_fetcher() {
244 return NULL; 276 return NULL;
245 } 277 }
246 278
247 BookmarkPromptController* TestingBrowserProcess::bookmark_prompt_controller() { 279 BookmarkPromptController* TestingBrowserProcess::bookmark_prompt_controller() {
280 #if defined(OS_IOS)
281 NOTIMPLEMENTED();
282 return NULL;
283 #else
248 return bookmark_prompt_controller_.get(); 284 return bookmark_prompt_controller_.get();
285 #endif
249 } 286 }
250 287
251 void TestingBrowserProcess::SetBookmarkPromptController( 288 void TestingBrowserProcess::SetBookmarkPromptController(
252 BookmarkPromptController* controller) { 289 BookmarkPromptController* controller) {
290 #if !defined(OS_IOS)
253 bookmark_prompt_controller_.reset(controller); 291 bookmark_prompt_controller_.reset(controller);
292 #endif
254 } 293 }
255 294
256 void TestingBrowserProcess::SetSystemRequestContext( 295 void TestingBrowserProcess::SetSystemRequestContext(
257 net::URLRequestContextGetter* context_getter) { 296 net::URLRequestContextGetter* context_getter) {
258 system_request_context_ = context_getter; 297 system_request_context_ = context_getter;
259 } 298 }
260 299
261 void TestingBrowserProcess::SetLocalState(PrefService* local_state) { 300 void TestingBrowserProcess::SetLocalState(PrefService* local_state) {
262 if (!local_state) { 301 if (!local_state) {
263 // The local_state_ PrefService is owned outside of TestingBrowserProcess, 302 // The local_state_ PrefService is owned outside of TestingBrowserProcess,
264 // but some of the members of TestingBrowserProcess hold references to it 303 // but some of the members of TestingBrowserProcess hold references to it
265 // (for example, via PrefNotifier members). But given our test 304 // (for example, via PrefNotifier members). But given our test
266 // infrastructure which tears down individual tests before freeing the 305 // infrastructure which tears down individual tests before freeing the
267 // TestingBrowserProcess, there's not a good way to make local_state outlive 306 // TestingBrowserProcess, there's not a good way to make local_state outlive
268 // these dependencies. As a workaround, whenever local_state_ is cleared 307 // these dependencies. As a workaround, whenever local_state_ is cleared
269 // (assumedly as part of exiting the test and freeing TestingBrowserProcess) 308 // (assumedly as part of exiting the test and freeing TestingBrowserProcess)
270 // any components owned by TestingBrowserProcess that depend on local_state 309 // any components owned by TestingBrowserProcess that depend on local_state
271 // are also freed. 310 // are also freed.
311 #if !defined(OS_IOS)
272 notification_ui_manager_.reset(); 312 notification_ui_manager_.reset();
313 #endif
273 #if defined(ENABLE_CONFIGURATION_POLICY) 314 #if defined(ENABLE_CONFIGURATION_POLICY)
274 SetBrowserPolicyConnector(NULL); 315 SetBrowserPolicyConnector(NULL);
275 #endif 316 #endif
276 } 317 }
277 local_state_ = local_state; 318 local_state_ = local_state;
278 } 319 }
279 320
280 void TestingBrowserProcess::SetIOThread(IOThread* io_thread) { 321 void TestingBrowserProcess::SetIOThread(IOThread* io_thread) {
281 io_thread_ = io_thread; 322 io_thread_ = io_thread;
282 } 323 }
283 324
284 void TestingBrowserProcess::SetBrowserPolicyConnector( 325 void TestingBrowserProcess::SetBrowserPolicyConnector(
285 policy::BrowserPolicyConnector* connector) { 326 policy::BrowserPolicyConnector* connector) {
286 #if defined(ENABLE_CONFIGURATION_POLICY) 327 #if defined(ENABLE_CONFIGURATION_POLICY)
287 if (browser_policy_connector_) 328 if (browser_policy_connector_)
288 browser_policy_connector_->Shutdown(); 329 browser_policy_connector_->Shutdown();
289 browser_policy_connector_.reset(connector); 330 browser_policy_connector_.reset(connector);
290 #else 331 #else
291 CHECK(false); 332 CHECK(false);
292 #endif 333 #endif
293 } 334 }
294 335
295 void TestingBrowserProcess::SetSafeBrowsingService( 336 void TestingBrowserProcess::SetSafeBrowsingService(
296 SafeBrowsingService* sb_service) { 337 SafeBrowsingService* sb_service) {
338 #if !defined(OS_IOS)
339 NOTIMPLEMENTED();
297 sb_service_ = sb_service; 340 sb_service_ = sb_service;
341 #endif
298 } 342 }
OLDNEW
« no previous file with comments | « chrome/test/base/testing_browser_process.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698