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

Side by Side Diff: chrome/browser/autocomplete_history_manager_unittest.cc

Issue 8490017: Setting up external delegate calls to allow a future delegate to handle autofill (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/task.h" 9 #include "base/task.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/autocomplete_history_manager.h" 11 #include "chrome/browser/autocomplete_history_manager.h"
12 #include "chrome/browser/autofill/autofill_external_delegate.h" 12 #include "chrome/browser/autofill/autofill_external_delegate.h"
13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
14 #include "chrome/browser/webdata/web_data_service.h" 14 #include "chrome/browser/webdata/web_data_service.h"
15 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
16 #include "chrome/test/base/testing_browser_process.h" 16 #include "chrome/test/base/testing_browser_process.h"
17 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
18 #include "content/browser/tab_contents/test_tab_contents.h" 18 #include "content/browser/tab_contents/test_tab_contents.h"
19 #include "content/test/test_browser_thread.h" 19 #include "content/test/test_browser_thread.h"
20 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "ui/gfx/rect.h"
22 #include "webkit/glue/form_data.h" 23 #include "webkit/glue/form_data.h"
23 24
24 using content::BrowserThread; 25 using content::BrowserThread;
25 using testing::_; 26 using testing::_;
26 using webkit_glue::FormData; 27 using webkit_glue::FormData;
27 28
28 class MockWebDataService : public WebDataService { 29 class MockWebDataService : public WebDataService {
29 public: 30 public:
30 MOCK_METHOD1(AddFormFields, 31 MOCK_METHOD1(AddFormFields,
31 void(const std::vector<webkit_glue::FormField>&)); // NOLINT 32 void(const std::vector<webkit_glue::FormField>&)); // NOLINT
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 virtual void OnQuery(int query_id, 148 virtual void OnQuery(int query_id,
148 const webkit_glue::FormData& form, 149 const webkit_glue::FormData& form,
149 const webkit_glue::FormField& field) {} 150 const webkit_glue::FormField& field) {}
150 MOCK_METHOD5(OnSuggestionsReturned, 151 MOCK_METHOD5(OnSuggestionsReturned,
151 void(int query_id, 152 void(int query_id,
152 const std::vector<string16>& autofill_values, 153 const std::vector<string16>& autofill_values,
153 const std::vector<string16>& autofill_labels, 154 const std::vector<string16>& autofill_labels,
154 const std::vector<string16>& autofill_icons, 155 const std::vector<string16>& autofill_icons,
155 const std::vector<int>& autofill_unique_ids)); 156 const std::vector<int>& autofill_unique_ids));
156 157
158 virtual void SetAutofillElementBounds(const gfx::Rect& bounds) {}
159
160 virtual void ShowAutofillPopup() {}
161
162 virtual void HideAutofillPopup() {}
Ilya Sherman 2011/11/07 21:48:49 nit: Please annotate these with OVERRIDE.
csharp1 2011/11/08 19:59:00 Done.
163
157 private: 164 private:
158 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); 165 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate);
159 }; 166 };
160 167
161 class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager { 168 class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager {
162 public: 169 public:
163 explicit AutocompleteHistoryManagerStubSend(TabContents* tab_contents, 170 explicit AutocompleteHistoryManagerStubSend(TabContents* tab_contents,
164 Profile* profile, 171 Profile* profile,
165 WebDataService* wds) 172 WebDataService* wds)
166 : AutocompleteHistoryManager(tab_contents, profile, wds) {} 173 : AutocompleteHistoryManager(tab_contents, profile, wds) {}
(...skipping 12 matching lines...) Expand all
179 &profile_, web_data_service_); 186 &profile_, web_data_service_);
180 187
181 MockAutofillExternalDelegate external_delegate( 188 MockAutofillExternalDelegate external_delegate(
182 TabContentsWrapper::GetCurrentWrapperForContents(contents())); 189 TabContentsWrapper::GetCurrentWrapperForContents(contents()));
183 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); 190 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _));
184 autocomplete_history_manager.SetExternalDelegate(&external_delegate); 191 autocomplete_history_manager.SetExternalDelegate(&external_delegate);
185 192
186 // Should trigger a call to OnSuggestionsReturned, verified by the mock. 193 // Should trigger a call to OnSuggestionsReturned, verified by the mock.
187 autocomplete_history_manager.SendSuggestions(NULL); 194 autocomplete_history_manager.SendSuggestions(NULL);
188 } 195 }
189
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698