summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/shown_sections_handler_unittest.cc
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-27 19:33:36 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-27 19:33:36 +0000
commitfd42ac30f127624def51d949e21f9776b0e6d257 (patch)
tree690ae7b46b66bbc03051b460ca5ee66a6665554f /chrome/browser/ui/webui/shown_sections_handler_unittest.cc
parent8ea6a9e57e924dabe697cbf73b6fda59c6297664 (diff)
downloadchromium_src-fd42ac30f127624def51d949e21f9776b0e6d257.zip
chromium_src-fd42ac30f127624def51d949e21f9776b0e6d257.tar.gz
chromium_src-fd42ac30f127624def51d949e21f9776b0e6d257.tar.bz2
WebUI: Move the remaining files from chrome/browser/webui to chrome/browser/ui/webui. Final Part.
BUG=59946 TEST=trybots Review URL: http://codereview.chromium.org/6594035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76191 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/webui/shown_sections_handler_unittest.cc')
-rw-r--r--chrome/browser/ui/webui/shown_sections_handler_unittest.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/chrome/browser/ui/webui/shown_sections_handler_unittest.cc b/chrome/browser/ui/webui/shown_sections_handler_unittest.cc
new file mode 100644
index 0000000..ee647a5
--- /dev/null
+++ b/chrome/browser/ui/webui/shown_sections_handler_unittest.cc
@@ -0,0 +1,43 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/shown_sections_handler.h"
+
+#include "base/scoped_ptr.h"
+#include "chrome/browser/prefs/pref_value_store.h"
+#include "chrome/common/json_pref_store.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/test/testing_pref_service.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class ShownSectionsHandlerTest : public testing::Test {
+};
+
+namespace {
+
+int MigratePrefValue(PrefService* prefs, int starting_value) {
+ prefs->SetInteger(prefs::kNTPShownSections, starting_value);
+ ShownSectionsHandler::MigrateUserPrefs(prefs, 1, 3);
+ return prefs->GetInteger(prefs::kNTPShownSections);
+}
+
+} // namespace
+
+TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs) {
+ scoped_ptr<PrefService> pref(new TestingPrefService);
+
+ pref->RegisterIntegerPref(prefs::kNTPShownSections, 0);
+
+ EXPECT_EQ(APPS, MigratePrefValue(pref.get(), APPS));
+ EXPECT_EQ(THUMB, MigratePrefValue(pref.get(), THUMB));
+ EXPECT_EQ(APPS, MigratePrefValue(pref.get(), APPS | THUMB));
+
+ // 2 is not currently used, but older state may contain it and we should do
+ // something reasonable.
+ EXPECT_EQ(THUMB, MigratePrefValue(pref.get(), 3));
+
+ // 0 can't correspond to any section, but we should still do something
+ // reasonable.
+ EXPECT_EQ(THUMB, MigratePrefValue(pref.get(), 0));
+}