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" | |
15 #include "content/public/common/page_transition_types.h" | 14 #include "content/public/common/page_transition_types.h" |
16 #include "webkit/glue/password_form.h" | |
17 #include "webkit/glue/webkit_glue.h" | |
18 | 15 |
19 TestTabContents::TestTabContents(content::BrowserContext* browser_context, | 16 TestTabContents::TestTabContents(content::BrowserContext* browser_context, |
20 SiteInstance* instance) | 17 SiteInstance* instance) |
21 : TabContents(browser_context, instance, MSG_ROUTING_NONE, NULL, NULL), | 18 : TabContents(browser_context, instance, MSG_ROUTING_NONE, NULL, NULL), |
22 transition_cross_site(false), | 19 transition_cross_site(false), |
23 delegate_view_override_(NULL), | 20 delegate_view_override_(NULL), |
24 expect_set_history_length_and_prune_(false), | 21 expect_set_history_length_and_prune_(false), |
25 expect_set_history_length_and_prune_site_instance_(NULL), | 22 expect_set_history_length_and_prune_site_instance_(NULL), |
26 expect_set_history_length_and_prune_history_length_(0), | 23 expect_set_history_length_and_prune_history_length_(0), |
27 expect_set_history_length_and_prune_min_page_id_(-1) { | 24 expect_set_history_length_and_prune_min_page_id_(-1) { |
28 } | 25 } |
29 | 26 |
30 TestTabContents::~TestTabContents() { | 27 TestTabContents::~TestTabContents() { |
31 } | 28 } |
32 | 29 |
33 TestRenderViewHost* TestTabContents::pending_rvh() const { | 30 TestRenderViewHost* TestTabContents::pending_rvh() const { |
34 return static_cast<TestRenderViewHost*>( | 31 return static_cast<TestRenderViewHost*>( |
35 render_manager_.pending_render_view_host_); | 32 render_manager_.pending_render_view_host_); |
36 } | 33 } |
37 | 34 |
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 | |
75 bool TestTabContents::CreateRenderViewForRenderManager( | 35 bool TestTabContents::CreateRenderViewForRenderManager( |
76 RenderViewHost* render_view_host) { | 36 RenderViewHost* render_view_host) { |
77 // This will go to a TestRenderViewHost. | 37 // This will go to a TestRenderViewHost. |
78 render_view_host->CreateRenderView(string16()); | 38 render_view_host->CreateRenderView(string16()); |
79 return true; | 39 return true; |
80 } | 40 } |
81 | 41 |
82 TabContents* TestTabContents::Clone() { | 42 TabContents* TestTabContents::Clone() { |
83 TabContents* tc = new TestTabContents( | 43 TabContents* tc = new TestTabContents( |
84 browser_context(), SiteInstance::CreateSiteInstance(browser_context())); | 44 browser_context(), SiteInstance::CreateSiteInstance(browser_context())); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 111 |
152 void TestTabContents::SetHistoryLengthAndPrune( | 112 void TestTabContents::SetHistoryLengthAndPrune( |
153 const SiteInstance* site_instance, int history_length, int32 min_page_id) { | 113 const SiteInstance* site_instance, int history_length, int32 min_page_id) { |
154 EXPECT_TRUE(expect_set_history_length_and_prune_); | 114 EXPECT_TRUE(expect_set_history_length_and_prune_); |
155 expect_set_history_length_and_prune_ = false; | 115 expect_set_history_length_and_prune_ = false; |
156 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); | 116 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); |
157 EXPECT_EQ(expect_set_history_length_and_prune_history_length_, | 117 EXPECT_EQ(expect_set_history_length_and_prune_history_length_, |
158 history_length); | 118 history_length); |
159 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id); | 119 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id); |
160 } | 120 } |
OLD | NEW |