diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-18 21:26:42 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-18 21:26:42 +0000 |
commit | 96e284571293e7706dc95acf919f2be8ac621127 (patch) | |
tree | afdf4ceb6951a0277f9a5732045e72cdff8c2d5d /chrome/browser/autofill | |
parent | 9d8fc9b143c891d4aba21ac2e4724db158f47e05 (diff) | |
download | chromium_src-96e284571293e7706dc95acf919f2be8ac621127.zip chromium_src-96e284571293e7706dc95acf919f2be8ac621127.tar.gz chromium_src-96e284571293e7706dc95acf919f2be8ac621127.tar.bz2 |
Don't use the TabContents in the AutoFillInfoBarDelegateTest. Fixes a few leaks.
BUG=38481
TEST=none
Review URL: http://codereview.chromium.org/1109005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41989 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
4 files changed, 16 insertions, 12 deletions
diff --git a/chrome/browser/autofill/autofill_infobar_delegate_unittest.cc b/chrome/browser/autofill/autofill_infobar_delegate_unittest.cc index a50bcff..f2fd4d0 100644 --- a/chrome/browser/autofill/autofill_infobar_delegate_unittest.cc +++ b/chrome/browser/autofill/autofill_infobar_delegate_unittest.cc @@ -6,10 +6,8 @@ #include "base/scoped_ptr.h" #include "chrome/browser/autofill/autofill_infobar_delegate.h" #include "chrome/browser/autofill/autofill_manager.h" -#include "chrome/browser/renderer_host/test/test_render_view_host.h" #include "chrome/browser/tab_contents/infobar_delegate.h" #include "chrome/browser/tab_contents/navigation_controller.h" -#include "chrome/browser/tab_contents/test_tab_contents.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "testing/gtest/include/gtest/gtest.h" @@ -20,9 +18,8 @@ namespace { class MockAutoFillManager : public AutoFillManager { public: - explicit MockAutoFillManager(TabContents* tab_contents) - : AutoFillManager(tab_contents), - responded_(false), + explicit MockAutoFillManager() + : responded_(false), accepted_(false) {} virtual void OnInfoBarClosed() { @@ -62,15 +59,12 @@ class MockAutoFillManager : public AutoFillManager { DISALLOW_COPY_AND_ASSIGN(MockAutoFillManager); }; -class AutoFillInfoBarDelegateTest : public RenderViewHostTestHarness { +class AutoFillInfoBarDelegateTest : public testing::Test { public: AutoFillInfoBarDelegateTest() {} virtual void SetUp() { - RenderViewHostTestHarness::SetUp(); - profile()->CreateWebDataService(true); - profile()->CreatePersonalDataManager(); - autofill_manager_.reset(new MockAutoFillManager(contents())); + autofill_manager_.reset(new MockAutoFillManager()); infobar_.reset(new AutoFillInfoBarDelegate(NULL, autofill_manager_.get())); } diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index 0e57d5e..718b9a1 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -32,7 +32,9 @@ AutoFillManager::AutoFillManager(TabContents* tab_contents) } AutoFillManager::~AutoFillManager() { - personal_data_->RemoveObserver(this); + // This is NULL in the MockAutoFillManager. + if (personal_data_) + personal_data_->RemoveObserver(this); } // static @@ -324,3 +326,8 @@ bool AutoFillManager::IsAutoFillEnabled() { return prefs->GetBoolean(prefs::kAutoFillEnabled); } + +AutoFillManager::AutoFillManager() + : tab_contents_(NULL), + personal_data_(NULL) { +} diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h index 9a94e62..e09cecf 100644 --- a/chrome/browser/autofill/autofill_manager.h +++ b/chrome/browser/autofill/autofill_manager.h @@ -87,6 +87,10 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill, // Returns the value of the AutoFillEnabled pref. bool IsAutoFillEnabled(); + protected: + // For AutoFillInfoBarDelegateTest. + AutoFillManager(); + private: // The TabContents hosting this AutoFillManager. // Weak reference. diff --git a/chrome/browser/autofill/personal_data_manager.h b/chrome/browser/autofill/personal_data_manager.h index 9442100..b30913d 100644 --- a/chrome/browser/autofill/personal_data_manager.h +++ b/chrome/browser/autofill/personal_data_manager.h @@ -101,7 +101,6 @@ class PersonalDataManager : public WebDataServiceConsumer, // instance of PersonalDataManager. friend class ProfileImpl; friend class PersonalDataManagerTest; - friend class TestingProfile; explicit PersonalDataManager(Profile* profile); |