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

Unified Diff: chrome/browser/dom_ui/shown_sections_handler_unittest.cc

Issue 3393013: Fix a bug where we would show both the apps and thumb sections (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: whoops Created 10 years, 3 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/dom_ui/shown_sections_handler.cc ('k') | chrome/browser/resources/new_new_tab.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/shown_sections_handler_unittest.cc
diff --git a/chrome/browser/dom_ui/shown_sections_handler_unittest.cc b/chrome/browser/dom_ui/shown_sections_handler_unittest.cc
index 48ca9a1c6d4abef7fba3d9e1f45fade61c71145c..9e89b1b05527bca0f9258189f99e33a31fcdebfd 100644
--- a/chrome/browser/dom_ui/shown_sections_handler_unittest.cc
+++ b/chrome/browser/dom_ui/shown_sections_handler_unittest.cc
@@ -15,35 +15,30 @@
class ShownSectionsHandlerTest : public testing::Test {
};
-TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs) {
- scoped_ptr<PrefService> pref(new TestingPrefService);
-
- // Set an *old* value
- pref->RegisterIntegerPref(prefs::kNTPShownSections, 0);
- pref->SetInteger(prefs::kNTPShownSections, THUMB);
+namespace {
- ShownSectionsHandler::MigrateUserPrefs(pref.get(), 0, 1);
-
- int shown_sections = pref->GetInteger(prefs::kNTPShownSections);
+int MigratePrefValue(PrefService* prefs, int starting_value) {
+ prefs->SetInteger(prefs::kNTPShownSections, starting_value);
+ ShownSectionsHandler::MigrateUserPrefs(prefs, 1, 3);
+ return prefs->GetInteger(prefs::kNTPShownSections);
+}
- EXPECT_TRUE(shown_sections & THUMB);
- EXPECT_FALSE(shown_sections & LIST);
- EXPECT_FALSE(shown_sections & RECENT);
- EXPECT_TRUE(shown_sections & TIPS);
- EXPECT_TRUE(shown_sections & SYNC);
}
-TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs1To2) {
+TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs) {
scoped_ptr<PrefService> pref(new TestingPrefService);
- // Set an *old* value
pref->RegisterIntegerPref(prefs::kNTPShownSections, 0);
- pref->SetInteger(prefs::kNTPShownSections, LIST);
- ShownSectionsHandler::MigrateUserPrefs(pref.get(), 1, 2);
+ EXPECT_EQ(APPS, MigratePrefValue(pref.get(), APPS));
+ EXPECT_EQ(THUMB, MigratePrefValue(pref.get(), THUMB));
+ EXPECT_EQ(APPS, MigratePrefValue(pref.get(), APPS | THUMB));
- int shown_sections = pref->GetInteger(prefs::kNTPShownSections);
+ // 2 is not currently used, but older state may contain it and we should do
+ // something reasonable.
+ EXPECT_EQ(THUMB, MigratePrefValue(pref.get(), 3));
- EXPECT_TRUE(shown_sections & THUMB);
- EXPECT_FALSE(shown_sections & LIST);
+ // 0 can't correspond to any section, but we should still do something
+ // reasonable.
+ EXPECT_EQ(THUMB, MigratePrefValue(pref.get(), 0));
}
« no previous file with comments | « chrome/browser/dom_ui/shown_sections_handler.cc ('k') | chrome/browser/resources/new_new_tab.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698