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

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: add test 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
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\": \"test.com\",\n"
erikwright (departed) 2014/02/04 20:55:28 use example.com
gab 2014/02/04 22:32:11 Done.
238 " \"homepage_is_newtabpage\": false\n"
239 "}\n";
240 // A test fixture which will run with in a first run scenario with
erikwright (departed) 2014/02/04 20:55:28 with in -> in
erikwright (departed) 2014/02/04 20:55:28 which -> that
gab 2014/02/04 22:32:11 Done.
gab 2014/02/04 22:32:11 Done.
241 // master_preferences set to kWithTrackedPrefs. Parametrizable on the
erikwright (departed) 2014/02/04 20:55:28 parameterizable
gab 2014/02/04 22:32:11 Done.
242 // SettingsEnforcement 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 const std::string force_settings_enforcement_trial(
250 "SettingsEnforcement/" + GetParam() + "/");
251 command_line->AppendSwitchASCII(switches::kForceFieldTrials,
erikwright (departed) 2014/02/04 20:55:28 I'd just break after (, indent by 4 spaces, and in
gab 2014/02/04 22:32:11 Done.
252 force_settings_enforcement_trial);
253 }
254 };
erikwright (departed) 2014/02/04 20:55:28 blank line after };
gab 2014/02/04 22:32:11 Done.
255 IN_PROC_BROWSER_TEST_P(FirstRunMasterPrefsWithTrackedPreferences,
256 TrackedPreferencesSurviveFirstRun) {
257 const PrefService* user_prefs = browser()->profile()->GetPrefs();
258 std::string tmp;
erikwright (departed) 2014/02/04 20:55:28 tmp is unused
gab 2014/02/04 22:32:11 Oops, got too used to the DictionaryValue::Get int
259 EXPECT_EQ("test.com", user_prefs->GetString(prefs::kHomePage));
260 EXPECT_FALSE(user_prefs->GetBoolean(prefs::kHomePageIsNewTabPage));
erikwright (departed) 2014/02/04 20:55:28 Can you add a test that the default is true, or so
gab 2014/02/04 22:32:11 Done.
261 }
262
263 INSTANTIATE_TEST_CASE_P(FirstRunMasterPrefsWithTrackedPreferencesInstance,
264 FirstRunMasterPrefsWithTrackedPreferences,
265 testing::Values("no_enforcement",
266 "enforce",
267 "enforce_no_seeding",
268 "enforce_no_seeding_no_migration"));
269
232 #endif // !defined(OS_CHROMEOS) 270 #endif // !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698