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

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

Powered by Google App Engine
This is Rietveld 408576698