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