summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui/dom_ui_unittest.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-20 19:55:57 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-20 19:55:57 +0000
commitce3fa3c831cba1f44d34c1c66020f830be33a068 (patch)
treeda18dbdfb081c17949dca2dcfa0633142a63a868 /chrome/browser/dom_ui/dom_ui_unittest.cc
parent6ee6368c466235c5919c9b4d5cfe11f8e48b29ca (diff)
downloadchromium_src-ce3fa3c831cba1f44d34c1c66020f830be33a068.zip
chromium_src-ce3fa3c831cba1f44d34c1c66020f830be33a068.tar.gz
chromium_src-ce3fa3c831cba1f44d34c1c66020f830be33a068.tar.bz2
Re-land my change to clean up TabContents/WebContents ownership. This
is the same except in tab_strip_model_unittest I fixed a leak by making a WebContents on the stack, I added a factory to the SiteInstance unittest to prevent another leak, and I re-added a NULL set to the external_tab_container. Fix the ownership model of TabContents and NavigationController. Previously the NavigationController owned the TabContents, and there were extra steps required at creation and destruction to clean everything up properly. NavigationController is now a member of TabContents, and there is no setup or tear down necessary other than the constructor and destructor. I could remove the tab contents creation in the NavigationController, as well as all the weird destruction code in WebContents which got moved to the destructor. I made the controller getter return a reference since the ownership is clear and there is no possibility of NULL. This required changing a lot of tiles, but many of them were simplified since they no longer have to NULL check. Previous review URL: http://codereview.chromium.org/69043 Review URL: http://codereview.chromium.org/67294 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14053 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui/dom_ui_unittest.cc')
-rw-r--r--chrome/browser/dom_ui/dom_ui_unittest.cc18
1 files changed, 7 insertions, 11 deletions
diff --git a/chrome/browser/dom_ui/dom_ui_unittest.cc b/chrome/browser/dom_ui/dom_ui_unittest.cc
index 51b045a..e108c23 100644
--- a/chrome/browser/dom_ui/dom_ui_unittest.cc
+++ b/chrome/browser/dom_ui/dom_ui_unittest.cc
@@ -16,7 +16,7 @@ class DOMUITest : public RenderViewHostTestHarness {
// ID that we should use is passed as a parameter. We'll use the next two
// values. This must be increasing for the life of the tests.
static void DoNavigationTest(WebContents* contents, int page_id) {
- NavigationController* controller = contents->controller();
+ NavigationController* controller = &contents->controller();
// Start a pending load.
GURL new_tab_url(chrome::kChromeUINewTabURL);
@@ -88,23 +88,19 @@ TEST_F(DOMUITest, DOMUIToStandard) {
// slightly different than the very-first-navigation case since the
// SiteInstance will be the same (the original WebContents must still be
// alive), which will trigger different behavior in RenderViewHostManager.
- WebContents* contents2 = new TestWebContents(profile_.get(), NULL);
- NavigationController* controller2 =
- new NavigationController(contents2, profile_.get());
- contents2->set_controller(controller2);
+ TestWebContents contents2(profile_.get(), NULL);
- DoNavigationTest(contents2, 101);
- contents2->CloseContents();
+ DoNavigationTest(&contents2, 101);
}
TEST_F(DOMUITest, DOMUIToDOMUI) {
// Do a load (this state is tested above).
GURL new_tab_url(chrome::kChromeUINewTabURL);
- controller()->LoadURL(new_tab_url, GURL(), PageTransition::LINK);
+ controller().LoadURL(new_tab_url, GURL(), PageTransition::LINK);
rvh()->SendNavigate(1, new_tab_url);
// Start another pending load of the new tab page.
- controller()->LoadURL(new_tab_url, GURL(), PageTransition::LINK);
+ controller().LoadURL(new_tab_url, GURL(), PageTransition::LINK);
rvh()->SendNavigate(2, new_tab_url);
// The flags should be the same as the non-pending state.
@@ -117,7 +113,7 @@ TEST_F(DOMUITest, DOMUIToDOMUI) {
TEST_F(DOMUITest, StandardToDOMUI) {
// Start a pending navigation to a regular page.
GURL std_url("http://google.com/");
- controller()->LoadURL(std_url, GURL(), PageTransition::LINK);
+ controller().LoadURL(std_url, GURL(), PageTransition::LINK);
// The state should now reflect the default.
EXPECT_TRUE(contents()->ShouldDisplayURL());
@@ -134,7 +130,7 @@ TEST_F(DOMUITest, StandardToDOMUI) {
// Start a pending load for a DOMUI.
GURL new_tab_url(chrome::kChromeUINewTabURL);
- controller()->LoadURL(new_tab_url, GURL(), PageTransition::LINK);
+ controller().LoadURL(new_tab_url, GURL(), PageTransition::LINK);
EXPECT_FALSE(contents()->ShouldDisplayURL());
EXPECT_TRUE(contents()->ShouldDisplayFavIcon());
EXPECT_FALSE(contents()->IsBookmarkBarAlwaysVisible());