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/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 2687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2698 FormData results; | 2698 FormData results; |
2699 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results)); | 2699 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results)); |
2700 ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, false); | 2700 ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, false); |
2701 | 2701 |
2702 // Simulate form submission. We should call into the PDM to try to save the | 2702 // Simulate form submission. We should call into the PDM to try to save the |
2703 // filled data. | 2703 // filled data. |
2704 EXPECT_CALL(personal_data_, SaveImportedProfile(::testing::_)).Times(1); | 2704 EXPECT_CALL(personal_data_, SaveImportedProfile(::testing::_)).Times(1); |
2705 FormSubmitted(results); | 2705 FormSubmitted(results); |
2706 } | 2706 } |
2707 | 2707 |
2708 // Test that when the personal data manager is null, the form submission flow | |
2709 // works as expected. | |
Ilya Sherman
2013/06/15 00:28:09
I don't see any code to trigger a form submission
sgurun-gerrit only
2013/06/17 21:20:32
I actually looked into it. I could not find any sa
Ilya Sherman
2013/06/18 05:56:25
Presumably you could install a test AutocompleteHi
| |
2710 TEST_F(AutofillManagerTest, FormSubmittedNoPersonalDataManager) { | |
2711 autofill_manager_.reset(new TestAutofillManager( | |
2712 web_contents(), | |
2713 autofill::TabAutofillManagerDelegate::FromWebContents(web_contents()), | |
2714 NULL)); | |
2715 | |
2716 // Set up our form data. | |
2717 FormData form; | |
2718 CreateTestAddressFormData(&form); | |
2719 form.method = ASCIIToUTF16("GET"); | |
2720 std::vector<FormData> forms(1, form); | |
2721 FormsSeen(forms); | |
2722 const FormFieldData& field = form.fields[0]; | |
2723 GetAutofillSuggestions(form, field); | |
2724 | |
2725 // Add some Autocomplete suggestions. We should return the autocomplete | |
2726 // suggestions and the warning; these will be culled by the renderer. | |
Ilya Sherman
2013/06/15 00:28:09
What is the warning referred to in this comment?
sgurun-gerrit only
2013/06/17 21:20:32
inherited from copy/paste. does not make sense, re
| |
2727 std::vector<base::string16> suggestions; | |
2728 suggestions.push_back(ASCIIToUTF16("Jay")); | |
2729 suggestions.push_back(ASCIIToUTF16("Jason")); | |
2730 AutocompleteSuggestionsReturned(suggestions); | |
2731 | |
2732 int page_id = 0; | |
2733 std::vector<base::string16> values; | |
2734 std::vector<base::string16> labels; | |
2735 std::vector<base::string16> icons; | |
2736 std::vector<int> unique_ids; | |
2737 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | |
2738 &unique_ids)); | |
2739 | |
2740 base::string16 expected_values[] = { | |
2741 ASCIIToUTF16("Jay"), | |
2742 ASCIIToUTF16("Jason") | |
2743 }; | |
2744 base::string16 expected_labels[] = { base::string16(), base::string16()}; | |
2745 base::string16 expected_icons[] = { base::string16(), base::string16()}; | |
2746 int expected_unique_ids[] = {0, 0}; | |
2747 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | |
2748 kDefaultPageID, arraysize(expected_values), expected_values, | |
2749 expected_labels, expected_icons, expected_unique_ids); | |
2750 } | |
2751 | |
2708 // Test that we are able to save form data when forms are submitted and we only | 2752 // Test that we are able to save form data when forms are submitted and we only |
2709 // have server data for the field types. | 2753 // have server data for the field types. |
2710 TEST_F(AutofillManagerTest, FormSubmittedServerTypes) { | 2754 TEST_F(AutofillManagerTest, FormSubmittedServerTypes) { |
2711 // Set up our form data. | 2755 // Set up our form data. |
2712 FormData form; | 2756 FormData form; |
2713 CreateTestAddressFormData(&form); | 2757 CreateTestAddressFormData(&form); |
2714 | 2758 |
2715 // Simulate having seen this form on page load. | 2759 // Simulate having seen this form on page load. |
2716 // |form_structure| will be owned by |autofill_manager_|. | 2760 // |form_structure| will be owned by |autofill_manager_|. |
2717 TestFormStructure* form_structure = new TestFormStructure(form); | 2761 TestFormStructure* form_structure = new TestFormStructure(form); |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3280 CreateTestAddressFormData(&form); | 3324 CreateTestAddressFormData(&form); |
3281 std::vector<FormData> forms(1, form); | 3325 std::vector<FormData> forms(1, form); |
3282 FormsSeen(forms); | 3326 FormsSeen(forms); |
3283 const FormFieldData& field = form.fields[0]; | 3327 const FormFieldData& field = form.fields[0]; |
3284 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 3328 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
3285 | 3329 |
3286 autofill_manager_->SetExternalDelegate(NULL); | 3330 autofill_manager_->SetExternalDelegate(NULL); |
3287 } | 3331 } |
3288 | 3332 |
3289 } // namespace autofill | 3333 } // namespace autofill |
OLD | NEW |