Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Unified Diff: components/autofill/core/browser/autofill_external_delegate_unittest.cc

Issue 1208133002: [Autofill/Autocomplete Feature] Substring matching instead of prefix matching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added |match_start| usage. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 18939bbaa732e7d0429807fa599a45a5c11d8be2..fe4cc0a931c9ac61d68a8d8a98afce184432895e 100644
--- a/components/autofill/core/browser/autofill_external_delegate_unittest.cc
+++ b/components/autofill/core/browser/autofill_external_delegate_unittest.cc
@@ -47,8 +47,8 @@ class MockAutofillDriver : public TestAutofillDriver {
MOCK_METHOD0(RendererShouldClearFilledForm, void());
MOCK_METHOD0(RendererShouldClearPreviewedForm, void());
MOCK_METHOD1(RendererShouldFillFieldWithValue, void(const base::string16&));
- MOCK_METHOD1(RendererShouldPreviewFieldWithValue,
- void(const base::string16&));
+ MOCK_METHOD2(RendererShouldPreviewFieldWithValue,
+ void(const base::string16&, size_t));
private:
DISALLOW_COPY_AND_ASSIGN(MockAutofillDriver);
@@ -319,9 +319,10 @@ TEST_F(AutofillExternalDelegateUnitTest, AutofillWarnings) {
// negative unique id.
TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) {
// Ensure it doesn't try to preview the negative id.
+ size_t match_start = 0;
EXPECT_CALL(*autofill_manager_, FillOrPreviewForm(_, _, _, _, _)).Times(0);
EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1);
- external_delegate_->DidSelectSuggestion(base::string16(), -1);
+ external_delegate_->DidSelectSuggestion(base::string16(), -1, match_start);
// Ensure it doesn't try to fill the form in with the negative id.
EXPECT_CALL(autofill_client_, HideAutofillPopup());
@@ -334,22 +335,24 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) {
TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearPreviewedForm) {
// Ensure selecting a new password entries or Autofill entries will
// cause any previews to get cleared.
+ size_t match_start = 0;
EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1);
- external_delegate_->DidSelectSuggestion(ASCIIToUTF16("baz foo"),
- POPUP_ITEM_ID_PASSWORD_ENTRY);
+ external_delegate_->DidSelectSuggestion(
+ ASCIIToUTF16("baz foo"), POPUP_ITEM_ID_PASSWORD_ENTRY, match_start);
EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1);
EXPECT_CALL(*autofill_manager_,
FillOrPreviewForm(
AutofillDriver::FORM_DATA_ACTION_PREVIEW, _, _, _, _));
- external_delegate_->DidSelectSuggestion(ASCIIToUTF16("baz foo"), 1);
+ external_delegate_->DidSelectSuggestion(ASCIIToUTF16("baz foo"), 1,
+ match_start);
// Ensure selecting an autocomplete entry will cause any previews to
// get cleared.
EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1);
EXPECT_CALL(*autofill_driver_, RendererShouldPreviewFieldWithValue(
- ASCIIToUTF16("baz foo")));
- external_delegate_->DidSelectSuggestion(ASCIIToUTF16("baz foo"),
- POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY);
+ ASCIIToUTF16("baz foo"), match_start));
+ external_delegate_->DidSelectSuggestion(
+ ASCIIToUTF16("baz foo"), POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, match_start);
}
// Test that the popup is hidden once we are done editing the autofill field.

Powered by Google App Engine
This is Rietveld 408576698