summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/base/testing_profile.cc34
-rw-r--r--chrome/test/base/testing_profile.h7
-rw-r--r--chrome/test/base/testing_profile_manager.cc2
3 files changed, 29 insertions, 14 deletions
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 8897002..74c7d01 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -132,6 +132,9 @@ using testing::Return;
namespace {
+// Default profile name
+const char kTestingProfile[] = "testing_profile";
+
// Task used to make sure history has finished processing a request. Intended
// for use with BlockUntilHistoryProcessesPendingRequests.
@@ -258,7 +261,8 @@ TestingProfile::TestingProfile()
browser_context_dependency_manager_(
BrowserContextDependencyManager::GetInstance()),
resource_context_(NULL),
- delegate_(NULL) {
+ delegate_(NULL),
+ profile_name_(kTestingProfile) {
CreateTempProfileDir();
profile_path_ = temp_dir_.path();
@@ -277,13 +281,13 @@ TestingProfile::TestingProfile(const base::FilePath& path)
browser_context_dependency_manager_(
BrowserContextDependencyManager::GetInstance()),
resource_context_(NULL),
- delegate_(NULL) {
+ delegate_(NULL),
+ profile_name_(kTestingProfile) {
Init();
FinishInit();
}
-TestingProfile::TestingProfile(const base::FilePath& path,
- Delegate* delegate)
+TestingProfile::TestingProfile(const base::FilePath& path, Delegate* delegate)
: start_time_(Time::Now()),
testing_prefs_(NULL),
force_incognito_(false),
@@ -294,7 +298,8 @@ TestingProfile::TestingProfile(const base::FilePath& path,
browser_context_dependency_manager_(
BrowserContextDependencyManager::GetInstance()),
resource_context_(NULL),
- delegate_(delegate) {
+ delegate_(delegate),
+ profile_name_(kTestingProfile) {
Init();
if (delegate_) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
@@ -316,7 +321,8 @@ TestingProfile::TestingProfile(
bool guest_session,
const std::string& supervised_user_id,
scoped_ptr<policy::PolicyService> policy_service,
- const TestingFactories& factories)
+ const TestingFactories& factories,
+ const std::string& profile_name)
: start_time_(Time::Now()),
prefs_(prefs.release()),
testing_prefs_(NULL),
@@ -332,6 +338,7 @@ TestingProfile::TestingProfile(
BrowserContextDependencyManager::GetInstance()),
resource_context_(NULL),
delegate_(delegate),
+ profile_name_(profile_name),
policy_service_(policy_service.release()) {
if (parent)
parent->SetOffTheRecordProfile(scoped_ptr<Profile>(this));
@@ -475,8 +482,6 @@ void TestingProfile::Init() {
store->SetInitializationCompleted();
}
#endif
-
- profile_name_ = "testing_profile";
}
void TestingProfile::FinishInit() {
@@ -975,8 +980,8 @@ Profile::ExitType TestingProfile::GetLastSessionExitType() {
TestingProfile::Builder::Builder()
: build_called_(false),
delegate_(NULL),
- guest_session_(false) {
-}
+ guest_session_(false),
+ profile_name_(kTestingProfile) {}
TestingProfile::Builder::~Builder() {
}
@@ -1015,6 +1020,10 @@ void TestingProfile::Builder::SetPolicyService(
policy_service_ = std::move(policy_service);
}
+void TestingProfile::Builder::SetProfileName(const std::string& profile_name) {
+ profile_name_ = profile_name;
+}
+
void TestingProfile::Builder::AddTestingFactory(
BrowserContextKeyedServiceFactory* service_factory,
BrowserContextKeyedServiceFactory::TestingFactoryFunction callback) {
@@ -1031,7 +1040,7 @@ scoped_ptr<TestingProfile> TestingProfile::Builder::Build() {
extension_policy_,
#endif
std::move(pref_service_), NULL, guest_session_, supervised_user_id_,
- std::move(policy_service_), testing_factories_));
+ std::move(policy_service_), testing_factories_, profile_name_));
}
TestingProfile* TestingProfile::Builder::BuildIncognito(
@@ -1047,5 +1056,6 @@ TestingProfile* TestingProfile::Builder::BuildIncognito(
#endif
std::move(pref_service_), original_profile,
guest_session_, supervised_user_id_,
- std::move(policy_service_), testing_factories_);
+ std::move(policy_service_), testing_factories_,
+ profile_name_);
}
diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h
index c177c72..7004078 100644
--- a/chrome/test/base/testing_profile.h
+++ b/chrome/test/base/testing_profile.h
@@ -111,6 +111,9 @@ class TestingProfile : public Profile {
// Sets the PolicyService to be used by this profile.
void SetPolicyService(scoped_ptr<policy::PolicyService> policy_service);
+ // Sets the UserProfileName to be used by this profile.
+ void SetProfileName(const std::string& profile_name);
+
// Creates the TestingProfile using previously-set settings.
scoped_ptr<TestingProfile> Build();
@@ -134,6 +137,7 @@ class TestingProfile : public Profile {
std::string supervised_user_id_;
scoped_ptr<policy::PolicyService> policy_service_;
TestingFactories testing_factories_;
+ std::string profile_name_;
DISALLOW_COPY_AND_ASSIGN(Builder);
};
@@ -163,7 +167,8 @@ class TestingProfile : public Profile {
bool guest_session,
const std::string& supervised_user_id,
scoped_ptr<policy::PolicyService> policy_service,
- const TestingFactories& factories);
+ const TestingFactories& factories,
+ const std::string& profile_name);
~TestingProfile() override;
diff --git a/chrome/test/base/testing_profile_manager.cc b/chrome/test/base/testing_profile_manager.cc
index 1f36331..0271c18 100644
--- a/chrome/test/base/testing_profile_manager.cc
+++ b/chrome/test/base/testing_profile_manager.cc
@@ -87,6 +87,7 @@ TestingProfile* TestingProfileManager::CreateTestingProfile(
builder.SetPath(profile_path);
builder.SetPrefService(std::move(prefs));
builder.SetSupervisedUserId(supervised_user_id);
+ builder.SetProfileName(profile_name);
for (TestingProfile::TestingFactories::const_iterator it = factories.begin();
it != factories.end(); ++it) {
@@ -94,7 +95,6 @@ TestingProfile* TestingProfileManager::CreateTestingProfile(
}
TestingProfile* profile = builder.Build().release();
- profile->set_profile_name(profile_name);
profile_manager_->AddProfile(profile); // Takes ownership.
// Update the user metadata.