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

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

Issue 880353002: [Autofill] Log the number of autofill profiles available at form submission (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleaned up Created 5 years, 10 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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/test/histogram_tester.h"
21 #include "base/time/time.h" 22 #include "base/time/time.h"
22 #include "components/autofill/core/browser/autocomplete_history_manager.h" 23 #include "components/autofill/core/browser/autocomplete_history_manager.h"
23 #include "components/autofill/core/browser/autofill_manager.h" 24 #include "components/autofill/core/browser/autofill_manager.h"
24 #include "components/autofill/core/browser/autofill_profile.h" 25 #include "components/autofill/core/browser/autofill_profile.h"
25 #include "components/autofill/core/browser/autofill_test_utils.h" 26 #include "components/autofill/core/browser/autofill_test_utils.h"
26 #include "components/autofill/core/browser/credit_card.h" 27 #include "components/autofill/core/browser/credit_card.h"
27 #include "components/autofill/core/browser/personal_data_manager.h" 28 #include "components/autofill/core/browser/personal_data_manager.h"
28 #include "components/autofill/core/browser/popup_item_ids.h" 29 #include "components/autofill/core/browser/popup_item_ids.h"
29 #include "components/autofill/core/browser/test_autofill_client.h" 30 #include "components/autofill/core/browser/test_autofill_client.h"
30 #include "components/autofill/core/browser/test_autofill_driver.h" 31 #include "components/autofill/core/browser/test_autofill_driver.h"
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 FillAutofillFormData(input_query_id, input_form, input_field, unique_id); 681 FillAutofillFormData(input_query_id, input_form, input_field, unique_id);
681 } 682 }
682 683
683 int MakeFrontendID(const SuggestionBackendID& cc_sid, 684 int MakeFrontendID(const SuggestionBackendID& cc_sid,
684 const SuggestionBackendID& profile_sid) const { 685 const SuggestionBackendID& profile_sid) const {
685 return autofill_manager_->MakeFrontendID(cc_sid, profile_sid); 686 return autofill_manager_->MakeFrontendID(cc_sid, profile_sid);
686 } 687 }
687 688
688 protected: 689 protected:
689 base::MessageLoop message_loop_; 690 base::MessageLoop message_loop_;
691 base::HistogramTester histogram_tester_;
690 TestAutofillClient autofill_client_; 692 TestAutofillClient autofill_client_;
691 scoped_ptr<MockAutofillDriver> autofill_driver_; 693 scoped_ptr<MockAutofillDriver> autofill_driver_;
692 scoped_ptr<TestAutofillManager> autofill_manager_; 694 scoped_ptr<TestAutofillManager> autofill_manager_;
693 scoped_ptr<TestAutofillExternalDelegate> external_delegate_; 695 scoped_ptr<TestAutofillExternalDelegate> external_delegate_;
694 TestPersonalDataManager personal_data_; 696 TestPersonalDataManager personal_data_;
695 }; 697 };
696 698
697 class TestFormStructure : public FormStructure { 699 class TestFormStructure : public FormStructure {
698 public: 700 public:
699 explicit TestFormStructure(const FormData& form) 701 explicit TestFormStructure(const FormData& form)
(...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 FormData response_data; 2225 FormData response_data;
2224 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], 2226 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0],
2225 MakeFrontendID(empty, guid), &response_page_id, &response_data); 2227 MakeFrontendID(empty, guid), &response_page_id, &response_data);
2226 ExpectFilledAddressFormElvis( 2228 ExpectFilledAddressFormElvis(
2227 response_page_id, response_data, kDefaultPageID, false); 2229 response_page_id, response_data, kDefaultPageID, false);
2228 2230
2229 // Simulate form submission. We should call into the PDM to try to save the 2231 // Simulate form submission. We should call into the PDM to try to save the
2230 // filled data. 2232 // filled data.
2231 EXPECT_CALL(personal_data_, SaveImportedProfile(::testing::_)).Times(1); 2233 EXPECT_CALL(personal_data_, SaveImportedProfile(::testing::_)).Times(1);
2232 FormSubmitted(response_data); 2234 FormSubmitted(response_data);
2235
2236 histogram_tester_.ExpectUniqueSample(
2237 "Autofill.StoredProfileCountAtAutofillableFormSubmission", 3, 1);
Ilya Sherman 2015/01/29 20:34:52 Please move this test to the autofill_metrics_unit
Mathieu 2015/01/30 15:22:41 Done.
2233 } 2238 }
2234 2239
2235 // Test that when Autocomplete is enabled and Autofill is disabled, 2240 // Test that when Autocomplete is enabled and Autofill is disabled,
2236 // form submissions are still received by AutocompleteHistoryManager. 2241 // form submissions are still received by AutocompleteHistoryManager.
2237 TEST_F(AutofillManagerTest, FormSubmittedAutocompleteEnabled) { 2242 TEST_F(AutofillManagerTest, FormSubmittedAutocompleteEnabled) {
2238 TestAutofillClient client; 2243 TestAutofillClient client;
2239 autofill_manager_.reset( 2244 autofill_manager_.reset(
2240 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); 2245 new TestAutofillManager(autofill_driver_.get(), &client, NULL));
2241 autofill_manager_->set_autofill_enabled(false); 2246 autofill_manager_->set_autofill_enabled(false);
2242 scoped_ptr<MockAutocompleteHistoryManager> autocomplete_history_manager; 2247 scoped_ptr<MockAutocompleteHistoryManager> autocomplete_history_manager;
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
2926 // results. This triggers the combined message send. 2931 // results. This triggers the combined message send.
2927 AutocompleteSuggestionsReturned(std::vector<base::string16>()); 2932 AutocompleteSuggestionsReturned(std::vector<base::string16>());
2928 2933
2929 external_delegate_->CheckSuggestions( 2934 external_delegate_->CheckSuggestions(
2930 kDefaultPageID, 2935 kDefaultPageID,
2931 Suggestion("Visa - 3456", "04/12", kVisaCard, 2936 Suggestion("Visa - 3456", "04/12", kVisaCard,
2932 autofill_manager_->GetPackedCreditCardID(4))); 2937 autofill_manager_->GetPackedCreditCardID(4)));
2933 } 2938 }
2934 2939
2935 } // namespace autofill 2940 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | components/autofill/core/browser/autofill_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698