OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
11 #include "content/browser/renderer_host/render_view_host.h" | 11 #include "content/browser/renderer_host/render_view_host.h" |
12 #include "content/browser/renderer_host/test_render_view_host.h" | 12 #include "content/browser/renderer_host/test_render_view_host.h" |
13 #include "content/browser/site_instance.h" | 13 #include "content/browser/site_instance.h" |
14 #include "content/common/page_transition_types.h" | 14 #include "content/common/page_transition_types.h" |
15 | 15 |
16 TestTabContents::TestTabContents(content::BrowserContext* browser_context, | 16 TestTabContents::TestTabContents(content::BrowserContext* browser_context, |
17 SiteInstance* instance) | 17 SiteInstance* instance) |
18 : TabContents(browser_context, instance, MSG_ROUTING_NONE, NULL, NULL), | 18 : TabContents(browser_context, instance, MSG_ROUTING_NONE, NULL, NULL), |
19 transition_cross_site(false), | 19 transition_cross_site(false), |
20 delegate_view_override_(NULL) { | 20 delegate_view_override_(NULL), |
| 21 expect_set_history_length_and_prune_(false), |
| 22 expect_set_history_length_and_prune_site_instance_(NULL), |
| 23 expect_set_history_length_and_prune_history_length_(0), |
| 24 expect_set_history_length_and_prune_min_page_id_(-1) { |
| 25 } |
| 26 |
| 27 TestTabContents::~TestTabContents() { |
21 } | 28 } |
22 | 29 |
23 TestRenderViewHost* TestTabContents::pending_rvh() const { | 30 TestRenderViewHost* TestTabContents::pending_rvh() const { |
24 return static_cast<TestRenderViewHost*>( | 31 return static_cast<TestRenderViewHost*>( |
25 render_manager_.pending_render_view_host_); | 32 render_manager_.pending_render_view_host_); |
26 } | 33 } |
27 | 34 |
28 bool TestTabContents::CreateRenderViewForRenderManager( | 35 bool TestTabContents::CreateRenderViewForRenderManager( |
29 RenderViewHost* render_view_host) { | 36 RenderViewHost* render_view_host) { |
30 // This will go to a TestRenderViewHost. | 37 // This will go to a TestRenderViewHost. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 TestRenderViewHost* rvh = static_cast<TestRenderViewHost*>( | 90 TestRenderViewHost* rvh = static_cast<TestRenderViewHost*>( |
84 render_manager_.current_host()); | 91 render_manager_.current_host()); |
85 rvh->SendShouldCloseACK(true); | 92 rvh->SendShouldCloseACK(true); |
86 } | 93 } |
87 | 94 |
88 RenderViewHostDelegate::View* TestTabContents::GetViewDelegate() { | 95 RenderViewHostDelegate::View* TestTabContents::GetViewDelegate() { |
89 if (delegate_view_override_) | 96 if (delegate_view_override_) |
90 return delegate_view_override_; | 97 return delegate_view_override_; |
91 return TabContents::GetViewDelegate(); | 98 return TabContents::GetViewDelegate(); |
92 } | 99 } |
| 100 |
| 101 void TestTabContents::ExpectSetHistoryLengthAndPrune( |
| 102 const SiteInstance* site_instance, |
| 103 int history_length, |
| 104 int32 min_page_id) { |
| 105 expect_set_history_length_and_prune_ = true; |
| 106 expect_set_history_length_and_prune_site_instance_ = site_instance; |
| 107 expect_set_history_length_and_prune_history_length_ = history_length; |
| 108 expect_set_history_length_and_prune_min_page_id_ = min_page_id; |
| 109 } |
| 110 |
| 111 void TestTabContents::SetHistoryLengthAndPrune( |
| 112 const SiteInstance* site_instance, int history_length, int32 min_page_id) { |
| 113 EXPECT_TRUE(expect_set_history_length_and_prune_); |
| 114 expect_set_history_length_and_prune_ = false; |
| 115 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); |
| 116 EXPECT_EQ(expect_set_history_length_and_prune_history_length_, |
| 117 history_length); |
| 118 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id); |
| 119 } |
OLD | NEW |