| 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));
|
| +}
|
|
|