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

Unified Diff: chrome/browser/autofill/autofill_external_delegate_unittest.cc

Issue 10443084: Add Datalist Support to New Autofill UI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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: chrome/browser/autofill/autofill_external_delegate_unittest.cc
diff --git a/chrome/browser/autofill/autofill_external_delegate_unittest.cc b/chrome/browser/autofill/autofill_external_delegate_unittest.cc
index 44e21e88b61b09cfb463041e33209a720972a540..3f11c6b1d20cfa18342ac5f7fd563d1ce6e575c4 100644
--- a/chrome/browser/autofill/autofill_external_delegate_unittest.cc
+++ b/chrome/browser/autofill/autofill_external_delegate_unittest.cc
@@ -88,6 +88,22 @@ class AutofillExternalDelegateUnitTest : public TabContentsWrapperTestHarness {
}
protected:
+ // Setup the expectation for a platform specific OnQuery call and then execute
+ // it with the given QueryId.
+ void SetupOnQuery(int query_id) {
+ const FormData form;
+ FormField field;
+ field.is_focusable = true;
+ field.should_autocomplete = true;
+ const gfx::Rect bounds;
+
+ EXPECT_CALL(*external_delegate_,
+ OnQueryPlatformSpecific(query_id, form, field, bounds));
+
+ // This should call OnQueryPlatform specific.
+ external_delegate_->OnQuery(query_id, form, field, bounds, false);
+ }
+
scoped_refptr<MockAutofillManager> autofill_manager_;
scoped_ptr<MockAutofillExternalDelegate> external_delegate_;
@@ -100,17 +116,7 @@ class AutofillExternalDelegateUnitTest : public TabContentsWrapperTestHarness {
// Test that our external delegate called the virtual methods at the right time.
TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) {
const int kQueryId = 5;
- const FormData form;
- FormField field;
- field.is_focusable = true;
- field.should_autocomplete = true;
- const gfx::Rect bounds;
-
- EXPECT_CALL(*external_delegate_,
- OnQueryPlatformSpecific(kQueryId, form, field, bounds));
-
- // This should call OnQueryPlatform specific.
- external_delegate_->OnQuery(kQueryId, form, field, bounds, false);
+ SetupOnQuery(kQueryId);
EXPECT_CALL(*external_delegate_, ApplyAutofillSuggestions(_, _, _, _));
@@ -137,6 +143,38 @@ TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) {
autofill_ids[0], 0);
}
+// Test that data list elements for a node will appear in the Autofill popup.
+TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateDataList) {
+ const int kQueryId = 5;
+ SetupOnQuery(kQueryId);
+
+ std::vector<string16> data_list_items;
+ data_list_items.push_back(string16());
+ std::vector<int> data_list_ids;
+ data_list_ids.push_back(WebAutofillClient::MenuItemIDDataListEntry);
+
+ external_delegate_->SetCurrentDataListValues(data_list_items,
+ data_list_items,
+ data_list_items,
+ data_list_ids);
+
+ EXPECT_CALL(*external_delegate_,
+ ApplyAutofillSuggestions(
+ _, _, _, testing::Contains(
+ WebAutofillClient::MenuItemIDDataListEntry)));
+
+ // This should call ApplyAutofillSuggestions.
+ std::vector<string16> autofill_item;
+ autofill_item.push_back(string16());
+ std::vector<int> autofill_ids;
+ autofill_ids.push_back(1);
+ external_delegate_->OnSuggestionsReturned(kQueryId,
+ autofill_item,
+ autofill_item,
+ autofill_item,
+ autofill_ids);
+}
+
// Test that the Autofill delegate doesn't try and fill a form with a
// negative unique id.
TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) {

Powered by Google App Engine
This is Rietveld 408576698