Remove unused code calling WebMediaPlayerClient::requestFullscreen()
[chromium-blink-merge.git] / content / test / test_render_view_host.cc
blob5e222d1862e1bcc51063a7ff093e2025af1c01fb
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
3 // found in the LICENSE file.
5 #include "content/test/test_render_view_host.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "content/browser/dom_storage/dom_storage_context_wrapper.h"
9 #include "content/browser/dom_storage/session_storage_namespace_impl.h"
10 #include "content/browser/loader/resource_dispatcher_host_impl.h"
11 #include "content/browser/site_instance_impl.h"
12 #include "content/common/dom_storage/dom_storage_types.h"
13 #include "content/common/frame_messages.h"
14 #include "content/common/view_messages.h"
15 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/navigation_controller.h"
18 #include "content/public/browser/storage_partition.h"
19 #include "content/public/common/content_client.h"
20 #include "content/public/common/page_state.h"
21 #include "content/public/common/web_preferences.h"
22 #include "content/test/test_render_frame_host.h"
23 #include "content/test/test_web_contents.h"
24 #include "media/base/video_frame.h"
25 #include "ui/gfx/geometry/rect.h"
27 namespace content {
29 void InitNavigateParams(FrameHostMsg_DidCommitProvisionalLoad_Params* params,
30 int page_id,
31 int nav_entry_id,
32 bool did_create_new_entry,
33 const GURL& url,
34 ui::PageTransition transition) {
35 params->page_id = page_id;
36 params->nav_entry_id = nav_entry_id;
37 params->url = url;
38 params->referrer = Referrer();
39 params->transition = transition;
40 params->redirects = std::vector<GURL>();
41 params->should_update_history = false;
42 params->searchable_form_url = GURL();
43 params->searchable_form_encoding = std::string();
44 params->did_create_new_entry = did_create_new_entry;
45 params->security_info = std::string();
46 params->gesture = NavigationGestureUser;
47 params->was_within_same_page = false;
48 params->is_post = false;
49 params->page_state = PageState::CreateFromURL(url);
52 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh)
53 : rwh_(RenderWidgetHostImpl::From(rwh)),
54 is_showing_(false),
55 is_occluded_(false),
56 did_swap_compositor_frame_(false) {
57 rwh_->SetView(this);
60 TestRenderWidgetHostView::~TestRenderWidgetHostView() {
63 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const {
64 return NULL;
67 gfx::Vector2dF TestRenderWidgetHostView::GetLastScrollOffset() const {
68 return gfx::Vector2dF();
71 gfx::NativeView TestRenderWidgetHostView::GetNativeView() const {
72 return NULL;
75 gfx::NativeViewId TestRenderWidgetHostView::GetNativeViewId() const {
76 return 0;
79 gfx::NativeViewAccessible TestRenderWidgetHostView::GetNativeViewAccessible() {
80 return NULL;
83 ui::TextInputClient* TestRenderWidgetHostView::GetTextInputClient() {
84 return &text_input_client_;
87 bool TestRenderWidgetHostView::HasFocus() const {
88 return true;
91 bool TestRenderWidgetHostView::IsSurfaceAvailableForCopy() const {
92 return true;
95 void TestRenderWidgetHostView::Show() {
96 is_showing_ = true;
97 is_occluded_ = false;
100 void TestRenderWidgetHostView::Hide() {
101 is_showing_ = false;
104 bool TestRenderWidgetHostView::IsShowing() {
105 return is_showing_;
108 void TestRenderWidgetHostView::WasUnOccluded() {
109 is_occluded_ = false;
112 void TestRenderWidgetHostView::WasOccluded() {
113 is_occluded_ = true;
116 void TestRenderWidgetHostView::RenderProcessGone(base::TerminationStatus status,
117 int error_code) {
118 delete this;
121 void TestRenderWidgetHostView::Destroy() { delete this; }
123 gfx::Rect TestRenderWidgetHostView::GetViewBounds() const {
124 return gfx::Rect();
127 void TestRenderWidgetHostView::CopyFromCompositingSurface(
128 const gfx::Rect& src_subrect,
129 const gfx::Size& dst_size,
130 ReadbackRequestCallback& callback,
131 const SkColorType preferred_color_type) {
132 callback.Run(SkBitmap(), content::READBACK_FAILED);
135 void TestRenderWidgetHostView::CopyFromCompositingSurfaceToVideoFrame(
136 const gfx::Rect& src_subrect,
137 const scoped_refptr<media::VideoFrame>& target,
138 const base::Callback<void(bool)>& callback) {
139 callback.Run(false);
142 bool TestRenderWidgetHostView::CanCopyToVideoFrame() const {
143 return false;
146 bool TestRenderWidgetHostView::HasAcceleratedSurface(
147 const gfx::Size& desired_size) {
148 return false;
151 #if defined(OS_MACOSX)
153 void TestRenderWidgetHostView::SetActive(bool active) {
154 // <viettrungluu@gmail.com>: Do I need to do anything here?
157 bool TestRenderWidgetHostView::SupportsSpeech() const {
158 return false;
161 void TestRenderWidgetHostView::SpeakSelection() {
164 bool TestRenderWidgetHostView::IsSpeaking() const {
165 return false;
168 void TestRenderWidgetHostView::StopSpeaking() {
171 bool TestRenderWidgetHostView::PostProcessEventForPluginIme(
172 const NativeWebKeyboardEvent& event) {
173 return false;
176 #endif
178 gfx::Rect TestRenderWidgetHostView::GetBoundsInRootWindow() {
179 return gfx::Rect();
182 void TestRenderWidgetHostView::OnSwapCompositorFrame(
183 uint32 output_surface_id,
184 scoped_ptr<cc::CompositorFrame> frame) {
185 did_swap_compositor_frame_ = true;
189 gfx::GLSurfaceHandle TestRenderWidgetHostView::GetCompositingSurface() {
190 return gfx::GLSurfaceHandle();
193 bool TestRenderWidgetHostView::LockMouse() {
194 return false;
197 void TestRenderWidgetHostView::UnlockMouse() {
200 #if defined(OS_WIN)
201 void TestRenderWidgetHostView::SetParentNativeViewAccessible(
202 gfx::NativeViewAccessible accessible_parent) {
205 gfx::NativeViewId TestRenderWidgetHostView::GetParentForWindowlessPlugin()
206 const {
207 return 0;
209 #endif
211 TestRenderViewHost::TestRenderViewHost(
212 SiteInstance* instance,
213 RenderViewHostDelegate* delegate,
214 RenderWidgetHostDelegate* widget_delegate,
215 int routing_id,
216 int main_frame_routing_id,
217 bool swapped_out)
218 : RenderViewHostImpl(instance,
219 delegate,
220 widget_delegate,
221 routing_id,
222 main_frame_routing_id,
223 swapped_out,
224 false /* hidden */,
225 false /* has_initialized_audio_host */),
226 delete_counter_(NULL),
227 opener_route_id_(MSG_ROUTING_NONE) {
228 // TestRenderWidgetHostView installs itself into this->view_ in its
229 // constructor, and deletes itself when TestRenderWidgetHostView::Destroy() is
230 // called.
231 new TestRenderWidgetHostView(this);
234 TestRenderViewHost::~TestRenderViewHost() {
235 if (delete_counter_)
236 ++*delete_counter_;
239 bool TestRenderViewHost::CreateTestRenderView(
240 const base::string16& frame_name,
241 int opener_route_id,
242 int proxy_route_id,
243 int32 max_page_id,
244 bool window_was_created_with_opener) {
245 return CreateRenderView(frame_name, opener_route_id, proxy_route_id,
246 max_page_id, FrameReplicationState(),
247 window_was_created_with_opener);
250 bool TestRenderViewHost::CreateRenderView(
251 const base::string16& frame_name,
252 int opener_route_id,
253 int proxy_route_id,
254 int32 max_page_id,
255 const FrameReplicationState& replicated_frame_state,
256 bool window_was_created_with_opener) {
257 DCHECK(!IsRenderViewLive());
258 set_renderer_initialized(true);
259 DCHECK(IsRenderViewLive());
260 opener_route_id_ = opener_route_id;
261 RenderFrameHost* main_frame = GetMainFrame();
262 if (main_frame)
263 static_cast<RenderFrameHostImpl*>(main_frame)->SetRenderFrameCreated(true);
265 return true;
268 bool TestRenderViewHost::IsFullscreenGranted() const {
269 return RenderViewHostImpl::IsFullscreenGranted();
272 MockRenderProcessHost* TestRenderViewHost::GetProcess() const {
273 return static_cast<MockRenderProcessHost*>(RenderViewHostImpl::GetProcess());
276 void TestRenderViewHost::SimulateWasHidden() {
277 WasHidden();
280 void TestRenderViewHost::SimulateWasShown() {
281 WasShown(ui::LatencyInfo());
284 WebPreferences TestRenderViewHost::TestComputeWebkitPrefs() {
285 return ComputeWebkitPrefs();
288 void TestRenderViewHost::TestOnStartDragging(
289 const DropData& drop_data) {
290 blink::WebDragOperationsMask drag_operation = blink::WebDragOperationEvery;
291 DragEventSourceInfo event_info;
292 OnStartDragging(drop_data, drag_operation, SkBitmap(), gfx::Vector2d(),
293 event_info);
296 void TestRenderViewHost::TestOnUpdateStateWithFile(
297 int page_id,
298 const base::FilePath& file_path) {
299 OnUpdateState(page_id,
300 PageState::CreateForTesting(GURL("http://www.google.com"),
301 false,
302 "data",
303 &file_path));
306 RenderViewHostImplTestHarness::RenderViewHostImplTestHarness() {
307 std::vector<ui::ScaleFactor> scale_factors;
308 scale_factors.push_back(ui::SCALE_FACTOR_100P);
309 scoped_set_supported_scale_factors_.reset(
310 new ui::test::ScopedSetSupportedScaleFactors(scale_factors));
313 RenderViewHostImplTestHarness::~RenderViewHostImplTestHarness() {
316 TestRenderViewHost* RenderViewHostImplTestHarness::test_rvh() {
317 return contents()->GetRenderViewHost();
320 TestRenderViewHost* RenderViewHostImplTestHarness::pending_test_rvh() {
321 return contents()->GetPendingMainFrame() ?
322 contents()->GetPendingMainFrame()->GetRenderViewHost() :
323 NULL;
326 TestRenderViewHost* RenderViewHostImplTestHarness::active_test_rvh() {
327 return static_cast<TestRenderViewHost*>(active_rvh());
330 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() {
331 return contents()->GetMainFrame();
334 TestWebContents* RenderViewHostImplTestHarness::contents() {
335 return static_cast<TestWebContents*>(web_contents());
338 } // namespace content