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" |
(...skipping 17 matching lines...) Expand all Loading... |
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; | |
39 scoped_refptr<content::GpuChannelHost> gpu_channel_host( | 38 scoped_refptr<content::GpuChannelHost> gpu_channel_host( |
40 factory->EstablishGpuChannelSync(kInitCause)); | 39 factory->EstablishGpuChannelSync(kInitCause)); |
41 context_.reset( | 40 context_.reset( |
42 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 41 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
43 gpu_channel_host.get(), | 42 gpu_channel_host.get(), |
44 blink::WebGraphicsContext3D::Attributes(), | 43 blink::WebGraphicsContext3D::Attributes(), |
45 lose_context_when_out_of_memory, | |
46 GURL(), | 44 GURL(), |
47 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), | 45 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), |
48 NULL)); | 46 NULL)); |
49 CHECK(context_.get()); | 47 CHECK(context_.get()); |
50 context_->makeContextCurrent(); | 48 context_->makeContextCurrent(); |
51 context_support_ = context_->GetContextSupport(); | 49 context_support_ = context_->GetContextSupport(); |
52 ContentBrowserTest::SetUpOnMainThread(); | 50 ContentBrowserTest::SetUpOnMainThread(); |
53 } | 51 } |
54 | 52 |
55 virtual void TearDownOnMainThread() OVERRIDE { | 53 virtual void TearDownOnMainThread() OVERRIDE { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 GpuChannelHost* GetGpuChannel() { | 108 GpuChannelHost* GetGpuChannel() { |
111 return GetFactory()->GetGpuChannel(); | 109 return GetFactory()->GetGpuChannel(); |
112 } | 110 } |
113 | 111 |
114 static void Signal(bool *event) { | 112 static void Signal(bool *event) { |
115 CHECK_EQ(*event, false); | 113 CHECK_EQ(*event, false); |
116 *event = true; | 114 *event = true; |
117 } | 115 } |
118 | 116 |
119 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext() { | 117 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext() { |
120 bool lose_context_when_out_of_memory = false; | |
121 return make_scoped_ptr( | 118 return make_scoped_ptr( |
122 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 119 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
123 GetGpuChannel(), | 120 GetGpuChannel(), |
124 blink::WebGraphicsContext3D::Attributes(), | 121 blink::WebGraphicsContext3D::Attributes(), |
125 lose_context_when_out_of_memory, | |
126 GURL(), | 122 GURL(), |
127 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), | 123 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), |
128 NULL)); | 124 NULL)); |
129 } | 125 } |
130 }; | 126 }; |
131 | 127 |
132 // Fails since UI Compositor establishes a GpuChannel. | 128 // Fails since UI Compositor establishes a GpuChannel. |
133 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, DISABLED_Basic) { | 129 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, DISABLED_Basic) { |
134 DCHECK(!IsChannelEstablished()); | 130 DCHECK(!IsChannelEstablished()); |
135 EstablishAndWait(); | 131 EstablishAndWait(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 shim->SimulateCrash(); | 182 shim->SimulateCrash(); |
187 run_loop.Run(); | 183 run_loop.Run(); |
188 | 184 |
189 EXPECT_EQ(1, counter); | 185 EXPECT_EQ(1, counter); |
190 EXPECT_FALSE(IsChannelEstablished()); | 186 EXPECT_FALSE(IsChannelEstablished()); |
191 EstablishAndWait(); | 187 EstablishAndWait(); |
192 EXPECT_TRUE(IsChannelEstablished()); | 188 EXPECT_TRUE(IsChannelEstablished()); |
193 } | 189 } |
194 | 190 |
195 } // namespace content | 191 } // namespace content |
OLD | NEW |