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

Unified Diff: chrome/browser/autofill/autofill_manager_unittest.cc

Issue 10222017: Make password generation switched by a preference in chrome settings rather than a command line fla… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change DCHECK_EQ to DCHECK to get around some type convertion issue. Created 8 years, 7 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 | « chrome/browser/autofill/autofill_manager.cc ('k') | chrome/browser/resources/options2/browser_options.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/autofill_manager_unittest.cc
diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
index 2f3ae8137a9932fb6ea42eefbc9792c9d670ad4a..2ec5081f6864dfe2eef28538b3ca49f7374b66df 100644
--- a/chrome/browser/autofill/autofill_manager_unittest.cc
+++ b/chrome/browser/autofill/autofill_manager_unittest.cc
@@ -2921,9 +2921,12 @@ TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) {
FormSubmitted(form);
}
-TEST_F(AutofillManagerTest, UpdatePasswordGenerationState) {
+TEST_F(AutofillManagerTest, UpdatePasswordSyncState) {
// Allow this test to control what should get synced.
profile()->GetPrefs()->SetBoolean(prefs::kSyncKeepEverythingSynced, false);
+ // Always set password generation enabled check box so we can test the
+ // behavior of password sync.
+ profile()->GetPrefs()->SetBoolean(prefs::kPasswordGenerationEnabled, true);
// Sync some things, but not passwords. Shouldn't send anything since
// password generation is disabled by default.
@@ -2973,6 +2976,48 @@ TEST_F(AutofillManagerTest, UpdatePasswordGenerationState) {
autofill_manager_->ClearSentStates();
}
+TEST_F(AutofillManagerTest, UpdatePasswordGenerationState) {
+ // Always set password sync enabled so we can test the behavior of password
+ // generation.
+ profile()->GetPrefs()->SetBoolean(prefs::kSyncKeepEverythingSynced, false);
+ ProfileSyncService* sync_service = GetProfileSyncService();
+ sync_service->SetSyncSetupCompleted();
+ syncable::ModelTypeSet preferred_set;
+ preferred_set.Put(syncable::PASSWORDS);
+ sync_service->ChangePreferredDataTypes(preferred_set);
+
+ // Enabled state remains false, should not sent.
+ profile()->GetPrefs()->SetBoolean(prefs::kPasswordGenerationEnabled, false);
+ UpdatePasswordGenerationState(false);
+ EXPECT_EQ(0u, autofill_manager_->GetSentStates().size());
+
+ // Enabled state from false to true, should sent true.
+ profile()->GetPrefs()->SetBoolean(prefs::kPasswordGenerationEnabled, true);
+ UpdatePasswordGenerationState(false);
+ EXPECT_EQ(1u, autofill_manager_->GetSentStates().size());
+ EXPECT_TRUE(autofill_manager_->GetSentStates()[0]);
+ autofill_manager_->ClearSentStates();
+
+ // Enabled states remains true, should not sent.
+ profile()->GetPrefs()->SetBoolean(prefs::kPasswordGenerationEnabled, true);
+ UpdatePasswordGenerationState(false);
+ EXPECT_EQ(0u, autofill_manager_->GetSentStates().size());
+
+ // Enabled states from true to false, should sent false.
+ profile()->GetPrefs()->SetBoolean(prefs::kPasswordGenerationEnabled, false);
+ UpdatePasswordGenerationState(false);
+ EXPECT_EQ(1u, autofill_manager_->GetSentStates().size());
+ EXPECT_FALSE(autofill_manager_->GetSentStates()[0]);
+ autofill_manager_->ClearSentStates();
+
+ // When a new render_view is created, we send the state even if it's the
+ // same.
+ UpdatePasswordGenerationState(true);
+ EXPECT_EQ(1u, autofill_manager_->GetSentStates().size());
+ EXPECT_FALSE(autofill_manager_->GetSentStates()[0]);
+ autofill_manager_->ClearSentStates();
+}
+
TEST_F(AutofillManagerTest, RemoveProfile) {
// Add and remove an Autofill profile.
AutofillProfile* profile = new AutofillProfile;
« no previous file with comments | « chrome/browser/autofill/autofill_manager.cc ('k') | chrome/browser/resources/options2/browser_options.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698