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

Side by Side Diff: chrome/browser/first_run/first_run_browsertest.cc

Issue 145053004: Let chrome_prefs handle Preferences initialization from master_preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang compile Created 6 years, 10 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
« no previous file with comments | « chrome/browser/first_run/first_run.cc ('k') | chrome/browser/first_run/first_run_internal.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/extensions/component_loader.h" 12 #include "chrome/browser/extensions/component_loader.h"
13 #include "chrome/browser/first_run/first_run.h" 13 #include "chrome/browser/first_run/first_run.h"
14 #include "chrome/browser/importer/importer_list.h" 14 #include "chrome/browser/importer/importer_list.h"
15 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
21 #include "chrome/test/base/in_process_browser_test.h" 21 #include "chrome/test/base/in_process_browser_test.h"
22 #include "chrome/test/base/ui_test_utils.h" 22 #include "chrome/test/base/ui_test_utils.h"
23 #include "components/user_prefs/user_prefs.h"
23 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
25 #include "content/public/common/content_switches.h"
24 #include "content/public/test/test_launcher.h" 26 #include "content/public/test/test_launcher.h"
25 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
26 28
27 typedef InProcessBrowserTest FirstRunBrowserTest; 29 typedef InProcessBrowserTest FirstRunBrowserTest;
28 30
29 IN_PROC_BROWSER_TEST_F(FirstRunBrowserTest, SetShowFirstRunBubblePref) { 31 IN_PROC_BROWSER_TEST_F(FirstRunBrowserTest, SetShowFirstRunBubblePref) {
30 EXPECT_TRUE(g_browser_process->local_state()->FindPreference( 32 EXPECT_TRUE(g_browser_process->local_state()->FindPreference(
31 prefs::kShowFirstRunBubbleOption)); 33 prefs::kShowFirstRunBubbleOption));
32 EXPECT_EQ(first_run::FIRST_RUN_BUBBLE_DONT_SHOW, 34 EXPECT_EQ(first_run::FIRST_RUN_BUBBLE_DONT_SHOW,
33 g_browser_process->local_state()->GetInteger( 35 g_browser_process->local_state()->GetInteger(
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportNothing, 224 IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportNothing,
223 MAYBE_ImportNothingAndShowNewTabPage) { 225 MAYBE_ImportNothingAndShowNewTabPage) {
224 EXPECT_EQ(first_run::AUTO_IMPORT_CALLED, first_run::auto_import_state()); 226 EXPECT_EQ(first_run::AUTO_IMPORT_CALLED, first_run::auto_import_state());
225 ui_test_utils::NavigateToURLWithDisposition( 227 ui_test_utils::NavigateToURLWithDisposition(
226 browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB, 228 browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB,
227 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 229 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
228 content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); 230 content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0);
229 EXPECT_EQ(1, tab->GetMaxPageID()); 231 EXPECT_EQ(1, tab->GetMaxPageID());
230 } 232 }
231 233
234 // Test first run with some tracked preferences.
235 extern const char kWithTrackedPrefs[] =
236 "{\n"
237 " \"homepage\": \"example.com\",\n"
238 " \"homepage_is_newtabpage\": false\n"
239 "}\n";
240 // A test fixture that will run in a first run scenario with master_preferences
241 // set to kWithTrackedPrefs. Parameterizable on the SettingsEnforcement
242 // experiment to be forced.
243 class FirstRunMasterPrefsWithTrackedPreferences
244 : public FirstRunMasterPrefsBrowserTestT<kWithTrackedPrefs>,
245 public testing::WithParamInterface<std::string> {
246 public:
247 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
248 FirstRunMasterPrefsBrowserTestT::SetUpCommandLine(command_line);
249 command_line->AppendSwitchASCII(
250 switches::kForceFieldTrials, "SettingsEnforcement/" + GetParam() + "/");
251 }
252 };
253
254 IN_PROC_BROWSER_TEST_P(FirstRunMasterPrefsWithTrackedPreferences,
255 TrackedPreferencesSurviveFirstRun) {
256 const PrefService* user_prefs = browser()->profile()->GetPrefs();
257 EXPECT_EQ("example.com", user_prefs->GetString(prefs::kHomePage));
258 EXPECT_FALSE(user_prefs->GetBoolean(prefs::kHomePageIsNewTabPage));
259
260 // The test for kHomePageIsNewTabPage above relies on the fact that true is
261 // the default (hence false must be the user's pref); ensure this fact remains
262 // true.
263 const base::Value* default_homepage_is_ntp_value =
264 user_prefs->GetDefaultPrefValue(prefs::kHomePageIsNewTabPage);
265 ASSERT_TRUE(default_homepage_is_ntp_value != NULL);
266 bool default_homepage_is_ntp = false;
267 EXPECT_TRUE(
268 default_homepage_is_ntp_value->GetAsBoolean(&default_homepage_is_ntp));
269 EXPECT_TRUE(default_homepage_is_ntp);
270 }
271
272 INSTANTIATE_TEST_CASE_P(FirstRunMasterPrefsWithTrackedPreferencesInstance,
273 FirstRunMasterPrefsWithTrackedPreferences,
274 testing::Values("no_enforcement",
275 "enforce",
276 "enforce_no_seeding",
277 "enforce_no_seeding_no_migration"));
278
232 #endif // !defined(OS_CHROMEOS) 279 #endif // !defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/first_run/first_run.cc ('k') | chrome/browser/first_run/first_run_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698