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

Side by Side Diff: chrome/browser/autofill/autocheckout_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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/tuple.h" 5 #include "base/tuple.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/autofill/autocheckout_manager.h" 7 #include "chrome/browser/autofill/autocheckout_manager.h"
8 #include "chrome/browser/autofill/autofill_common_test.h" 8 #include "chrome/browser/autofill/autofill_common_test.h"
9 #include "chrome/browser/autofill/autofill_manager.h" 9 #include "chrome/browser/autofill/autofill_manager.h"
10 #include "chrome/browser/autofill/autofill_manager_delegate.h"
11 #include "chrome/browser/autofill/form_structure.h" 10 #include "chrome/browser/autofill/form_structure.h"
11 #include "chrome/browser/autofill/test_autofill_manager_delegate.h"
12 #include "chrome/common/autofill_messages.h" 12 #include "chrome/common/autofill_messages.h"
13 #include "chrome/common/form_data.h" 13 #include "chrome/common/form_data.h"
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/test/mock_render_process_host.h" 16 #include "content/public/test/mock_render_process_host.h"
17 #include "content/public/test/test_browser_thread.h" 17 #include "content/public/test/test_browser_thread.h"
18 #include "ipc/ipc_test_sink.h" 18 #include "ipc/ipc_test_sink.h"
19 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 kTestFields[i].field_value)); 191 kTestFields[i].field_value));
192 } 192 }
193 scoped_ptr<FormStructure> form_structure; 193 scoped_ptr<FormStructure> form_structure;
194 form_structure.reset(new FormStructure(formdata, std::string())); 194 form_structure.reset(new FormStructure(formdata, std::string()));
195 for (size_t i = 0; i < arraysize(kTestFields); ++i) 195 for (size_t i = 0; i < arraysize(kTestFields); ++i)
196 form_structure->field(i)->set_server_type(kTestFields[i].autofill_type); 196 form_structure->field(i)->set_server_type(kTestFields[i].autofill_type);
197 197
198 return form_structure.Pass(); 198 return form_structure.Pass();
199 } 199 }
200 200
201 class TestAutofillManagerDelegate : public AutofillManagerDelegate { 201 class MockAutofillManagerDelegate : public TestAutofillManagerDelegate {
202 public: 202 public:
203 TestAutofillManagerDelegate() 203 MockAutofillManagerDelegate()
204 : request_autocomplete_dialog_open_(false), 204 : request_autocomplete_dialog_open_(false),
205 autocheckout_bubble_shown_(false) { 205 autocheckout_bubble_shown_(false) {}
206 }
207 206
208 virtual ~TestAutofillManagerDelegate() { 207 virtual ~MockAutofillManagerDelegate() {}
209 }
210
211 virtual InfoBarService* GetInfoBarService() OVERRIDE {
212 return NULL;
213 }
214
215 virtual PersonalDataManager* GetPersonalDataManager() OVERRIDE {
216 return NULL;
217 }
218
219 virtual PrefService* GetPrefs() OVERRIDE {
220 return NULL;
221 }
222
223 virtual ProfileSyncServiceBase* GetProfileSyncService() OVERRIDE {
224 return NULL;
225 }
226 208
227 virtual void HideRequestAutocompleteDialog() OVERRIDE { 209 virtual void HideRequestAutocompleteDialog() OVERRIDE {
228 request_autocomplete_dialog_open_ = false; 210 request_autocomplete_dialog_open_ = false;
229 } 211 }
230 212
231 virtual bool IsSavingPasswordsEnabled() const OVERRIDE {
232 return false;
233 }
234
235 MOCK_METHOD0(OnAutocheckoutError, void()); 213 MOCK_METHOD0(OnAutocheckoutError, void());
236 214
237 virtual void ShowAutofillSettings() OVERRIDE {
238 }
239
240 virtual void ShowPasswordGenerationBubble(
241 const gfx::Rect& bounds,
242 const content::PasswordForm& form,
243 PasswordGenerator* generator) OVERRIDE {
244 }
245
246 virtual void ShowAutocheckoutBubble( 215 virtual void ShowAutocheckoutBubble(
247 const gfx::RectF& bounds, 216 const gfx::RectF& bounds,
248 const gfx::NativeView& native_view, 217 const gfx::NativeView& native_view,
249 const base::Closure& callback) OVERRIDE { 218 const base::Closure& callback) OVERRIDE {
250 autocheckout_bubble_shown_ = true; 219 autocheckout_bubble_shown_ = true;
251 callback.Run(); 220 callback.Run();
252 } 221 }
253 222
254 virtual void ShowRequestAutocompleteDialog( 223 virtual void ShowRequestAutocompleteDialog(
255 const FormData& form, 224 const FormData& form,
256 const GURL& source_url, 225 const GURL& source_url,
257 const content::SSLStatus& ssl_status, 226 const content::SSLStatus& ssl_status,
258 const AutofillMetrics& metric_logger, 227 const AutofillMetrics& metric_logger,
259 DialogType dialog_type, 228 DialogType dialog_type,
260 const base::Callback<void(const FormStructure*)>& callback) OVERRIDE { 229 const base::Callback<void(const FormStructure*)>& callback) OVERRIDE {
261 request_autocomplete_dialog_open_ = true; 230 request_autocomplete_dialog_open_ = true;
262 callback.Run(user_supplied_data_.get()); 231 callback.Run(user_supplied_data_.get());
263 } 232 }
264 233
265 virtual void RequestAutocompleteDialogClosed() OVERRIDE {
266 }
267
268 MOCK_METHOD1(UpdateProgressBar, void(double value)); 234 MOCK_METHOD1(UpdateProgressBar, void(double value));
269 235
270 void SetUserSuppliedData(scoped_ptr<FormStructure> user_supplied_data) { 236 void SetUserSuppliedData(scoped_ptr<FormStructure> user_supplied_data) {
271 user_supplied_data_.reset(user_supplied_data.release()); 237 user_supplied_data_.reset(user_supplied_data.release());
272 } 238 }
273 239
274 bool autocheckout_bubble_shown() const { 240 bool autocheckout_bubble_shown() const {
275 return autocheckout_bubble_shown_; 241 return autocheckout_bubble_shown_;
276 } 242 }
277 243
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 autofill_manager_delegate_->request_autocomplete_dialog_open()); 333 autofill_manager_delegate_->request_autocomplete_dialog_open());
368 autofill_manager_delegate_->HideRequestAutocompleteDialog(); 334 autofill_manager_delegate_->HideRequestAutocompleteDialog();
369 EXPECT_FALSE( 335 EXPECT_FALSE(
370 autofill_manager_delegate_->request_autocomplete_dialog_open()); 336 autofill_manager_delegate_->request_autocomplete_dialog_open());
371 } 337 }
372 338
373 protected: 339 protected:
374 content::TestBrowserThread ui_thread_; 340 content::TestBrowserThread ui_thread_;
375 scoped_ptr<TestAutofillManager> autofill_manager_; 341 scoped_ptr<TestAutofillManager> autofill_manager_;
376 scoped_ptr<TestAutocheckoutManager> autocheckout_manager_; 342 scoped_ptr<TestAutocheckoutManager> autocheckout_manager_;
377 scoped_ptr<TestAutofillManagerDelegate> autofill_manager_delegate_; 343 scoped_ptr<MockAutofillManagerDelegate> autofill_manager_delegate_;
378 344
379 private: 345 private:
380 virtual void SetUp() OVERRIDE { 346 virtual void SetUp() OVERRIDE {
381 ChromeRenderViewHostTestHarness::SetUp(); 347 ChromeRenderViewHostTestHarness::SetUp();
382 autofill_manager_delegate_.reset(new TestAutofillManagerDelegate()); 348 autofill_manager_delegate_.reset(new MockAutofillManagerDelegate());
383 autofill_manager_.reset(new TestAutofillManager( 349 autofill_manager_.reset(new TestAutofillManager(
384 web_contents(), 350 web_contents(),
385 autofill_manager_delegate_.get())); 351 autofill_manager_delegate_.get()));
386 autocheckout_manager_.reset( 352 autocheckout_manager_.reset(
387 new TestAutocheckoutManager(autofill_manager_.get())); 353 new TestAutocheckoutManager(autofill_manager_.get()));
388 } 354 }
389 355
390 virtual void TearDown() OVERRIDE { 356 virtual void TearDown() OVERRIDE {
391 autocheckout_manager_.reset(); 357 autocheckout_manager_.reset();
392 autofill_manager_delegate_.reset(); 358 autofill_manager_delegate_.reset();
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 CheckIpcMessageSent(); 520 CheckIpcMessageSent();
555 // Go to third page. 521 // Go to third page.
556 EXPECT_CALL(*autofill_manager_delegate_, UpdateProgressBar(1)).Times(1); 522 EXPECT_CALL(*autofill_manager_delegate_, UpdateProgressBar(1)).Times(1);
557 autocheckout_manager_->OnLoadedPageMetaData(CreateEndOfFlowMetaData()); 523 autocheckout_manager_->OnLoadedPageMetaData(CreateEndOfFlowMetaData());
558 CheckIpcMessageSent(); 524 CheckIpcMessageSent();
559 EXPECT_FALSE(autocheckout_manager_->in_autocheckout_flow()); 525 EXPECT_FALSE(autocheckout_manager_->in_autocheckout_flow());
560 EXPECT_FALSE(autofill_manager_delegate_->request_autocomplete_dialog_open()); 526 EXPECT_FALSE(autofill_manager_delegate_->request_autocomplete_dialog_open());
561 } 527 }
562 528
563 } // namespace autofill 529 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/autofill/DEPS ('k') | chrome/browser/autofill/autocomplete_history_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698