| 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> |
| (...skipping 5881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |