| 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 02671427304cff14d793f21973fef114a9cfd5a6..df255f23ca51d41c8fdbcc2c31acbf6c2a86e454 100644
|
| --- a/chrome/browser/autocomplete_history_manager_unittest.cc
|
| +++ b/chrome/browser/autocomplete_history_manager_unittest.cc
|
| @@ -9,6 +9,8 @@
|
| #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/ui/tab_contents/tab_contents_wrapper.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"
|
| @@ -132,3 +134,54 @@ TEST_F(AutocompleteHistoryManagerTest, SearchField) {
|
| EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1);
|
| autocomplete_manager_->OnFormSubmitted(form);
|
| }
|
| +
|
| +namespace {
|
| +
|
| +class MockAutofillExternalDelegate : public AutofillExternalDelegate {
|
| + public:
|
| + explicit MockAutofillExternalDelegate(TabContentsWrapper* wrapper)
|
| + : AutofillExternalDelegate(wrapper) {}
|
| + virtual ~MockAutofillExternalDelegate() {}
|
| +
|
| + virtual void OnQuery(int query_id,
|
| + const webkit_glue::FormData& form,
|
| + const webkit_glue::FormField& field) {}
|
| + MOCK_METHOD5(OnSuggestionsReturned,
|
| + void(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()
|
| + AutocompleteHistoryManagerStubSend autocomplete_history_manager(
|
| + contents(),
|
| + &profile_, web_data_service_);
|
| +
|
| + MockAutofillExternalDelegate external_delegate(
|
| + TabContentsWrapper::GetCurrentWrapperForContents(contents()));
|
| + 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);
|
| +}
|
| +
|
|
|