OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 // Used when we want an off the record profile. This will store the original | 753 // Used when we want an off the record profile. This will store the original |
754 // profile from which the off the record profile is derived. | 754 // profile from which the off the record profile is derived. |
755 scoped_ptr<Profile> other_browser_context_; | 755 scoped_ptr<Profile> other_browser_context_; |
756 | 756 |
757 private: | 757 private: |
758 DISALLOW_COPY_AND_ASSIGN(AutofillManagerTest); | 758 DISALLOW_COPY_AND_ASSIGN(AutofillManagerTest); |
759 }; | 759 }; |
760 | 760 |
761 class TestFormStructure : public FormStructure { | 761 class TestFormStructure : public FormStructure { |
762 public: | 762 public: |
763 explicit TestFormStructure(const FormData& form) : FormStructure(form) {} | 763 explicit TestFormStructure(const FormData& form) |
| 764 : FormStructure(form, false) {} |
764 virtual ~TestFormStructure() {} | 765 virtual ~TestFormStructure() {} |
765 | 766 |
766 void SetFieldTypes(const std::vector<AutofillFieldType>& heuristic_types, | 767 void SetFieldTypes(const std::vector<AutofillFieldType>& heuristic_types, |
767 const std::vector<AutofillFieldType>& server_types) { | 768 const std::vector<AutofillFieldType>& server_types) { |
768 ASSERT_EQ(field_count(), heuristic_types.size()); | 769 ASSERT_EQ(field_count(), heuristic_types.size()); |
769 ASSERT_EQ(field_count(), server_types.size()); | 770 ASSERT_EQ(field_count(), server_types.size()); |
770 | 771 |
771 for (size_t i = 0; i < field_count(); ++i) { | 772 for (size_t i = 0; i < field_count(); ++i) { |
772 AutofillField* form_field = field(i); | 773 AutofillField* form_field = field(i); |
773 ASSERT_TRUE(form_field); | 774 ASSERT_TRUE(form_field); |
(...skipping 1894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2668 // Test that the form signature for an uploaded form always matches the form | 2669 // Test that the form signature for an uploaded form always matches the form |
2669 // signature from the query. | 2670 // signature from the query. |
2670 TEST_F(AutofillManagerTest, FormSubmittedWithDifferentFields) { | 2671 TEST_F(AutofillManagerTest, FormSubmittedWithDifferentFields) { |
2671 // Set up our form data. | 2672 // Set up our form data. |
2672 FormData form; | 2673 FormData form; |
2673 CreateTestAddressFormData(&form); | 2674 CreateTestAddressFormData(&form); |
2674 std::vector<FormData> forms(1, form); | 2675 std::vector<FormData> forms(1, form); |
2675 FormsSeen(forms); | 2676 FormsSeen(forms); |
2676 | 2677 |
2677 // Cache the expected form signature. | 2678 // Cache the expected form signature. |
2678 std::string signature = FormStructure(form).FormSignature(); | 2679 std::string signature = FormStructure(form, false).FormSignature(); |
2679 | 2680 |
2680 // Change the structure of the form prior to submission. | 2681 // Change the structure of the form prior to submission. |
2681 // Websites would typically invoke JavaScript either on page load or on form | 2682 // Websites would typically invoke JavaScript either on page load or on form |
2682 // submit to achieve this. | 2683 // submit to achieve this. |
2683 form.fields.pop_back(); | 2684 form.fields.pop_back(); |
2684 FormFieldData field = form.fields[3]; | 2685 FormFieldData field = form.fields[3]; |
2685 form.fields[3] = form.fields[7]; | 2686 form.fields[3] = form.fields[7]; |
2686 form.fields[7] = field; | 2687 form.fields[7] = field; |
2687 | 2688 |
2688 // Simulate form submission. | 2689 // Simulate form submission. |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3237 | 3238 |
3238 FormData form; | 3239 FormData form; |
3239 CreateTestAddressFormData(&form); | 3240 CreateTestAddressFormData(&form); |
3240 std::vector<FormData> forms(1, form); | 3241 std::vector<FormData> forms(1, form); |
3241 FormsSeen(forms); | 3242 FormsSeen(forms); |
3242 const FormFieldData& field = form.fields[0]; | 3243 const FormFieldData& field = form.fields[0]; |
3243 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 3244 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
3244 | 3245 |
3245 autofill_manager_->SetExternalDelegate(NULL); | 3246 autofill_manager_->SetExternalDelegate(NULL); |
3246 } | 3247 } |
OLD | NEW |