summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-10 19:31:40 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-10 19:31:40 +0000
commit0683cf6f68e994804058a11528a876d4b767e7d4 (patch)
tree7d3b8957221758bfaa87dc56c80a41d1f63b778d
parent358fbd5f2ff4bcd94d262fdf6d8d8df3bed220b2 (diff)
downloadchromium_src-0683cf6f68e994804058a11528a876d4b767e7d4.zip
chromium_src-0683cf6f68e994804058a11528a876d4b767e7d4.tar.gz
chromium_src-0683cf6f68e994804058a11528a876d4b767e7d4.tar.bz2
Remove auto commit from TestTabContents. This is the thing preventing me from
replacing it with WebContents. Fortunately, only one test was affected. Review URL: http://codereview.chromium.org/66003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13527 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_commands_unittest.cc6
-rw-r--r--chrome/test/browser_with_test_window_test.cc26
-rw-r--r--chrome/test/browser_with_test_window_test.h14
-rw-r--r--chrome/test/test_tab_contents.cc19
-rw-r--r--chrome/test/test_tab_contents.h15
5 files changed, 41 insertions, 39 deletions
diff --git a/chrome/browser/browser_commands_unittest.cc b/chrome/browser/browser_commands_unittest.cc
index 9916d05..e30bf44 100644
--- a/chrome/browser/browser_commands_unittest.cc
+++ b/chrome/browser/browser_commands_unittest.cc
@@ -49,9 +49,9 @@ TEST_F(BrowserCommandsTest, DuplicateTab) {
// Navigate to the three urls, then go back.
AddTestingTab(browser());
- browser()->OpenURL(url1, GURL(), CURRENT_TAB, PageTransition::TYPED);
- browser()->OpenURL(url2, GURL(), CURRENT_TAB, PageTransition::TYPED);
- browser()->OpenURL(url3, GURL(), CURRENT_TAB, PageTransition::TYPED);
+ NavigateAndCommitActiveTab(url1);
+ NavigateAndCommitActiveTab(url2);
+ NavigateAndCommitActiveTab(url3);
size_t initial_window_count = BrowserList::size();
diff --git a/chrome/test/browser_with_test_window_test.cc b/chrome/test/browser_with_test_window_test.cc
index 35b3dafc..3c2e879 100644
--- a/chrome/test/browser_with_test_window_test.cc
+++ b/chrome/test/browser_with_test_window_test.cc
@@ -5,6 +5,7 @@
#include "chrome/test/browser_with_test_window_test.h"
#include "chrome/browser/browser.h"
+#include "chrome/common/render_messages.h"
#include "chrome/test/test_browser_window.h"
#include "chrome/test/testing_profile.h"
@@ -43,8 +44,31 @@ BrowserWithTestWindowTest::~BrowserWithTestWindowTest() {
void BrowserWithTestWindowTest::AddTestingTab(Browser* browser) {
TestTabContents* tab_contents = tab_contents_factory_->CreateInstanceImpl();
- tab_contents->set_commit_on_navigate(true);
tab_contents->SetupController(profile());
browser->tabstrip_model()->AddTabContents(
tab_contents, 0, PageTransition::TYPED, true);
}
+
+void BrowserWithTestWindowTest::NavigateAndCommit(
+ NavigationController* controller,
+ const GURL& url) {
+ controller->LoadURL(url, GURL(), 0);
+
+ // Commit the load.
+ // TODO(brettw) once this uses TestRenderViewHost, we should call SendNavigate
+ // on it instead of doing this stuff.
+ ViewHostMsg_FrameNavigate_Params params;
+ params.page_id = reinterpret_cast<TestTabContents*>(
+ controller->tab_contents())->GetNextPageID();
+ params.url = url;
+ params.transition = PageTransition::LINK;
+ params.should_update_history = false;
+ params.gesture = NavigationGestureUser;
+ params.is_post = false;
+ NavigationController::LoadCommittedDetails details;
+ controller->RendererDidNavigate(params, &details);
+}
+
+void BrowserWithTestWindowTest::NavigateAndCommitActiveTab(const GURL& url) {
+ NavigateAndCommit(browser()->GetSelectedTabContents()->controller(), url);
+}
diff --git a/chrome/test/browser_with_test_window_test.h b/chrome/test/browser_with_test_window_test.h
index 7790cf4..dfcb520 100644
--- a/chrome/test/browser_with_test_window_test.h
+++ b/chrome/test/browser_with_test_window_test.h
@@ -41,10 +41,6 @@ class BrowserWithTestWindowTest : public testing::Test {
TestingProfile* profile() const { return profile_.get(); }
- TestTabContentsFactory* tab_contents_factory() const {
- return tab_contents_factory_.get();
- }
-
// Adds a tab to |browser| whose TabContents comes from a
// TestTabContentsFactory. Use test_url_with_path to obtain a URL that
// that uses the newly created TabContents.
@@ -56,6 +52,16 @@ class BrowserWithTestWindowTest : public testing::Test {
return tab_contents_factory_->test_url_with_path(path);
}
+ // Creates a pending navigation on the given navigation controller to the
+ // given URL 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(NavigationController* controller,
+ const GURL& url);
+
+ // Navigates the current tab. This is a wrapper around NavigateAndCommit.
+ void NavigateAndCommitActiveTab(const GURL& url);
+
private:
// We need to create a MessageLoop, otherwise a bunch of things fails.
MessageLoopForUI ui_loop_;
diff --git a/chrome/test/test_tab_contents.cc b/chrome/test/test_tab_contents.cc
index 1ee16fb..92bec46 100644
--- a/chrome/test/test_tab_contents.cc
+++ b/chrome/test/test_tab_contents.cc
@@ -12,28 +12,9 @@ SiteInstance* TestTabContents::site_instance_ = NULL;
TestTabContents::TestTabContents(TabContentsType type)
: TabContents(type),
- commit_on_navigate_(false),
next_page_id_(1) {
}
bool TestTabContents::NavigateToPendingEntry(bool reload) {
- if (commit_on_navigate_) {
- CompleteNavigationAsRenderer(next_page_id_++,
- controller()->GetPendingEntry()->url());
- }
return true;
}
-
-void TestTabContents::CompleteNavigationAsRenderer(int page_id,
- const GURL& url) {
- ViewHostMsg_FrameNavigate_Params params;
- params.page_id = page_id;
- params.url = url;
- params.transition = PageTransition::LINK;
- params.should_update_history = false;
- params.gesture = NavigationGestureUser;
- params.is_post = false;
-
- NavigationController::LoadCommittedDetails details;
- controller()->RendererDidNavigate(params, &details);
-}
diff --git a/chrome/test/test_tab_contents.h b/chrome/test/test_tab_contents.h
index 421bec7..91d3114 100644
--- a/chrome/test/test_tab_contents.h
+++ b/chrome/test/test_tab_contents.h
@@ -19,10 +19,8 @@ class TestTabContents : public TabContents {
site_instance_ = site_instance;
}
- // Sets whether we commit the load on NavigateToPendingEntry. The default is
- // false.
- void set_commit_on_navigate(bool commit_on_navigate) {
- commit_on_navigate_ = commit_on_navigate;
+ int GetNextPageID() {
+ return next_page_id_++;
}
// Overridden from TabContents so we can provide a non-NULL site instance in
@@ -32,19 +30,12 @@ class TestTabContents : public TabContents {
return site_instance_;
}
- // Does one of two things. If |commit_on_navigate| is true the navigation is
- // committed immediately. Otherwise this returns true and you must invoke
- // CompleteNavigationAsRenderer when you want to commit the load.
+ // Overrides to be more like WebContents (don't autocommit).
virtual bool NavigateToPendingEntry(bool reload);
- // Sets up a call to RendererDidNavigate pretending to be a main frame
- // navigation to the given URL.
- void CompleteNavigationAsRenderer(int page_id, const GURL& url);
-
private:
static SiteInstance* site_instance_;
- bool commit_on_navigate_;
int next_page_id_;
DISALLOW_COPY_AND_ASSIGN(TestTabContents);