summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 21:26:42 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 21:26:42 +0000
commit96e284571293e7706dc95acf919f2be8ac621127 (patch)
treeafdf4ceb6951a0277f9a5732045e72cdff8c2d5d /chrome
parent9d8fc9b143c891d4aba21ac2e4724db158f47e05 (diff)
downloadchromium_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')
-rw-r--r--chrome/browser/autofill/autofill_infobar_delegate_unittest.cc14
-rw-r--r--chrome/browser/autofill/autofill_manager.cc9
-rw-r--r--chrome/browser/autofill/autofill_manager.h4
-rw-r--r--chrome/browser/autofill/personal_data_manager.h1
-rw-r--r--chrome/test/testing_profile.cc5
-rw-r--r--chrome/test/testing_profile.h13
6 files changed, 17 insertions, 29 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);
diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc
index 9a5b1b9..27708f2 100644
--- a/chrome/test/testing_profile.cc
+++ b/chrome/test/testing_profile.cc
@@ -7,7 +7,6 @@
#include "build/build_config.h"
#include "base/command_line.h"
#include "base/string_util.h"
-#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/dom_ui/ntp_resource_cache.h"
#include "chrome/browser/history/history_backend.h"
@@ -230,10 +229,6 @@ void TestingProfile::CreateWebDataService(bool delete_file) {
web_data_service_->Init(GetPath());
}
-void TestingProfile::CreatePersonalDataManager() {
- personal_data_.reset(new PersonalDataManager(this));
-}
-
void TestingProfile::BlockUntilBookmarkModelLoaded() {
DCHECK(bookmark_bar_model_.get());
if (bookmark_bar_model_->IsLoaded())
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h
index 74d654d..82535c5 100644
--- a/chrome/test/testing_profile.h
+++ b/chrome/test/testing_profile.h
@@ -21,7 +21,6 @@
#include "chrome/browser/search_engines/template_url_model.h"
#include "net/base/cookie_monster.h"
-class PersonalDataManager;
class ProfileSyncFactory;
class ProfileSyncService;
class SessionService;
@@ -64,10 +63,6 @@ class TestingProfile : public Profile {
// only matters if you're recreating the WebDataService.
void CreateWebDataService(bool delete_file);
- // Creates the PersonalDataManager. Consequent calls will recreate the
- // service.
- void CreatePersonalDataManager();
-
// Destroys
// Blocks until the BookmarkModel finishes loaded. This is NOT invoked from
@@ -140,9 +135,6 @@ class TestingProfile : public Profile {
virtual WebDataService* GetWebDataServiceWithoutCreating() {
return web_data_service_.get();
}
- virtual PersonalDataManager* GetPersonalDataManager() {
- return personal_data_.get();
- }
virtual PasswordStore* GetPasswordStore(ServiceAccessType access) {
return NULL;
}
@@ -162,6 +154,7 @@ class TestingProfile : public Profile {
virtual TemplateURLFetcher* GetTemplateURLFetcher() { return NULL; }
virtual ThumbnailStore* GetThumbnailStore() { return NULL; }
virtual DownloadManager* GetDownloadManager() { return NULL; }
+ virtual PersonalDataManager* GetPersonalDataManager() { return NULL; }
virtual bool HasCreatedDownloadManager() const { return false; }
virtual void InitThemes();
virtual void SetTheme(Extension* extension) {}
@@ -287,10 +280,6 @@ class TestingProfile : public Profile {
// The WebDataService. Only created if CreateWebDataService is invoked.
scoped_refptr<WebDataService> web_data_service_;
- // The PersonalDataManager. Only created if CreatePersonalDataManager is
- // invoked.
- scoped_ptr<PersonalDataManager> personal_data_;
-
// The TemplateURLFetcher. Only created if CreateTemplateURLModel is invoked.
scoped_ptr<TemplateURLModel> template_url_model_;