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

Side by Side Diff: chrome/test/testing_profile.h

Issue 3133031: Make TestingProfile use ScopedTempDir. (Closed)
Patch Set: trybots Created 10 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
« no previous file with comments | « chrome/browser/views/bookmark_bar_view_unittest.cc ('k') | chrome/test/testing_profile.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_TEST_TESTING_PROFILE_H_ 5 #ifndef CHROME_TEST_TESTING_PROFILE_H_
6 #define CHROME_TEST_TESTING_PROFILE_H_ 6 #define CHROME_TEST_TESTING_PROFILE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
(...skipping 24 matching lines...) Expand all
35 class SessionService; 35 class SessionService;
36 class TemplateURLModel; 36 class TemplateURLModel;
37 class TestingPrefService; 37 class TestingPrefService;
38 class URLRequestContextGetter; 38 class URLRequestContextGetter;
39 class WebKitContext; 39 class WebKitContext;
40 40
41 class TestingProfile : public Profile { 41 class TestingProfile : public Profile {
42 public: 42 public:
43 TestingProfile(); 43 TestingProfile();
44 44
45 // Creates a new profile by adding |count| to the end of the path. Use this
46 // when you need to have more than one TestingProfile running at the same
47 // time.
48 explicit TestingProfile(int count);
49
50 // Creates a new profile specifying the target directory.
51 // Use this as a temporary solution for tests requiring a ScopedTempDir.
52 // This directory must already exist.
53 // TODO(chron): Use a ScopedTempDir. Remove constructor. BUG=51833
54 explicit TestingProfile(const FilePath& directory);
55
56 virtual ~TestingProfile(); 45 virtual ~TestingProfile();
57 46
58 // Creates the favicon service. Consequent calls would recreate the service. 47 // Creates the favicon service. Consequent calls would recreate the service.
59 void CreateFaviconService(); 48 void CreateFaviconService();
60 49
61 // Creates the history service. If |delete_file| is true, the history file is 50 // Creates the history service. If |delete_file| is true, the history file is
62 // deleted first, then the HistoryService is created. As TestingProfile 51 // deleted first, then the HistoryService is created. As TestingProfile
63 // deletes the directory containing the files used by HistoryService, this 52 // deletes the directory containing the files used by HistoryService, this
64 // only matters if you're recreating the HistoryService. If |no_db| is true, 53 // only matters if you're recreating the HistoryService. If |no_db| is true,
65 // the history backend will fail to initialize its database; this is useful 54 // the history backend will fail to initialize its database; this is useful
(...skipping 30 matching lines...) Expand all
96 // Uses a specific theme provider for this profile. TestingProfile takes 85 // Uses a specific theme provider for this profile. TestingProfile takes
97 // ownership of |theme_provider|. 86 // ownership of |theme_provider|.
98 void UseThemeProvider(BrowserThemeProvider* theme_provider); 87 void UseThemeProvider(BrowserThemeProvider* theme_provider);
99 88
100 TestingPrefService* GetTestingPrefService(); 89 TestingPrefService* GetTestingPrefService();
101 90
102 virtual ProfileId GetRuntimeId() { 91 virtual ProfileId GetRuntimeId() {
103 return reinterpret_cast<ProfileId>(this); 92 return reinterpret_cast<ProfileId>(this);
104 } 93 }
105 94
106 virtual FilePath GetPath() { 95 virtual FilePath GetPath();
107 return path_; 96
108 }
109 // Sets whether we're off the record. Default is false. 97 // Sets whether we're off the record. Default is false.
110 void set_off_the_record(bool off_the_record) { 98 void set_off_the_record(bool off_the_record) {
111 off_the_record_ = off_the_record; 99 off_the_record_ = off_the_record;
112 } 100 }
113 virtual bool IsOffTheRecord() { return off_the_record_; } 101 virtual bool IsOffTheRecord() { return off_the_record_; }
114 virtual Profile* GetOffTheRecordProfile() { return NULL; } 102 virtual Profile* GetOffTheRecordProfile() { return NULL; }
115 103
116 virtual void DestroyOffTheRecordProfile() {} 104 virtual void DestroyOffTheRecordProfile() {}
117 105
118 virtual bool HasOffTheRecordProfile() { return false; } 106 virtual bool HasOffTheRecordProfile() { return false; }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // task is processed. This has the effect of blocking the caller until the 242 // task is processed. This has the effect of blocking the caller until the
255 // history service processes all pending requests. 243 // history service processes all pending requests.
256 void BlockUntilHistoryProcessesPendingRequests(); 244 void BlockUntilHistoryProcessesPendingRequests();
257 245
258 // Creates and initializes a profile sync service if the tests require one. 246 // Creates and initializes a profile sync service if the tests require one.
259 virtual TokenService* GetTokenService(); 247 virtual TokenService* GetTokenService();
260 virtual ProfileSyncService* GetProfileSyncService(); 248 virtual ProfileSyncService* GetProfileSyncService();
261 virtual CloudPrintProxyService* GetCloudPrintProxyService() { return NULL; } 249 virtual CloudPrintProxyService* GetCloudPrintProxyService() { return NULL; }
262 250
263 protected: 251 protected:
264 // The path of the profile; the various database and other files are relative
265 // to this.
266 FilePath path_;
267 base::Time start_time_; 252 base::Time start_time_;
268 scoped_ptr<TestingPrefService> prefs_; 253 scoped_ptr<TestingPrefService> prefs_;
269 254
270 private: 255 private:
271 // Destroys favicon service if it has been created. 256 // Destroys favicon service if it has been created.
272 void DestroyFaviconService(); 257 void DestroyFaviconService();
273 258
274 // If the history service has been created, it is destroyed. This is invoked 259 // If the history service has been created, it is destroyed. This is invoked
275 // from the destructor. 260 // from the destructor.
276 void DestroyHistoryService(); 261 void DestroyHistoryService();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 scoped_refptr<GeolocationContentSettingsMap> 325 scoped_refptr<GeolocationContentSettingsMap>
341 geolocation_content_settings_map_; 326 geolocation_content_settings_map_;
342 scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_; 327 scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_;
343 scoped_ptr<DesktopNotificationService> desktop_notification_service_; 328 scoped_ptr<DesktopNotificationService> desktop_notification_service_;
344 329
345 // Find bar state. Created lazily by GetFindBarState(). 330 // Find bar state. Created lazily by GetFindBarState().
346 scoped_ptr<FindBarState> find_bar_state_; 331 scoped_ptr<FindBarState> find_bar_state_;
347 332
348 FilePath last_selected_directory_; 333 FilePath last_selected_directory_;
349 scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails. 334 scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails.
335
336 // We use a temporary directory to store testing profile data.
350 ScopedTempDir temp_dir_; 337 ScopedTempDir temp_dir_;
351 }; 338 };
352 339
353 // A profile that derives from another profile. This does not actually 340 // A profile that derives from another profile. This does not actually
354 // override anything except the GetRuntimeId() in order to test sharing of 341 // override anything except the GetRuntimeId() in order to test sharing of
355 // site information. 342 // site information.
356 class DerivedTestingProfile : public TestingProfile { 343 class DerivedTestingProfile : public TestingProfile {
357 public: 344 public:
358 explicit DerivedTestingProfile(Profile* profile) 345 explicit DerivedTestingProfile(Profile* profile)
359 : original_profile_(profile) {} 346 : original_profile_(profile) {}
360 347
361 virtual ProfileId GetRuntimeId() { 348 virtual ProfileId GetRuntimeId() {
362 return original_profile_->GetRuntimeId(); 349 return original_profile_->GetRuntimeId();
363 } 350 }
364 351
365 protected: 352 protected:
366 Profile* original_profile_; 353 Profile* original_profile_;
367 }; 354 };
368 355
369 #endif // CHROME_TEST_TESTING_PROFILE_H_ 356 #endif // CHROME_TEST_TESTING_PROFILE_H_
OLDNEW
« no previous file with comments | « chrome/browser/views/bookmark_bar_view_unittest.cc ('k') | chrome/test/testing_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698