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/browser/prefs/pref_hash_browsertest.cc

Issue 271533004: Turning on MultiProfile by default for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 <set> 5 #include <set>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/profiles/profile_info_cache.h" 25 #include "chrome/browser/profiles/profile_info_cache.h"
26 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
27 #include "chrome/browser/profiles/profiles_state.h" 27 #include "chrome/browser/profiles/profiles_state.h"
28 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
29 #include "chrome/test/base/in_process_browser_test.h" 29 #include "chrome/test/base/in_process_browser_test.h"
30 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
31 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
32 #include "content/public/test/test_utils.h" 32 #include "content/public/test/test_utils.h"
33 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
34 34
35 #if defined(OS_CHROMEOS)
36 #include "chromeos/chromeos_switches.h"
37 #endif
38
35 namespace { 39 namespace {
36 40
37 // An observer that returns back to test code after a new profile is 41 // An observer that returns back to test code after a new profile is
38 // initialized. 42 // initialized.
39 void OnUnblockOnProfileCreation(const base::Closure& callback, 43 void OnUnblockOnProfileCreation(const base::Closure& callback,
40 Profile* profile, 44 Profile* profile,
41 Profile::CreateStatus status) { 45 Profile::CreateStatus status) {
42 switch (status) { 46 switch (status) {
43 case Profile::CREATE_STATUS_CREATED: 47 case Profile::CREATE_STATUS_CREATED:
44 // Wait for CREATE_STATUS_INITIALIZED. 48 // Wait for CREATE_STATUS_INITIALIZED.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 PrefHashBrowserTest() 103 PrefHashBrowserTest()
100 : is_unloaded_profile_seeding_allowed_( 104 : is_unloaded_profile_seeding_allowed_(
101 IsUnloadedProfileSeedingAllowed()) {} 105 IsUnloadedProfileSeedingAllowed()) {}
102 106
103 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 107 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
104 InProcessBrowserTest::SetUpCommandLine(command_line); 108 InProcessBrowserTest::SetUpCommandLine(command_line);
105 command_line->AppendSwitchASCII( 109 command_line->AppendSwitchASCII(
106 switches::kForceFieldTrials, 110 switches::kForceFieldTrials,
107 std::string(chrome_prefs::internals::kSettingsEnforcementTrialName) + 111 std::string(chrome_prefs::internals::kSettingsEnforcementTrialName) +
108 "/" + GetParam() + "/"); 112 "/" + GetParam() + "/");
113 #if defined(OS_CHROMEOS)
114 command_line->AppendSwitch(
115 chromeos::switches::kIgnoreUserProfileMappingForTests);
116 #endif
109 } 117 }
110 118
111 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 119 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
112 // Force the delayed PrefHashStore update task to happen immediately with 120 // Force the delayed PrefHashStore update task to happen immediately with
113 // no domain check (bots are on a domain). 121 // no domain check (bots are on a domain).
114 chrome_prefs::DisableDelaysAndDomainCheckForTesting(); 122 chrome_prefs::DisableDelaysAndDomainCheckForTesting();
115 } 123 }
116 124
117 virtual void SetUpOnMainThread() OVERRIDE { 125 virtual void SetUpOnMainThread() OVERRIDE {
118 // content::RunAllPendingInMessageLoop() is already called before 126 // content::RunAllPendingInMessageLoop() is already called before
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 #define MAYBE_PRE_InitializeUnloadedProfiles DISABLED_PRE_InitializeUnloadedProf iles 165 #define MAYBE_PRE_InitializeUnloadedProfiles DISABLED_PRE_InitializeUnloadedProf iles
158 #define MAYBE_InitializeUnloadedProfiles DISABLED_InitializeUnloadedProfiles 166 #define MAYBE_InitializeUnloadedProfiles DISABLED_InitializeUnloadedProfiles
159 #else 167 #else
160 #define MAYBE_PRE_PRE_InitializeUnloadedProfiles PRE_PRE_InitializeUnloadedProfi les 168 #define MAYBE_PRE_PRE_InitializeUnloadedProfiles PRE_PRE_InitializeUnloadedProfi les
161 #define MAYBE_PRE_InitializeUnloadedProfiles PRE_InitializeUnloadedProfiles 169 #define MAYBE_PRE_InitializeUnloadedProfiles PRE_InitializeUnloadedProfiles
162 #define MAYBE_InitializeUnloadedProfiles InitializeUnloadedProfiles 170 #define MAYBE_InitializeUnloadedProfiles InitializeUnloadedProfiles
163 #endif 171 #endif
164 172
165 IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest, 173 IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest,
166 MAYBE_PRE_PRE_InitializeUnloadedProfiles) { 174 MAYBE_PRE_PRE_InitializeUnloadedProfiles) {
167 if (!profiles::IsMultipleProfilesEnabled())
168 return;
169 ProfileManager* profile_manager = g_browser_process->profile_manager(); 175 ProfileManager* profile_manager = g_browser_process->profile_manager();
170 176
171 // Create an additional profile. 177 // Create an additional profile.
172 const base::FilePath new_path = 178 const base::FilePath new_path =
173 profile_manager->GenerateNextProfileDirectoryPath(); 179 profile_manager->GenerateNextProfileDirectoryPath();
174 const scoped_refptr<content::MessageLoopRunner> runner( 180 const scoped_refptr<content::MessageLoopRunner> runner(
175 new content::MessageLoopRunner); 181 new content::MessageLoopRunner);
176 profile_manager->CreateProfileAsync( 182 profile_manager->CreateProfileAsync(
177 new_path, 183 new_path,
178 base::Bind(&OnUnblockOnProfileCreation, runner->QuitClosure()), 184 base::Bind(&OnUnblockOnProfileCreation, runner->QuitClosure()),
179 base::string16(), 185 base::string16(),
180 base::string16(), 186 base::string16(),
181 std::string()); 187 std::string());
182 188
183 // Spin to allow profile creation to take place, loop is terminated 189 // Spin to allow profile creation to take place, loop is terminated
184 // by OnUnblockOnProfileCreation when the profile is created. 190 // by OnUnblockOnProfileCreation when the profile is created.
185 runner->Run(); 191 runner->Run();
186 192
187 // No profile should have gone through the unloaded profile initialization in 193 // No profile should have gone through the unloaded profile initialization in
188 // this phase as both profiles should have been loaded normally. 194 // this phase as both profiles should have been loaded normally.
189 EXPECT_EQ( 195 EXPECT_EQ(
190 0, GetTrackedPrefHistogramCount( 196 0, GetTrackedPrefHistogramCount(
191 "Settings.TrackedPreferencesAlternateStoreVersionUpdatedFrom", 197 "Settings.TrackedPreferencesAlternateStoreVersionUpdatedFrom",
192 true)); 198 true));
193 } 199 }
194 200
195 IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest, 201 IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest,
196 MAYBE_PRE_InitializeUnloadedProfiles) { 202 MAYBE_PRE_InitializeUnloadedProfiles) {
197 if (!profiles::IsMultipleProfilesEnabled())
198 return;
199
200 // Creating the profile would have initialized its hash store. Also, we don't 203 // Creating the profile would have initialized its hash store. Also, we don't
201 // know whether the newly created or original profile will be launched (does 204 // know whether the newly created or original profile will be launched (does
202 // creating a profile cause it to be the most recently used?). 205 // creating a profile cause it to be the most recently used?).
203 206
204 // So we will find the profile that isn't loaded, reset its hash store, and 207 // So we will find the profile that isn't loaded, reset its hash store, and
205 // then verify in the _next_ launch that it is, indeed, restored despite not 208 // then verify in the _next_ launch that it is, indeed, restored despite not
206 // having been loaded. 209 // having been loaded.
207 210
208 const base::DictionaryValue* hashes = 211 const base::DictionaryValue* hashes =
209 g_browser_process->local_state()->GetDictionary( 212 g_browser_process->local_state()->GetDictionary(
(...skipping 14 matching lines...) Expand all
224 // this phase (resetting the unloaded profile's PrefHashStore should only 227 // this phase (resetting the unloaded profile's PrefHashStore should only
225 // force initialization in the next phase's startup). 228 // force initialization in the next phase's startup).
226 EXPECT_EQ( 229 EXPECT_EQ(
227 0, GetTrackedPrefHistogramCount( 230 0, GetTrackedPrefHistogramCount(
228 "Settings.TrackedPreferencesAlternateStoreVersionUpdatedFrom", 231 "Settings.TrackedPreferencesAlternateStoreVersionUpdatedFrom",
229 true)); 232 true));
230 } 233 }
231 234
232 IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest, 235 IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest,
233 MAYBE_InitializeUnloadedProfiles) { 236 MAYBE_InitializeUnloadedProfiles) {
234 if (!profiles::IsMultipleProfilesEnabled())
235 return;
236
237 const base::DictionaryValue* hashes = 237 const base::DictionaryValue* hashes =
238 g_browser_process->local_state()->GetDictionary( 238 g_browser_process->local_state()->GetDictionary(
239 prefs::kProfilePreferenceHashes); 239 prefs::kProfilePreferenceHashes);
240 240
241 // The deleted hash collection should be restored only if the current 241 // The deleted hash collection should be restored only if the current
242 // SettingsEnforcement group allows it. 242 // SettingsEnforcement group allows it.
243 if (is_unloaded_profile_seeding_allowed_) { 243 if (is_unloaded_profile_seeding_allowed_) {
244 EXPECT_EQ(4U, hashes->size()); 244 EXPECT_EQ(4U, hashes->size());
245 245
246 // Verify that the initialization truly did occur in this phase's startup; 246 // Verify that the initialization truly did occur in this phase's startup;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 PrefHashBrowserTestInstance, 320 PrefHashBrowserTestInstance,
321 PrefHashBrowserTest, 321 PrefHashBrowserTest,
322 testing::Values( 322 testing::Values(
323 chrome_prefs::internals::kSettingsEnforcementGroupNoEnforcement, 323 chrome_prefs::internals::kSettingsEnforcementGroupNoEnforcement,
324 chrome_prefs::internals::kSettingsEnforcementGroupEnforceOnload, 324 chrome_prefs::internals::kSettingsEnforcementGroupEnforceOnload,
325 chrome_prefs::internals::kSettingsEnforcementGroupEnforceAlways, 325 chrome_prefs::internals::kSettingsEnforcementGroupEnforceAlways,
326 chrome_prefs::internals:: 326 chrome_prefs::internals::
327 kSettingsEnforcementGroupEnforceAlwaysWithExtensions, 327 kSettingsEnforcementGroupEnforceAlwaysWithExtensions,
328 chrome_prefs::internals:: 328 chrome_prefs::internals::
329 kSettingsEnforcementGroupEnforceAlwaysWithExtensionsAndDSE)); 329 kSettingsEnforcementGroupEnforceAlwaysWithExtensionsAndDSE));
OLDNEW
« no previous file with comments | « chrome/browser/performance_monitor/performance_monitor_browsertest.cc ('k') | chrome/browser/profiles/profile_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698