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

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

Issue 575283003: mac: Don't show access Address Book prompt if user has any Autofill state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix another unit test. Fix some broken (unused) logic in that unit test. Created 6 years, 3 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: components/autofill/core/browser/autofill_manager_unittest.cc
diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc
index 99faf6f998a7cf9f22f995f6f771ed537b020c46..963da431f22583ead8b4b9a59bd953b3e4486ab7 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -95,15 +95,13 @@ class TestPersonalDataManager : public PersonalDataManager {
CreditCard* credit_card = GetCreditCardWithGUID(guid.c_str());
if (credit_card) {
credit_cards_.erase(
- std::remove(credit_cards_.begin(), credit_cards_.end(), credit_card),
erikchen 2014/09/18 21:02:54 This logic is incorrect. std::remove and erase() b
- credit_cards_.end());
+ std::find(credit_cards_.begin(), credit_cards_.end(), credit_card));
}
AutofillProfile* profile = GetProfileWithGUID(guid.c_str());
if (profile) {
web_profiles_.erase(
- std::remove(web_profiles_.begin(), web_profiles_.end(), profile),
- web_profiles_.end());
+ std::find(web_profiles_.begin(), web_profiles_.end(), profile));
}
}
@@ -2787,14 +2785,20 @@ TEST_F(AutofillManagerTest, AccessAddressBookPrompt) {
std::vector<FormData> forms(1, form);
FormsSeen(forms);
FormFieldData& field = form.fields[0];
+ field.should_autocomplete = true;
- field.should_autocomplete = false;
+ // A profile already exists.
EXPECT_FALSE(
autofill_manager_->ShouldShowAccessAddressBookSuggestion(form, field));
- field.should_autocomplete = true;
+ // Remove all profiles.
+ personal_data_.ClearAutofillProfiles();
EXPECT_TRUE(
autofill_manager_->ShouldShowAccessAddressBookSuggestion(form, field));
+
+ field.should_autocomplete = false;
+ EXPECT_FALSE(
+ autofill_manager_->ShouldShowAccessAddressBookSuggestion(form, field));
}
#endif // defined(OS_MACOSX) && !defined(OS_IOS)

Powered by Google App Engine
This is Rietveld 408576698