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

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

Issue 10987100: Switch AutofillManager to be UserData on WebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 const char* year, 434 const char* year,
435 const char* month) { 435 const char* month) {
436 ExpectFilledForm(page_id, filled_form, expected_page_id, 436 ExpectFilledForm(page_id, filled_form, expected_page_id,
437 "", "", "", "", "", "", "", "", "", "", "", 437 "", "", "", "", "", "", "", "", "", "", "",
438 "Miku Hatsune", "4234567890654321", month, year, 438 "Miku Hatsune", "4234567890654321", month, year,
439 has_address_fields, true, true); 439 has_address_fields, true, true);
440 } 440 }
441 441
442 class TestAutofillManager : public AutofillManager { 442 class TestAutofillManager : public AutofillManager {
443 public: 443 public:
444 TestAutofillManager(autofill::AutofillManagerDelegate* delegate, 444 TestAutofillManager(content::WebContents* web_contents,
445 TabContents* tab_contents, 445 autofill::AutofillManagerDelegate* delegate,
446 TestPersonalDataManager* personal_data) 446 TestPersonalDataManager* personal_data)
447 : AutofillManager(delegate, tab_contents, personal_data), 447 : AutofillManager(web_contents, delegate, personal_data),
448 personal_data_(personal_data), 448 personal_data_(personal_data),
449 autofill_enabled_(true), 449 autofill_enabled_(true),
450 did_finish_async_form_submit_(false), 450 did_finish_async_form_submit_(false),
451 message_loop_is_running_(false) { 451 message_loop_is_running_(false) {
452 } 452 }
453 453
454 virtual bool IsAutofillEnabled() const OVERRIDE { return autofill_enabled_; } 454 virtual bool IsAutofillEnabled() const OVERRIDE { return autofill_enabled_; }
455 455
456 void set_autofill_enabled(bool autofill_enabled) { 456 void set_autofill_enabled(bool autofill_enabled) {
457 autofill_enabled_ = autofill_enabled; 457 autofill_enabled_ = autofill_enabled;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 600
601 virtual void SetUp() OVERRIDE { 601 virtual void SetUp() OVERRIDE {
602 Profile* profile = new TestingProfile(); 602 Profile* profile = new TestingProfile();
603 browser_context_.reset(profile); 603 browser_context_.reset(profile);
604 PersonalDataManagerFactory::GetInstance()->SetTestingFactory( 604 PersonalDataManagerFactory::GetInstance()->SetTestingFactory(
605 profile, TestPersonalDataManager::Build); 605 profile, TestPersonalDataManager::Build);
606 606
607 TabContentsTestHarness::SetUp(); 607 TabContentsTestHarness::SetUp();
608 TabAutofillManagerDelegate::CreateForWebContents(web_contents()); 608 TabAutofillManagerDelegate::CreateForWebContents(web_contents());
609 autofill_manager_ = new TestAutofillManager( 609 autofill_manager_ = new TestAutofillManager(
610 web_contents(),
610 TabAutofillManagerDelegate::FromWebContents(web_contents()), 611 TabAutofillManagerDelegate::FromWebContents(web_contents()),
611 tab_contents(),
612 &personal_data_); 612 &personal_data_);
613 613
614 file_thread_.Start(); 614 file_thread_.Start();
615 } 615 }
616 616
617 virtual void TearDown() OVERRIDE { 617 virtual void TearDown() OVERRIDE {
618 file_thread_.Stop(); 618 file_thread_.Stop();
619 TabContentsTestHarness::TearDown(); 619 TabContentsTestHarness::TearDown();
620 } 620 }
621 621
(...skipping 2502 matching lines...) Expand 10 before | Expand all | Expand 10 after
3124 // Turn on the external delegate. Recreate a WebContents. Make sure 3124 // Turn on the external delegate. Recreate a WebContents. Make sure
3125 // an external delegate was set in the proper structures. 3125 // an external delegate was set in the proper structures.
3126 TEST_F(AutofillManagerTest, TestTabContentsWithExternalDelegate) { 3126 TEST_F(AutofillManagerTest, TestTabContentsWithExternalDelegate) {
3127 CommandLine::ForCurrentProcess()->AppendSwitch( 3127 CommandLine::ForCurrentProcess()->AppendSwitch(
3128 switches::kExternalAutofillPopup); 3128 switches::kExternalAutofillPopup);
3129 3129
3130 // Setting the contents creates a new TabContents. 3130 // Setting the contents creates a new TabContents.
3131 WebContents* contents = CreateTestWebContents(); 3131 WebContents* contents = CreateTestWebContents();
3132 SetContents(contents); 3132 SetContents(contents);
3133 3133
3134 AutofillManager* autofill_manager = tab_contents()->autofill_manager(); 3134 AutofillManager* autofill_manager =
3135 AutofillManager::FromWebContents(contents);
3135 EXPECT_TRUE(autofill_manager->external_delegate()); 3136 EXPECT_TRUE(autofill_manager->external_delegate());
3136 3137
3137 AutocompleteHistoryManager* autocomplete_history_manager = 3138 AutocompleteHistoryManager* autocomplete_history_manager =
3138 AutocompleteHistoryManager::FromWebContents(web_contents()); 3139 AutocompleteHistoryManager::FromWebContents(contents);
3139 EXPECT_TRUE(autocomplete_history_manager->external_delegate()); 3140 EXPECT_TRUE(autocomplete_history_manager->external_delegate());
3140 } 3141 }
3141 3142
3142 #endif // OS_ANDROID 3143 #endif // OS_ANDROID
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698