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

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

Issue 12851008: Create a common base class for all the webdatas (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to committed parent and head. Created 7 years, 9 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"
11 #include "chrome/browser/webdata/autofill_web_data_service_impl.h" 11 #include "chrome/browser/webdata/autofill_web_data_service_impl.h"
12 #include "chrome/browser/webdata/web_data_service.h" 12 #include "chrome/browser/webdata/web_data_service.h"
13 #include "chrome/browser/webdata/web_data_service_factory.h" 13 #include "chrome/browser/webdata/web_data_service_factory.h"
14 #include "chrome/browser/webdata/web_data_service_test_util.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 "components/autofill/browser/autocomplete_history_manager.h" 18 #include "components/autofill/browser/autocomplete_history_manager.h"
18 #include "components/autofill/browser/autofill_external_delegate.h" 19 #include "components/autofill/browser/autofill_external_delegate.h"
19 #include "components/autofill/browser/autofill_manager.h" 20 #include "components/autofill/browser/autofill_manager.h"
20 #include "components/autofill/browser/test_autofill_manager_delegate.h" 21 #include "components/autofill/browser/test_autofill_manager_delegate.h"
21 #include "components/autofill/common/form_data.h" 22 #include "components/autofill/common/form_data.h"
22 #include "content/public/test/test_browser_thread.h" 23 #include "content/public/test/test_browser_thread.h"
23 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 25 matching lines...) Expand all
49 virtual ~MockWebDataService() {} 50 virtual ~MockWebDataService() {}
50 51
51 private: 52 private:
52 // Keep track of the most recently created instance, so that it can be 53 // Keep track of the most recently created instance, so that it can be
53 // associated with the current profile when Build() is called. 54 // associated with the current profile when Build() is called.
54 static MockWebDataService* current_mock_web_data_service_; 55 static MockWebDataService* current_mock_web_data_service_;
55 }; 56 };
56 57
57 MockWebDataService* MockWebDataService::current_mock_web_data_service_ = NULL; 58 MockWebDataService* MockWebDataService::current_mock_web_data_service_ = NULL;
58 59
59 class MockWebDataServiceWrapper : public WebDataServiceWrapper { 60 class MockWebDataServiceWrapperCurrent : public MockWebDataServiceWrapperBase {
60 public: 61 public:
61 static ProfileKeyedService* Build(Profile* profile) { 62 static ProfileKeyedService* Build(Profile* profile) {
62 return new MockWebDataServiceWrapper(); 63 return new MockWebDataServiceWrapperCurrent();
63 } 64 }
64 65
65 MockWebDataServiceWrapper() { 66 MockWebDataServiceWrapperCurrent() {}
66 }
67
68 void Shutdown() OVERRIDE {}
69
70 ~MockWebDataServiceWrapper() {}
71 67
72 scoped_refptr<WebDataService> GetWebData() OVERRIDE { 68 scoped_refptr<WebDataService> GetWebData() OVERRIDE {
73 return MockWebDataService::GetCurrent(); 69 return MockWebDataService::GetCurrent();
74 } 70 }
75 71
76 private: 72 private:
77 DISALLOW_COPY_AND_ASSIGN(MockWebDataServiceWrapper); 73 DISALLOW_COPY_AND_ASSIGN(MockWebDataServiceWrapperCurrent);
78 }; 74 };
79 75
80 class MockAutofillManagerDelegate 76 class MockAutofillManagerDelegate
81 : public autofill::TestAutofillManagerDelegate { 77 : public autofill::TestAutofillManagerDelegate {
82 public: 78 public:
83 MockAutofillManagerDelegate() {} 79 MockAutofillManagerDelegate() {}
84 virtual ~MockAutofillManagerDelegate() {} 80 virtual ~MockAutofillManagerDelegate() {}
85 virtual PrefService* GetPrefs() OVERRIDE { return &prefs_; } 81 virtual PrefService* GetPrefs() OVERRIDE { return &prefs_; }
86 82
87 private: 83 private:
88 TestingPrefServiceSimple prefs_; 84 TestingPrefServiceSimple prefs_;
89 85
90 DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate); 86 DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate);
91 }; 87 };
92 88
93 } // namespace 89 } // namespace
94 90
95 class AutocompleteHistoryManagerTest : public ChromeRenderViewHostTestHarness { 91 class AutocompleteHistoryManagerTest : public ChromeRenderViewHostTestHarness {
96 protected: 92 protected:
97 AutocompleteHistoryManagerTest() 93 AutocompleteHistoryManagerTest()
98 : ui_thread_(BrowserThread::UI, &message_loop_), 94 : ui_thread_(BrowserThread::UI, &message_loop_),
99 db_thread_(BrowserThread::DB) { 95 db_thread_(BrowserThread::DB) {
100 } 96 }
101 97
102 virtual void SetUp() OVERRIDE { 98 virtual void SetUp() OVERRIDE {
103 ChromeRenderViewHostTestHarness::SetUp(); 99 ChromeRenderViewHostTestHarness::SetUp();
104 web_data_service_ = new MockWebDataService(); 100 web_data_service_ = new MockWebDataService();
105 WebDataServiceFactory::GetInstance()->SetTestingFactory( 101 WebDataServiceFactory::GetInstance()->SetTestingFactory(
106 profile(), MockWebDataServiceWrapper::Build); 102 profile(), MockWebDataServiceWrapperCurrent::Build);
107 autocomplete_manager_.reset(new AutocompleteHistoryManager(web_contents())); 103 autocomplete_manager_.reset(new AutocompleteHistoryManager(web_contents()));
108 } 104 }
109 105
110 virtual void TearDown() OVERRIDE { 106 virtual void TearDown() OVERRIDE {
111 autocomplete_manager_.reset(); 107 autocomplete_manager_.reset();
112 web_data_service_ = NULL; 108 web_data_service_ = NULL;
113 ChromeRenderViewHostTestHarness::TearDown(); 109 ChromeRenderViewHostTestHarness::TearDown();
114 message_loop_.RunUntilIdle(); 110 message_loop_.RunUntilIdle();
115 111
116 } 112 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 AutofillManager::CreateForWebContentsAndDelegate( 251 AutofillManager::CreateForWebContentsAndDelegate(
256 web_contents(), &manager_delegate); 252 web_contents(), &manager_delegate);
257 253
258 MockAutofillExternalDelegate external_delegate(web_contents()); 254 MockAutofillExternalDelegate external_delegate(web_contents());
259 autocomplete_history_manager.SetExternalDelegate(&external_delegate); 255 autocomplete_history_manager.SetExternalDelegate(&external_delegate);
260 256
261 // Should trigger a call to OnSuggestionsReturned, verified by the mock. 257 // Should trigger a call to OnSuggestionsReturned, verified by the mock.
262 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); 258 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _));
263 autocomplete_history_manager.SendSuggestions(NULL); 259 autocomplete_history_manager.SendSuggestions(NULL);
264 } 260 }
OLDNEW
« no previous file with comments | « components/autofill/browser/autocomplete_history_manager.h ('k') | components/autofill/browser/personal_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698