Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(986)

Side by Side Diff: content/browser/tab_contents/test_tab_contents.h

Issue 7618016: Additional fixes for prerender/instant + browsing history. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Wrong signature Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef CONTENT_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ 5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_
6 #define CONTENT_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ 6 #define CONTENT_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_
7 #pragma once 7 #pragma once
8 8
9 #include "content/browser/tab_contents/tab_contents.h" 9 #include "content/browser/tab_contents/tab_contents.h"
10 #include "webkit/glue/webpreferences.h" 10 #include "webkit/glue/webpreferences.h"
11 11
12 class TestRenderViewHost; 12 class TestRenderViewHost;
13 13
14 // Subclass TabContents to ensure it creates TestRenderViewHosts and does 14 // Subclass TabContents to ensure it creates TestRenderViewHosts and does
15 // not do anything involving views. 15 // not do anything involving views.
16 class TestTabContents : public TabContents { 16 class TestTabContents : public TabContents {
17 public: 17 public:
18 TestTabContents(content::BrowserContext* browser_context, 18 TestTabContents(content::BrowserContext* browser_context,
19 SiteInstance* instance); 19 SiteInstance* instance);
20 virtual ~TestTabContents();
20 21
21 TestRenderViewHost* pending_rvh() const; 22 TestRenderViewHost* pending_rvh() const;
22 23
23 // State accessor. 24 // State accessor.
24 bool cross_navigation_pending() { 25 bool cross_navigation_pending() {
25 return render_manager_.cross_navigation_pending_; 26 return render_manager_.cross_navigation_pending_;
26 } 27 }
27 28
28 // Overrides TabContents::ShouldTransitionCrossSite so that we can test both 29 // Overrides TabContents::ShouldTransitionCrossSite so that we can test both
29 // alternatives without using command-line switches. 30 // alternatives without using command-line switches.
30 bool ShouldTransitionCrossSite() { return transition_cross_site; } 31 bool ShouldTransitionCrossSite() { return transition_cross_site; }
31 32
32 // Promote DidNavigate to public. 33 // Promote DidNavigate to public.
33 void TestDidNavigate(RenderViewHost* render_view_host, 34 void TestDidNavigate(RenderViewHost* render_view_host,
34 const ViewHostMsg_FrameNavigate_Params& params) { 35 const ViewHostMsg_FrameNavigate_Params& params) {
35 DidNavigate(render_view_host, params); 36 DidNavigate(render_view_host, params);
36 } 37 }
37 38
38 // Promote GetWebkitPrefs to public. 39 // Promote GetWebkitPrefs to public.
39 WebPreferences TestGetWebkitPrefs() { 40 WebPreferences TestGetWebkitPrefs() {
40 return GetWebkitPrefs(); 41 return GetWebkitPrefs();
41 } 42 }
42 43
43 // Prevent interaction with views. 44 // Prevent interaction with views.
44 virtual bool CreateRenderViewForRenderManager( 45 virtual bool CreateRenderViewForRenderManager(
45 RenderViewHost* render_view_host); 46 RenderViewHost* render_view_host) OVERRIDE;
46 virtual void UpdateRenderViewSizeForRenderManager() {} 47 virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE {}
47 48
48 // Returns a clone of this TestTabContents. The returned object is also a 49 // Returns a clone of this TestTabContents. The returned object is also a
49 // TestTabContents. The caller owns the returned object. 50 // TestTabContents. The caller owns the returned object.
50 virtual TabContents* Clone(); 51 virtual TabContents* Clone() OVERRIDE;
51 52
52 // Creates a pending navigation to the given URL with the default parameters 53 // Creates a pending navigation to the given URL with the default parameters
53 // and then commits the load with a page ID one larger than any seen. This 54 // and then commits the load with a page ID one larger than any seen. This
54 // emulates what happens on a new navigation. 55 // emulates what happens on a new navigation.
55 void NavigateAndCommit(const GURL& url); 56 void NavigateAndCommit(const GURL& url);
56 57
57 // Simulates the appropriate RenderView (pending if any, current otherwise) 58 // Simulates the appropriate RenderView (pending if any, current otherwise)
58 // sending a navigate notification for the NavigationController pending entry. 59 // sending a navigate notification for the NavigationController pending entry.
59 void CommitPendingNavigation(); 60 void CommitPendingNavigation();
60 61
61 // Simulates the current RVH notifying that it has unloaded so that the 62 // Simulates the current RVH notifying that it has unloaded so that the
62 // pending RVH navigation can proceed. 63 // pending RVH navigation can proceed.
63 // Does nothing if no cross-navigation is pending. 64 // Does nothing if no cross-navigation is pending.
64 void ProceedWithCrossSiteNavigation(); 65 void ProceedWithCrossSiteNavigation();
65 66
66 // Set by individual tests. 67 // Set by individual tests.
67 bool transition_cross_site; 68 bool transition_cross_site;
68 69
69 // Allow mocking of the RenderViewHostDelegate::View. 70 // Allow mocking of the RenderViewHostDelegate::View.
70 virtual RenderViewHostDelegate::View* GetViewDelegate(); 71 virtual RenderViewHostDelegate::View* GetViewDelegate() OVERRIDE;
71 void set_view_delegate(RenderViewHostDelegate::View* view) { 72 void set_view_delegate(RenderViewHostDelegate::View* view) {
72 delegate_view_override_ = view; 73 delegate_view_override_ = view;
73 } 74 }
75
76 // Establish expected arguments for |SetHistoryLengthAndPrune()|. When
77 // |SetHistoryLengthAndPrune()| is called, the arguments are compared
78 // with the expected arguments specified here.
79 void ExpectSetHistoryLengthAndPrune(const SiteInstance* site_instance,
80 int history_length,
81 int32 min_page_id);
82
83 // Compares the arguments passed in with the expected arguments passed in
84 // to |ExpectSetHistoryLengthAndPrune()|.
85 virtual void SetHistoryLengthAndPrune(const SiteInstance* site_instance,
86 int history_length,
87 int32 min_page_id) OVERRIDE;
88
74 private: 89 private:
75 RenderViewHostDelegate::View* delegate_view_override_; 90 RenderViewHostDelegate::View* delegate_view_override_;
91
92 // Expectations for arguments of |SetHistoryLengthAndPrune()|.
93 bool expect_set_history_length_and_prune_;
94 scoped_refptr<const SiteInstance>
95 expect_set_history_length_and_prune_site_instance_;
96 int expect_set_history_length_and_prune_history_length_;
97 int32 expect_set_history_length_and_prune_min_page_id_;
76 }; 98 };
77 99
78 #endif // CONTENT_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_ 100 #endif // CONTENT_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698