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

Unified Diff: chrome/test/base/testing_profile.h

Issue 10823212: Relanding this as this did not fix the chromiumos breakage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/testing_browser_process.cc ('k') | chrome/test/base/testing_profile.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/testing_profile.h
===================================================================
--- chrome/test/base/testing_profile.h (revision 150400)
+++ chrome/test/base/testing_profile.h (working copy)
@@ -58,6 +58,54 @@
// Default constructor that cannot be used with multi-profiles.
TestingProfile();
+ // Helper class for building an instance of TestingProfile (allows injecting
+ // mocks for various services prior to profile initialization).
+ // TODO(atwilson): Remove non-default constructors and various setters in
+ // favor of using the Builder API.
+ class Builder {
+ public:
+ Builder();
+ ~Builder();
+
+ // Sets a Delegate to be called back when the Profile is fully initialized.
+ // This causes the final initialization to be performed via a task so the
+ // caller must run a MessageLoop. Caller maintains ownership of the Delegate
+ // and must manage its lifetime so it continues to exist until profile
+ // initialization is complete.
+ void SetDelegate(Delegate* delegate);
+
+ // Sets the ExtensionSpecialStoragePolicy to be returned by
+ // GetExtensionSpecialStoragePolicy().
+ void SetExtensionSpecialStoragePolicy(
+ scoped_refptr<ExtensionSpecialStoragePolicy> policy);
+
+ // Sets the path to the directory to be used to hold profile data.
+ void SetPath(const FilePath& path);
+
+ // Sets the PrefService to be used by this profile.
+ void SetPrefService(scoped_ptr<PrefService> prefs);
+
+ // Sets the UserCloudPolicyManager to be used by this profile.
+ void SetUserCloudPolicyManager(
+ scoped_ptr<policy::UserCloudPolicyManager> manager);
+
+ // Creates the TestingProfile using previously-set settings.
+ scoped_ptr<TestingProfile> Build();
+
+ private:
+ // If true, Build() has already been called.
+ bool build_called_;
+
+ // Various staging variables where values are held until Build() is invoked.
+ scoped_ptr<policy::UserCloudPolicyManager> user_cloud_policy_manager_;
+ scoped_ptr<PrefService> pref_service_;
+ scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy_;
+ FilePath path_;
+ Delegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(Builder);
+ };
+
// Multi-profile aware constructor that takes the path to a directory managed
// for this profile. This constructor is meant to be used by
// TestingProfileManager::CreateTestingProfile. If you need to create multi-
@@ -71,6 +119,14 @@
// for unittesting the ProfileManager.
TestingProfile(const FilePath& path, Delegate* delegate);
+ // Full constructor allowing the setting of all possible instance data.
+ // Callers should use Builder::Build() instead of invoking this constructor.
+ TestingProfile(const FilePath& path,
+ Delegate* delegate,
+ scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy,
+ scoped_ptr<PrefService> prefs,
+ scoped_ptr<policy::UserCloudPolicyManager> manager);
+
virtual ~TestingProfile();
// Creates the favicon service. Consequent calls would recreate the service.
@@ -167,6 +223,8 @@
// this by calling CreateRequestContext(). See the note at GetRequestContext
// for more information.
net::CookieMonster* GetCookieMonster();
+
+ virtual policy::UserCloudPolicyManager* GetUserCloudPolicyManager() OVERRIDE;
virtual policy::PolicyService* GetPolicyService() OVERRIDE;
// Sets the profile's PrefService. If a pref service hasn't been explicitly
// set GetPrefs creates one, so normally you need not invoke this. If you need
@@ -242,6 +300,9 @@
TestingPrefService* testing_prefs_;
private:
+ // Creates a temporary directory for use by this profile.
+ void CreateTempProfileDir();
+
// Common initialization between the two constructors.
void Init();
@@ -289,6 +350,9 @@
// The proxy prefs tracker.
scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
+ // UserCloudPolicyManager returned by GetUserCloudPolicyManager().
+ scoped_ptr<policy::UserCloudPolicyManager> user_cloud_policy_manager_;
+
// We use a temporary directory to store testing profile data. In a multi-
// profile environment, this is invalid and the directory is managed by the
// TestingProfileManager.
Property changes on: chrome\test\base\testing_profile.h
___________________________________________________________________
Added: svn:mergeinfo
« no previous file with comments | « chrome/test/base/testing_browser_process.cc ('k') | chrome/test/base/testing_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698