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

Side by Side Diff: chrome/browser/dom_ui/shown_sections_handler_unittest.cc

Issue 3051001: Adjust preference sync code to only sync user modifiable preferences. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: separate out the download_manager_unittest.cc fixes Created 10 years, 5 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/dom_ui/shown_sections_handler.h" 5 #include "chrome/browser/dom_ui/shown_sections_handler.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "chrome/browser/chrome_thread.h" 9 #include "chrome/browser/chrome_thread.h"
10 #include "chrome/browser/pref_service.h"
11 #include "chrome/browser/pref_value_store.h" 10 #include "chrome/browser/pref_value_store.h"
12 #include "chrome/common/json_pref_store.h" 11 #include "chrome/common/json_pref_store.h"
13 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
13 #include "chrome/test/testing_pref_service.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 class ShownSectionsHandlerTest : public testing::Test { 16 class ShownSectionsHandlerTest : public testing::Test {
17 }; 17 };
18 18
19 TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs) { 19 TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs) {
20 // Create a preference value that has only user defined 20 scoped_ptr<PrefService> pref(new TestingPrefService);
21 // preference values.
22 FilePath user_prefs = FilePath();
23 scoped_ptr<PrefService> pref(PrefService::CreateUserPrefService(user_prefs));
24 21
25 // Set an *old* value 22 // Set an *old* value
26 pref->RegisterIntegerPref(prefs::kNTPShownSections, 0); 23 pref->RegisterIntegerPref(prefs::kNTPShownSections, 0);
27 pref->SetInteger(prefs::kNTPShownSections, THUMB); 24 pref->SetInteger(prefs::kNTPShownSections, THUMB);
28 25
29 ShownSectionsHandler::MigrateUserPrefs(pref.get(), 0, 1); 26 ShownSectionsHandler::MigrateUserPrefs(pref.get(), 0, 1);
30 27
31 int shown_sections = pref->GetInteger(prefs::kNTPShownSections); 28 int shown_sections = pref->GetInteger(prefs::kNTPShownSections);
32 29
33 EXPECT_TRUE(shown_sections & THUMB); 30 EXPECT_TRUE(shown_sections & THUMB);
34 EXPECT_FALSE(shown_sections & LIST); 31 EXPECT_FALSE(shown_sections & LIST);
35 EXPECT_FALSE(shown_sections & RECENT); 32 EXPECT_FALSE(shown_sections & RECENT);
36 EXPECT_TRUE(shown_sections & TIPS); 33 EXPECT_TRUE(shown_sections & TIPS);
37 EXPECT_TRUE(shown_sections & SYNC); 34 EXPECT_TRUE(shown_sections & SYNC);
38 } 35 }
39 36
40 TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs1To2) { 37 TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs1To2) {
41 FilePath user_prefs = FilePath(); 38 scoped_ptr<PrefService> pref(new TestingPrefService);
42 scoped_ptr<PrefService> pref(PrefService::CreateUserPrefService(user_prefs));
43 39
44 // Set an *old* value 40 // Set an *old* value
45 pref->RegisterIntegerPref(prefs::kNTPShownSections, 0); 41 pref->RegisterIntegerPref(prefs::kNTPShownSections, 0);
46 pref->SetInteger(prefs::kNTPShownSections, LIST); 42 pref->SetInteger(prefs::kNTPShownSections, LIST);
47 43
48 ShownSectionsHandler::MigrateUserPrefs(pref.get(), 1, 2); 44 ShownSectionsHandler::MigrateUserPrefs(pref.get(), 1, 2);
49 45
50 int shown_sections = pref->GetInteger(prefs::kNTPShownSections); 46 int shown_sections = pref->GetInteger(prefs::kNTPShownSections);
51 47
52 EXPECT_TRUE(shown_sections & THUMB); 48 EXPECT_TRUE(shown_sections & THUMB);
53 EXPECT_FALSE(shown_sections & LIST); 49 EXPECT_FALSE(shown_sections & LIST);
54 } 50 }
55
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/new_tab_ui_uitest.cc ('k') | chrome/browser/managed_prefs_banner_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698