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

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

Issue 12340065: Move the UI related code from AutofillExternalDelegate to AutofillManagerDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Try to fix AutofillTest.DisableAutocompleteWhileFilling 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/autofill/autocomplete_history_manager.h" 11 #include "chrome/browser/autofill/autocomplete_history_manager.h"
12 #include "chrome/browser/autofill/autofill_external_delegate.h"
12 #include "chrome/browser/autofill/autofill_manager.h" 13 #include "chrome/browser/autofill/autofill_manager.h"
13 #include "chrome/browser/autofill/autofill_manager_delegate.h" 14 #include "chrome/browser/autofill/test_autofill_manager_delegate.h"
14 #include "chrome/browser/autofill/test_autofill_external_delegate.h"
15 #include "chrome/browser/webdata/autofill_web_data_service_impl.h" 15 #include "chrome/browser/webdata/autofill_web_data_service_impl.h"
16 #include "chrome/browser/webdata/web_data_service.h" 16 #include "chrome/browser/webdata/web_data_service.h"
17 #include "chrome/browser/webdata/web_data_service_factory.h" 17 #include "chrome/browser/webdata/web_data_service_factory.h"
18 #include "chrome/common/form_data.h" 18 #include "chrome/common/form_data.h"
19 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 19 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
20 #include "chrome/test/base/testing_browser_process.h" 20 #include "chrome/test/base/testing_browser_process.h"
21 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
22 #include "content/public/test/test_browser_thread.h" 22 #include "content/public/test/test_browser_thread.h"
23 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 23 matching lines...) Expand all
48 virtual ~MockWebDataService() {} 48 virtual ~MockWebDataService() {}
49 49
50 private: 50 private:
51 // Keep track of the most recently created instance, so that it can be 51 // Keep track of the most recently created instance, so that it can be
52 // associated with the current profile when Build() is called. 52 // associated with the current profile when Build() is called.
53 static MockWebDataService* current_mock_web_data_service_; 53 static MockWebDataService* current_mock_web_data_service_;
54 }; 54 };
55 55
56 MockWebDataService* MockWebDataService::current_mock_web_data_service_ = NULL; 56 MockWebDataService* MockWebDataService::current_mock_web_data_service_ = NULL;
57 57
58 class MockAutofillManagerDelegate : public autofill::AutofillManagerDelegate { 58 class MockAutofillManagerDelegate
59 : public autofill::TestAutofillManagerDelegate {
59 public: 60 public:
60 MockAutofillManagerDelegate() {} 61 MockAutofillManagerDelegate() {}
61 virtual ~MockAutofillManagerDelegate() {} 62 virtual ~MockAutofillManagerDelegate() {}
62
63 // AutofillManagerDelegate:
64 virtual PersonalDataManager* GetPersonalDataManager() OVERRIDE {
65 return NULL;
66 }
67 virtual InfoBarService* GetInfoBarService() { return NULL; }
68 virtual PrefService* GetPrefs() { return &prefs_; } 63 virtual PrefService* GetPrefs() { return &prefs_; }
69 virtual ProfileSyncServiceBase* GetProfileSyncService() { return NULL; }
70 virtual void HideRequestAutocompleteDialog() OVERRIDE {}
71 virtual bool IsSavingPasswordsEnabled() const { return false; }
72 virtual void OnAutocheckoutError() OVERRIDE {}
73 virtual void ShowAutofillSettings() {}
74 virtual void ShowPasswordGenerationBubble(
75 const gfx::Rect& bounds,
76 const content::PasswordForm& form,
77 autofill::PasswordGenerator* generator) {}
78 virtual void ShowAutocheckoutBubble(
79 const gfx::RectF& bounding_box,
80 const gfx::NativeView& native_view,
81 const base::Closure& callback) {}
82 virtual void ShowRequestAutocompleteDialog(
83 const FormData& form,
84 const GURL& source_url,
85 const content::SSLStatus& ssl_status,
86 const AutofillMetrics& metric_logger,
87 autofill::DialogType dialog_type,
88 const base::Callback<void(const FormStructure*)>& callback) {}
89 virtual void RequestAutocompleteDialogClosed() {}
90 virtual void UpdateProgressBar(double value) {}
91 64
92 private: 65 private:
93 TestingPrefServiceSimple prefs_; 66 TestingPrefServiceSimple prefs_;
94 67
95 DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate); 68 DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate);
96 }; 69 };
97 70
98 } // namespace 71 } // namespace
99 72
100 class AutocompleteHistoryManagerTest : public ChromeRenderViewHostTestHarness { 73 class AutocompleteHistoryManagerTest : public ChromeRenderViewHostTestHarness {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 search_field.value = ASCIIToUTF16("my favorite query"); 176 search_field.value = ASCIIToUTF16("my favorite query");
204 search_field.form_control_type = "search"; 177 search_field.form_control_type = "search";
205 form.fields.push_back(search_field); 178 form.fields.push_back(search_field);
206 179
207 EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1); 180 EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1);
208 autocomplete_manager_->OnFormSubmitted(form); 181 autocomplete_manager_->OnFormSubmitted(form);
209 } 182 }
210 183
211 namespace { 184 namespace {
212 185
213 class MockAutofillExternalDelegate : 186 class MockAutofillExternalDelegate : public AutofillExternalDelegate {
214 public autofill::TestAutofillExternalDelegate {
215 public: 187 public:
216 explicit MockAutofillExternalDelegate(content::WebContents* web_contents) 188 explicit MockAutofillExternalDelegate(content::WebContents* web_contents)
217 : TestAutofillExternalDelegate( 189 : AutofillExternalDelegate(
218 web_contents, AutofillManager::FromWebContents(web_contents)) {} 190 web_contents, AutofillManager::FromWebContents(web_contents)) {}
219 virtual ~MockAutofillExternalDelegate() {} 191 virtual ~MockAutofillExternalDelegate() {}
220 192
221 virtual void ApplyAutofillSuggestions(
222 const std::vector<string16>& autofill_values,
223 const std::vector<string16>& autofill_labels,
224 const std::vector<string16>& autofill_icons,
225 const std::vector<int>& autofill_unique_ids) OVERRIDE {};
226
227 MOCK_METHOD5(OnSuggestionsReturned, 193 MOCK_METHOD5(OnSuggestionsReturned,
228 void(int query_id, 194 void(int query_id,
229 const std::vector<string16>& autofill_values, 195 const std::vector<string16>& autofill_values,
230 const std::vector<string16>& autofill_labels, 196 const std::vector<string16>& autofill_labels,
231 const std::vector<string16>& autofill_icons, 197 const std::vector<string16>& autofill_icons,
232 const std::vector<int>& autofill_unique_ids)); 198 const std::vector<int>& autofill_unique_ids));
233 199
234 private: 200 private:
235 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); 201 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate);
236 }; 202 };
(...skipping 26 matching lines...) Expand all
263 AutofillManager::CreateForWebContentsAndDelegate( 229 AutofillManager::CreateForWebContentsAndDelegate(
264 web_contents(), &manager_delegate); 230 web_contents(), &manager_delegate);
265 231
266 MockAutofillExternalDelegate external_delegate(web_contents()); 232 MockAutofillExternalDelegate external_delegate(web_contents());
267 autocomplete_history_manager.SetExternalDelegate(&external_delegate); 233 autocomplete_history_manager.SetExternalDelegate(&external_delegate);
268 234
269 // Should trigger a call to OnSuggestionsReturned, verified by the mock. 235 // Should trigger a call to OnSuggestionsReturned, verified by the mock.
270 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); 236 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _));
271 autocomplete_history_manager.SendSuggestions(NULL); 237 autocomplete_history_manager.SendSuggestions(NULL);
272 } 238 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autocheckout_manager_unittest.cc ('k') | chrome/browser/autofill/autofill_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698