Index: chrome/browser/autocomplete_history_manager_unittest.cc |
diff --git a/chrome/browser/autocomplete_history_manager_unittest.cc b/chrome/browser/autocomplete_history_manager_unittest.cc |
index 540e5f04733bf67d34f99e13601a5bc4595dee59..674ca31ca0cb9ab0b91372ee486b604409872155 100644 |
--- a/chrome/browser/autocomplete_history_manager_unittest.cc |
+++ b/chrome/browser/autocomplete_history_manager_unittest.cc |
@@ -9,6 +9,7 @@ |
#include "base/task.h" |
#include "base/utf_string_conversions.h" |
#include "chrome/browser/autocomplete_history_manager.h" |
+#include "chrome/browser/autofill/autofill_external_delegate.h" |
#include "chrome/browser/webdata/web_data_service.h" |
#include "chrome/test/base/chrome_render_view_host_test_harness.h" |
#include "chrome/test/base/testing_browser_process.h" |
@@ -131,3 +132,52 @@ TEST_F(AutocompleteHistoryManagerTest, SearchField) { |
EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1); |
autocomplete_manager_->OnFormSubmitted(form); |
} |
+ |
+namespace { |
+ |
+class MockAutofillExternalDelegate : public AutofillExternalDelegate { |
+ public: |
+ MockAutofillExternalDelegate() {} |
+ virtual ~MockAutofillExternalDelegate() {} |
+ |
+ virtual void OnQuery(int query_id, |
+ const webkit_glue::FormData& form, |
+ const webkit_glue::FormField& field) {} |
+ MOCK_METHOD5(OnSuggestionsReturned, void( |
dhollowa
2011/10/26 16:14:22
nit: indent seems off here. What about pulling vo
|
+ int query_id, |
+ const std::vector<string16>& autofill_values, |
+ const std::vector<string16>& autofill_labels, |
+ const std::vector<string16>& autofill_icons, |
+ const std::vector<int>& autofill_unique_ids)); |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); |
+}; |
+ |
+class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager { |
+ public: |
+ explicit AutocompleteHistoryManagerStubSend(TabContents* tab_contents, |
+ Profile* profile, |
+ WebDataService* wds) |
+ : AutocompleteHistoryManager(tab_contents, profile, wds) {} |
+ |
+ virtual bool Send(IPC::Message* message) { return true; } // intentional nop |
+}; |
+ |
+} // namespace |
+ |
+// Make sure our external delegate is called at the right time. |
+TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) { |
+ // Local version with a stubbed out Send() |
+ scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager( |
+ new AutocompleteHistoryManagerStubSend(contents(), |
+ &profile_, web_data_service_)); |
Ilya Sherman
2011/10/26 11:09:58
nit: Can this be stack-allocated, rather than heap
|
+ |
+ MockAutofillExternalDelegate external_delegate; |
+ EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); |
+ autocomplete_history_manager->SetExternalDelegate(&external_delegate); |
+ |
+ // Should trigger a call to OnSuggestionsReturned, verified by the mock. |
+ autocomplete_history_manager->SendSuggestions(NULL); |
+} |
+ |