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

Unified Diff: components/autofill/core/browser/options_util_unittest.cc

Issue 1571863002: Update the Payments integration setting now that it now governs uploads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: UI string wordsmithing Created 4 years, 11 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 | « components/autofill/core/browser/options_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/options_util_unittest.cc
diff --git a/components/autofill/core/browser/options_util_unittest.cc b/components/autofill/core/browser/options_util_unittest.cc
index c8ec660e0984b57783c49a16438b2c2978f73a93..5a89d00391c049714bb2a7af43cd8f12ffb5ae58 100644
--- a/components/autofill/core/browser/options_util_unittest.cc
+++ b/components/autofill/core/browser/options_util_unittest.cc
@@ -46,24 +46,19 @@ class TestSyncService : public sync_driver::FakeSyncService {
};
scoped_ptr<TestSyncService> CreateSyncService(bool has_autofill_profile,
- bool has_autofill_wallet_data,
bool is_enabled_and_logged_in) {
syncer::ModelTypeSet type_set;
if (has_autofill_profile)
type_set.Put(syncer::AUTOFILL_PROFILE);
- if (has_autofill_wallet_data)
- type_set.Put(syncer::AUTOFILL_WALLET_DATA);
return make_scoped_ptr(
new TestSyncService(type_set, is_enabled_and_logged_in));
}
scoped_ptr<TestingPrefServiceSimple> CreatePrefService(
- bool autofill_enabled,
bool autofill_wallet_import_enabled,
bool autofill_wallet_sync_experiment_enabled) {
scoped_ptr<TestingPrefServiceSimple> prefs(new TestingPrefServiceSimple());
- prefs->registry()->RegisterBooleanPref(prefs::kAutofillEnabled,
- autofill_enabled);
+ prefs->registry()->RegisterBooleanPref(prefs::kAutofillEnabled, true);
prefs->registry()->RegisterBooleanPref(prefs::kAutofillWalletImportEnabled,
autofill_wallet_import_enabled);
prefs->registry()->RegisterBooleanPref(
@@ -74,15 +69,9 @@ scoped_ptr<TestingPrefServiceSimple> CreatePrefService(
}
scoped_ptr<TestPersonalDataManager> CreatePersonalDataManager(
- PrefService* prefs,
- bool has_server_data) {
+ PrefService* prefs) {
scoped_ptr<TestPersonalDataManager> pdm(new TestPersonalDataManager());
pdm->SetTestingPrefService(prefs);
- if (has_server_data) {
- // This will cause pdm->HasServerData() to return true.
- pdm->AddTestingServerCreditCard(test::GetVerifiedCreditCard());
- }
-
return pdm;
}
@@ -90,92 +79,60 @@ scoped_ptr<TestPersonalDataManager> CreatePersonalDataManager(
// Verify that true is returned when all inputs are complete.
TEST(WalletIntegrationAvailableTest, AllInputsComplete) {
- scoped_ptr<TestSyncService> sync = CreateSyncService(true, true, true);
- scoped_ptr<TestingPrefServiceSimple> prefs =
- CreatePrefService(true, true, true);
+ scoped_ptr<TestSyncService> sync = CreateSyncService(true, true);
+ scoped_ptr<TestingPrefServiceSimple> prefs = CreatePrefService(true, true);
+ scoped_ptr<TestPersonalDataManager> pdm =
+ CreatePersonalDataManager(prefs.get());
+
+ EXPECT_TRUE(WalletIntegrationAvailable(sync.get(), *pdm));
+}
+
+// Verify that true is returned even if wallet import is disabled. (Otherwise
+// the user will never be able to enable it).
+TEST(WalletIntegrationAvailableTest, WalletImportDisabled) {
+ scoped_ptr<TestSyncService> sync = CreateSyncService(true, true);
+ scoped_ptr<TestingPrefServiceSimple> prefs = CreatePrefService(false, true);
scoped_ptr<TestPersonalDataManager> pdm =
- CreatePersonalDataManager(prefs.get(), true);
+ CreatePersonalDataManager(prefs.get());
- EXPECT_TRUE(WalletIntegrationAvailable(sync.get(), *prefs, *pdm));
+ EXPECT_TRUE(WalletIntegrationAvailable(sync.get(), *pdm));
}
// Verify that false is returned when SyncService is missing or incomplete.
TEST(WalletIntegrationAvailableTest, MissingOrIncompleteSyncService) {
// Setup |prefs| and |pdm| to do their part to make
// WalletIntegrationAvailable() return true.
- scoped_ptr<TestingPrefServiceSimple> prefs =
- CreatePrefService(true, true, true);
+ scoped_ptr<TestingPrefServiceSimple> prefs = CreatePrefService(true, true);
scoped_ptr<TestPersonalDataManager> pdm =
- CreatePersonalDataManager(prefs.get(), true);
+ CreatePersonalDataManager(prefs.get());
// Incomplete SyncService data should return false.
- EXPECT_FALSE(WalletIntegrationAvailable(NULL, *prefs, *pdm));
+ EXPECT_FALSE(WalletIntegrationAvailable(NULL, *pdm));
- scoped_ptr<TestSyncService> sync = CreateSyncService(false, false, false);
- EXPECT_FALSE(WalletIntegrationAvailable(sync.get(), *prefs, *pdm));
+ scoped_ptr<TestSyncService> sync = CreateSyncService(false, false);
+ EXPECT_FALSE(WalletIntegrationAvailable(sync.get(), *pdm));
- sync = CreateSyncService(false, false, true);
- EXPECT_FALSE(WalletIntegrationAvailable(sync.get(), *prefs, *pdm));
+ sync = CreateSyncService(false, true);
+ EXPECT_FALSE(WalletIntegrationAvailable(sync.get(), *pdm));
- sync = CreateSyncService(true, false, false);
- EXPECT_FALSE(WalletIntegrationAvailable(sync.get(), *prefs, *pdm));
+ sync = CreateSyncService(true, false);
+ EXPECT_FALSE(WalletIntegrationAvailable(sync.get(), *pdm));
// Complete SyncService data should return true.
- sync = CreateSyncService(true, true, true);
- EXPECT_TRUE(WalletIntegrationAvailable(sync.get(), *prefs, *pdm));
+ sync = CreateSyncService(true, true);
+ EXPECT_TRUE(WalletIntegrationAvailable(sync.get(), *pdm));
}
// Verify that false is returned when
// !prefs::kAutofillWalletSyncExperimentEnabled.
TEST(WalletIntegrationAvailableTest, ExperimentalWalletIntegrationDisabled) {
- scoped_ptr<TestSyncService> sync = CreateSyncService(true, true, true);
+ scoped_ptr<TestSyncService> sync = CreateSyncService(true, true);
// Set kAutofillWalletSyncExperimentEnabled to false.
- scoped_ptr<TestingPrefServiceSimple> prefs =
- CreatePrefService(true, true, false);
- scoped_ptr<TestPersonalDataManager> pdm =
- CreatePersonalDataManager(prefs.get(), true);
-
- EXPECT_FALSE(WalletIntegrationAvailable(sync.get(), *prefs, *pdm));
-}
-
-// Verify that false is returned if server data is missing.
-TEST(WalletIntegrationAvailableTest, NoServerData) {
- scoped_ptr<TestSyncService> sync = CreateSyncService(true, true, true);
- scoped_ptr<TestingPrefServiceSimple> prefs =
- CreatePrefService(true, true, true);
- // Set server data as missing.
- scoped_ptr<TestPersonalDataManager> pdm =
- CreatePersonalDataManager(prefs.get(), false);
-
- EXPECT_FALSE(WalletIntegrationAvailable(sync.get(), *prefs, *pdm));
-}
-
-// Verify that true is returned when !prefs::kAutofillWalletImportEnabled,
-// even if server data is missing.
-TEST(WalletIntegrationAvailableTest, WalletImportDisabled) {
- scoped_ptr<TestSyncService> sync = CreateSyncService(true, true, true);
- // Set kAutofillWalletImportEnabled to false.
- scoped_ptr<TestingPrefServiceSimple> prefs =
- CreatePrefService(true, false, true);
- // Set server data as missing.
- scoped_ptr<TestPersonalDataManager> pdm =
- CreatePersonalDataManager(prefs.get(), false);
-
- EXPECT_TRUE(WalletIntegrationAvailable(sync.get(), *prefs, *pdm));
-}
-
-// Verify that true is returned when data hasn't been synced yet, even if
-// server data is missing.
-TEST(WalletIntegrationAvailableTest, WalletDataNotSyncedYet) {
- // Set wallet data as not synced yet.
- scoped_ptr<TestSyncService> sync = CreateSyncService(true, false, true);
- scoped_ptr<TestingPrefServiceSimple> prefs =
- CreatePrefService(true, true, true);
- // Set server data as missing.
+ scoped_ptr<TestingPrefServiceSimple> prefs = CreatePrefService(true, false);
scoped_ptr<TestPersonalDataManager> pdm =
- CreatePersonalDataManager(prefs.get(), false);
+ CreatePersonalDataManager(prefs.get());
- EXPECT_TRUE(WalletIntegrationAvailable(sync.get(), *prefs, *pdm));
+ EXPECT_FALSE(WalletIntegrationAvailable(sync.get(), *pdm));
}
} // namespace autofill
« no previous file with comments | « components/autofill/core/browser/options_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698