Chromium Code Reviews| 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" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/test/scoped_task_scheduler.h" | |
| 14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 15 #include "cc/surfaces/surface.h" | 16 #include "cc/surfaces/surface.h" |
| 16 #include "cc/surfaces/surface_factory.h" | 17 #include "cc/surfaces/surface_factory.h" |
| 17 #include "cc/surfaces/surface_manager.h" | 18 #include "cc/surfaces/surface_manager.h" |
| 18 #include "cc/surfaces/surface_sequence.h" | 19 #include "cc/surfaces/surface_sequence.h" |
| 19 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 20 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 20 #include "content/browser/compositor/test/no_transport_image_transport_factory.h " | 21 #include "content/browser/compositor/test/no_transport_image_transport_factory.h " |
| 21 #include "content/browser/gpu/compositor_util.h" | 22 #include "content/browser/gpu/compositor_util.h" |
| 22 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 23 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 23 #include "content/browser/renderer_host/render_widget_host_impl.h" | 24 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 46 private: | 47 private: |
| 47 // RenderWidgetHostDelegate: | 48 // RenderWidgetHostDelegate: |
| 48 void Cut() override {} | 49 void Cut() override {} |
| 49 void Copy() override {} | 50 void Copy() override {} |
| 50 void Paste() override {} | 51 void Paste() override {} |
| 51 void SelectAll() override {} | 52 void SelectAll() override {} |
| 52 }; | 53 }; |
| 53 | 54 |
| 54 class RenderWidgetHostViewGuestTest : public testing::Test { | 55 class RenderWidgetHostViewGuestTest : public testing::Test { |
| 55 public: | 56 public: |
| 56 RenderWidgetHostViewGuestTest() {} | 57 RenderWidgetHostViewGuestTest() : task_scheduler_(&message_loop_) {} |
| 57 | 58 |
| 58 void SetUp() override { | 59 void SetUp() override { |
| 59 #if !defined(OS_ANDROID) | 60 #if !defined(OS_ANDROID) |
| 60 ImageTransportFactory::InitializeForUnitTests( | 61 ImageTransportFactory::InitializeForUnitTests( |
| 61 std::unique_ptr<ImageTransportFactory>( | 62 std::unique_ptr<ImageTransportFactory>( |
| 62 new NoTransportImageTransportFactory)); | 63 new NoTransportImageTransportFactory)); |
| 63 #else | 64 #else |
| 64 ContextProviderFactoryImpl::Initialize(&gpu_channel_factory_); | 65 ContextProviderFactoryImpl::Initialize(&gpu_channel_factory_); |
| 65 ui::ContextProviderFactory::SetInstance( | 66 ui::ContextProviderFactory::SetInstance( |
| 66 ContextProviderFactoryImpl::GetInstance()); | 67 ContextProviderFactoryImpl::GetInstance()); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 89 #if !defined(OS_ANDROID) | 90 #if !defined(OS_ANDROID) |
| 90 ImageTransportFactory::Terminate(); | 91 ImageTransportFactory::Terminate(); |
| 91 #else | 92 #else |
| 92 ui::ContextProviderFactory::SetInstance(nullptr); | 93 ui::ContextProviderFactory::SetInstance(nullptr); |
| 93 ContextProviderFactoryImpl::Terminate(); | 94 ContextProviderFactoryImpl::Terminate(); |
| 94 #endif | 95 #endif |
| 95 } | 96 } |
| 96 | 97 |
| 97 protected: | 98 protected: |
| 98 base::MessageLoopForUI message_loop_; | 99 base::MessageLoopForUI message_loop_; |
| 100 base::test::ScopedTaskScheduler task_scheduler_; | |
|
alexmos
2017/02/23 22:31:54
Perhaps also add a quick comment here why this is
tzik
2017/02/23 23:49:42
Done.
| |
| 99 std::unique_ptr<BrowserContext> browser_context_; | 101 std::unique_ptr<BrowserContext> browser_context_; |
| 100 MockRenderWidgetHostDelegate delegate_; | 102 MockRenderWidgetHostDelegate delegate_; |
| 101 | 103 |
| 102 // Tests should set these to NULL if they've already triggered their | 104 // Tests should set these to NULL if they've already triggered their |
| 103 // destruction. | 105 // destruction. |
| 104 RenderWidgetHostImpl* widget_host_; | 106 RenderWidgetHostImpl* widget_host_; |
| 105 RenderWidgetHostViewGuest* view_; | 107 RenderWidgetHostViewGuest* view_; |
| 106 | 108 |
| 107 #if defined(OS_ANDROID) | 109 #if defined(OS_ANDROID) |
| 108 MockGpuChannelEstablishFactory gpu_channel_factory_; | 110 MockGpuChannelEstablishFactory gpu_channel_factory_; |
| 109 #endif | 111 #endif |
| 110 | 112 |
| 111 private: | 113 private: |
| 112 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewGuestTest); | 114 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewGuestTest); |
| 113 }; | 115 }; |
| 114 | 116 |
| 115 } // namespace | 117 } // namespace |
| 116 | 118 |
| 117 // Fails on Windows, crbug.com/695375. | 119 TEST_F(RenderWidgetHostViewGuestTest, VisibilityTest) { |
| 118 #if defined(OS_WIN) | |
| 119 #define MAYBE_VisibilityTest DISABLED_VisibilityTest | |
| 120 #else | |
| 121 #define MAYBE_VisibilityTest VisibilityTest | |
| 122 #endif | |
| 123 TEST_F(RenderWidgetHostViewGuestTest, MAYBE_VisibilityTest) { | |
| 124 view_->Show(); | 120 view_->Show(); |
| 125 ASSERT_TRUE(view_->IsShowing()); | 121 ASSERT_TRUE(view_->IsShowing()); |
| 126 | 122 |
| 127 view_->Hide(); | 123 view_->Hide(); |
| 128 ASSERT_FALSE(view_->IsShowing()); | 124 ASSERT_FALSE(view_->IsShowing()); |
| 129 } | 125 } |
| 130 | 126 |
| 131 class TestBrowserPluginGuest : public BrowserPluginGuest { | 127 class TestBrowserPluginGuest : public BrowserPluginGuest { |
| 132 public: | 128 public: |
| 133 TestBrowserPluginGuest(WebContentsImpl* web_contents, | 129 TestBrowserPluginGuest(WebContentsImpl* web_contents, |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 | 305 |
| 310 browser_plugin_guest_->set_attached(false); | 306 browser_plugin_guest_->set_attached(false); |
| 311 browser_plugin_guest_->ResetTestData(); | 307 browser_plugin_guest_->ResetTestData(); |
| 312 | 308 |
| 313 view_->OnSwapCompositorFrame( | 309 view_->OnSwapCompositorFrame( |
| 314 0, CreateDelegatedFrame(scale_factor, view_size, view_rect)); | 310 0, CreateDelegatedFrame(scale_factor, view_size, view_rect)); |
| 315 EXPECT_FALSE(GetSurfaceId().is_valid()); | 311 EXPECT_FALSE(GetSurfaceId().is_valid()); |
| 316 } | 312 } |
| 317 | 313 |
| 318 } // namespace content | 314 } // namespace content |
| OLD | NEW |