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

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

Issue 1371713002: [Autofill] Return early when no new forms are parsed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 5 years, 2 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
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "base/test/histogram_tester.h"
20 #include "base/thread_task_runner_handle.h" 21 #include "base/thread_task_runner_handle.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"
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 form_field->set_server_type(server_types[i]); 802 form_field->set_server_type(server_types[i]);
802 } 803 }
803 804
804 UpdateAutofillCount(); 805 UpdateAutofillCount();
805 } 806 }
806 807
807 private: 808 private:
808 DISALLOW_COPY_AND_ASSIGN(TestFormStructure); 809 DISALLOW_COPY_AND_ASSIGN(TestFormStructure);
809 }; 810 };
810 811
812 // Test that calling OnFormsSeen with an empty set of forms (such as when
813 // reloading a page or when the renderer processes a set of forms but detects
814 // no changes) does not load the forms again.
815 TEST_F(AutofillManagerTest, OnFormsSeen_Empty) {
816 // Set up our form data.
817 FormData form;
818 test::CreateTestAddressFormData(&form);
819 std::vector<FormData> forms(1, form);
820
821 base::HistogramTester histogram_tester;
822 FormsSeen(forms);
823 histogram_tester.ExpectUniqueSample(
824 "Autofill.UserHappiness", 0 /* FORMS_LOADED */, 1);
825
826 // No more forms, metric is not logged.
827 FormsSeen(std::vector<FormData>{});
828 histogram_tester.ExpectUniqueSample(
829 "Autofill.UserHappiness", 0 /* FORMS_LOADED */, 1);
830 }
831
811 // Test that we return all address profile suggestions when all form fields are 832 // Test that we return all address profile suggestions when all form fields are
812 // empty. 833 // empty.
813 TEST_F(AutofillManagerTest, GetProfileSuggestionsEmptyValue) { 834 TEST_F(AutofillManagerTest, GetProfileSuggestionsEmptyValue) {
814 // Set up our form data. 835 // Set up our form data.
815 FormData form; 836 FormData form;
816 test::CreateTestAddressFormData(&form); 837 test::CreateTestAddressFormData(&form);
817 std::vector<FormData> forms(1, form); 838 std::vector<FormData> forms(1, form);
818 FormsSeen(forms); 839 FormsSeen(forms);
819 840
820 const FormFieldData& field = form.fields[0]; 841 const FormFieldData& field = form.fields[0];
(...skipping 2415 matching lines...) Expand 10 before | Expand all | Expand 10 after
3236 3257
3237 external_delegate_->CheckSuggestions( 3258 external_delegate_->CheckSuggestions(
3238 kDefaultPageID, 3259 kDefaultPageID,
3239 Suggestion("Shawn Smith", "1234 Smith Blvd., Robin Adam Smith Grimes", "", 3260 Suggestion("Shawn Smith", "1234 Smith Blvd., Robin Adam Smith Grimes", "",
3240 1), 3261 1),
3241 Suggestion("Adam Smith", "1234 Smith Blvd., Carl Shawn Smith Grimes", "", 3262 Suggestion("Adam Smith", "1234 Smith Blvd., Carl Shawn Smith Grimes", "",
3242 2)); 3263 2));
3243 } 3264 }
3244 3265
3245 } // namespace autofill 3266 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698