| 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 <memory> | 5 #include <memory> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 external_delegate_.reset(); | 129 external_delegate_.reset(); |
| 130 autofill_driver_.reset(); | 130 autofill_driver_.reset(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 // Issue an OnQuery call with the given |query_id|. | 133 // Issue an OnQuery call with the given |query_id|. |
| 134 void IssueOnQuery(int query_id) { | 134 void IssueOnQuery(int query_id) { |
| 135 const FormData form; | 135 const FormData form; |
| 136 FormFieldData field; | 136 FormFieldData field; |
| 137 field.is_focusable = true; | 137 field.is_focusable = true; |
| 138 field.should_autocomplete = true; | 138 field.should_autocomplete = true; |
| 139 const gfx::RectF element_bounds; | |
| 140 | 139 |
| 141 external_delegate_->OnQuery(query_id, form, field, element_bounds); | 140 external_delegate_->OnQuery(query_id, form, field, gfx::RectF()); |
| 142 } | 141 } |
| 143 | 142 |
| 144 void IssueOnSuggestionsReturned() { | 143 void IssueOnSuggestionsReturned() { |
| 145 std::vector<Suggestion> suggestions; | 144 std::vector<Suggestion> suggestions; |
| 146 suggestions.push_back(Suggestion()); | 145 suggestions.push_back(Suggestion()); |
| 147 suggestions[0].frontend_id = kAutofillProfileId; | 146 suggestions[0].frontend_id = kAutofillProfileId; |
| 148 external_delegate_->OnSuggestionsReturned(kQueryId, suggestions); | 147 external_delegate_->OnSuggestionsReturned(kQueryId, suggestions); |
| 149 } | 148 } |
| 150 | 149 |
| 151 testing::NiceMock<MockAutofillClient> autofill_client_; | 150 testing::NiceMock<MockAutofillClient> autofill_client_; |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 base::string16())); | 577 base::string16())); |
| 579 external_delegate_->OnCreditCardScanned(card_number, expiration_month, | 578 external_delegate_->OnCreditCardScanned(card_number, expiration_month, |
| 580 expiration_year); | 579 expiration_year); |
| 581 } | 580 } |
| 582 | 581 |
| 583 TEST_F(AutofillExternalDelegateUnitTest, IgnoreAutocompleteOffForAutofill) { | 582 TEST_F(AutofillExternalDelegateUnitTest, IgnoreAutocompleteOffForAutofill) { |
| 584 const FormData form; | 583 const FormData form; |
| 585 FormFieldData field; | 584 FormFieldData field; |
| 586 field.is_focusable = true; | 585 field.is_focusable = true; |
| 587 field.should_autocomplete = false; | 586 field.should_autocomplete = false; |
| 588 const gfx::RectF element_bounds; | |
| 589 | 587 |
| 590 external_delegate_->OnQuery(kQueryId, form, field, element_bounds); | 588 external_delegate_->OnQuery(kQueryId, form, field, gfx::RectF()); |
| 591 | 589 |
| 592 std::vector<Suggestion> autofill_items; | 590 std::vector<Suggestion> autofill_items; |
| 593 autofill_items.push_back(Suggestion()); | 591 autofill_items.push_back(Suggestion()); |
| 594 autofill_items[0].frontend_id = POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY; | 592 autofill_items[0].frontend_id = POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY; |
| 595 | 593 |
| 596 // Ensure the popup tries to show itself, despite autocomplete="off". | 594 // Ensure the popup tries to show itself, despite autocomplete="off". |
| 597 EXPECT_CALL(autofill_client_, ShowAutofillPopup(_, _, _, _)); | 595 EXPECT_CALL(autofill_client_, ShowAutofillPopup(_, _, _, _)); |
| 598 EXPECT_CALL(autofill_client_, HideAutofillPopup()).Times(0); | 596 EXPECT_CALL(autofill_client_, HideAutofillPopup()).Times(0); |
| 599 | 597 |
| 600 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_items); | 598 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_items); |
| 601 } | 599 } |
| 602 | 600 |
| 603 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillFieldWithValue) { | 601 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillFieldWithValue) { |
| 604 EXPECT_CALL(autofill_client_, HideAutofillPopup()); | 602 EXPECT_CALL(autofill_client_, HideAutofillPopup()); |
| 605 base::string16 dummy_string(ASCIIToUTF16("baz foo")); | 603 base::string16 dummy_string(ASCIIToUTF16("baz foo")); |
| 606 EXPECT_CALL(*autofill_driver_, | 604 EXPECT_CALL(*autofill_driver_, |
| 607 RendererShouldFillFieldWithValue(dummy_string)); | 605 RendererShouldFillFieldWithValue(dummy_string)); |
| 608 base::HistogramTester histogram_tester; | 606 base::HistogramTester histogram_tester; |
| 609 external_delegate_->DidAcceptSuggestion(dummy_string, | 607 external_delegate_->DidAcceptSuggestion(dummy_string, |
| 610 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, | 608 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, |
| 611 0); | 609 0); |
| 612 histogram_tester.ExpectUniqueSample( | 610 histogram_tester.ExpectUniqueSample( |
| 613 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); | 611 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); |
| 614 } | 612 } |
| 615 | 613 |
| 616 } // namespace autofill | 614 } // namespace autofill |
| OLD | NEW |