diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-18 18:09:36 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-18 18:09:36 +0000 |
commit | 59b49a66c3cd959fcf9d7b4bd9c6d88c70b39919 (patch) | |
tree | da55718682e3a4d7da3c6f3d70870eee0542d0b9 /chrome/browser/find_backend_unittest.cc | |
parent | d940627c90386df7844092dae635ed2f20535f28 (diff) | |
download | chromium_src-59b49a66c3cd959fcf9d7b4bd9c6d88c70b39919.zip chromium_src-59b49a66c3cd959fcf9d7b4bd9c6d88c70b39919.tar.gz chromium_src-59b49a66c3cd959fcf9d7b4bd9c6d88c70b39919.tar.bz2 |
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.
Review URL: http://codereview.chromium.org/69043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14005 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/find_backend_unittest.cc')
-rw-r--r-- | chrome/browser/find_backend_unittest.cc | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/chrome/browser/find_backend_unittest.cc b/chrome/browser/find_backend_unittest.cc index 2a2dba4..260e897 100644 --- a/chrome/browser/find_backend_unittest.cc +++ b/chrome/browser/find_backend_unittest.cc @@ -15,16 +15,13 @@ TEST_F(FindBackendTest, InternalState) { EXPECT_EQ(string16(), contents()->find_text()); // Get another WebContents object ready. - WebContents* contents2 = new TestWebContents(profile_.get(), NULL); - NavigationController* controller2 = - new NavigationController(contents2, profile_.get()); - contents2->set_controller(controller2); + TestWebContents contents2(profile_.get(), NULL); // No search has still been issued, strings should be blank. EXPECT_EQ(string16(), contents()->find_prepopulate_text()); EXPECT_EQ(string16(), contents()->find_text()); - EXPECT_EQ(string16(), contents2->find_prepopulate_text()); - EXPECT_EQ(string16(), contents2->find_text()); + EXPECT_EQ(string16(), contents2.find_prepopulate_text()); + EXPECT_EQ(string16(), contents2.find_text()); string16 search_term1 = L" I had a 401K "; string16 search_term2 = L" but the economy "; @@ -37,18 +34,18 @@ TEST_F(FindBackendTest, InternalState) { // should not. EXPECT_EQ(search_term1, contents()->find_prepopulate_text()); EXPECT_EQ(search_term1, contents()->find_text()); - EXPECT_EQ(search_term1, contents2->find_prepopulate_text()); - EXPECT_EQ(string16(), contents2->find_text()); + EXPECT_EQ(search_term1, contents2.find_prepopulate_text()); + EXPECT_EQ(string16(), contents2.find_text()); // Now search in the other WebContents. - contents2->StartFinding(search_term2, true); // true=forward. + contents2.StartFinding(search_term2, true); // true=forward. // Again, pre-populate string should always match between the two, but // find_text should not. EXPECT_EQ(search_term2, contents()->find_prepopulate_text()); EXPECT_EQ(search_term1, contents()->find_text()); - EXPECT_EQ(search_term2, contents2->find_prepopulate_text()); - EXPECT_EQ(search_term2, contents2->find_text()); + EXPECT_EQ(search_term2, contents2.find_prepopulate_text()); + EXPECT_EQ(search_term2, contents2.find_text()); // Search again in the first WebContents. contents()->StartFinding(search_term3, true); // true=forward. @@ -57,8 +54,6 @@ TEST_F(FindBackendTest, InternalState) { // find_text should not. EXPECT_EQ(search_term3, contents()->find_prepopulate_text()); EXPECT_EQ(search_term3, contents()->find_text()); - EXPECT_EQ(search_term3, contents2->find_prepopulate_text()); - EXPECT_EQ(search_term2, contents2->find_text()); - - contents2->CloseContents(); + EXPECT_EQ(search_term3, contents2.find_prepopulate_text()); + EXPECT_EQ(search_term2, contents2.find_text()); } |