summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-05 18:19:59 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-05 18:19:59 +0000
commit97e780da17ba0e8933e690e33751e19c5fe1bbb9 (patch)
tree000fd0f30e238c1f523a92e7094ad1bbc0cd7bb5 /content
parent7ffdf6ebd685eee46e65dbdc03862b79fa0522f5 (diff)
downloadchromium_src-97e780da17ba0e8933e690e33751e19c5fe1bbb9.zip
chromium_src-97e780da17ba0e8933e690e33751e19c5fe1bbb9.tar.gz
chromium_src-97e780da17ba0e8933e690e33751e19c5fe1bbb9.tar.bz2
Make contents settable in RVHTH.
Add ability to swap out the TestTabContents in RenderViewHostTestHarness/TabContentsWrapperTestHarness. BUG=71097 TEST=no visible change Review URL: http://codereview.chromium.org/6720050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80491 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/renderer_host/test_render_view_host.cc10
-rw-r--r--content/browser/renderer_host/test_render_view_host.h5
-rw-r--r--content/browser/webui/web_ui_unittest.cc5
3 files changed, 13 insertions, 7 deletions
diff --git a/content/browser/renderer_host/test_render_view_host.cc b/content/browser/renderer_host/test_render_view_host.cc
index b7842cf..06e884c 100644
--- a/content/browser/renderer_host/test_render_view_host.cc
+++ b/content/browser/renderer_host/test_render_view_host.cc
@@ -312,7 +312,11 @@ MockRenderProcessHost* RenderViewHostTestHarness::process() {
}
void RenderViewHostTestHarness::DeleteContents() {
- contents_.reset();
+ SetContents(NULL);
+}
+
+void RenderViewHostTestHarness::SetContents(TestTabContents* contents) {
+ contents_.reset(contents);
}
TestTabContents* RenderViewHostTestHarness::CreateTestTabContents() {
@@ -338,11 +342,11 @@ void RenderViewHostTestHarness::Reload() {
}
void RenderViewHostTestHarness::SetUp() {
- contents_.reset(CreateTestTabContents());
+ SetContents(CreateTestTabContents());
}
void RenderViewHostTestHarness::TearDown() {
- contents_.reset();
+ SetContents(NULL);
// Make sure that we flush any messages related to TabContents destruction
// before we destroy the profile.
diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h
index 927af93..f25c8c7 100644
--- a/content/browser/renderer_host/test_render_view_host.h
+++ b/content/browser/renderer_host/test_render_view_host.h
@@ -277,6 +277,10 @@ class RenderViewHostTestHarness : public testing::Test {
// Frees the current tab contents for tests that want to test destruction.
void DeleteContents();
+ // Sets the current tab contents for tests that want to alter it. Takes
+ // ownership of the TestTabContents passed.
+ void SetContents(TestTabContents* contents);
+
// Creates a new TestTabContents. Ownership passes to the caller.
TestTabContents* CreateTestTabContents();
@@ -302,6 +306,7 @@ class RenderViewHostTestHarness : public testing::Test {
MockRenderProcessHostFactory rph_factory_;
TestRenderViewHostFactory rvh_factory_;
+ private:
scoped_ptr<TestTabContents> contents_;
DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness);
diff --git a/content/browser/webui/web_ui_unittest.cc b/content/browser/webui/web_ui_unittest.cc
index bbb7ab1..b81f3a8 100644
--- a/content/browser/webui/web_ui_unittest.cc
+++ b/content/browser/webui/web_ui_unittest.cc
@@ -166,8 +166,7 @@ TEST_F(WebUITest, FocusOnNavigate) {
contents()->profile(),
SiteInstance::CreateSiteInstance(contents()->profile()));
tc->controller().CopyStateFrom(controller());
- scoped_ptr<TestTabContents> tc_scoped_ptr(tc);
- contents_.swap(tc_scoped_ptr);
+ SetContents(tc);
int page_id = 200;
// Load the NTP.
@@ -194,6 +193,4 @@ TEST_F(WebUITest, FocusOnNavigate) {
controller().GoForward();
pending_rvh()->SendNavigate(next_page_id, next_url);
EXPECT_EQ(focus_called, tc->focus_called());
-
- contents_.swap(tc_scoped_ptr);
}