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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
688 suggestions_ = suggestions; | 688 suggestions_ = suggestions; |
689 } | 689 } |
690 | 690 |
691 void CheckSuggestions(int expected_page_id, | 691 void CheckSuggestions(int expected_page_id, |
692 size_t expected_num_suggestions, | 692 size_t expected_num_suggestions, |
693 const Suggestion expected_suggestions[]) { | 693 const Suggestion expected_suggestions[]) { |
694 // Ensure that these results are from the most recent query. | 694 // Ensure that these results are from the most recent query. |
695 EXPECT_TRUE(on_suggestions_returned_seen_); | 695 EXPECT_TRUE(on_suggestions_returned_seen_); |
696 | 696 |
697 EXPECT_EQ(expected_page_id, query_id_); | 697 EXPECT_EQ(expected_page_id, query_id_); |
698 ASSERT_EQ(expected_num_suggestions, suggestions_.size()); | 698 ASSERT_LE(expected_num_suggestions, suggestions_.size()); |
Mathieu
2017/01/25 16:28:50
what happened between 698 and 707 warranting the d
| |
699 for (size_t i = 0; i < expected_num_suggestions; ++i) { | 699 for (size_t i = 0; i < expected_num_suggestions; ++i) { |
700 SCOPED_TRACE(base::StringPrintf("i: %" PRIuS, i)); | 700 SCOPED_TRACE(base::StringPrintf("i: %" PRIuS, i)); |
701 EXPECT_EQ(expected_suggestions[i].value, suggestions_[i].value); | 701 EXPECT_EQ(expected_suggestions[i].value, suggestions_[i].value); |
702 EXPECT_EQ(expected_suggestions[i].label, suggestions_[i].label); | 702 EXPECT_EQ(expected_suggestions[i].label, suggestions_[i].label); |
703 EXPECT_EQ(expected_suggestions[i].icon, suggestions_[i].icon); | 703 EXPECT_EQ(expected_suggestions[i].icon, suggestions_[i].icon); |
704 EXPECT_EQ(expected_suggestions[i].frontend_id, | 704 EXPECT_EQ(expected_suggestions[i].frontend_id, |
705 suggestions_[i].frontend_id); | 705 suggestions_[i].frontend_id); |
706 } | 706 } |
707 ASSERT_EQ(expected_num_suggestions, suggestions_.size()); | |
707 } | 708 } |
708 | 709 |
709 // Wrappers around the above GetSuggestions call that take a hardcoded number | 710 // Wrappers around the above GetSuggestions call that take a hardcoded number |
710 // of expected results so callsites are cleaner. | 711 // of expected results so callsites are cleaner. |
711 void CheckSuggestions(int expected_page_id, | 712 void CheckSuggestions(int expected_page_id, |
712 const Suggestion& suggestion0) { | 713 const Suggestion& suggestion0) { |
713 std::vector<Suggestion> suggestion_vector; | 714 std::vector<Suggestion> suggestion_vector; |
714 suggestion_vector.push_back(suggestion0); | 715 suggestion_vector.push_back(suggestion0); |
715 CheckSuggestions(expected_page_id, 1, &suggestion_vector[0]); | 716 CheckSuggestions(expected_page_id, 1, &suggestion_vector[0]); |
716 } | 717 } |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1623 IDS_AUTOFILL_CREDIT_CARD_HTTP_WARNING_MESSAGE), | 1624 IDS_AUTOFILL_CREDIT_CARD_HTTP_WARNING_MESSAGE), |
1624 l10n_util::GetStringUTF8(IDS_AUTOFILL_HTTP_WARNING_LEARN_MORE), | 1625 l10n_util::GetStringUTF8(IDS_AUTOFILL_HTTP_WARNING_LEARN_MORE), |
1625 "httpWarning", POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE), | 1626 "httpWarning", POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE), |
1626 #if !defined(OS_ANDROID) | 1627 #if !defined(OS_ANDROID) |
1627 Suggestion("", "", "", POPUP_ITEM_ID_SEPARATOR), | 1628 Suggestion("", "", "", POPUP_ITEM_ID_SEPARATOR), |
1628 #endif | 1629 #endif |
1629 Suggestion( | 1630 Suggestion( |
1630 l10n_util::GetStringUTF8(IDS_AUTOFILL_WARNING_PAYMENT_DISABLED), "", | 1631 l10n_util::GetStringUTF8(IDS_AUTOFILL_WARNING_PAYMENT_DISABLED), "", |
1631 "", POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE)); | 1632 "", POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE)); |
1632 | 1633 |
1633 // Clear the test credit cards and try again -- we shouldn't return a warning. | 1634 // Clear the test credit cards and try again -- we should still show the |
1635 // warning. | |
1634 personal_data_.ClearCreditCards(); | 1636 personal_data_.ClearCreditCards(); |
1635 GetAutofillSuggestions(form, field); | 1637 GetAutofillSuggestions(form, field); |
1636 // Autocomplete suggestions are queried, but not Autofill. | 1638 // Test that we sent the right values to the external delegate. |
1637 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen()); | 1639 external_delegate_->CheckSuggestions( |
1640 kDefaultPageID, | |
1641 Suggestion(l10n_util::GetStringUTF8( | |
1642 IDS_AUTOFILL_CREDIT_CARD_HTTP_WARNING_MESSAGE), | |
1643 l10n_util::GetStringUTF8(IDS_AUTOFILL_HTTP_WARNING_LEARN_MORE), | |
1644 "httpWarning", POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE)); | |
1638 } | 1645 } |
1639 | 1646 |
1640 // Test that we don't show the extra "Payment not secure" warning when the page | 1647 // Test that we don't show the extra "Payment not secure" warning when the page |
1641 // and the form target URL are secure, even when the switch is on. | 1648 // and the form target URL are secure, even when the switch is on. |
1642 TEST_F(AutofillManagerTest, | 1649 TEST_F(AutofillManagerTest, |
1643 GetCreditCardSuggestions_SecureContextWithHttpBadSwitchOn) { | 1650 GetCreditCardSuggestions_SecureContextWithHttpBadSwitchOn) { |
1644 SetHttpWarningEnabled(); | 1651 SetHttpWarningEnabled(); |
1645 | 1652 |
1646 // Set up our form data. | 1653 // Set up our form data. |
1647 FormData form; | 1654 FormData form; |
(...skipping 3935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5583 | 5590 |
5584 // The driver should always be notified. | 5591 // The driver should always be notified. |
5585 for (const FormFieldData& field : form.fields) { | 5592 for (const FormFieldData& field : form.fields) { |
5586 GetAutofillSuggestions(form, field); | 5593 GetAutofillSuggestions(form, field); |
5587 EXPECT_TRUE(autofill_driver_->did_interact_with_credit_card_form()); | 5594 EXPECT_TRUE(autofill_driver_->did_interact_with_credit_card_form()); |
5588 autofill_driver_->ClearDidInteractWithCreditCardForm(); | 5595 autofill_driver_->ClearDidInteractWithCreditCardForm(); |
5589 } | 5596 } |
5590 } | 5597 } |
5591 | 5598 |
5592 } // namespace autofill | 5599 } // namespace autofill |
OLD | NEW |