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

Side by Side Diff: content/public/test/test_renderer_host.h

Issue 636673002: Remove navigation from TestRenderViewHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a TODO Created 6 years, 2 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
OLDNEW
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_PUBLIC_TEST_TEST_RENDERER_HOST_H_ 5 #ifndef CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_
6 #define CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_ 6 #define CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "content/public/browser/render_frame_host.h" 10 #include "content/public/browser/render_frame_host.h"
(...skipping 30 matching lines...) Expand all
41 41
42 // An interface and utility for driving tests of RenderFrameHost. 42 // An interface and utility for driving tests of RenderFrameHost.
43 class RenderFrameHostTester { 43 class RenderFrameHostTester {
44 public: 44 public:
45 // Retrieves the RenderFrameHostTester that drives the specified 45 // Retrieves the RenderFrameHostTester that drives the specified
46 // RenderFrameHost. The RenderFrameHost must have been created while 46 // RenderFrameHost. The RenderFrameHost must have been created while
47 // RenderFrameHost testing was enabled; use a 47 // RenderFrameHost testing was enabled; use a
48 // RenderViewHostTestEnabler instance (see below) to do this. 48 // RenderViewHostTestEnabler instance (see below) to do this.
49 static RenderFrameHostTester* For(RenderFrameHost* host); 49 static RenderFrameHostTester* For(RenderFrameHost* host);
50 50
51 // If the given NavigationController has a pending main frame, returns it,
52 // otherwise NULL. This is an alternative to
53 // WebContentsTester::GetPendingMainFrame() when your WebContents was not
54 // created via a TestWebContents.
55 static RenderFrameHost* GetPendingForController(
56 NavigationController* controller);
57
51 virtual ~RenderFrameHostTester() {} 58 virtual ~RenderFrameHostTester() {}
52 59
53 // Gives tests access to RenderFrameHostImpl::OnCreateChild. The returned 60 // Gives tests access to RenderFrameHostImpl::OnCreateChild. The returned
54 // RenderFrameHost is owned by the parent RenderFrameHost. 61 // RenderFrameHost is owned by the parent RenderFrameHost.
55 virtual RenderFrameHost* AppendChild(const std::string& frame_name) = 0; 62 virtual RenderFrameHost* AppendChild(const std::string& frame_name) = 0;
56 63
57 // Calls OnDidCommitProvisionalLoad on the RenderFrameHost with the given 64 // Calls OnDidCommitProvisionalLoad on the RenderFrameHost with the given
65 // information. Sets the rest of the parameters in the message to the
66 // "typical" values. This is a helper function for simulating the most common
67 // types of loads.
68 virtual void SendNavigate(int page_id, const GURL& url) = 0;
69 virtual void SendFailedNavigate(int page_id, const GURL& url) = 0;
70
71 // Calls OnDidCommitProvisionalLoad on the RenderFrameHost with the given
58 // information, including a custom PageTransition. Sets the rest of the 72 // information, including a custom PageTransition. Sets the rest of the
59 // parameters in the message to the "typical" values. This is a helper 73 // parameters in the message to the "typical" values. This is a helper
60 // function for simulating the most common types of loads. 74 // function for simulating the most common types of loads.
61 virtual void SendNavigateWithTransition(int page_id, 75 virtual void SendNavigateWithTransition(int page_id,
62 const GURL& url, 76 const GURL& url,
63 ui::PageTransition transition) = 0; 77 ui::PageTransition transition) = 0;
64 78
79 // If set, future loads will have |mime_type| set as the mime type.
80 // If not set, the mime type will default to "text/html".
81 virtual void SetContentsMimeType(const std::string& mime_type) = 0;
82
65 // Calls OnBeforeUnloadACK on this RenderFrameHost with the given parameter. 83 // Calls OnBeforeUnloadACK on this RenderFrameHost with the given parameter.
66 virtual void SendBeforeUnloadACK(bool proceed) = 0; 84 virtual void SendBeforeUnloadACK(bool proceed) = 0;
67 85
68 // Simulates the SwapOut_ACK that fires if you commit a cross-site 86 // Simulates the SwapOut_ACK that fires if you commit a cross-site
69 // navigation without making any network requests. 87 // navigation without making any network requests.
70 virtual void SimulateSwapOutACK() = 0; 88 virtual void SimulateSwapOutACK() = 0;
71 }; 89 };
72 90
73 // An interface and utility for driving tests of RenderViewHost. 91 // An interface and utility for driving tests of RenderViewHost.
74 class RenderViewHostTester { 92 class RenderViewHostTester {
75 public: 93 public:
76 // Retrieves the RenderViewHostTester that drives the specified 94 // Retrieves the RenderViewHostTester that drives the specified
77 // RenderViewHost. The RenderViewHost must have been created while 95 // RenderViewHost. The RenderViewHost must have been created while
78 // RenderViewHost testing was enabled; use a 96 // RenderViewHost testing was enabled; use a
79 // RenderViewHostTestEnabler instance (see below) to do this. 97 // RenderViewHostTestEnabler instance (see below) to do this.
80 static RenderViewHostTester* For(RenderViewHost* host); 98 static RenderViewHostTester* For(RenderViewHost* host);
81 99
82 // If the given WebContentsImpl has a pending RVH, returns it, otherwise NULL.
83 static RenderViewHost* GetPendingForController(
84 NavigationController* controller);
85
86 // This removes the need to expose 100 // This removes the need to expose
87 // RenderViewHostImpl::is_swapped_out() outside of content. 101 // RenderViewHostImpl::is_swapped_out() outside of content.
88 // 102 //
89 // This is safe to call on any RenderViewHost, not just ones 103 // This is safe to call on any RenderViewHost, not just ones
90 // constructed while a RenderViewHostTestEnabler is in play. 104 // constructed while a RenderViewHostTestEnabler is in play.
91 static bool IsRenderViewHostSwappedOut(RenderViewHost* rvh); 105 static bool IsRenderViewHostSwappedOut(RenderViewHost* rvh);
92 106
93 // Calls the RenderViewHosts' private OnMessageReceived function with the 107 // Calls the RenderViewHosts' private OnMessageReceived function with the
94 // given message. 108 // given message.
95 static bool TestOnMessageReceived(RenderViewHost* rvh, 109 static bool TestOnMessageReceived(RenderViewHost* rvh,
96 const IPC::Message& msg); 110 const IPC::Message& msg);
97 111
98 // Returns whether the underlying web-page has any touch-event handlers. 112 // Returns whether the underlying web-page has any touch-event handlers.
99 static bool HasTouchEventHandler(RenderViewHost* rvh); 113 static bool HasTouchEventHandler(RenderViewHost* rvh);
100 114
101 virtual ~RenderViewHostTester() {} 115 virtual ~RenderViewHostTester() {}
102 116
103 // Gives tests access to RenderViewHostImpl::CreateRenderView. 117 // Gives tests access to RenderViewHostImpl::CreateRenderView.
104 virtual bool CreateRenderView(const base::string16& frame_name, 118 virtual bool CreateRenderView(const base::string16& frame_name,
105 int opener_route_id, 119 int opener_route_id,
106 int proxy_routing_id, 120 int proxy_routing_id,
107 int32 max_page_id, 121 int32 max_page_id,
108 bool created_with_opener) = 0; 122 bool created_with_opener) = 0;
109 123
110 // Calls OnMsgNavigate on the RenderViewHost with the given information,
111 // setting the rest of the parameters in the message to the "typical" values.
112 // This is a helper function for simulating the most common types of loads.
113 virtual void SendNavigate(int page_id, const GURL& url) = 0;
114 virtual void SendFailedNavigate(int page_id, const GURL& url) = 0;
115
116 // Calls OnMsgNavigate on the RenderViewHost with the given information,
117 // including a custom PageTransition. Sets the rest of the
118 // parameters in the message to the "typical" values. This is a helper
119 // function for simulating the most common types of loads.
120 virtual void SendNavigateWithTransition(int page_id, const GURL& url,
121 ui::PageTransition transition) = 0;
122
123 // If set, future loads will have |mime_type| set as the mime type.
124 // If not set, the mime type will default to "text/html".
125 virtual void SetContentsMimeType(const std::string& mime_type) = 0;
126
127 // Makes the WasHidden/WasShown calls to the RenderWidget that 124 // Makes the WasHidden/WasShown calls to the RenderWidget that
128 // tell it it has been hidden or restored from having been hidden. 125 // tell it it has been hidden or restored from having been hidden.
129 virtual void SimulateWasHidden() = 0; 126 virtual void SimulateWasHidden() = 0;
130 virtual void SimulateWasShown() = 0; 127 virtual void SimulateWasShown() = 0;
131 }; 128 };
132 129
133 // You can instantiate only one class like this at a time. During its 130 // You can instantiate only one class like this at a time. During its
134 // lifetime, RenderViewHost and RenderFrameHost objects created may be used via 131 // lifetime, RenderViewHost and RenderFrameHost objects created may be used via
135 // RenderViewHostTester and RenderFrameHostTester respectively. 132 // RenderViewHostTester and RenderFrameHostTester respectively.
136 class RenderViewHostTestEnabler { 133 class RenderViewHostTestEnabler {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 239
243 int thread_bundle_options_; 240 int thread_bundle_options_;
244 scoped_ptr<TestBrowserThreadBundle> thread_bundle_; 241 scoped_ptr<TestBrowserThreadBundle> thread_bundle_;
245 242
246 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); 243 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness);
247 }; 244 };
248 245
249 } // namespace content 246 } // namespace content
250 247
251 #endif // CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_ 248 #endif // CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_unittest.cc ('k') | content/public/test/test_renderer_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698