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

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

Issue 14348036: Move AutofillWebData DB methods into separate class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge Created 7 years, 7 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/synchronization/waitable_event.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/webdata/web_data_service_factory.h" 12 #include "chrome/browser/webdata/web_data_service_factory.h"
12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 13 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
13 #include "chrome/test/base/testing_browser_process.h" 14 #include "chrome/test/base/testing_browser_process.h"
14 #include "chrome/test/base/testing_profile.h" 15 #include "chrome/test/base/testing_profile.h"
15 #include "components/autofill/browser/autocomplete_history_manager.h" 16 #include "components/autofill/browser/autocomplete_history_manager.h"
16 #include "components/autofill/browser/autofill_external_delegate.h" 17 #include "components/autofill/browser/autofill_external_delegate.h"
17 #include "components/autofill/browser/autofill_manager.h" 18 #include "components/autofill/browser/autofill_manager.h"
18 #include "components/autofill/browser/test_autofill_manager_delegate.h" 19 #include "components/autofill/browser/test_autofill_manager_delegate.h"
19 #include "components/autofill/browser/webdata/autofill_webdata_service.h" 20 #include "components/autofill/browser/webdata/autofill_webdata_service.h"
20 #include "components/autofill/common/form_data.h" 21 #include "components/autofill/common/form_data.h"
21 #include "components/webdata/common/web_data_service_test_util.h" 22 #include "components/webdata/common/web_data_service_test_util.h"
22 #include "content/public/test/test_browser_thread.h" 23 #include "content/public/test/test_browser_thread.h"
24 #include "content/public/test/test_utils.h"
23 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
25 #include "ui/gfx/rect.h" 27 #include "ui/gfx/rect.h"
26 28
27 using content::BrowserThread; 29 using content::BrowserThread;
28 using content::WebContents; 30 using content::WebContents;
29 using testing::_; 31 using testing::_;
30 32
31 namespace autofill { 33 namespace autofill {
32 34
33 namespace { 35 namespace {
34 36
35 class MockWebDataService : public AutofillWebDataService { 37 class MockWebDataService : public AutofillWebDataService {
36 public: 38 public:
37 MockWebDataService() 39 MockWebDataService()
38 : AutofillWebDataService( 40 : AutofillWebDataService() {
39 NULL, WebDataServiceBase::ProfileErrorCallback()) {
40 current_mock_web_data_service_ = this; 41 current_mock_web_data_service_ = this;
41 } 42 }
42 43
43 MOCK_METHOD1(AddFormFields, void(const std::vector<FormFieldData>&)); 44 MOCK_METHOD1(AddFormFields, void(const std::vector<FormFieldData>&));
44 45
45 static scoped_refptr<MockWebDataService> GetCurrent() { 46 static scoped_refptr<MockWebDataService> GetCurrent() {
46 if (!current_mock_web_data_service_) { 47 if (!current_mock_web_data_service_) {
47 return new MockWebDataService(); 48 return new MockWebDataService();
48 } 49 }
49 return current_mock_web_data_service_; 50 return current_mock_web_data_service_;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } // namespace 93 } // namespace
93 94
94 class AutocompleteHistoryManagerTest : public ChromeRenderViewHostTestHarness { 95 class AutocompleteHistoryManagerTest : public ChromeRenderViewHostTestHarness {
95 protected: 96 protected:
96 AutocompleteHistoryManagerTest() 97 AutocompleteHistoryManagerTest()
97 : ui_thread_(BrowserThread::UI, &message_loop_), 98 : ui_thread_(BrowserThread::UI, &message_loop_),
98 db_thread_(BrowserThread::DB) { 99 db_thread_(BrowserThread::DB) {
99 } 100 }
100 101
101 virtual void SetUp() OVERRIDE { 102 virtual void SetUp() OVERRIDE {
103 db_thread_.Start();
102 ChromeRenderViewHostTestHarness::SetUp(); 104 ChromeRenderViewHostTestHarness::SetUp();
103 web_data_service_ = new MockWebDataService(); 105 web_data_service_ = new MockWebDataService();
104 WebDataServiceFactory::GetInstance()->SetTestingFactory( 106 WebDataServiceFactory::GetInstance()->SetTestingFactory(
105 profile(), MockWebDataServiceWrapperCurrent::Build); 107 profile(), MockWebDataServiceWrapperCurrent::Build);
106 autocomplete_manager_.reset(new AutocompleteHistoryManager(web_contents())); 108 autocomplete_manager_.reset(new AutocompleteHistoryManager(web_contents()));
107 } 109 }
108 110
109 virtual void TearDown() OVERRIDE { 111 virtual void TearDown() OVERRIDE {
110 autocomplete_manager_.reset(); 112 autocomplete_manager_.reset();
111 web_data_service_ = NULL; 113 web_data_service_ = NULL;
112 ChromeRenderViewHostTestHarness::TearDown(); 114 ChromeRenderViewHostTestHarness::TearDown();
115 content::RunAllPendingInMessageLoop(BrowserThread::DB);
113 message_loop_.RunUntilIdle(); 116 message_loop_.RunUntilIdle();
114 117
115 } 118 }
116 119
117 content::TestBrowserThread ui_thread_; 120 content::TestBrowserThread ui_thread_;
118 content::TestBrowserThread db_thread_; 121 content::TestBrowserThread db_thread_;
119 scoped_refptr<MockWebDataService> web_data_service_; 122 scoped_refptr<MockWebDataService> web_data_service_;
120 scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_; 123 scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_;
121 MockAutofillManagerDelegate manager_delegate; 124 MockAutofillManagerDelegate manager_delegate;
122 }; 125 };
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 259
257 MockAutofillExternalDelegate external_delegate(web_contents()); 260 MockAutofillExternalDelegate external_delegate(web_contents());
258 autocomplete_history_manager.SetExternalDelegate(&external_delegate); 261 autocomplete_history_manager.SetExternalDelegate(&external_delegate);
259 262
260 // Should trigger a call to OnSuggestionsReturned, verified by the mock. 263 // Should trigger a call to OnSuggestionsReturned, verified by the mock.
261 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); 264 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _));
262 autocomplete_history_manager.SendSuggestions(NULL); 265 autocomplete_history_manager.SendSuggestions(NULL);
263 } 266 }
264 267
265 } // namespace autofill 268 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill.gypi ('k') | components/autofill/browser/webdata/autofill_webdata_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698