Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1373)

Unified Diff: chrome/test/base/browser_with_test_window_test.cc

Issue 9645003: Introduce abstractions to allow embedders to test RenderViewHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/base/browser_with_test_window_test.cc
diff --git a/chrome/test/base/browser_with_test_window_test.cc b/chrome/test/base/browser_with_test_window_test.cc
index 1595939253305e80438980a9623df4a425f06477..209f884a12d005f315ba4d4ba72363ff5ddce008 100644
--- a/chrome/test/base/browser_with_test_window_test.cc
+++ b/chrome/test/base/browser_with_test_window_test.cc
@@ -17,6 +17,7 @@
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/page_transition_types.h"
+#include "content/test/test_renderer_host.h"
#if defined(USE_AURA)
#include "ui/aura/root_window.h"
@@ -26,16 +27,15 @@
using content::BrowserThread;
using content::NavigationController;
-using content::TestRenderViewHost;
+using content::RenderViewHost;
+using content::RenderViewHostTester;
using content::WebContents;
BrowserWithTestWindowTest::BrowserWithTestWindowTest()
: ui_thread_(BrowserThread::UI, message_loop()),
file_thread_(BrowserThread::FILE, message_loop()),
file_user_blocking_thread_(
- BrowserThread::FILE_USER_BLOCKING, message_loop()),
- rph_factory_(),
- rvh_factory_(&rph_factory_) {
+ BrowserThread::FILE_USER_BLOCKING, message_loop()) {
#if defined(OS_WIN)
OleInitialize(NULL);
#endif
@@ -80,11 +80,6 @@ BrowserWithTestWindowTest::~BrowserWithTestWindowTest() {
#endif
}
-TestRenderViewHost* BrowserWithTestWindowTest::TestRenderViewHostForTab(
- WebContents* web_contents) {
- return static_cast<TestRenderViewHost*>(web_contents->GetRenderViewHost());
-}
-
void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) {
browser::NavigateParams params(browser, url, content::PAGE_TRANSITION_TYPED);
params.tabstrip_index = 0;
@@ -98,41 +93,40 @@ void BrowserWithTestWindowTest::CommitPendingLoad(
if (!controller->GetPendingEntry())
return; // Nothing to commit.
- TestRenderViewHost* old_rvh =
- TestRenderViewHostForTab(controller->GetWebContents());
+ RenderViewHost* old_rvh =
+ controller->GetWebContents()->GetRenderViewHost();
- TestRenderViewHost* pending_rvh = TestRenderViewHost::GetPendingForController(
+ RenderViewHost* pending_rvh = RenderViewHostTester::GetPendingForController(
controller);
if (pending_rvh) {
// Simulate the ShouldClose_ACK that is received from the current renderer
// for a cross-site navigation.
DCHECK_NE(old_rvh, pending_rvh);
- old_rvh->SendShouldCloseACK(true);
+ RenderViewHostTester::For(old_rvh)->SendShouldCloseACK(true);
}
// Commit on the pending_rvh, if one exists.
- TestRenderViewHost* test_rvh = pending_rvh ? pending_rvh : old_rvh;
+ RenderViewHost* test_rvh = pending_rvh ? pending_rvh : old_rvh;
+ RenderViewHostTester* test_rvh_tester = RenderViewHostTester::For(test_rvh);
// For new navigations, we need to send a larger page ID. For renavigations,
// we need to send the preexisting page ID. We can tell these apart because
// renavigations will have a pending_entry_index while new ones won't (they'll
// just have a standalong pending_entry that isn't in the list already).
if (controller->GetPendingEntryIndex() >= 0) {
- test_rvh->SendNavigateWithTransition(
+ test_rvh_tester->SendNavigateWithTransition(
controller->GetPendingEntry()->GetPageID(),
controller->GetPendingEntry()->GetURL(),
controller->GetPendingEntry()->GetTransitionType());
} else {
- test_rvh->SendNavigateWithTransition(
+ test_rvh_tester->SendNavigateWithTransition(
controller->GetWebContents()->
GetMaxPageIDForSiteInstance(test_rvh->GetSiteInstance()) + 1,
controller->GetPendingEntry()->GetURL(),
controller->GetPendingEntry()->GetTransitionType());
}
- // Simulate the SwapOut_ACK that fires if you commit a cross-site navigation
- // without making any network requests.
if (pending_rvh)
- old_rvh->OnSwapOutACK();
+ RenderViewHostTester::For(old_rvh)->SimulateSwapOutACK();
}
void BrowserWithTestWindowTest::NavigateAndCommit(
« no previous file with comments | « chrome/test/base/browser_with_test_window_test.h ('k') | chrome/test/base/chrome_render_view_host_test_harness.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698