summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-21 03:21:51 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-21 03:21:51 +0000
commit33b2261718852034e1c93b708fc176337d862db5 (patch)
treef5ae5e98e3162a5ad7a6857800134430c9d9c1f9 /chrome
parent81af939f99865071091db5393e87d85fb0f02012 (diff)
downloadchromium_src-33b2261718852034e1c93b708fc176337d862db5.zip
chromium_src-33b2261718852034e1c93b708fc176337d862db5.tar.gz
chromium_src-33b2261718852034e1c93b708fc176337d862db5.tar.bz2
Fix a leak of the NavigationController during many tests. A duplicate
NavigationController was begin created from when we had to create this separately. BUG=10781 Review URL: http://codereview.chromium.org/88018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/renderer_host/test_render_view_host.cc6
-rw-r--r--chrome/browser/renderer_host/test_render_view_host.h21
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc6
-rw-r--r--chrome/browser/tab_contents/web_contents_unittest.cc3
4 files changed, 14 insertions, 22 deletions
diff --git a/chrome/browser/renderer_host/test_render_view_host.cc b/chrome/browser/renderer_host/test_render_view_host.cc
index 4255393..5117465 100644
--- a/chrome/browser/renderer_host/test_render_view_host.cc
+++ b/chrome/browser/renderer_host/test_render_view_host.cc
@@ -82,13 +82,11 @@ void RenderViewHostTestHarness::SetUp() {
// This will be deleted when the WebContents goes away.
SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get());
- contents_ = new TestWebContents(profile_.get(), instance);
- controller_ = new NavigationController(contents_, profile_.get());
+ contents_.reset(new TestWebContents(profile_.get(), instance));
}
void RenderViewHostTestHarness::TearDown() {
- if (contents_)
- delete contents_;
+ contents_.reset();
// Make sure that we flush any messages related to WebContents destruction
// before we destroy the profile.
diff --git a/chrome/browser/renderer_host/test_render_view_host.h b/chrome/browser/renderer_host/test_render_view_host.h
index 2d07975..5f67ec1 100644
--- a/chrome/browser/renderer_host/test_render_view_host.h
+++ b/chrome/browser/renderer_host/test_render_view_host.h
@@ -180,8 +180,7 @@ class RenderViewHostTestHarness : public testing::Test {
RenderViewHostTestHarness()
: rph_factory_(),
rvh_factory_(&rph_factory_),
- contents_(NULL),
- controller_(NULL) {}
+ contents_(NULL) {}
virtual ~RenderViewHostTestHarness() {}
NavigationController& controller() {
@@ -189,7 +188,7 @@ class RenderViewHostTestHarness : public testing::Test {
}
TestWebContents* contents() {
- return contents_;
+ return contents_.get();
}
TestRenderViewHost* rvh() {
@@ -204,17 +203,16 @@ class RenderViewHostTestHarness : public testing::Test {
return static_cast<MockRenderProcessHost*>(rvh()->process());
}
+ // Frees the current tab contents for tests that want to test destruction.
+ void DeleteContents() {
+ contents_.reset();
+ }
+
// Creates a pending navigation to the given oURL with the default parameters
// and the commits the load with a page ID one larger than any seen. This
// emulates what happens on a new navigation.
void NavigateAndCommit(const GURL& url);
- // Marks the contents as already cleaned up. If a test calls CloseContents,
- // then our cleanup code shouldn't run. This function makes sure that happens.
- void ContentsCleanedUp() {
- contents_ = NULL;
- }
-
protected:
// testing::Test
virtual void SetUp();
@@ -230,10 +228,7 @@ class RenderViewHostTestHarness : public testing::Test {
MockRenderProcessHostFactory rph_factory_;
TestRenderViewHostFactory rvh_factory_;
- // We clean up the WebContents by calling CloseContents, which deletes itself.
- // This in turn causes the destruction of these other things.
- TestWebContents* contents_;
- NavigationController* controller_;
+ scoped_ptr<TestWebContents> contents_;
DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness);
};
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
index 771d4be..a7f8307 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
@@ -111,7 +111,7 @@ class SafeBrowsingBlockingPageTest : public RenderViewHostTestHarness,
// showing.
SafeBrowsingBlockingPage* GetSafeBrowsingBlockingPage() {
InterstitialPage* interstitial =
- InterstitialPage::GetInterstitialPage(contents_);
+ InterstitialPage::GetInterstitialPage(contents());
if (!interstitial)
return NULL;
return static_cast<SafeBrowsingBlockingPage*>(interstitial);
@@ -186,11 +186,11 @@ TEST_F(SafeBrowsingBlockingPageTest, MalwarePageProceed) {
ProceedThroughInterstitial(sb_interstitial);
// The interstitial is shown until the navigation commits.
- ASSERT_TRUE(InterstitialPage::GetInterstitialPage(contents_));
+ ASSERT_TRUE(InterstitialPage::GetInterstitialPage(contents()));
// Commit the navigation.
Navigate(kBadURL, 1);
// The interstitial should be gone now.
- ASSERT_FALSE(InterstitialPage::GetInterstitialPage(contents_));
+ ASSERT_FALSE(InterstitialPage::GetInterstitialPage(contents()));
}
// Tests showing a blocking page for a page that contains malware subresources
diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc
index 5c91259..1c936c5 100644
--- a/chrome/browser/tab_contents/web_contents_unittest.cc
+++ b/chrome/browser/tab_contents/web_contents_unittest.cc
@@ -896,8 +896,7 @@ TEST_F(WebContentsTest, ShowInterstitialThenCloseTab) {
interstitial->TestDidNavigate(1, url);
// Now close the tab.
- delete contents();
- ContentsCleanedUp();
+ DeleteContents();
EXPECT_TRUE(deleted);
EXPECT_EQ(TestInterstitialPage::CANCELED, state);
}