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

Side by Side Diff: components/autofill/core/browser/autofill_manager_unittest.cc

Issue 512933004: mac: Don't show "Access Address Book" prompt if Autofill is disabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to estade's style suggestion. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 void CreateTestCreditCardsYearAndMonth(const char* year, const char* month) { 126 void CreateTestCreditCardsYearAndMonth(const char* year, const char* month) {
127 ClearCreditCards(); 127 ClearCreditCards();
128 CreditCard* credit_card = new CreditCard; 128 CreditCard* credit_card = new CreditCard;
129 test::SetCreditCardInfo(credit_card, "Miku Hatsune", 129 test::SetCreditCardInfo(credit_card, "Miku Hatsune",
130 "4234567890654321", // Visa 130 "4234567890654321", // Visa
131 month, year); 131 month, year);
132 credit_card->set_guid("00000000-0000-0000-0000-000000000007"); 132 credit_card->set_guid("00000000-0000-0000-0000-000000000007");
133 credit_cards_.push_back(credit_card); 133 credit_cards_.push_back(credit_card);
134 } 134 }
135 135
136 #if defined(OS_MACOSX) && !defined(OS_IOS)
137 bool ShouldShowAccessAddressBookSuggestion(AutofillType type) { return true; }
Evan Stade 2014/08/28 17:31:55 where is this used? is it supposed to be virtual/O
erikchen 2014/08/28 17:37:52 Yup. Good catch, the method it was overriding wasn
Evan Stade 2014/08/28 17:42:32 can you just remove it instead?
erikchen 2014/08/28 18:14:46 Done.
138 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
139
136 private: 140 private:
137 void CreateTestAutofillProfiles(ScopedVector<AutofillProfile>* profiles) { 141 void CreateTestAutofillProfiles(ScopedVector<AutofillProfile>* profiles) {
138 AutofillProfile* profile = new AutofillProfile; 142 AutofillProfile* profile = new AutofillProfile;
139 test::SetProfileInfo(profile, "Elvis", "Aaron", 143 test::SetProfileInfo(profile, "Elvis", "Aaron",
140 "Presley", "theking@gmail.com", "RCA", 144 "Presley", "theking@gmail.com", "RCA",
141 "3734 Elvis Presley Blvd.", "Apt. 10", 145 "3734 Elvis Presley Blvd.", "Apt. 10",
142 "Memphis", "Tennessee", "38116", "US", 146 "Memphis", "Tennessee", "38116", "US",
143 "12345678901"); 147 "12345678901");
144 profile->set_guid("00000000-0000-0000-0000-000000000001"); 148 profile->set_guid("00000000-0000-0000-0000-000000000001");
145 profiles->push_back(profile); 149 profiles->push_back(profile);
(...skipping 2627 matching lines...) Expand 10 before | Expand all | Expand 10 after
2773 int id = PackGUIDs(empty, guid_pair); 2777 int id = PackGUIDs(empty, guid_pair);
2774 2778
2775 autofill_manager_->RemoveAutofillProfileOrCreditCard(id); 2779 autofill_manager_->RemoveAutofillProfileOrCreditCard(id);
2776 2780
2777 // TODO(csharp): Currently variants should not be deleted, but once they are 2781 // TODO(csharp): Currently variants should not be deleted, but once they are
2778 // update these expectations. 2782 // update these expectations.
2779 // http://crbug.com/124211 2783 // http://crbug.com/124211
2780 EXPECT_TRUE(autofill_manager_->GetProfileWithGUID(guid.c_str())); 2784 EXPECT_TRUE(autofill_manager_->GetProfileWithGUID(guid.c_str()));
2781 } 2785 }
2782 2786
2787 #if defined(OS_MACOSX) && !defined(OS_IOS)
2788 TEST_F(AutofillManagerTest, AccessAddressBookPrompt) {
2789 FormData form;
2790 test::CreateTestAddressFormData(&form);
2791 std::vector<FormData> forms(1, form);
2792 FormsSeen(forms);
2793 FormFieldData& field = form.fields[0];
2794
2795 field.should_autocomplete = false;
2796 EXPECT_FALSE(
2797 autofill_manager_->ShouldShowAccessAddressBookSuggestion(form, field));
2798
2799 field.should_autocomplete = true;
2800 EXPECT_TRUE(
2801 autofill_manager_->ShouldShowAccessAddressBookSuggestion(form, field));
2802 }
2803 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
2804
2783 namespace { 2805 namespace {
2784 2806
2785 class MockAutofillClient : public TestAutofillClient { 2807 class MockAutofillClient : public TestAutofillClient {
2786 public: 2808 public:
2787 MockAutofillClient() {} 2809 MockAutofillClient() {}
2788 2810
2789 virtual ~MockAutofillClient() {} 2811 virtual ~MockAutofillClient() {}
2790 2812
2791 virtual void ShowRequestAutocompleteDialog( 2813 virtual void ShowRequestAutocompleteDialog(
2792 const FormData& form, 2814 const FormData& form,
(...skipping 23 matching lines...) Expand all
2816 test::CreateTestAddressFormData(&form); 2838 test::CreateTestAddressFormData(&form);
2817 std::vector<FormData> forms(1, form); 2839 std::vector<FormData> forms(1, form);
2818 FormsSeen(forms); 2840 FormsSeen(forms);
2819 const FormFieldData& field = form.fields[0]; 2841 const FormFieldData& field = form.fields[0];
2820 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() 2842 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery()
2821 2843
2822 EXPECT_TRUE(external_delegate_->on_query_seen()); 2844 EXPECT_TRUE(external_delegate_->on_query_seen());
2823 } 2845 }
2824 2846
2825 } // namespace autofill 2847 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | components/autofill/core/browser/personal_data_manager_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698