| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/frame_host/render_widget_host_view_guest.h" | 5 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/message_loop/message_loop.h" | |
| 12 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 13 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 14 #include "base/test/scoped_task_scheduler.h" | 13 #include "base/test/scoped_task_environment.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "cc/surfaces/surface.h" | 16 #include "cc/surfaces/surface.h" |
| 17 #include "cc/surfaces/surface_manager.h" | 17 #include "cc/surfaces/surface_manager.h" |
| 18 #include "cc/surfaces/surface_sequence.h" | 18 #include "cc/surfaces/surface_sequence.h" |
| 19 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 19 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 20 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" | 20 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" |
| 21 #include "content/browser/gpu/compositor_util.h" | 21 #include "content/browser/gpu/compositor_util.h" |
| 22 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 22 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 23 #include "content/browser/renderer_host/render_widget_host_impl.h" | 23 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 24 #include "content/common/view_messages.h" | 24 #include "content/common/view_messages.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 42 private: | 42 private: |
| 43 // RenderWidgetHostDelegate: | 43 // RenderWidgetHostDelegate: |
| 44 void Cut() override {} | 44 void Cut() override {} |
| 45 void Copy() override {} | 45 void Copy() override {} |
| 46 void Paste() override {} | 46 void Paste() override {} |
| 47 void SelectAll() override {} | 47 void SelectAll() override {} |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class RenderWidgetHostViewGuestTest : public testing::Test { | 50 class RenderWidgetHostViewGuestTest : public testing::Test { |
| 51 public: | 51 public: |
| 52 RenderWidgetHostViewGuestTest() : task_scheduler_(&message_loop_) {} | 52 RenderWidgetHostViewGuestTest() |
| 53 : scoped_task_environment_( |
| 54 base::test::ScopedTaskEnvironment::MainThreadType::UI) {} |
| 53 | 55 |
| 54 void SetUp() override { | 56 void SetUp() override { |
| 55 #if !defined(OS_ANDROID) | 57 #if !defined(OS_ANDROID) |
| 56 ImageTransportFactory::InitializeForUnitTests( | 58 ImageTransportFactory::InitializeForUnitTests( |
| 57 std::unique_ptr<ImageTransportFactory>( | 59 std::unique_ptr<ImageTransportFactory>( |
| 58 new NoTransportImageTransportFactory)); | 60 new NoTransportImageTransportFactory)); |
| 59 #endif | 61 #endif |
| 60 browser_context_.reset(new TestBrowserContext); | 62 browser_context_.reset(new TestBrowserContext); |
| 61 MockRenderProcessHost* process_host = | 63 MockRenderProcessHost* process_host = |
| 62 new MockRenderProcessHost(browser_context_.get()); | 64 new MockRenderProcessHost(browser_context_.get()); |
| 63 int32_t routing_id = process_host->GetNextRoutingID(); | 65 int32_t routing_id = process_host->GetNextRoutingID(); |
| 64 widget_host_ = | 66 widget_host_ = |
| 65 new RenderWidgetHostImpl(&delegate_, process_host, routing_id, false); | 67 new RenderWidgetHostImpl(&delegate_, process_host, routing_id, false); |
| 66 view_ = RenderWidgetHostViewGuest::Create( | 68 view_ = RenderWidgetHostViewGuest::Create( |
| 67 widget_host_, NULL, | 69 widget_host_, NULL, |
| 68 (new TestRenderWidgetHostView(widget_host_))->GetWeakPtr()); | 70 (new TestRenderWidgetHostView(widget_host_))->GetWeakPtr()); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void TearDown() override { | 73 void TearDown() override { |
| 72 if (view_) | 74 if (view_) |
| 73 view_->Destroy(); | 75 view_->Destroy(); |
| 74 delete widget_host_; | 76 delete widget_host_; |
| 75 | 77 |
| 76 browser_context_.reset(); | 78 browser_context_.reset(); |
| 77 | 79 |
| 78 message_loop_.task_runner()->DeleteSoon(FROM_HERE, | 80 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, |
| 79 browser_context_.release()); | 81 browser_context_.release()); |
| 80 base::RunLoop().RunUntilIdle(); | 82 base::RunLoop().RunUntilIdle(); |
| 81 #if !defined(OS_ANDROID) | 83 #if !defined(OS_ANDROID) |
| 82 ImageTransportFactory::Terminate(); | 84 ImageTransportFactory::Terminate(); |
| 83 #endif | 85 #endif |
| 84 } | 86 } |
| 85 | 87 |
| 86 protected: | 88 protected: |
| 87 base::MessageLoopForUI message_loop_; | |
| 88 | |
| 89 // Needed by base::PostTaskWithTraits in RenderWidgetHostImpl constructor. | 89 // Needed by base::PostTaskWithTraits in RenderWidgetHostImpl constructor. |
| 90 base::test::ScopedTaskScheduler task_scheduler_; | 90 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 91 | 91 |
| 92 std::unique_ptr<BrowserContext> browser_context_; | 92 std::unique_ptr<BrowserContext> browser_context_; |
| 93 MockRenderWidgetHostDelegate delegate_; | 93 MockRenderWidgetHostDelegate delegate_; |
| 94 | 94 |
| 95 // Tests should set these to NULL if they've already triggered their | 95 // Tests should set these to NULL if they've already triggered their |
| 96 // destruction. | 96 // destruction. |
| 97 RenderWidgetHostImpl* widget_host_; | 97 RenderWidgetHostImpl* widget_host_; |
| 98 RenderWidgetHostViewGuest* view_; | 98 RenderWidgetHostViewGuest* view_; |
| 99 | 99 |
| 100 private: | 100 private: |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 302 |
| 303 view_->SubmitCompositorFrame( | 303 view_->SubmitCompositorFrame( |
| 304 local_surface_id, | 304 local_surface_id, |
| 305 CreateDelegatedFrame(scale_factor, view_size, view_rect)); | 305 CreateDelegatedFrame(scale_factor, view_size, view_rect)); |
| 306 // Since guest is not attached, the CompositorFrame must be processed but the | 306 // Since guest is not attached, the CompositorFrame must be processed but the |
| 307 // frame must be evicted to return the resources immediately. | 307 // frame must be evicted to return the resources immediately. |
| 308 EXPECT_FALSE(view_->has_frame()); | 308 EXPECT_FALSE(view_->has_frame()); |
| 309 } | 309 } |
| 310 | 310 |
| 311 } // namespace content | 311 } // namespace content |
| OLD | NEW |