| Index: components/autofill/core/browser/autofill_external_delegate_unittest.cc
|
| diff --git a/components/autofill/core/browser/autofill_external_delegate_unittest.cc b/components/autofill/core/browser/autofill_external_delegate_unittest.cc
|
| index ad86d836bebc462876e46505413897ae12815aec..d7b673f0db9f9dbc60f4c99be561e497381344ca 100644
|
| --- a/components/autofill/core/browser/autofill_external_delegate_unittest.cc
|
| +++ b/components/autofill/core/browser/autofill_external_delegate_unittest.cc
|
| @@ -10,6 +10,7 @@
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "chrome/test/base/testing_profile.h"
|
| #include "components/autofill/core/browser/autofill_manager.h"
|
| +#include "components/autofill/core/browser/popup_item_ids.h"
|
| #include "components/autofill/core/browser/test_autofill_driver.h"
|
| #include "components/autofill/core/browser/test_autofill_external_delegate.h"
|
| #include "components/autofill/core/browser/test_autofill_manager_delegate.h"
|
| @@ -18,11 +19,9 @@
|
| #include "components/autofill/core/common/password_form_fill_data.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| -#include "third_party/WebKit/public/web/WebAutofillClient.h"
|
| #include "ui/gfx/rect.h"
|
|
|
| using base::ASCIIToUTF16;
|
| -using blink::WebAutofillClient;
|
| using testing::_;
|
|
|
| namespace autofill {
|
| @@ -141,15 +140,18 @@ TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) {
|
| IssueOnQuery(kQueryId);
|
|
|
| // The enums must be cast to ints to prevent compile errors on linux_rel.
|
| - EXPECT_CALL(manager_delegate_,
|
| - ShowAutofillPopup(
|
| - _, _, _, _, _,
|
| - testing::ElementsAre(
|
| - kAutofillProfileId,
|
| - static_cast<int>(WebAutofillClient::MenuItemIDSeparator),
|
| - static_cast<int>(
|
| - WebAutofillClient::MenuItemIDAutofillOptions)),
|
| - _));
|
| + EXPECT_CALL(
|
| + manager_delegate_,
|
| + ShowAutofillPopup(_,
|
| + _,
|
| + _,
|
| + _,
|
| + _,
|
| + testing::ElementsAre(
|
| + kAutofillProfileId,
|
| + static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
|
| + static_cast<int>(POPUP_ITEM_ID_AUTOFILL_OPTIONS)),
|
| + _));
|
|
|
| // This should call ShowAutofillPopup.
|
| std::vector<base::string16> autofill_item;
|
| @@ -186,18 +188,20 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateDataList) {
|
| data_list_items);
|
|
|
| // The enums must be cast to ints to prevent compile errors on linux_rel.
|
| - EXPECT_CALL(manager_delegate_,
|
| - ShowAutofillPopup(
|
| - _, _, _, _, _,
|
| - testing::ElementsAre(
|
| - static_cast<int>(
|
| - WebAutofillClient::MenuItemIDDataListEntry),
|
| - static_cast<int>(WebAutofillClient::MenuItemIDSeparator),
|
| - kAutofillProfileId,
|
| - static_cast<int>(WebAutofillClient::MenuItemIDSeparator),
|
| - static_cast<int>(
|
| - WebAutofillClient::MenuItemIDAutofillOptions)),
|
| - _));
|
| + EXPECT_CALL(
|
| + manager_delegate_,
|
| + ShowAutofillPopup(_,
|
| + _,
|
| + _,
|
| + _,
|
| + _,
|
| + testing::ElementsAre(
|
| + static_cast<int>(POPUP_ITEM_ID_DATALIST_ENTRY),
|
| + static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
|
| + kAutofillProfileId,
|
| + static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
|
| + static_cast<int>(POPUP_ITEM_ID_AUTOFILL_OPTIONS)),
|
| + _));
|
|
|
| // This should call ShowAutofillPopup.
|
| std::vector<base::string16> autofill_item;
|
| @@ -213,13 +217,16 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateDataList) {
|
| // Try calling OnSuggestionsReturned with no Autofill values and ensure
|
| // the datalist items are still shown.
|
| // The enum must be cast to an int to prevent compile errors on linux_rel.
|
| - EXPECT_CALL(manager_delegate_,
|
| - ShowAutofillPopup(
|
| - _, _, _, _, _,
|
| - testing::ElementsAre(
|
| - static_cast<int>(
|
| - WebAutofillClient::MenuItemIDDataListEntry)),
|
| - _));
|
| + EXPECT_CALL(
|
| + manager_delegate_,
|
| + ShowAutofillPopup(
|
| + _,
|
| + _,
|
| + _,
|
| + _,
|
| + _,
|
| + testing::ElementsAre(static_cast<int>(POPUP_ITEM_ID_DATALIST_ENTRY)),
|
| + _));
|
|
|
| autofill_item = std::vector<base::string16>();
|
| autofill_ids = std::vector<int>();
|
| @@ -246,18 +253,20 @@ TEST_F(AutofillExternalDelegateUnitTest, UpdateDataListWhileShowingPopup) {
|
| data_list_items);
|
|
|
| // The enums must be cast to ints to prevent compile errors on linux_rel.
|
| - EXPECT_CALL(manager_delegate_,
|
| - ShowAutofillPopup(
|
| - _, _, _, _, _,
|
| - testing::ElementsAre(
|
| - static_cast<int>(
|
| - WebAutofillClient::MenuItemIDDataListEntry),
|
| - static_cast<int>(WebAutofillClient::MenuItemIDSeparator),
|
| - kAutofillProfileId,
|
| - static_cast<int>(WebAutofillClient::MenuItemIDSeparator),
|
| - static_cast<int>(
|
| - WebAutofillClient::MenuItemIDAutofillOptions)),
|
| - _));
|
| + EXPECT_CALL(
|
| + manager_delegate_,
|
| + ShowAutofillPopup(_,
|
| + _,
|
| + _,
|
| + _,
|
| + _,
|
| + testing::ElementsAre(
|
| + static_cast<int>(POPUP_ITEM_ID_DATALIST_ENTRY),
|
| + static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
|
| + kAutofillProfileId,
|
| + static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
|
| + static_cast<int>(POPUP_ITEM_ID_AUTOFILL_OPTIONS)),
|
| + _));
|
|
|
| // Ensure the popup is displayed.
|
| std::vector<base::string16> autofill_item;
|
| @@ -293,19 +302,22 @@ TEST_F(AutofillExternalDelegateUnitTest, AutofillWarnings) {
|
| IssueOnQuery(kQueryId);
|
|
|
| // The enums must be cast to ints to prevent compile errors on linux_rel.
|
| - EXPECT_CALL(manager_delegate_,
|
| - ShowAutofillPopup(
|
| - _, _, _, _, _,
|
| - testing::ElementsAre(
|
| - static_cast<int>(
|
| - WebAutofillClient::MenuItemIDWarningMessage)),
|
| - _));
|
| + EXPECT_CALL(
|
| + manager_delegate_,
|
| + ShowAutofillPopup(
|
| + _,
|
| + _,
|
| + _,
|
| + _,
|
| + _,
|
| + testing::ElementsAre(static_cast<int>(POPUP_ITEM_ID_WARNING_MESSAGE)),
|
| + _));
|
|
|
| // This should call ShowAutofillPopup.
|
| std::vector<base::string16> autofill_item;
|
| autofill_item.push_back(base::string16());
|
| std::vector<int> autofill_ids;
|
| - autofill_ids.push_back(WebAutofillClient::MenuItemIDWarningMessage);
|
| + autofill_ids.push_back(POPUP_ITEM_ID_WARNING_MESSAGE);
|
| external_delegate_->OnSuggestionsReturned(kQueryId,
|
| autofill_item,
|
| autofill_item,
|
| @@ -333,7 +345,7 @@ TEST_F(AutofillExternalDelegateUnitTest, NoAutofillWarningsWithoutSuggestions) {
|
| std::vector<base::string16> autofill_item;
|
| autofill_item.push_back(base::string16());
|
| std::vector<int> autofill_ids;
|
| - autofill_ids.push_back(WebAutofillClient::MenuItemIDAutocompleteEntry);
|
| + autofill_ids.push_back(POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY);
|
| external_delegate_->OnSuggestionsReturned(kQueryId,
|
| autofill_item,
|
| autofill_item,
|
| @@ -368,9 +380,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearPreviewedForm) {
|
| // Ensure selecting a new password entries or Autofill entries will
|
| // cause any previews to get cleared.
|
| EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1);
|
| - external_delegate_->DidSelectSuggestion(
|
| - WebAutofillClient::MenuItemIDPasswordEntry);
|
| -
|
| + external_delegate_->DidSelectSuggestion(POPUP_ITEM_ID_PASSWORD_ENTRY);
|
| EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1);
|
| EXPECT_CALL(*autofill_driver_, SetRendererActionOnFormDataReception(
|
| AutofillDriver::FORM_DATA_ACTION_PREVIEW));
|
| @@ -409,13 +419,16 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegatePasswordSuggestions) {
|
| external_delegate_->AddPasswordFormMapping(field, password_form_fill_data);
|
|
|
| // The enums must be cast to ints to prevent compile errors on linux_rel.
|
| - EXPECT_CALL(manager_delegate_,
|
| - ShowAutofillPopup(
|
| - _, _, _, _, _,
|
| - testing::ElementsAre(
|
| - static_cast<int>(
|
| - WebAutofillClient::MenuItemIDPasswordEntry)),
|
| - _));
|
| + EXPECT_CALL(
|
| + manager_delegate_,
|
| + ShowAutofillPopup(
|
| + _,
|
| + _,
|
| + _,
|
| + _,
|
| + _,
|
| + testing::ElementsAre(static_cast<int>(POPUP_ITEM_ID_PASSWORD_ENTRY)),
|
| + _));
|
|
|
| external_delegate_->OnShowPasswordSuggestions(suggestions,
|
| realms,
|
| @@ -426,9 +439,8 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegatePasswordSuggestions) {
|
|
|
| // This should trigger a call to hide the popup since
|
| // we've selected an option.
|
| - external_delegate_->DidAcceptSuggestion(
|
| - suggestions[0],
|
| - WebAutofillClient::MenuItemIDPasswordEntry);
|
| + external_delegate_->DidAcceptSuggestion(suggestions[0],
|
| + POPUP_ITEM_ID_PASSWORD_ENTRY);
|
| }
|
|
|
| // Test that the driver is directed to accept the data list after being notified
|
| @@ -438,9 +450,8 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateAcceptSuggestion) {
|
| base::string16 dummy_string(ASCIIToUTF16("baz qux"));
|
| EXPECT_CALL(*autofill_driver_,
|
| RendererShouldAcceptDataListSuggestion(dummy_string));
|
| - external_delegate_->DidAcceptSuggestion(
|
| - dummy_string,
|
| - WebAutofillClient::MenuItemIDDataListEntry);
|
| + external_delegate_->DidAcceptSuggestion(dummy_string,
|
| + POPUP_ITEM_ID_DATALIST_ENTRY);
|
| }
|
|
|
| // Test that the driver is directed to clear the form after being notified that
|
| @@ -449,9 +460,8 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearForm) {
|
| EXPECT_CALL(manager_delegate_, HideAutofillPopup());
|
| EXPECT_CALL(*autofill_driver_, RendererShouldClearFilledForm());
|
|
|
| - external_delegate_->DidAcceptSuggestion(
|
| - base::string16(),
|
| - WebAutofillClient::MenuItemIDClearForm);
|
| + external_delegate_->DidAcceptSuggestion(base::string16(),
|
| + POPUP_ITEM_ID_CLEAR_FORM);
|
| }
|
|
|
| TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateHideWarning) {
|
| @@ -467,7 +477,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateHideWarning) {
|
| std::vector<base::string16> autofill_items;
|
| autofill_items.push_back(base::string16());
|
| std::vector<int> autofill_ids;
|
| - autofill_ids.push_back(WebAutofillClient::MenuItemIDAutocompleteEntry);
|
| + autofill_ids.push_back(POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY);
|
|
|
| // Ensure the popup tries to hide itself, since it is not allowed to show
|
| // anything.
|
| @@ -485,9 +495,8 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateSetNodeText) {
|
| base::string16 dummy_string(ASCIIToUTF16("baz foo"));
|
| EXPECT_CALL(*autofill_driver_,
|
| RendererShouldSetNodeText(dummy_string));
|
| - external_delegate_->DidAcceptSuggestion(
|
| - dummy_string,
|
| - WebAutofillClient::MenuItemIDAutocompleteEntry);
|
| + external_delegate_->DidAcceptSuggestion(dummy_string,
|
| + POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY);
|
| }
|
|
|
| } // namespace autofill
|
|
|