OLD | NEW |
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/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 public: | 72 public: |
73 TestPersonalDataManager() : PersonalDataManager("en-US") { | 73 TestPersonalDataManager() : PersonalDataManager("en-US") { |
74 CreateTestAutofillProfiles(&web_profiles_); | 74 CreateTestAutofillProfiles(&web_profiles_); |
75 CreateTestCreditCards(&credit_cards_); | 75 CreateTestCreditCards(&credit_cards_); |
76 } | 76 } |
77 | 77 |
78 void SetBrowserContext(content::BrowserContext* context) { | 78 void SetBrowserContext(content::BrowserContext* context) { |
79 set_browser_context(context); | 79 set_browser_context(context); |
80 } | 80 } |
81 | 81 |
| 82 void SetPrefService(PrefService* pref_service) { |
| 83 set_pref_service(pref_service); |
| 84 } |
| 85 |
82 // Factory method for keyed service. PersonalDataManager is NULL for testing. | 86 // Factory method for keyed service. PersonalDataManager is NULL for testing. |
83 static BrowserContextKeyedService* Build(content::BrowserContext* profile) { | 87 static BrowserContextKeyedService* Build(content::BrowserContext* profile) { |
84 return NULL; | 88 return NULL; |
85 } | 89 } |
86 | 90 |
87 MOCK_METHOD1(SaveImportedProfile, std::string(const AutofillProfile&)); | 91 MOCK_METHOD1(SaveImportedProfile, std::string(const AutofillProfile&)); |
88 | 92 |
89 AutofillProfile* GetProfileWithGUID(const char* guid) { | 93 AutofillProfile* GetProfileWithGUID(const char* guid) { |
90 for (std::vector<AutofillProfile *>::iterator it = web_profiles_.begin(); | 94 for (std::vector<AutofillProfile *>::iterator it = web_profiles_.begin(); |
91 it != web_profiles_.end(); ++it) { | 95 it != web_profiles_.end(); ++it) { |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 virtual void SetUp() OVERRIDE { | 694 virtual void SetUp() OVERRIDE { |
691 ChromeRenderViewHostTestHarness::SetUp(); | 695 ChromeRenderViewHostTestHarness::SetUp(); |
692 | 696 |
693 autofill::PersonalDataManagerFactory::GetInstance()->SetTestingFactory( | 697 autofill::PersonalDataManagerFactory::GetInstance()->SetTestingFactory( |
694 profile(), TestPersonalDataManager::Build); | 698 profile(), TestPersonalDataManager::Build); |
695 | 699 |
696 | 700 |
697 autofill::TabAutofillManagerDelegate::CreateForWebContents(web_contents()); | 701 autofill::TabAutofillManagerDelegate::CreateForWebContents(web_contents()); |
698 | 702 |
699 personal_data_.SetBrowserContext(profile()); | 703 personal_data_.SetBrowserContext(profile()); |
| 704 personal_data_.SetPrefService(profile()->GetPrefs()); |
700 autofill_driver_.reset(new MockAutofillDriver(web_contents())); | 705 autofill_driver_.reset(new MockAutofillDriver(web_contents())); |
701 autofill_manager_.reset(new TestAutofillManager( | 706 autofill_manager_.reset(new TestAutofillManager( |
702 autofill_driver_.get(), | 707 autofill_driver_.get(), |
703 autofill::TabAutofillManagerDelegate::FromWebContents(web_contents()), | 708 autofill::TabAutofillManagerDelegate::FromWebContents(web_contents()), |
704 &personal_data_)); | 709 &personal_data_)); |
705 | 710 |
706 external_delegate_.reset(new TestAutofillExternalDelegate( | 711 external_delegate_.reset(new TestAutofillExternalDelegate( |
707 web_contents(), | 712 web_contents(), |
708 autofill_manager_.get(), | 713 autofill_manager_.get(), |
709 autofill_driver_.get())); | 714 autofill_driver_.get())); |
(...skipping 2293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3003 test::CreateTestAddressFormData(&form); | 3008 test::CreateTestAddressFormData(&form); |
3004 std::vector<FormData> forms(1, form); | 3009 std::vector<FormData> forms(1, form); |
3005 FormsSeen(forms); | 3010 FormsSeen(forms); |
3006 const FormFieldData& field = form.fields[0]; | 3011 const FormFieldData& field = form.fields[0]; |
3007 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 3012 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
3008 | 3013 |
3009 EXPECT_TRUE(external_delegate_->on_query_seen()); | 3014 EXPECT_TRUE(external_delegate_->on_query_seen()); |
3010 } | 3015 } |
3011 | 3016 |
3012 } // namespace autofill | 3017 } // namespace autofill |
OLD | NEW |