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

Unified Diff: components/browsing_data/core/browsing_data_utils_unittest.cc

Issue 2671743002: Separate state of basic and advanced tab in CBD dialog (Closed)
Patch Set: rebase and fix compilation Created 3 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
Index: components/browsing_data/core/browsing_data_utils_unittest.cc
diff --git a/components/browsing_data/core/browsing_data_utils_unittest.cc b/components/browsing_data/core/browsing_data_utils_unittest.cc
index eaad13b4b84c3f799c586a876f45835bc6c0e824..bd22d2867be2276ee856f1ffa33d82fdaf1efb69 100644
--- a/components/browsing_data/core/browsing_data_utils_unittest.cc
+++ b/components/browsing_data/core/browsing_data_utils_unittest.cc
@@ -12,6 +12,9 @@
#include "base/threading/thread_task_runner_handle.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/browsing_data/core/counters/autofill_counter.h"
+#include "components/browsing_data/core/pref_names.h"
+#include "components/prefs/pref_service.h"
+#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -33,8 +36,15 @@ class BrowsingDataUtilsTest : public testing::Test {
BrowsingDataUtilsTest() {}
~BrowsingDataUtilsTest() override {}
+ void SetUp() override {
+ browsing_data::prefs::RegisterBrowserUserPrefs(prefs_.registry());
+ }
+
+ PrefService* prefs() { return &prefs_; }
+
private:
base::MessageLoop loop_;
+ sync_preferences::TestingPrefServiceSyncable prefs_;
};
// Tests the complex output of the Autofill counter.
@@ -77,3 +87,32 @@ TEST_F(BrowsingDataUtilsTest, AutofillCounterResult) {
EXPECT_EQ(output, base::ASCIIToUTF16(test_case.expected_output));
}
}
+
+TEST_F(BrowsingDataUtilsTest, MigratePreferencesToBasic) {
+ using namespace browsing_data::prefs;
+
+ prefs()->SetBoolean(kDeleteBrowsingHistory, true);
+ prefs()->SetBoolean(kDeleteCookies, false);
+ prefs()->SetBoolean(kDeleteCache, false);
+ prefs()->SetInteger(kDeleteTimePeriod, 42);
+
+ // History, cookies and cache should be migrated to their basic counterpart.
+ browsing_data::MigratePreferencesToBasic(prefs());
+ EXPECT_TRUE(prefs()->GetBoolean(kDeleteBrowsingHistoryBasic));
+ EXPECT_FALSE(prefs()->GetBoolean(kDeleteCookiesBasic));
+ EXPECT_FALSE(prefs()->GetBoolean(kDeleteCacheBasic));
+ EXPECT_EQ(42, prefs()->GetInteger(kDeleteTimePeriodBasic));
+
+ prefs()->SetBoolean(kDeleteBrowsingHistory, true);
+ prefs()->SetBoolean(kDeleteCookies, true);
+ prefs()->SetBoolean(kDeleteCache, true);
+ prefs()->SetInteger(kDeleteTimePeriod, 100);
+
+ // After the first migration all settings should stay the same if the
+ // migration is executed again.
+ browsing_data::MigratePreferencesToBasic(prefs());
+ EXPECT_TRUE(prefs()->GetBoolean(kDeleteBrowsingHistoryBasic));
+ EXPECT_FALSE(prefs()->GetBoolean(kDeleteCookiesBasic));
+ EXPECT_FALSE(prefs()->GetBoolean(kDeleteCacheBasic));
+ EXPECT_EQ(42, prefs()->GetInteger(kDeleteTimePeriodBasic));
+}
« no previous file with comments | « components/browsing_data/core/browsing_data_utils.cc ('k') | components/browsing_data/core/clear_browsing_data_tab.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698