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 ce23a585afa1c901bc81cd0096747f6882e34f77..2538d320ea1fc1d33e0fdea3be7ebbd4677e056d 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) { |