| 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/browser/tab_contents/navigation_entry.h" | 14 #include "content/browser/tab_contents/navigation_entry_impl.h" |
| 15 #include "content/common/view_messages.h" | 15 #include "content/common/view_messages.h" |
| 16 #include "content/public/common/page_transition_types.h" | 16 #include "content/public/common/page_transition_types.h" |
| 17 #include "webkit/glue/webkit_glue.h" | 17 #include "webkit/glue/webkit_glue.h" |
| 18 #include "webkit/forms/password_form.h" | 18 #include "webkit/forms/password_form.h" |
| 19 | 19 |
| 20 using content::NavigationEntry; |
| 21 |
| 20 TestTabContents::TestTabContents(content::BrowserContext* browser_context, | 22 TestTabContents::TestTabContents(content::BrowserContext* browser_context, |
| 21 SiteInstance* instance) | 23 SiteInstance* instance) |
| 22 : TabContents(browser_context, instance, MSG_ROUTING_NONE, NULL, NULL), | 24 : TabContents(browser_context, instance, MSG_ROUTING_NONE, NULL, NULL), |
| 23 transition_cross_site(false), | 25 transition_cross_site(false), |
| 24 delegate_view_override_(NULL), | 26 delegate_view_override_(NULL), |
| 25 expect_set_history_length_and_prune_(false), | 27 expect_set_history_length_and_prune_(false), |
| 26 expect_set_history_length_and_prune_site_instance_(NULL), | 28 expect_set_history_length_and_prune_site_instance_(NULL), |
| 27 expect_set_history_length_and_prune_history_length_(0), | 29 expect_set_history_length_and_prune_history_length_(0), |
| 28 expect_set_history_length_and_prune_min_page_id_(-1) { | 30 expect_set_history_length_and_prune_min_page_id_(-1) { |
| 29 } | 31 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 void TestTabContents::CommitPendingNavigation() { | 106 void TestTabContents::CommitPendingNavigation() { |
| 105 // If we are doing a cross-site navigation, this simulates the current RVH | 107 // If we are doing a cross-site navigation, this simulates the current RVH |
| 106 // notifying that it has unloaded so the pending RVH is resumed and can | 108 // notifying that it has unloaded so the pending RVH is resumed and can |
| 107 // navigate. | 109 // navigate. |
| 108 ProceedWithCrossSiteNavigation(); | 110 ProceedWithCrossSiteNavigation(); |
| 109 RenderViewHost* old_rvh = render_manager_.current_host(); | 111 RenderViewHost* old_rvh = render_manager_.current_host(); |
| 110 TestRenderViewHost* rvh = pending_rvh(); | 112 TestRenderViewHost* rvh = pending_rvh(); |
| 111 if (!rvh) | 113 if (!rvh) |
| 112 rvh = static_cast<TestRenderViewHost*>(old_rvh); | 114 rvh = static_cast<TestRenderViewHost*>(old_rvh); |
| 113 | 115 |
| 114 const content::NavigationEntry* entry = GetController().GetPendingEntry(); | 116 const NavigationEntry* entry = GetController().GetPendingEntry(); |
| 115 DCHECK(entry); | 117 DCHECK(entry); |
| 116 int page_id = entry->GetPageID(); | 118 int page_id = entry->GetPageID(); |
| 117 if (page_id == -1) { | 119 if (page_id == -1) { |
| 118 // It's a new navigation, assign a never-seen page id to it. | 120 // It's a new navigation, assign a never-seen page id to it. |
| 119 page_id = GetMaxPageIDForSiteInstance(rvh->site_instance()) + 1; | 121 page_id = GetMaxPageIDForSiteInstance(rvh->site_instance()) + 1; |
| 120 } | 122 } |
| 121 rvh->SendNavigate(page_id, entry->GetURL()); | 123 rvh->SendNavigate(page_id, entry->GetURL()); |
| 122 | 124 |
| 123 // Simulate the SwapOut_ACK that fires if you commit a cross-site navigation | 125 // Simulate the SwapOut_ACK that fires if you commit a cross-site navigation |
| 124 // without making any network requests. | 126 // without making any network requests. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 152 | 154 |
| 153 void TestTabContents::SetHistoryLengthAndPrune( | 155 void TestTabContents::SetHistoryLengthAndPrune( |
| 154 const SiteInstance* site_instance, int history_length, int32 min_page_id) { | 156 const SiteInstance* site_instance, int history_length, int32 min_page_id) { |
| 155 EXPECT_TRUE(expect_set_history_length_and_prune_); | 157 EXPECT_TRUE(expect_set_history_length_and_prune_); |
| 156 expect_set_history_length_and_prune_ = false; | 158 expect_set_history_length_and_prune_ = false; |
| 157 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); | 159 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); |
| 158 EXPECT_EQ(expect_set_history_length_and_prune_history_length_, | 160 EXPECT_EQ(expect_set_history_length_and_prune_history_length_, |
| 159 history_length); | 161 history_length); |
| 160 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id); | 162 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id); |
| 161 } | 163 } |
| OLD | NEW |