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

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

Issue 10908065: Introduce a couple of abstract bases for WebDataService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to comments Created 8 years, 3 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/string16.h" 8 #include "base/string16.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/autofill/autocomplete_history_manager.h" 10 #include "chrome/browser/autofill/autocomplete_history_manager.h"
11 #include "chrome/browser/autofill/test_autofill_external_delegate.h" 11 #include "chrome/browser/autofill/test_autofill_external_delegate.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents.h" 12 #include "chrome/browser/ui/tab_contents/tab_contents.h"
13 #include "chrome/browser/webdata/autofill_web_data_service_impl.h"
13 #include "chrome/browser/webdata/web_data_service.h" 14 #include "chrome/browser/webdata/web_data_service.h"
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
15 #include "chrome/test/base/testing_browser_process.h" 16 #include "chrome/test/base/testing_browser_process.h"
16 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
17 #include "content/public/test/test_browser_thread.h" 18 #include "content/public/test/test_browser_thread.h"
18 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 #include "ui/gfx/rect.h" 21 #include "ui/gfx/rect.h"
21 #include "webkit/forms/form_data.h" 22 #include "webkit/forms/form_data.h"
22 23
(...skipping 14 matching lines...) Expand all
37 class AutocompleteHistoryManagerTest : public ChromeRenderViewHostTestHarness { 38 class AutocompleteHistoryManagerTest : public ChromeRenderViewHostTestHarness {
38 protected: 39 protected:
39 AutocompleteHistoryManagerTest() 40 AutocompleteHistoryManagerTest()
40 : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()), 41 : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()),
41 db_thread_(BrowserThread::DB) { 42 db_thread_(BrowserThread::DB) {
42 } 43 }
43 44
44 virtual void SetUp() { 45 virtual void SetUp() {
45 ChromeRenderViewHostTestHarness::SetUp(); 46 ChromeRenderViewHostTestHarness::SetUp();
46 web_data_service_ = new MockWebDataService(); 47 web_data_service_ = new MockWebDataService();
47 autocomplete_manager_.reset(new AutocompleteHistoryManager( 48 autocomplete_manager_.reset(
48 contents(), &profile_, web_data_service_)); 49 new AutocompleteHistoryManager(
50 contents(),
51 &profile_,
52 scoped_ptr<AutofillWebDataService>(
53 new AutofillWebDataServiceImpl(web_data_service_))));
49 } 54 }
50 55
51 content::TestBrowserThread ui_thread_; 56 content::TestBrowserThread ui_thread_;
52 content::TestBrowserThread db_thread_; 57 content::TestBrowserThread db_thread_;
53 58
54 TestingProfile profile_; 59 TestingProfile profile_;
55 scoped_refptr<MockWebDataService> web_data_service_; 60 scoped_refptr<MockWebDataService> web_data_service_;
56 scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_; 61 scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_;
57 }; 62 };
58 63
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 const std::vector<string16>& autofill_labels, 166 const std::vector<string16>& autofill_labels,
162 const std::vector<string16>& autofill_icons, 167 const std::vector<string16>& autofill_icons,
163 const std::vector<int>& autofill_unique_ids)); 168 const std::vector<int>& autofill_unique_ids));
164 169
165 private: 170 private:
166 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); 171 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate);
167 }; 172 };
168 173
169 class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager { 174 class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager {
170 public: 175 public:
171 explicit AutocompleteHistoryManagerStubSend(WebContents* web_contents, 176 explicit AutocompleteHistoryManagerStubSend(
172 Profile* profile, 177 WebContents* web_contents,
173 WebDataService* wds) 178 Profile* profile,
174 : AutocompleteHistoryManager(web_contents, profile, wds) {} 179 scoped_ptr<AutofillWebDataService> wds)
180 : AutocompleteHistoryManager(web_contents, profile, wds.Pass()) {}
175 181
176 // Intentionally swallow the message. 182 // Intentionally swallow the message.
177 virtual bool Send(IPC::Message* message) { delete message; return true; } 183 virtual bool Send(IPC::Message* message) { delete message; return true; }
178 }; 184 };
179 185
180 } // namespace 186 } // namespace
181 187
182 // Make sure our external delegate is called at the right time. 188 // Make sure our external delegate is called at the right time.
183 TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) { 189 TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) {
184 // Local version with a stubbed out Send() 190 // Local version with a stubbed out Send()
185 AutocompleteHistoryManagerStubSend autocomplete_history_manager( 191 AutocompleteHistoryManagerStubSend autocomplete_history_manager(
186 contents(), 192 contents(),
187 &profile_, web_data_service_); 193 &profile_,
194 scoped_ptr<AutofillWebDataService>(
195 new AutofillWebDataServiceImpl(web_data_service_)));
188 196
189 MockAutofillExternalDelegate external_delegate( 197 MockAutofillExternalDelegate external_delegate(
190 TabContents::FromWebContents(contents())); 198 TabContents::FromWebContents(contents()));
191 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); 199 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _));
192 autocomplete_history_manager.SetExternalDelegate(&external_delegate); 200 autocomplete_history_manager.SetExternalDelegate(&external_delegate);
193 201
194 // Should trigger a call to OnSuggestionsReturned, verified by the mock. 202 // Should trigger a call to OnSuggestionsReturned, verified by the mock.
195 autocomplete_history_manager.SendSuggestions(NULL); 203 autocomplete_history_manager.SendSuggestions(NULL);
196 } 204 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autocomplete_history_manager.cc ('k') | chrome/browser/autofill/personal_data_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698