Chromium Code Reviews| 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" |
| 11 #include "cc/surfaces/surface_manager.h" | |
| 12 #include "content/browser/compositor/image_transport_factory.h" | |
| 13 #include "content/browser/compositor/surface_utils.h" | |
| 11 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 14 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
| 12 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 15 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 13 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 16 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 14 #include "content/browser/site_instance_impl.h" | 17 #include "content/browser/site_instance_impl.h" |
| 15 #include "content/common/dom_storage/dom_storage_types.h" | 18 #include "content/common/dom_storage/dom_storage_types.h" |
| 16 #include "content/common/frame_messages.h" | 19 #include "content/common/frame_messages.h" |
| 17 #include "content/common/site_isolation_policy.h" | 20 #include "content/common/site_isolation_policy.h" |
| 18 #include "content/common/view_messages.h" | 21 #include "content/common/view_messages.h" |
| 19 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
| 20 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/navigation_controller.h" | 24 #include "content/public/browser/navigation_controller.h" |
| 22 #include "content/public/browser/storage_partition.h" | 25 #include "content/public/browser/storage_partition.h" |
| 23 #include "content/public/common/content_client.h" | 26 #include "content/public/common/content_client.h" |
| 24 #include "content/public/common/page_state.h" | 27 #include "content/public/common/page_state.h" |
| 25 #include "content/public/common/web_preferences.h" | 28 #include "content/public/common/web_preferences.h" |
| 26 #include "content/test/test_render_frame_host.h" | 29 #include "content/test/test_render_frame_host.h" |
| 27 #include "content/test/test_web_contents.h" | 30 #include "content/test/test_web_contents.h" |
| 28 #include "media/base/video_frame.h" | 31 #include "media/base/video_frame.h" |
| 32 #include "ui/aura/env.h" | |
| 33 #include "ui/compositor/compositor.h" | |
| 29 #include "ui/gfx/geometry/rect.h" | 34 #include "ui/gfx/geometry/rect.h" |
| 30 | 35 |
| 31 namespace { | |
| 32 static uint32_t s_next_surface_id_namespace = 1; | |
| 33 } | |
| 34 | |
| 35 namespace content { | 36 namespace content { |
| 36 | 37 |
| 37 void InitNavigateParams(FrameHostMsg_DidCommitProvisionalLoad_Params* params, | 38 void InitNavigateParams(FrameHostMsg_DidCommitProvisionalLoad_Params* params, |
| 38 int page_id, | 39 int page_id, |
| 39 int nav_entry_id, | 40 int nav_entry_id, |
| 40 bool did_create_new_entry, | 41 bool did_create_new_entry, |
| 41 const GURL& url, | 42 const GURL& url, |
| 42 ui::PageTransition transition) { | 43 ui::PageTransition transition) { |
| 43 params->page_id = page_id; | 44 params->page_id = page_id; |
| 44 params->nav_entry_id = nav_entry_id; | 45 params->nav_entry_id = nav_entry_id; |
| 45 params->url = url; | 46 params->url = url; |
| 46 params->referrer = Referrer(); | 47 params->referrer = Referrer(); |
| 47 params->transition = transition; | 48 params->transition = transition; |
| 48 params->redirects = std::vector<GURL>(); | 49 params->redirects = std::vector<GURL>(); |
| 49 params->should_update_history = false; | 50 params->should_update_history = false; |
| 50 params->searchable_form_url = GURL(); | 51 params->searchable_form_url = GURL(); |
| 51 params->searchable_form_encoding = std::string(); | 52 params->searchable_form_encoding = std::string(); |
| 52 params->did_create_new_entry = did_create_new_entry; | 53 params->did_create_new_entry = did_create_new_entry; |
| 53 params->security_info = std::string(); | 54 params->security_info = std::string(); |
| 54 params->gesture = NavigationGestureUser; | 55 params->gesture = NavigationGestureUser; |
| 55 params->was_within_same_page = false; | 56 params->was_within_same_page = false; |
| 56 params->method = "GET"; | 57 params->method = "GET"; |
| 57 params->page_state = PageState::CreateFromURL(url); | 58 params->page_state = PageState::CreateFromURL(url); |
| 58 } | 59 } |
| 59 | 60 |
| 60 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) | 61 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) |
| 61 : rwh_(RenderWidgetHostImpl::From(rwh)), | 62 : rwh_(RenderWidgetHostImpl::From(rwh)), |
| 62 surface_id_namespace_(s_next_surface_id_namespace++), | |
| 63 is_showing_(false), | 63 is_showing_(false), |
| 64 is_occluded_(false), | 64 is_occluded_(false), |
| 65 did_swap_compositor_frame_(false) { | 65 did_swap_compositor_frame_(false) { |
| 66 #if defined(OS_ANDROID) | |
| 67 surface_id_allocator_ = CreateSurfaceIdAllocator(); | |
| 68 #else | |
| 69 // Not all tests initialize or need an image transport factory. | |
| 70 if (ImageTransportFactory::GetInstance()) | |
| 71 surface_id_allocator_ = CreateSurfaceIdAllocator(); | |
| 72 #endif | |
| 73 | |
| 66 rwh_->SetView(this); | 74 rwh_->SetView(this); |
| 67 } | 75 } |
| 68 | 76 |
| 69 TestRenderWidgetHostView::~TestRenderWidgetHostView() { | 77 TestRenderWidgetHostView::~TestRenderWidgetHostView() { |
| 70 } | 78 } |
| 71 | 79 |
| 72 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const { | 80 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const { |
| 73 return rwh_; | 81 return rwh_; |
| 74 } | 82 } |
| 75 | 83 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 } | 205 } |
| 198 | 206 |
| 199 bool TestRenderWidgetHostView::LockMouse() { | 207 bool TestRenderWidgetHostView::LockMouse() { |
| 200 return false; | 208 return false; |
| 201 } | 209 } |
| 202 | 210 |
| 203 void TestRenderWidgetHostView::UnlockMouse() { | 211 void TestRenderWidgetHostView::UnlockMouse() { |
| 204 } | 212 } |
| 205 | 213 |
| 206 uint32_t TestRenderWidgetHostView::GetSurfaceIdNamespace() { | 214 uint32_t TestRenderWidgetHostView::GetSurfaceIdNamespace() { |
| 207 return surface_id_namespace_; | 215 // See constructor. If a test needs this, its harness needs to construct an |
| 216 // ImageTransportFactory. | |
|
piman
2016/06/20 20:40:27
nit: add DCHECK(surface_id_allocator_);
enne (OOO)
2016/06/20 20:58:41
Done.
| |
| 217 return surface_id_allocator_->id_namespace(); | |
| 208 } | 218 } |
| 209 | 219 |
| 210 TestRenderViewHost::TestRenderViewHost( | 220 TestRenderViewHost::TestRenderViewHost( |
| 211 SiteInstance* instance, | 221 SiteInstance* instance, |
| 212 std::unique_ptr<RenderWidgetHostImpl> widget, | 222 std::unique_ptr<RenderWidgetHostImpl> widget, |
| 213 RenderViewHostDelegate* delegate, | 223 RenderViewHostDelegate* delegate, |
| 214 int32_t main_frame_routing_id, | 224 int32_t main_frame_routing_id, |
| 215 bool swapped_out) | 225 bool swapped_out) |
| 216 : RenderViewHostImpl(instance, | 226 : RenderViewHostImpl(instance, |
| 217 std::move(widget), | 227 std::move(widget), |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 | 333 |
| 324 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() { | 334 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() { |
| 325 return contents()->GetMainFrame(); | 335 return contents()->GetMainFrame(); |
| 326 } | 336 } |
| 327 | 337 |
| 328 TestWebContents* RenderViewHostImplTestHarness::contents() { | 338 TestWebContents* RenderViewHostImplTestHarness::contents() { |
| 329 return static_cast<TestWebContents*>(web_contents()); | 339 return static_cast<TestWebContents*>(web_contents()); |
| 330 } | 340 } |
| 331 | 341 |
| 332 } // namespace content | 342 } // namespace content |
| OLD | NEW |