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

Unified Diff: chrome/browser/autocomplete_history_manager_unittest.cc

Issue 8353025: External autofill delegates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Carnitasify Created 9 years, 2 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/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);
+}
+

Powered by Google App Engine
This is Rietveld 408576698