| 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 "components/autofill/core/browser/autofill_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/feature_list.h" | 14 #include "base/feature_list.h" |
| 15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
| 19 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
| 20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 21 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
| 22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| 26 #include "base/test/histogram_tester.h" | 26 #include "base/test/histogram_tester.h" |
| 27 #include "base/test/scoped_feature_list.h" |
| 27 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
| 28 #include "base/time/time.h" | 29 #include "base/time/time.h" |
| 29 #include "build/build_config.h" | 30 #include "build/build_config.h" |
| 30 #include "components/autofill/core/browser/autocomplete_history_manager.h" | 31 #include "components/autofill/core/browser/autocomplete_history_manager.h" |
| 31 #include "components/autofill/core/browser/autofill_download_manager.h" | 32 #include "components/autofill/core/browser/autofill_download_manager.h" |
| 32 #include "components/autofill/core/browser/autofill_experiments.h" | 33 #include "components/autofill/core/browser/autofill_experiments.h" |
| 33 #include "components/autofill/core/browser/autofill_profile.h" | 34 #include "components/autofill/core/browser/autofill_profile.h" |
| 34 #include "components/autofill/core/browser/autofill_test_utils.h" | 35 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 35 #include "components/autofill/core/browser/credit_card.h" | 36 #include "components/autofill/core/browser/credit_card.h" |
| 36 #include "components/autofill/core/browser/personal_data_manager.h" | 37 #include "components/autofill/core/browser/personal_data_manager.h" |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 download_manager_ = new TestAutofillDownloadManager( | 762 download_manager_ = new TestAutofillDownloadManager( |
| 762 autofill_driver_.get(), autofill_manager_.get()); | 763 autofill_driver_.get(), autofill_manager_.get()); |
| 763 // AutofillManager takes ownership of |download_manager_|. | 764 // AutofillManager takes ownership of |download_manager_|. |
| 764 autofill_manager_->set_download_manager(download_manager_); | 765 autofill_manager_->set_download_manager(download_manager_); |
| 765 external_delegate_.reset(new TestAutofillExternalDelegate( | 766 external_delegate_.reset(new TestAutofillExternalDelegate( |
| 766 autofill_manager_.get(), | 767 autofill_manager_.get(), |
| 767 autofill_driver_.get())); | 768 autofill_driver_.get())); |
| 768 autofill_manager_->SetExternalDelegate(external_delegate_.get()); | 769 autofill_manager_->SetExternalDelegate(external_delegate_.get()); |
| 769 | 770 |
| 770 // Clear all the things. | 771 // Clear all the things. |
| 771 base::FeatureList::ClearInstanceForTesting(); | |
| 772 variations::testing::ClearAllVariationParams(); | 772 variations::testing::ClearAllVariationParams(); |
| 773 } | 773 } |
| 774 | 774 |
| 775 void TearDown() override { | 775 void TearDown() override { |
| 776 // Order of destruction is important as AutofillManager relies on | 776 // Order of destruction is important as AutofillManager relies on |
| 777 // PersonalDataManager to be around when it gets destroyed. | 777 // PersonalDataManager to be around when it gets destroyed. |
| 778 autofill_manager_.reset(); | 778 autofill_manager_.reset(); |
| 779 autofill_driver_.reset(); | 779 autofill_driver_.reset(); |
| 780 | 780 |
| 781 // Remove the AutofillWebDataService so TestPersonalDataManager does not | 781 // Remove the AutofillWebDataService so TestPersonalDataManager does not |
| (...skipping 14 matching lines...) Expand all Loading... |
| 796 params[kCreditCardSigninPromoImpressionLimitParamKey] = | 796 params[kCreditCardSigninPromoImpressionLimitParamKey] = |
| 797 base::IntToString(impression_limit); | 797 base::IntToString(impression_limit); |
| 798 ASSERT_TRUE( | 798 ASSERT_TRUE( |
| 799 variations::AssociateVariationParams(kTrialName, kGroupName, params)); | 799 variations::AssociateVariationParams(kTrialName, kGroupName, params)); |
| 800 | 800 |
| 801 // Enable the feature. | 801 // Enable the feature. |
| 802 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | 802 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| 803 feature_list->RegisterFieldTrialOverride( | 803 feature_list->RegisterFieldTrialOverride( |
| 804 kAutofillCreditCardSigninPromo.name, | 804 kAutofillCreditCardSigninPromo.name, |
| 805 base::FeatureList::OVERRIDE_ENABLE_FEATURE, trial.get()); | 805 base::FeatureList::OVERRIDE_ENABLE_FEATURE, trial.get()); |
| 806 base::FeatureList::SetInstance(std::move(feature_list)); | 806 scoped_feature_list_.InitWithFeatureList(std::move(feature_list)); |
| 807 | 807 |
| 808 // Double-checking our params made it. | 808 // Double-checking our params made it. |
| 809 std::map<std::string, std::string> actualParams; | 809 std::map<std::string, std::string> actualParams; |
| 810 EXPECT_TRUE(variations::GetVariationParamsByFeature( | 810 EXPECT_TRUE(variations::GetVariationParamsByFeature( |
| 811 kAutofillCreditCardSigninPromo, &actualParams)); | 811 kAutofillCreditCardSigninPromo, &actualParams)); |
| 812 EXPECT_EQ(params, actualParams); | 812 EXPECT_EQ(params, actualParams); |
| 813 } | 813 } |
| 814 | 814 |
| 815 void GetAutofillSuggestions(int query_id, | 815 void GetAutofillSuggestions(int query_id, |
| 816 const FormData& form, | 816 const FormData& form, |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 base::MessageLoop message_loop_; | 993 base::MessageLoop message_loop_; |
| 994 MockAutofillClient autofill_client_; | 994 MockAutofillClient autofill_client_; |
| 995 std::unique_ptr<MockAutofillDriver> autofill_driver_; | 995 std::unique_ptr<MockAutofillDriver> autofill_driver_; |
| 996 std::unique_ptr<TestAutofillManager> autofill_manager_; | 996 std::unique_ptr<TestAutofillManager> autofill_manager_; |
| 997 std::unique_ptr<TestAutofillExternalDelegate> external_delegate_; | 997 std::unique_ptr<TestAutofillExternalDelegate> external_delegate_; |
| 998 scoped_refptr<net::TestURLRequestContextGetter> request_context_; | 998 scoped_refptr<net::TestURLRequestContextGetter> request_context_; |
| 999 TestPaymentsClient* payments_client_; | 999 TestPaymentsClient* payments_client_; |
| 1000 TestAutofillDownloadManager* download_manager_; | 1000 TestAutofillDownloadManager* download_manager_; |
| 1001 TestPersonalDataManager personal_data_; | 1001 TestPersonalDataManager personal_data_; |
| 1002 base::FieldTrialList field_trial_list_; | 1002 base::FieldTrialList field_trial_list_; |
| 1003 base::test::ScopedFeatureList scoped_feature_list_; |
| 1003 }; | 1004 }; |
| 1004 | 1005 |
| 1005 class TestFormStructure : public FormStructure { | 1006 class TestFormStructure : public FormStructure { |
| 1006 public: | 1007 public: |
| 1007 explicit TestFormStructure(const FormData& form) | 1008 explicit TestFormStructure(const FormData& form) |
| 1008 : FormStructure(form) {} | 1009 : FormStructure(form) {} |
| 1009 ~TestFormStructure() override {} | 1010 ~TestFormStructure() override {} |
| 1010 | 1011 |
| 1011 void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types, | 1012 void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types, |
| 1012 const std::vector<ServerFieldType>& server_types) { | 1013 const std::vector<ServerFieldType>& server_types) { |
| (...skipping 4199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5212 FormsSeen(mixed_forms); | 5213 FormsSeen(mixed_forms); |
| 5213 | 5214 |
| 5214 // Suggestions should always be displayed. | 5215 // Suggestions should always be displayed. |
| 5215 for (const FormFieldData& field : mixed_form.fields) { | 5216 for (const FormFieldData& field : mixed_form.fields) { |
| 5216 GetAutofillSuggestions(mixed_form, field); | 5217 GetAutofillSuggestions(mixed_form, field); |
| 5217 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 5218 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); |
| 5218 } | 5219 } |
| 5219 } | 5220 } |
| 5220 | 5221 |
| 5221 } // namespace autofill | 5222 } // namespace autofill |
| OLD | NEW |