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

Side by Side Diff: chrome/browser/supervised_user/supervised_user_service_browsertest.cc

Issue 697693004: Supervised users: if history recording is off, allow incognito and deleting history (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/callback.h" 5 #include "base/callback.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 Profile* profile = browser()->profile(); 109 Profile* profile = browser()->profile();
110 PrefService* prefs = profile->GetPrefs(); 110 PrefService* prefs = profile->GetPrefs();
111 std::string original_name = prefs->GetString(prefs::kProfileName); 111 std::string original_name = prefs->GetString(prefs::kProfileName);
112 ProfileManager* profile_manager = g_browser_process->profile_manager(); 112 ProfileManager* profile_manager = g_browser_process->profile_manager();
113 const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 113 const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
114 114
115 SupervisedUserSettingsService* settings = 115 SupervisedUserSettingsService* settings =
116 SupervisedUserSettingsServiceFactory::GetForProfile(profile); 116 SupervisedUserSettingsServiceFactory::GetForProfile(profile);
117 117
118 std::string name = "Supervised User Test Name"; 118 std::string name = "Supervised User Test Name";
119 settings->SetLocalSettingForTesting( 119 settings->SetLocalSetting(
120 supervised_users::kUserName, 120 supervised_users::kUserName,
121 scoped_ptr<base::Value>(new base::StringValue(name))); 121 scoped_ptr<base::Value>(new base::StringValue(name)));
122 EXPECT_FALSE(prefs->IsUserModifiablePreference(prefs::kProfileName)); 122 EXPECT_FALSE(prefs->IsUserModifiablePreference(prefs::kProfileName));
123 EXPECT_EQ(name, prefs->GetString(prefs::kProfileName)); 123 EXPECT_EQ(name, prefs->GetString(prefs::kProfileName));
124 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); 124 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath());
125 EXPECT_EQ(name, 125 EXPECT_EQ(name,
126 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_index))); 126 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_index)));
127 127
128 // Change the name once more. 128 // Change the name once more.
129 std::string new_name = "New Supervised User Test Name"; 129 std::string new_name = "New Supervised User Test Name";
130 settings->SetLocalSettingForTesting( 130 settings->SetLocalSetting(
131 supervised_users::kUserName, 131 supervised_users::kUserName,
132 scoped_ptr<base::Value>(new base::StringValue(new_name))); 132 scoped_ptr<base::Value>(new base::StringValue(new_name)));
133 EXPECT_EQ(new_name, prefs->GetString(prefs::kProfileName)); 133 EXPECT_EQ(new_name, prefs->GetString(prefs::kProfileName));
134 profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); 134 profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath());
135 EXPECT_EQ(new_name, 135 EXPECT_EQ(new_name,
136 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_index))); 136 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_index)));
137 137
138 // Remove the setting. 138 // Remove the setting.
139 settings->SetLocalSettingForTesting(supervised_users::kUserName, 139 settings->SetLocalSetting(supervised_users::kUserName,
140 scoped_ptr<base::Value>()); 140 scoped_ptr<base::Value>());
141 EXPECT_EQ(original_name, prefs->GetString(prefs::kProfileName)); 141 EXPECT_EQ(original_name, prefs->GetString(prefs::kProfileName));
142 profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); 142 profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath());
143 EXPECT_EQ(original_name, 143 EXPECT_EQ(original_name,
144 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_index))); 144 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_index)));
145 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698