| Index: content/browser/webui/web_ui_unittest.cc
|
| diff --git a/content/browser/webui/web_ui_unittest.cc b/content/browser/webui/web_ui_unittest.cc
|
| index b81f3a811335d0df59443533ab2428fade23946a..e96642e7bdc3284c64a3588a51c95edc5a906f67 100644
|
| --- a/content/browser/webui/web_ui_unittest.cc
|
| +++ b/content/browser/webui/web_ui_unittest.cc
|
| @@ -2,17 +2,19 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "chrome/browser/favicon_tab_helper.h"
|
| +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
|
| +#include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
|
| #include "chrome/browser/ui/webui/new_tab_ui.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "chrome/test/testing_profile.h"
|
| #include "content/browser/browser_thread.h"
|
| -#include "content/browser/renderer_host/test_render_view_host.h"
|
| #include "content/browser/site_instance.h"
|
| #include "content/browser/tab_contents/navigation_controller.h"
|
| #include "content/browser/tab_contents/test_tab_contents.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| -class WebUITest : public RenderViewHostTestHarness {
|
| +class WebUITest : public TabContentsWrapperTestHarness {
|
| public:
|
| WebUITest() : ui_thread_(BrowserThread::UI, MessageLoop::current()) {}
|
|
|
| @@ -20,7 +22,8 @@ class WebUITest : public RenderViewHostTestHarness {
|
| // state, through pending, committed, then another navigation. The first page
|
| // 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(TabContents* contents, int page_id) {
|
| + static void DoNavigationTest(TabContentsWrapper* wrapper, int page_id) {
|
| + TabContents* contents = wrapper->tab_contents();
|
| NavigationController* controller = &contents->controller();
|
|
|
| // Start a pending load.
|
| @@ -33,7 +36,7 @@ class WebUITest : public RenderViewHostTestHarness {
|
|
|
| // Check the things the pending Web UI should have set.
|
| EXPECT_FALSE(contents->ShouldDisplayURL());
|
| - EXPECT_FALSE(contents->ShouldDisplayFavicon());
|
| + EXPECT_FALSE(wrapper->favicon_tab_helper()->ShouldDisplayFavicon());
|
| EXPECT_TRUE(contents->ShouldShowBookmarkBar());
|
| EXPECT_TRUE(contents->FocusLocationBarByDefault());
|
|
|
| @@ -43,7 +46,7 @@ class WebUITest : public RenderViewHostTestHarness {
|
|
|
| // The same flags should be set as before now that the load has committed.
|
| EXPECT_FALSE(contents->ShouldDisplayURL());
|
| - EXPECT_FALSE(contents->ShouldDisplayFavicon());
|
| + EXPECT_FALSE(wrapper->favicon_tab_helper()->ShouldDisplayFavicon());
|
| EXPECT_TRUE(contents->ShouldShowBookmarkBar());
|
| EXPECT_TRUE(contents->FocusLocationBarByDefault());
|
|
|
| @@ -54,7 +57,7 @@ class WebUITest : public RenderViewHostTestHarness {
|
| // Check the flags. Some should reflect the new page (URL, title), some
|
| // should reflect the old one (bookmark bar) until it has committed.
|
| EXPECT_TRUE(contents->ShouldDisplayURL());
|
| - EXPECT_TRUE(contents->ShouldDisplayFavicon());
|
| + EXPECT_TRUE(wrapper->favicon_tab_helper()->ShouldDisplayFavicon());
|
| EXPECT_TRUE(contents->ShouldShowBookmarkBar());
|
| EXPECT_FALSE(contents->FocusLocationBarByDefault());
|
|
|
| @@ -74,7 +77,7 @@ class WebUITest : public RenderViewHostTestHarness {
|
|
|
| // The state should now reflect a regular page.
|
| EXPECT_TRUE(contents->ShouldDisplayURL());
|
| - EXPECT_TRUE(contents->ShouldDisplayFavicon());
|
| + EXPECT_TRUE(wrapper->favicon_tab_helper()->ShouldDisplayFavicon());
|
| EXPECT_FALSE(contents->ShouldShowBookmarkBar());
|
| EXPECT_FALSE(contents->FocusLocationBarByDefault());
|
| }
|
| @@ -89,15 +92,16 @@ class WebUITest : public RenderViewHostTestHarness {
|
| // TabContents when we first navigate to a Web UI page, then to a standard
|
| // non-DOM-UI page.
|
| TEST_F(WebUITest, WebUIToStandard) {
|
| - DoNavigationTest(contents(), 1);
|
| + DoNavigationTest(contents_wrapper(), 1);
|
|
|
| // Test the case where we're not doing the initial navigation. This is
|
| // slightly different than the very-first-navigation case since the
|
| // SiteInstance will be the same (the original TabContents must still be
|
| // alive), which will trigger different behavior in RenderViewHostManager.
|
| - TestTabContents contents2(profile_.get(), NULL);
|
| + TestTabContents* contents2 = new TestTabContents(profile_.get(), NULL);
|
| + TabContentsWrapper wrapper2(contents2);
|
|
|
| - DoNavigationTest(&contents2, 101);
|
| + DoNavigationTest(&wrapper2, 101);
|
| }
|
|
|
| TEST_F(WebUITest, WebUIToWebUI) {
|
| @@ -112,7 +116,8 @@ TEST_F(WebUITest, WebUIToWebUI) {
|
|
|
| // The flags should be the same as the non-pending state.
|
| EXPECT_FALSE(contents()->ShouldDisplayURL());
|
| - EXPECT_FALSE(contents()->ShouldDisplayFavicon());
|
| + EXPECT_FALSE(
|
| + contents_wrapper()->favicon_tab_helper()->ShouldDisplayFavicon());
|
| EXPECT_TRUE(contents()->ShouldShowBookmarkBar());
|
| EXPECT_TRUE(contents()->FocusLocationBarByDefault());
|
| }
|
| @@ -125,14 +130,14 @@ TEST_F(WebUITest, StandardToWebUI) {
|
|
|
| // The state should now reflect the default.
|
| EXPECT_TRUE(contents()->ShouldDisplayURL());
|
| - EXPECT_TRUE(contents()->ShouldDisplayFavicon());
|
| + EXPECT_TRUE(contents_wrapper()->favicon_tab_helper()->ShouldDisplayFavicon());
|
| EXPECT_FALSE(contents()->ShouldShowBookmarkBar());
|
| EXPECT_FALSE(contents()->FocusLocationBarByDefault());
|
|
|
| // Commit the load, the state should be the same.
|
| rvh()->SendNavigate(1, std_url);
|
| EXPECT_TRUE(contents()->ShouldDisplayURL());
|
| - EXPECT_TRUE(contents()->ShouldDisplayFavicon());
|
| + EXPECT_TRUE(contents_wrapper()->favicon_tab_helper()->ShouldDisplayFavicon());
|
| EXPECT_FALSE(contents()->ShouldShowBookmarkBar());
|
| EXPECT_FALSE(contents()->FocusLocationBarByDefault());
|
|
|
| @@ -140,7 +145,7 @@ TEST_F(WebUITest, StandardToWebUI) {
|
| GURL new_tab_url(chrome::kChromeUINewTabURL);
|
| controller().LoadURL(new_tab_url, GURL(), PageTransition::LINK);
|
| EXPECT_FALSE(contents()->ShouldDisplayURL());
|
| - EXPECT_TRUE(contents()->ShouldDisplayFavicon());
|
| + EXPECT_TRUE(contents_wrapper()->favicon_tab_helper()->ShouldDisplayFavicon());
|
| EXPECT_FALSE(contents()->ShouldShowBookmarkBar());
|
| EXPECT_TRUE(contents()->FocusLocationBarByDefault());
|
|
|
|
|