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

Side by Side Diff: chrome/test/browser_with_test_window_test.cc

Issue 100031: Write a test for my previous patch to fix a crash in back/forward navigations... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/browser_with_test_window_test.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/browser_with_test_window_test.h" 5 #include "chrome/test/browser_with_test_window_test.h"
6 6
7 #include "chrome/browser/browser.h" 7 #include "chrome/browser/browser.h"
8 #include "chrome/browser/tab_contents/navigation_entry.h"
8 #include "chrome/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
9 #include "chrome/test/test_browser_window.h" 10 #include "chrome/test/test_browser_window.h"
10 #include "chrome/test/testing_profile.h" 11 #include "chrome/test/testing_profile.h"
11 12
12 BrowserWithTestWindowTest::BrowserWithTestWindowTest() 13 BrowserWithTestWindowTest::BrowserWithTestWindowTest()
13 : rph_factory_(), 14 : rph_factory_(),
14 rvh_factory_(&rph_factory_) { 15 rvh_factory_(&rph_factory_) {
15 OleInitialize(NULL); 16 OleInitialize(NULL);
16 } 17 }
17 18
(...skipping 26 matching lines...) Expand all
44 TestRenderViewHost* BrowserWithTestWindowTest::TestRenderViewHostForTab( 45 TestRenderViewHost* BrowserWithTestWindowTest::TestRenderViewHostForTab(
45 TabContents* tab_contents) { 46 TabContents* tab_contents) {
46 return static_cast<TestRenderViewHost*>( 47 return static_cast<TestRenderViewHost*>(
47 tab_contents->AsWebContents()->render_view_host()); 48 tab_contents->AsWebContents()->render_view_host());
48 } 49 }
49 50
50 void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) { 51 void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) {
51 TabContents* new_tab = browser->AddTabWithURL(url, GURL(), 52 TabContents* new_tab = browser->AddTabWithURL(url, GURL(),
52 PageTransition::TYPED, true, 53 PageTransition::TYPED, true,
53 0, NULL); 54 0, NULL);
54 CommitPendingLoadAsNewNavigation(&new_tab->controller(), url); 55 CommitPendingLoad(&new_tab->controller());
55 } 56 }
56 57
57 void BrowserWithTestWindowTest::CommitPendingLoadAsNewNavigation( 58 void BrowserWithTestWindowTest::CommitPendingLoad(
58 NavigationController* controller, 59 NavigationController* controller) {
59 const GURL& url) { 60 if (!controller->pending_entry())
61 return; // Nothing to commit.
62
60 TestRenderViewHost* test_rvh = 63 TestRenderViewHost* test_rvh =
61 TestRenderViewHostForTab(controller->tab_contents()); 64 TestRenderViewHostForTab(controller->tab_contents());
62 MockRenderProcessHost* mock_rph = static_cast<MockRenderProcessHost*>( 65 MockRenderProcessHost* mock_rph = static_cast<MockRenderProcessHost*>(
63 test_rvh->process()); 66 test_rvh->process());
64 67
65 test_rvh->SendNavigate(mock_rph->max_page_id() + 1, url); 68 // For new navigations, we need to send a larger page ID. For renavigations,
69 // we need to send the preexisting page ID. We can tell these apart because
70 // renavigations will have a pending_entry_index while new ones won't (they'll
71 // just have a standalong pending_entry that isn't in the list already).
72 if (controller->pending_entry_index() >= 0) {
73 test_rvh->SendNavigate(controller->pending_entry()->page_id(),
74 controller->pending_entry()->url());
75 } else {
76 test_rvh->SendNavigate(mock_rph->max_page_id() + 1,
77 controller->pending_entry()->url());
78 }
66 } 79 }
67 80
68 void BrowserWithTestWindowTest::NavigateAndCommit( 81 void BrowserWithTestWindowTest::NavigateAndCommit(
69 NavigationController* controller, 82 NavigationController* controller,
70 const GURL& url) { 83 const GURL& url) {
71 controller->LoadURL(url, GURL(), 0); 84 controller->LoadURL(url, GURL(), 0);
72 CommitPendingLoadAsNewNavigation(controller, url); 85 CommitPendingLoad(controller);
73 } 86 }
74 87
75 void BrowserWithTestWindowTest::NavigateAndCommitActiveTab(const GURL& url) { 88 void BrowserWithTestWindowTest::NavigateAndCommitActiveTab(const GURL& url) {
76 NavigateAndCommit(&browser()->GetSelectedTabContents()->controller(), url); 89 NavigateAndCommit(&browser()->GetSelectedTabContents()->controller(), url);
77 } 90 }
OLDNEW
« no previous file with comments | « chrome/test/browser_with_test_window_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698