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

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

Issue 2796873002: Sending autofill types for username fields in sign-in forms for improving username detection. (Closed)
Patch Set: Fix compilation error Created 3 years, 8 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 "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>
(...skipping 5881 matching lines...) Expand 10 before | Expand all | Expand 10 after
5892 5892
5893 FormsSeen({form}); 5893 FormsSeen({form});
5894 5894
5895 // Suggestions should be displayed. 5895 // Suggestions should be displayed.
5896 for (const FormFieldData& field : form.fields) { 5896 for (const FormFieldData& field : form.fields) {
5897 GetAutofillSuggestions(form, field); 5897 GetAutofillSuggestions(form, field);
5898 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); 5898 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen());
5899 } 5899 }
5900 } 5900 }
5901 5901
5902 // Test that a sign-in form submission sends an upload with types matching the
5903 // fields.
5904 TEST_F(AutofillManagerTest, SignInFormSubmission_Upload) {
5905 // Set up our form data (it's already filled out with user data).
5906 FormData form;
5907 form.origin = GURL("http://myform.com/form.html");
5908 form.action = GURL("http://myform.com/submit.html");
5909
5910 std::vector<ServerFieldTypeSet> expected_types;
5911 ServerFieldTypeSet types;
5912
5913 FormFieldData field;
5914 test::CreateTestFormField("Email", "email", "theking@gmail.com", "text",
5915 &field);
5916 form.fields.push_back(field);
5917 types.insert(EMAIL_ADDRESS);
5918 expected_types.push_back(types);
5919
5920 test::CreateTestFormField("Password", "pw", "secret", "password", &field);
5921 form.fields.push_back(field);
5922 types.clear();
5923 types.insert(PASSWORD);
5924 expected_types.push_back(types);
5925
5926 // We will expect these types in the upload and no observed submission. (the
5927 // callback initiated by WaitForAsyncUploadProcess checks these expectations.)
5928 autofill_manager_->set_expected_submitted_field_types(expected_types);
5929 autofill_manager_->set_expected_observed_submission(true);
5930 autofill_manager_->ResetRunLoop();
5931
5932 std::unique_ptr<FormStructure> form_structure(new FormStructure(form));
5933 form_structure->set_is_signin_upload(true);
5934 form_structure->field(1)->set_possible_types({autofill::PASSWORD});
5935
5936 std::string signature = form_structure->FormSignatureAsStr();
5937 autofill_manager_->StartUploadProcess(std::move(form_structure),
5938 base::TimeTicks::Now(), true);
5939
5940 // Wait for upload to complete (will check expected types as well).
5941 autofill_manager_->WaitForAsyncUploadProcess();
5942
5943 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature());
5944 }
5945
5902 } // namespace autofill 5946 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | components/autofill/core/browser/form_structure.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698