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

Side by Side Diff: components/autofill/browser/autocomplete_history_manager_unittest.cc

Issue 13928035: WIP Component build of autofill Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make windows compiling Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/prefs/testing_pref_service.h" 8 #include "base/prefs/testing_pref_service.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 AutocompleteHistoryManagerTest() 96 AutocompleteHistoryManagerTest()
97 : ui_thread_(BrowserThread::UI, &message_loop_), 97 : ui_thread_(BrowserThread::UI, &message_loop_),
98 db_thread_(BrowserThread::DB) { 98 db_thread_(BrowserThread::DB) {
99 } 99 }
100 100
101 virtual void SetUp() OVERRIDE { 101 virtual void SetUp() OVERRIDE {
102 ChromeRenderViewHostTestHarness::SetUp(); 102 ChromeRenderViewHostTestHarness::SetUp();
103 web_data_service_ = new MockWebDataService(); 103 web_data_service_ = new MockWebDataService();
104 WebDataServiceFactory::GetInstance()->SetTestingFactory( 104 WebDataServiceFactory::GetInstance()->SetTestingFactory(
105 profile(), MockWebDataServiceWrapperCurrent::Build); 105 profile(), MockWebDataServiceWrapperCurrent::Build);
106 autocomplete_manager_.reset(new AutocompleteHistoryManager(web_contents())); 106 autocomplete_manager_.reset(
107 new AutocompleteHistoryManager(
108 web_contents(),
109 WebDataServiceFactory::GetAutofillWebDataServiceForProfile(
110 profile())));
107 } 111 }
108 112
109 virtual void TearDown() OVERRIDE { 113 virtual void TearDown() OVERRIDE {
110 autocomplete_manager_.reset(); 114 autocomplete_manager_.reset();
111 web_data_service_ = NULL; 115 web_data_service_ = NULL;
112 ChromeRenderViewHostTestHarness::TearDown(); 116 ChromeRenderViewHostTestHarness::TearDown();
113 message_loop_.RunUntilIdle(); 117 message_loop_.RunUntilIdle();
114 118
115 } 119 }
116 120
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 const std::vector<base::string16>& autofill_labels, 225 const std::vector<base::string16>& autofill_labels,
222 const std::vector<base::string16>& autofill_icons, 226 const std::vector<base::string16>& autofill_icons,
223 const std::vector<int>& autofill_unique_ids)); 227 const std::vector<int>& autofill_unique_ids));
224 228
225 private: 229 private:
226 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); 230 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate);
227 }; 231 };
228 232
229 class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager { 233 class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager {
230 public: 234 public:
231 explicit AutocompleteHistoryManagerStubSend(WebContents* web_contents) 235 explicit AutocompleteHistoryManagerStubSend(WebContents* web_contents,
232 : AutocompleteHistoryManager(web_contents) {} 236 TestingProfile* profile)
237 : AutocompleteHistoryManager(
238 web_contents,
239 WebDataServiceFactory::GetAutofillWebDataServiceForProfile(profile)) {
240 }
233 241
234 // Increase visibility for testing. 242 // Increase visibility for testing.
235 void SendSuggestions(const std::vector<base::string16>* suggestions) { 243 void SendSuggestions(const std::vector<base::string16>* suggestions) {
236 AutocompleteHistoryManager::SendSuggestions(suggestions); 244 AutocompleteHistoryManager::SendSuggestions(suggestions);
237 } 245 }
238 246
239 // Intentionally swallow the message. 247 // Intentionally swallow the message.
240 virtual bool Send(IPC::Message* message) OVERRIDE { 248 virtual bool Send(IPC::Message* message) OVERRIDE {
241 delete message; 249 delete message;
242 return true; 250 return true;
243 } 251 }
244 }; 252 };
245 253
246 } // namespace 254 } // namespace
247 255
248 // Make sure our external delegate is called at the right time. 256 // Make sure our external delegate is called at the right time.
249 TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) { 257 TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) {
250 // Local version with a stubbed out Send() 258 // Local version with a stubbed out Send()
251 AutocompleteHistoryManagerStubSend autocomplete_history_manager( 259 AutocompleteHistoryManagerStubSend autocomplete_history_manager(
252 web_contents()); 260 web_contents(), profile());
253 261
254 AutofillManager::CreateForWebContentsAndDelegate( 262 AutofillManager::CreateForWebContentsAndDelegate(
255 web_contents(), &manager_delegate, "en-US"); 263 web_contents(), &manager_delegate, "en-US");
256 264
257 MockAutofillExternalDelegate external_delegate(web_contents()); 265 MockAutofillExternalDelegate external_delegate(web_contents());
258 autocomplete_history_manager.SetExternalDelegate(&external_delegate); 266 autocomplete_history_manager.SetExternalDelegate(&external_delegate);
259 267
260 // Should trigger a call to OnSuggestionsReturned, verified by the mock. 268 // Should trigger a call to OnSuggestionsReturned, verified by the mock.
261 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); 269 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _));
262 autocomplete_history_manager.SendSuggestions(NULL); 270 autocomplete_history_manager.SendSuggestions(NULL);
263 } 271 }
264 272
265 } // namespace autofill 273 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698