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

Side by Side Diff: content/browser/tab_contents/test_tab_contents.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/tab_contents/test_tab_contents.h ('k') | content/content_tests.gypi » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/tab_contents/test_tab_contents.h" 5 #include "content/browser/tab_contents/test_tab_contents.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "content/browser/browser_url_handler.h" 9 #include "content/browser/browser_url_handler.h"
10 #include "content/browser/renderer_host/mock_render_process_host.h" 10 #include "content/browser/renderer_host/mock_render_process_host.h"
(...skipping 20 matching lines...) Expand all
31 delegate_view_override_(NULL), 31 delegate_view_override_(NULL),
32 expect_set_history_length_and_prune_(false), 32 expect_set_history_length_and_prune_(false),
33 expect_set_history_length_and_prune_site_instance_(NULL), 33 expect_set_history_length_and_prune_site_instance_(NULL),
34 expect_set_history_length_and_prune_history_length_(0), 34 expect_set_history_length_and_prune_history_length_(0),
35 expect_set_history_length_and_prune_min_page_id_(-1) { 35 expect_set_history_length_and_prune_min_page_id_(-1) {
36 } 36 }
37 37
38 TestTabContents::~TestTabContents() { 38 TestTabContents::~TestTabContents() {
39 } 39 }
40 40
41 TestRenderViewHost* TestTabContents::pending_rvh() const { 41 RenderViewHost* TestTabContents::pending_rvh() const {
42 return static_cast<TestRenderViewHost*>( 42 return render_manager_.pending_render_view_host_;
43 render_manager_.pending_render_view_host_); 43 }
44
45 TestRenderViewHost* TestTabContents::pending_test_rvh() const {
46 return static_cast<TestRenderViewHost*>(pending_rvh());
44 } 47 }
45 48
46 void TestTabContents::TestDidNavigate(RenderViewHost* render_view_host, 49 void TestTabContents::TestDidNavigate(RenderViewHost* render_view_host,
47 int page_id, 50 int page_id,
48 const GURL& url, 51 const GURL& url,
49 content::PageTransition transition) { 52 content::PageTransition transition) {
50 TestDidNavigateWithReferrer(render_view_host, 53 TestDidNavigateWithReferrer(render_view_host,
51 page_id, 54 page_id,
52 url, 55 url,
53 content::Referrer(), 56 content::Referrer(),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // a notification that it actually navigated. 111 // a notification that it actually navigated.
109 CommitPendingNavigation(); 112 CommitPendingNavigation();
110 } 113 }
111 114
112 void TestTabContents::CommitPendingNavigation() { 115 void TestTabContents::CommitPendingNavigation() {
113 // If we are doing a cross-site navigation, this simulates the current RVH 116 // If we are doing a cross-site navigation, this simulates the current RVH
114 // notifying that it has unloaded so the pending RVH is resumed and can 117 // notifying that it has unloaded so the pending RVH is resumed and can
115 // navigate. 118 // navigate.
116 ProceedWithCrossSiteNavigation(); 119 ProceedWithCrossSiteNavigation();
117 RenderViewHost* old_rvh = render_manager_.current_host(); 120 RenderViewHost* old_rvh = render_manager_.current_host();
118 TestRenderViewHost* rvh = pending_rvh(); 121 TestRenderViewHost* rvh = static_cast<TestRenderViewHost*>(pending_rvh());
119 if (!rvh) 122 if (!rvh)
120 rvh = static_cast<TestRenderViewHost*>(old_rvh); 123 rvh = static_cast<TestRenderViewHost*>(old_rvh);
121 124
122 const NavigationEntry* entry = GetController().GetPendingEntry(); 125 const NavigationEntry* entry = GetController().GetPendingEntry();
123 DCHECK(entry); 126 DCHECK(entry);
124 int page_id = entry->GetPageID(); 127 int page_id = entry->GetPageID();
125 if (page_id == -1) { 128 if (page_id == -1) {
126 // It's a new navigation, assign a never-seen page id to it. 129 // It's a new navigation, assign a never-seen page id to it.
127 page_id = GetMaxPageIDForSiteInstance(rvh->GetSiteInstance()) + 1; 130 page_id = GetMaxPageIDForSiteInstance(rvh->GetSiteInstance()) + 1;
128 } 131 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 void TestTabContents::SetHistoryLengthAndPrune( 165 void TestTabContents::SetHistoryLengthAndPrune(
163 const SiteInstance* site_instance, int history_length, 166 const SiteInstance* site_instance, int history_length,
164 int32 min_page_id) { 167 int32 min_page_id) {
165 EXPECT_TRUE(expect_set_history_length_and_prune_); 168 EXPECT_TRUE(expect_set_history_length_and_prune_);
166 expect_set_history_length_and_prune_ = false; 169 expect_set_history_length_and_prune_ = false;
167 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); 170 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance);
168 EXPECT_EQ(expect_set_history_length_and_prune_history_length_, 171 EXPECT_EQ(expect_set_history_length_and_prune_history_length_,
169 history_length); 172 history_length);
170 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id); 173 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id);
171 } 174 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/test_tab_contents.h ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698