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/view_messages.h" |
14 #include "content/public/common/page_transition_types.h" | 15 #include "content/public/common/page_transition_types.h" |
| 16 #include "webkit/glue/password_form.h" |
| 17 #include "webkit/glue/webkit_glue.h" |
15 | 18 |
16 TestTabContents::TestTabContents(content::BrowserContext* browser_context, | 19 TestTabContents::TestTabContents(content::BrowserContext* browser_context, |
17 SiteInstance* instance) | 20 SiteInstance* instance) |
18 : TabContents(browser_context, instance, MSG_ROUTING_NONE, NULL, NULL), | 21 : TabContents(browser_context, instance, MSG_ROUTING_NONE, NULL, NULL), |
19 transition_cross_site(false), | 22 transition_cross_site(false), |
20 delegate_view_override_(NULL), | 23 delegate_view_override_(NULL), |
21 expect_set_history_length_and_prune_(false), | 24 expect_set_history_length_and_prune_(false), |
22 expect_set_history_length_and_prune_site_instance_(NULL), | 25 expect_set_history_length_and_prune_site_instance_(NULL), |
23 expect_set_history_length_and_prune_history_length_(0), | 26 expect_set_history_length_and_prune_history_length_(0), |
24 expect_set_history_length_and_prune_min_page_id_(-1) { | 27 expect_set_history_length_and_prune_min_page_id_(-1) { |
25 } | 28 } |
26 | 29 |
27 TestTabContents::~TestTabContents() { | 30 TestTabContents::~TestTabContents() { |
28 } | 31 } |
29 | 32 |
30 TestRenderViewHost* TestTabContents::pending_rvh() const { | 33 TestRenderViewHost* TestTabContents::pending_rvh() const { |
31 return static_cast<TestRenderViewHost*>( | 34 return static_cast<TestRenderViewHost*>( |
32 render_manager_.pending_render_view_host_); | 35 render_manager_.pending_render_view_host_); |
33 } | 36 } |
34 | 37 |
| 38 void TestTabContents::TestDidNavigate(RenderViewHost* render_view_host, |
| 39 int page_id, |
| 40 const GURL& url, |
| 41 content::PageTransition transition) { |
| 42 TestDidNavigateWithReferrer(render_view_host, |
| 43 page_id, |
| 44 url, |
| 45 content::Referrer(), |
| 46 transition); |
| 47 } |
| 48 |
| 49 void TestTabContents::TestDidNavigateWithReferrer( |
| 50 RenderViewHost* render_view_host, |
| 51 int page_id, |
| 52 const GURL& url, |
| 53 const content::Referrer& referrer, |
| 54 content::PageTransition transition) { |
| 55 ViewHostMsg_FrameNavigate_Params params; |
| 56 |
| 57 params.page_id = page_id; |
| 58 params.url = url; |
| 59 params.referrer = referrer; |
| 60 params.transition = transition; |
| 61 params.redirects = std::vector<GURL>(); |
| 62 params.should_update_history = false; |
| 63 params.searchable_form_url = GURL(); |
| 64 params.searchable_form_encoding = std::string(); |
| 65 params.password_form = webkit_glue::PasswordForm(); |
| 66 params.security_info = std::string(); |
| 67 params.gesture = NavigationGestureUser; |
| 68 params.was_within_same_page = false; |
| 69 params.is_post = false; |
| 70 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); |
| 71 |
| 72 DidNavigate(render_view_host, params); |
| 73 } |
| 74 |
35 bool TestTabContents::CreateRenderViewForRenderManager( | 75 bool TestTabContents::CreateRenderViewForRenderManager( |
36 RenderViewHost* render_view_host) { | 76 RenderViewHost* render_view_host) { |
37 // This will go to a TestRenderViewHost. | 77 // This will go to a TestRenderViewHost. |
38 render_view_host->CreateRenderView(string16()); | 78 render_view_host->CreateRenderView(string16()); |
39 return true; | 79 return true; |
40 } | 80 } |
41 | 81 |
42 TabContents* TestTabContents::Clone() { | 82 TabContents* TestTabContents::Clone() { |
43 TabContents* tc = new TestTabContents( | 83 TabContents* tc = new TestTabContents( |
44 browser_context(), SiteInstance::CreateSiteInstance(browser_context())); | 84 browser_context(), SiteInstance::CreateSiteInstance(browser_context())); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 151 |
112 void TestTabContents::SetHistoryLengthAndPrune( | 152 void TestTabContents::SetHistoryLengthAndPrune( |
113 const SiteInstance* site_instance, int history_length, int32 min_page_id) { | 153 const SiteInstance* site_instance, int history_length, int32 min_page_id) { |
114 EXPECT_TRUE(expect_set_history_length_and_prune_); | 154 EXPECT_TRUE(expect_set_history_length_and_prune_); |
115 expect_set_history_length_and_prune_ = false; | 155 expect_set_history_length_and_prune_ = false; |
116 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); | 156 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); |
117 EXPECT_EQ(expect_set_history_length_and_prune_history_length_, | 157 EXPECT_EQ(expect_set_history_length_and_prune_history_length_, |
118 history_length); | 158 history_length); |
119 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id); | 159 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id); |
120 } | 160 } |
OLD | NEW |