| 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 #include "content/test/test_render_view_host.h" | 5 #include "content/test/test_render_view_host.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "content/public/common/content_client.h" | 26 #include "content/public/common/content_client.h" |
| 27 #include "content/public/common/page_state.h" | 27 #include "content/public/common/page_state.h" |
| 28 #include "content/public/common/web_preferences.h" | 28 #include "content/public/common/web_preferences.h" |
| 29 #include "content/test/test_render_frame_host.h" | 29 #include "content/test/test_render_frame_host.h" |
| 30 #include "content/test/test_web_contents.h" | 30 #include "content/test/test_web_contents.h" |
| 31 #include "media/base/video_frame.h" | 31 #include "media/base/video_frame.h" |
| 32 #include "ui/aura/env.h" | 32 #include "ui/aura/env.h" |
| 33 #include "ui/compositor/compositor.h" | 33 #include "ui/compositor/compositor.h" |
| 34 #include "ui/gfx/geometry/rect.h" | 34 #include "ui/gfx/geometry/rect.h" |
| 35 | 35 |
| 36 #if defined(OS_ANDROID) | |
| 37 #include "content/browser/renderer_host/context_provider_factory_impl_android.h" | |
| 38 #endif | |
| 39 | |
| 40 namespace content { | 36 namespace content { |
| 41 | 37 |
| 42 void InitNavigateParams(FrameHostMsg_DidCommitProvisionalLoad_Params* params, | 38 void InitNavigateParams(FrameHostMsg_DidCommitProvisionalLoad_Params* params, |
| 43 int page_id, | 39 int page_id, |
| 44 int nav_entry_id, | 40 int nav_entry_id, |
| 45 bool did_create_new_entry, | 41 bool did_create_new_entry, |
| 46 const GURL& url, | 42 const GURL& url, |
| 47 ui::PageTransition transition) { | 43 ui::PageTransition transition) { |
| 48 params->page_id = page_id; | 44 params->page_id = page_id; |
| 49 params->nav_entry_id = nav_entry_id; | 45 params->nav_entry_id = nav_entry_id; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 60 params->method = "GET"; | 56 params->method = "GET"; |
| 61 params->page_state = PageState::CreateFromURL(url); | 57 params->page_state = PageState::CreateFromURL(url); |
| 62 } | 58 } |
| 63 | 59 |
| 64 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) | 60 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) |
| 65 : rwh_(RenderWidgetHostImpl::From(rwh)), | 61 : rwh_(RenderWidgetHostImpl::From(rwh)), |
| 66 is_showing_(false), | 62 is_showing_(false), |
| 67 is_occluded_(false), | 63 is_occluded_(false), |
| 68 did_swap_compositor_frame_(false) { | 64 did_swap_compositor_frame_(false) { |
| 69 #if defined(OS_ANDROID) | 65 #if defined(OS_ANDROID) |
| 70 // Not all tests initialize or need a context provider factory. | 66 surface_id_allocator_.reset( |
| 71 if (ContextProviderFactoryImpl::GetInstance()) { | 67 new cc::SurfaceIdAllocator(AllocateSurfaceClientId())); |
| 72 surface_id_allocator_.reset( | 68 GetSurfaceManager()->RegisterSurfaceClientId( |
| 73 new cc::SurfaceIdAllocator(AllocateSurfaceClientId())); | 69 surface_id_allocator_->client_id()); |
| 74 GetSurfaceManager()->RegisterSurfaceClientId( | |
| 75 surface_id_allocator_->client_id()); | |
| 76 } | |
| 77 #else | 70 #else |
| 78 // Not all tests initialize or need an image transport factory. | 71 // Not all tests initialize or need an image transport factory. |
| 79 if (ImageTransportFactory::GetInstance()) { | 72 if (ImageTransportFactory::GetInstance()) { |
| 80 surface_id_allocator_.reset( | 73 surface_id_allocator_.reset( |
| 81 new cc::SurfaceIdAllocator(AllocateSurfaceClientId())); | 74 new cc::SurfaceIdAllocator(AllocateSurfaceClientId())); |
| 82 GetSurfaceManager()->RegisterSurfaceClientId( | 75 GetSurfaceManager()->RegisterSurfaceClientId( |
| 83 surface_id_allocator_->client_id()); | 76 surface_id_allocator_->client_id()); |
| 84 } | 77 } |
| 85 #endif | 78 #endif |
| 86 | 79 |
| 87 rwh_->SetView(this); | 80 rwh_->SetView(this); |
| 88 } | 81 } |
| 89 | 82 |
| 90 TestRenderWidgetHostView::~TestRenderWidgetHostView() { | 83 TestRenderWidgetHostView::~TestRenderWidgetHostView() { |
| 91 cc::SurfaceManager* manager = nullptr; | 84 if (GetSurfaceManager()) { |
| 92 #if defined(OS_ANDROID) | 85 GetSurfaceManager()->InvalidateSurfaceClientId( |
| 93 if (ContextProviderFactoryImpl::GetInstance()) | 86 surface_id_allocator_->client_id()); |
| 94 manager = GetSurfaceManager(); | |
| 95 #else | |
| 96 manager = GetSurfaceManager(); | |
| 97 #endif | |
| 98 if (manager) { | |
| 99 manager->InvalidateSurfaceClientId(surface_id_allocator_->client_id()); | |
| 100 } | 87 } |
| 101 } | 88 } |
| 102 | 89 |
| 103 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const { | 90 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const { |
| 104 return rwh_; | 91 return rwh_; |
| 105 } | 92 } |
| 106 | 93 |
| 107 gfx::Vector2dF TestRenderWidgetHostView::GetLastScrollOffset() const { | 94 gfx::Vector2dF TestRenderWidgetHostView::GetLastScrollOffset() const { |
| 108 return gfx::Vector2dF(); | 95 return gfx::Vector2dF(); |
| 109 } | 96 } |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 338 |
| 352 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() { | 339 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() { |
| 353 return contents()->GetMainFrame(); | 340 return contents()->GetMainFrame(); |
| 354 } | 341 } |
| 355 | 342 |
| 356 TestWebContents* RenderViewHostImplTestHarness::contents() { | 343 TestWebContents* RenderViewHostImplTestHarness::contents() { |
| 357 return static_cast<TestWebContents*>(web_contents()); | 344 return static_cast<TestWebContents*>(web_contents()); |
| 358 } | 345 } |
| 359 | 346 |
| 360 } // namespace content | 347 } // namespace content |
| OLD | NEW |