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

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: Hard coding input element position 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 namespace { 140 namespace {
140 141
141 class MockAutofillExternalDelegate : public AutofillExternalDelegate { 142 class MockAutofillExternalDelegate : public AutofillExternalDelegate {
142 public: 143 public:
143 explicit MockAutofillExternalDelegate(TabContentsWrapper* wrapper) 144 explicit MockAutofillExternalDelegate(TabContentsWrapper* wrapper)
144 : AutofillExternalDelegate(wrapper) {} 145 : AutofillExternalDelegate(wrapper) {}
145 virtual ~MockAutofillExternalDelegate() {} 146 virtual ~MockAutofillExternalDelegate() {}
146 147
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,
151 const gfx::Rect& bounds) OVERRIDE {}
150 MOCK_METHOD5(OnSuggestionsReturned, 152 MOCK_METHOD5(OnSuggestionsReturned,
151 void(int query_id, 153 void(int query_id,
152 const std::vector<string16>& autofill_values, 154 const std::vector<string16>& autofill_values,
153 const std::vector<string16>& autofill_labels, 155 const std::vector<string16>& autofill_labels,
154 const std::vector<string16>& autofill_icons, 156 const std::vector<string16>& autofill_icons,
155 const std::vector<int>& autofill_unique_ids)); 157 const std::vector<int>& autofill_unique_ids));
156 158
159 virtual void HideAutofillPopup() OVERRIDE {}
160
157 private: 161 private:
158 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); 162 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate);
159 }; 163 };
160 164
161 class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager { 165 class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager {
162 public: 166 public:
163 explicit AutocompleteHistoryManagerStubSend(TabContents* tab_contents, 167 explicit AutocompleteHistoryManagerStubSend(TabContents* tab_contents,
164 Profile* profile, 168 Profile* profile,
165 WebDataService* wds) 169 WebDataService* wds)
166 : AutocompleteHistoryManager(tab_contents, profile, wds) {} 170 : AutocompleteHistoryManager(tab_contents, profile, wds) {}
(...skipping 12 matching lines...) Expand all
179 &profile_, web_data_service_); 183 &profile_, web_data_service_);
180 184
181 MockAutofillExternalDelegate external_delegate( 185 MockAutofillExternalDelegate external_delegate(
182 TabContentsWrapper::GetCurrentWrapperForContents(contents())); 186 TabContentsWrapper::GetCurrentWrapperForContents(contents()));
183 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); 187 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _));
184 autocomplete_history_manager.SetExternalDelegate(&external_delegate); 188 autocomplete_history_manager.SetExternalDelegate(&external_delegate);
185 189
186 // Should trigger a call to OnSuggestionsReturned, verified by the mock. 190 // Should trigger a call to OnSuggestionsReturned, verified by the mock.
187 autocomplete_history_manager.SendSuggestions(NULL); 191 autocomplete_history_manager.SendSuggestions(NULL);
188 } 192 }
189
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete_history_manager.cc ('k') | chrome/browser/autofill/autofill_external_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698