| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/browsing_data/core/browsing_data_utils.h" | 5 #include "components/browsing_data/core/browsing_data_utils.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 // Test all configurations of zero and nonzero partial results for datatypes. | 57 // Test all configurations of zero and nonzero partial results for datatypes. |
| 58 // Test singular and plural for each datatype. | 58 // Test singular and plural for each datatype. |
| 59 const struct TestCase { | 59 const struct TestCase { |
| 60 int num_credit_cards; | 60 int num_credit_cards; |
| 61 int num_addresses; | 61 int num_addresses; |
| 62 int num_suggestions; | 62 int num_suggestions; |
| 63 bool sync_enabled; | 63 bool sync_enabled; |
| 64 std::string expected_output; | 64 std::string expected_output; |
| 65 } kTestCases[] = { | 65 } kTestCases[] = { |
| 66 {0, 0, 0, false, "none"}, | 66 {0, 0, 0, false, "None"}, |
| 67 {0, 0, 0, true, "none"}, | 67 {0, 0, 0, true, "None"}, |
| 68 {1, 0, 0, false, "1 credit card"}, | 68 {1, 0, 0, false, "1 credit card"}, |
| 69 {0, 5, 0, false, "5 addresses"}, | 69 {0, 5, 0, false, "5 addresses"}, |
| 70 {0, 0, 1, false, "1 suggestion"}, | 70 {0, 0, 1, false, "1 suggestion"}, |
| 71 {0, 0, 2, false, "2 suggestions"}, | 71 {0, 0, 2, false, "2 suggestions"}, |
| 72 {0, 0, 2, true, "2 suggestions (synced)"}, | 72 {0, 0, 2, true, "2 suggestions (synced)"}, |
| 73 {4, 7, 0, false, "4 credit cards, 7 addresses"}, | 73 {4, 7, 0, false, "4 credit cards, 7 addresses"}, |
| 74 {4, 7, 0, true, "4 credit cards, 7 addresses (synced)"}, | 74 {4, 7, 0, true, "4 credit cards, 7 addresses (synced)"}, |
| 75 {3, 0, 9, false, "3 credit cards, 9 other suggestions"}, | 75 {3, 0, 9, false, "3 credit cards, 9 other suggestions"}, |
| 76 {0, 1, 1, false, "1 address, 1 other suggestion"}, | 76 {0, 1, 1, false, "1 address, 1 other suggestion"}, |
| 77 {9, 6, 3, false, "9 credit cards, 6 addresses, 3 others"}, | 77 {9, 6, 3, false, "9 credit cards, 6 addresses, 3 others"}, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 100 scoped_refptr<password_manager::TestPasswordStore> store( | 100 scoped_refptr<password_manager::TestPasswordStore> store( |
| 101 new password_manager::TestPasswordStore()); | 101 new password_manager::TestPasswordStore()); |
| 102 browsing_data::PasswordsCounter counter( | 102 browsing_data::PasswordsCounter counter( |
| 103 scoped_refptr<password_manager::PasswordStore>(store), nullptr); | 103 scoped_refptr<password_manager::PasswordStore>(store), nullptr); |
| 104 | 104 |
| 105 const struct TestCase { | 105 const struct TestCase { |
| 106 int num_passwords; | 106 int num_passwords; |
| 107 int is_synced; | 107 int is_synced; |
| 108 std::string expected_output; | 108 std::string expected_output; |
| 109 } kTestCases[] = { | 109 } kTestCases[] = { |
| 110 {0, false, "none"}, {0, true, "none"}, | 110 {0, false, "None"}, {0, true, "None"}, |
| 111 {1, false, "1 password"}, {1, true, "1 password (synced)"}, | 111 {1, false, "1 password"}, {1, true, "1 password (synced)"}, |
| 112 {5, false, "5 passwords"}, {5, true, "5 passwords (synced)"}, | 112 {5, false, "5 passwords"}, {5, true, "5 passwords (synced)"}, |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 for (const TestCase& test_case : kTestCases) { | 115 for (const TestCase& test_case : kTestCases) { |
| 116 browsing_data::BrowsingDataCounter::SyncResult result( | 116 browsing_data::BrowsingDataCounter::SyncResult result( |
| 117 &counter, test_case.num_passwords, test_case.is_synced); | 117 &counter, test_case.num_passwords, test_case.is_synced); |
| 118 SCOPED_TRACE(base::StringPrintf("Test params: %d password(s), %d is_synced", | 118 SCOPED_TRACE(base::StringPrintf("Test params: %d password(s), %d is_synced", |
| 119 test_case.num_passwords, | 119 test_case.num_passwords, |
| 120 test_case.is_synced)); | 120 test_case.is_synced)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 145 prefs()->SetInteger(kDeleteTimePeriod, 100); | 145 prefs()->SetInteger(kDeleteTimePeriod, 100); |
| 146 | 146 |
| 147 // After the first migration all settings should stay the same if the | 147 // After the first migration all settings should stay the same if the |
| 148 // migration is executed again. | 148 // migration is executed again. |
| 149 browsing_data::MigratePreferencesToBasic(prefs()); | 149 browsing_data::MigratePreferencesToBasic(prefs()); |
| 150 EXPECT_TRUE(prefs()->GetBoolean(kDeleteBrowsingHistoryBasic)); | 150 EXPECT_TRUE(prefs()->GetBoolean(kDeleteBrowsingHistoryBasic)); |
| 151 EXPECT_FALSE(prefs()->GetBoolean(kDeleteCookiesBasic)); | 151 EXPECT_FALSE(prefs()->GetBoolean(kDeleteCookiesBasic)); |
| 152 EXPECT_FALSE(prefs()->GetBoolean(kDeleteCacheBasic)); | 152 EXPECT_FALSE(prefs()->GetBoolean(kDeleteCacheBasic)); |
| 153 EXPECT_EQ(42, prefs()->GetInteger(kDeleteTimePeriodBasic)); | 153 EXPECT_EQ(42, prefs()->GetInteger(kDeleteTimePeriodBasic)); |
| 154 } | 154 } |
| OLD | NEW |