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

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: Make password generation checkbox hidden by the command flag. Created 8 years, 8 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: 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 8962b2d7a47baf5850d117feef2960496661b7f3..340fd3da6f5b79520ad11c1b842cd09309326d56 100644
--- a/chrome/browser/autofill/autofill_manager_unittest.cc
+++ b/chrome/browser/autofill/autofill_manager_unittest.cc
@@ -2891,9 +2891,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.
@@ -2943,6 +2946,47 @@ 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();
+}
Ilya Sherman 2012/05/01 22:27:48 nit: Please leave a blank line after this closing
zysxqn 2012/05/03 00:57:24 Done.
namespace {
class MockAutofillExternalDelegate : public TestAutofillExternalDelegate {

Powered by Google App Engine
This is Rietveld 408576698