| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 7 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 8 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 8 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 9 #include "content/common/gpu/client/context_provider_command_buffer.h" | 9 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 10 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 10 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 11 #include "content/common/gpu/gpu_process_launch_causes.h" | 11 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 12 #include "content/public/browser/gpu_data_manager.h" | 12 #include "content/public/browser/gpu_data_manager.h" |
| 13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 14 #include "content/public/test/content_browser_test.h" | 14 #include "content/public/test/content_browser_test.h" |
| 15 #include "ui/gl/gl_switches.h" | 15 #include "ui/gl/gl_switches.h" |
| 16 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" | 16 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 using content::WebGraphicsContext3DCommandBufferImpl; | 20 using content::WebGraphicsContext3DCommandBufferImpl; |
| 21 | 21 |
| 22 const content::CauseForGpuLaunch kInitCause = | 22 const content::CauseForGpuLaunch kInitCause = |
| 23 content:: | 23 content:: |
| 24 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; | 24 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
| 25 | 25 |
| 26 class ContextTestBase : public content::ContentBrowserTest { | 26 class ContextTestBase : public content::ContentBrowserTest { |
| 27 public: | 27 public: |
| 28 virtual void SetUpOnMainThread() OVERRIDE { | 28 virtual void SetUpOnMainThread() override { |
| 29 if (!content::BrowserGpuChannelHostFactory::CanUseForTesting()) | 29 if (!content::BrowserGpuChannelHostFactory::CanUseForTesting()) |
| 30 return; | 30 return; |
| 31 | 31 |
| 32 if (!content::BrowserGpuChannelHostFactory::instance()) | 32 if (!content::BrowserGpuChannelHostFactory::instance()) |
| 33 content::BrowserGpuChannelHostFactory::Initialize(true); | 33 content::BrowserGpuChannelHostFactory::Initialize(true); |
| 34 | 34 |
| 35 content::BrowserGpuChannelHostFactory* factory = | 35 content::BrowserGpuChannelHostFactory* factory = |
| 36 content::BrowserGpuChannelHostFactory::instance(); | 36 content::BrowserGpuChannelHostFactory::instance(); |
| 37 CHECK(factory); | 37 CHECK(factory); |
| 38 bool lose_context_when_out_of_memory = false; | 38 bool lose_context_when_out_of_memory = false; |
| 39 scoped_refptr<content::GpuChannelHost> gpu_channel_host( | 39 scoped_refptr<content::GpuChannelHost> gpu_channel_host( |
| 40 factory->EstablishGpuChannelSync(kInitCause)); | 40 factory->EstablishGpuChannelSync(kInitCause)); |
| 41 context_.reset( | 41 context_.reset( |
| 42 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 42 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
| 43 gpu_channel_host.get(), | 43 gpu_channel_host.get(), |
| 44 blink::WebGraphicsContext3D::Attributes(), | 44 blink::WebGraphicsContext3D::Attributes(), |
| 45 lose_context_when_out_of_memory, | 45 lose_context_when_out_of_memory, |
| 46 GURL(), | 46 GURL(), |
| 47 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), | 47 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), |
| 48 NULL)); | 48 NULL)); |
| 49 CHECK(context_.get()); | 49 CHECK(context_.get()); |
| 50 context_->InitializeOnCurrentThread(); | 50 context_->InitializeOnCurrentThread(); |
| 51 context_support_ = context_->GetContextSupport(); | 51 context_support_ = context_->GetContextSupport(); |
| 52 ContentBrowserTest::SetUpOnMainThread(); | 52 ContentBrowserTest::SetUpOnMainThread(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 virtual void TearDownOnMainThread() OVERRIDE { | 55 virtual void TearDownOnMainThread() override { |
| 56 // Must delete the context first. | 56 // Must delete the context first. |
| 57 context_.reset(NULL); | 57 context_.reset(NULL); |
| 58 ContentBrowserTest::TearDownOnMainThread(); | 58 ContentBrowserTest::TearDownOnMainThread(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 protected: | 61 protected: |
| 62 scoped_ptr<content::WebGraphicsContext3DCommandBufferImpl> context_; | 62 scoped_ptr<content::WebGraphicsContext3DCommandBufferImpl> context_; |
| 63 gpu::ContextSupport* context_support_; | 63 gpu::ContextSupport* context_support_; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 } // namespace | 66 } // namespace |
| 67 | 67 |
| 68 // Include the shared tests. | 68 // Include the shared tests. |
| 69 #define CONTEXT_TEST_F IN_PROC_BROWSER_TEST_F | 69 #define CONTEXT_TEST_F IN_PROC_BROWSER_TEST_F |
| 70 #include "content/common/gpu/client/gpu_context_tests.h" | 70 #include "content/common/gpu/client/gpu_context_tests.h" |
| 71 | 71 |
| 72 namespace content { | 72 namespace content { |
| 73 | 73 |
| 74 class BrowserGpuChannelHostFactoryTest : public ContentBrowserTest { | 74 class BrowserGpuChannelHostFactoryTest : public ContentBrowserTest { |
| 75 public: | 75 public: |
| 76 virtual void SetUpOnMainThread() OVERRIDE { | 76 virtual void SetUpOnMainThread() override { |
| 77 if (!BrowserGpuChannelHostFactory::CanUseForTesting()) | 77 if (!BrowserGpuChannelHostFactory::CanUseForTesting()) |
| 78 return; | 78 return; |
| 79 | 79 |
| 80 // Start all tests without a gpu channel so that the tests exercise a | 80 // Start all tests without a gpu channel so that the tests exercise a |
| 81 // consistent codepath. | 81 // consistent codepath. |
| 82 if (!BrowserGpuChannelHostFactory::instance()) | 82 if (!BrowserGpuChannelHostFactory::instance()) |
| 83 BrowserGpuChannelHostFactory::Initialize(false); | 83 BrowserGpuChannelHostFactory::Initialize(false); |
| 84 | 84 |
| 85 CHECK(GetFactory()); | 85 CHECK(GetFactory()); |
| 86 | 86 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 shim->SimulateCrash(); | 186 shim->SimulateCrash(); |
| 187 run_loop.Run(); | 187 run_loop.Run(); |
| 188 | 188 |
| 189 EXPECT_EQ(1, counter); | 189 EXPECT_EQ(1, counter); |
| 190 EXPECT_FALSE(IsChannelEstablished()); | 190 EXPECT_FALSE(IsChannelEstablished()); |
| 191 EstablishAndWait(); | 191 EstablishAndWait(); |
| 192 EXPECT_TRUE(IsChannelEstablished()); | 192 EXPECT_TRUE(IsChannelEstablished()); |
| 193 } | 193 } |
| 194 | 194 |
| 195 } // namespace content | 195 } // namespace content |
| OLD | NEW |