blob: fb7b1bc23ca3a8172e519c4b64d709e56eec3262 [file] [log] [blame]
[email protected]0dd3a0ab2011-02-18 08:17:441// 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
3// found in the LICENSE file.
4
5#ifndef CONTENT_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_
6#define CONTENT_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_
7#pragma once
8
[email protected]21f11682011-03-02 16:45:429#include "content/browser/tab_contents/tab_contents.h"
[email protected]0dd3a0ab2011-02-18 08:17:4410#include "webkit/glue/webpreferences.h"
11
[email protected]0dd3a0ab2011-02-18 08:17:4412class TestRenderViewHost;
13
14// Subclass TabContents to ensure it creates TestRenderViewHosts and does
15// not do anything involving views.
16class TestTabContents : public TabContents {
17 public:
[email protected]e7013f4c2011-08-01 16:04:1218 TestTabContents(content::BrowserContext* browser_context,
19 SiteInstance* instance);
[email protected]0dd3a0ab2011-02-18 08:17:4420
21 TestRenderViewHost* pending_rvh() const;
22
23 // State accessor.
24 bool cross_navigation_pending() {
25 return render_manager_.cross_navigation_pending_;
26 }
27
28 // Overrides TabContents::ShouldTransitionCrossSite so that we can test both
29 // alternatives without using command-line switches.
30 bool ShouldTransitionCrossSite() { return transition_cross_site; }
31
[email protected]0dd3a0ab2011-02-18 08:17:4432 // Promote DidNavigate to public.
33 void TestDidNavigate(RenderViewHost* render_view_host,
34 const ViewHostMsg_FrameNavigate_Params& params) {
35 DidNavigate(render_view_host, params);
36 }
37
38 // Promote GetWebkitPrefs to public.
39 WebPreferences TestGetWebkitPrefs() {
40 return GetWebkitPrefs();
41 }
42
43 // Prevent interaction with views.
44 virtual bool CreateRenderViewForRenderManager(
45 RenderViewHost* render_view_host);
46 virtual void UpdateRenderViewSizeForRenderManager() {}
47
48 // Returns a clone of this TestTabContents. The returned object is also a
49 // TestTabContents. The caller owns the returned object.
50 virtual TabContents* Clone();
51
52 // 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 // emulates what happens on a new navigation.
55 void NavigateAndCommit(const GURL& url);
56
57 // Simulates the appropriate RenderView (pending if any, current otherwise)
58 // sending a navigate notification for the NavigationController pending entry.
59 void CommitPendingNavigation();
60
61 // Simulates the current RVH notifying that it has unloaded so that the
62 // pending RVH navigation can proceed.
63 // Does nothing if no cross-navigation is pending.
64 void ProceedWithCrossSiteNavigation();
65
66 // Set by individual tests.
67 bool transition_cross_site;
[email protected]8c4575b2011-06-07 21:11:0368
69 // Allow mocking of the RenderViewHostDelegate::View.
70 virtual RenderViewHostDelegate::View* GetViewDelegate();
71 void set_view_delegate(RenderViewHostDelegate::View* view) {
72 delegate_view_override_ = view;
73 }
74 private:
75 RenderViewHostDelegate::View* delegate_view_override_;
[email protected]0dd3a0ab2011-02-18 08:17:4476};
77
78#endif // CONTENT_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_