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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/first_run/first_run_browsertest.cc
diff --git a/chrome/browser/first_run/first_run_browsertest.cc b/chrome/browser/first_run/first_run_browsertest.cc
index bdcf1f5e5d7daf644db6637ce6e8f435f4eb915b..973748fc81fe088282b45331975c5862e1fa91c0 100644
--- a/chrome/browser/first_run/first_run_browsertest.cc
+++ b/chrome/browser/first_run/first_run_browsertest.cc
@@ -20,7 +20,9 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/content_switches.h"
#include "content/public/test/test_launcher.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -229,4 +231,49 @@ IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportNothing,
EXPECT_EQ(1, tab->GetMaxPageID());
}
+// Test first run with some tracked preferences.
+extern const char kWithTrackedPrefs[] =
+ "{\n"
+ " \"homepage\": \"example.com\",\n"
+ " \"homepage_is_newtabpage\": false\n"
+ "}\n";
+// A test fixture that will run in a first run scenario with master_preferences
+// set to kWithTrackedPrefs. Parameterizable on the SettingsEnforcement
+// experiment to be forced.
+class FirstRunMasterPrefsWithTrackedPreferences
+ : public FirstRunMasterPrefsBrowserTestT<kWithTrackedPrefs>,
+ public testing::WithParamInterface<std::string> {
+ public:
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ FirstRunMasterPrefsBrowserTestT::SetUpCommandLine(command_line);
+ command_line->AppendSwitchASCII(
+ switches::kForceFieldTrials, "SettingsEnforcement/" + GetParam() + "/");
+ }
+};
+
+IN_PROC_BROWSER_TEST_P(FirstRunMasterPrefsWithTrackedPreferences,
+ TrackedPreferencesSurviveFirstRun) {
+ const PrefService* user_prefs = browser()->profile()->GetPrefs();
+ EXPECT_EQ("example.com", user_prefs->GetString(prefs::kHomePage));
+ EXPECT_FALSE(user_prefs->GetBoolean(prefs::kHomePageIsNewTabPage));
+
+ // The test for kHomePageIsNewTabPage above relies on the fact that true is
+ // the default (hence false must be the user's pref); ensure this fact remains
+ // true.
+ const base::Value* default_homepage_is_ntp_value =
+ user_prefs->GetDefaultPrefValue(prefs::kHomePageIsNewTabPage);
+ ASSERT_TRUE(default_homepage_is_ntp_value != NULL);
+ bool default_homepage_is_ntp = false;
+ EXPECT_TRUE(
+ default_homepage_is_ntp_value->GetAsBoolean(&default_homepage_is_ntp));
+ EXPECT_TRUE(default_homepage_is_ntp);
+}
+
+INSTANTIATE_TEST_CASE_P(FirstRunMasterPrefsWithTrackedPreferencesInstance,
+ FirstRunMasterPrefsWithTrackedPreferences,
+ testing::Values("no_enforcement",
+ "enforce",
+ "enforce_no_seeding",
+ "enforce_no_seeding_no_migration"));
+
#endif // !defined(OS_CHROMEOS)
« 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