OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_BROWSER_WEB_CONTENTS_TEST_WEB_CONTENTS_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_TEST_WEB_CONTENTS_H_ |
6 #define CONTENT_BROWSER_WEB_CONTENTS_TEST_WEB_CONTENTS_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_TEST_WEB_CONTENTS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
10 #include "content/public/common/page_transition_types.h" | 10 #include "content/public/common/page_transition_types.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 bool cross_navigation_pending() { | 49 bool cross_navigation_pending() { |
50 return render_manager_.cross_navigation_pending_; | 50 return render_manager_.cross_navigation_pending_; |
51 } | 51 } |
52 | 52 |
53 // Overrides WebContentsImpl::ShouldTransitionCrossSite so that we can test | 53 // Overrides WebContentsImpl::ShouldTransitionCrossSite so that we can test |
54 // both alternatives without using command-line switches. | 54 // both alternatives without using command-line switches. |
55 bool ShouldTransitionCrossSite() { return transition_cross_site; } | 55 bool ShouldTransitionCrossSite() { return transition_cross_site; } |
56 | 56 |
57 // Prevent interaction with views. | 57 // Prevent interaction with views. |
58 virtual bool CreateRenderViewForRenderManager( | 58 virtual bool CreateRenderViewForRenderManager( |
59 RenderViewHost* render_view_host) OVERRIDE; | 59 RenderViewHost* render_view_host, int opener_route_id) OVERRIDE; |
60 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE {} | 60 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE {} |
61 | 61 |
62 // Returns a clone of this TestWebContents. The returned object is also a | 62 // Returns a clone of this TestWebContents. The returned object is also a |
63 // TestWebContents. The caller owns the returned object. | 63 // TestWebContents. The caller owns the returned object. |
64 virtual WebContents* Clone() OVERRIDE; | 64 virtual WebContents* Clone() OVERRIDE; |
65 | 65 |
66 // Set by individual tests. | 66 // Set by individual tests. |
67 bool transition_cross_site; | 67 bool transition_cross_site; |
68 | 68 |
69 // Allow mocking of the RenderViewHostDelegate::View. | 69 // Allow mocking of the RenderViewHostDelegate::View. |
70 virtual RenderViewHostDelegate::View* GetViewDelegate() OVERRIDE; | 70 virtual RenderViewHostDelegate::View* GetViewDelegate() OVERRIDE; |
71 void set_view_delegate(RenderViewHostDelegate::View* view) { | 71 void set_view_delegate(RenderViewHostDelegate::View* view) { |
72 delegate_view_override_ = view; | 72 delegate_view_override_ = view; |
73 } | 73 } |
74 | 74 |
| 75 // Allows us to simulate this tab having an opener. |
| 76 void SetOpener(TestWebContents* opener); |
| 77 |
75 // Establish expected arguments for |SetHistoryLengthAndPrune()|. When | 78 // Establish expected arguments for |SetHistoryLengthAndPrune()|. When |
76 // |SetHistoryLengthAndPrune()| is called, the arguments are compared | 79 // |SetHistoryLengthAndPrune()| is called, the arguments are compared |
77 // with the expected arguments specified here. | 80 // with the expected arguments specified here. |
78 void ExpectSetHistoryLengthAndPrune(const SiteInstance* site_instance, | 81 void ExpectSetHistoryLengthAndPrune(const SiteInstance* site_instance, |
79 int history_length, | 82 int history_length, |
80 int32 min_page_id); | 83 int32 min_page_id); |
81 | 84 |
82 // Compares the arguments passed in with the expected arguments passed in | 85 // Compares the arguments passed in with the expected arguments passed in |
83 // to |ExpectSetHistoryLengthAndPrune()|. | 86 // to |ExpectSetHistoryLengthAndPrune()|. |
84 virtual void SetHistoryLengthAndPrune(const SiteInstance* site_instance, | 87 virtual void SetHistoryLengthAndPrune(const SiteInstance* site_instance, |
85 int history_length, | 88 int history_length, |
86 int32 min_page_id) OVERRIDE; | 89 int32 min_page_id) OVERRIDE; |
87 | 90 |
88 private: | 91 private: |
89 RenderViewHostDelegate::View* delegate_view_override_; | 92 RenderViewHostDelegate::View* delegate_view_override_; |
90 | 93 |
91 // Expectations for arguments of |SetHistoryLengthAndPrune()|. | 94 // Expectations for arguments of |SetHistoryLengthAndPrune()|. |
92 bool expect_set_history_length_and_prune_; | 95 bool expect_set_history_length_and_prune_; |
93 scoped_refptr<const SiteInstanceImpl> | 96 scoped_refptr<const SiteInstanceImpl> |
94 expect_set_history_length_and_prune_site_instance_; | 97 expect_set_history_length_and_prune_site_instance_; |
95 int expect_set_history_length_and_prune_history_length_; | 98 int expect_set_history_length_and_prune_history_length_; |
96 int32 expect_set_history_length_and_prune_min_page_id_; | 99 int32 expect_set_history_length_and_prune_min_page_id_; |
97 }; | 100 }; |
98 | 101 |
99 } // namespace content | 102 } // namespace content |
100 | 103 |
101 #endif // CONTENT_BROWSER_WEB_CONTENTS_TEST_WEB_CONTENTS_H_ | 104 #endif // CONTENT_BROWSER_WEB_CONTENTS_TEST_WEB_CONTENTS_H_ |
OLD | NEW |