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 "content/browser/gpu/browser_gpu_channel_host_factory.h" | 6 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
7 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 7 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
8 #include "content/public/common/content_switches.h" | 8 #include "content/public/common/content_switches.h" |
9 #include "content/test/content_browser_test.h" | 9 #include "content/test/content_browser_test.h" |
10 #include "ui/gl/gl_switches.h" | 10 #include "ui/gl/gl_switches.h" |
11 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" | 11 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 class ContextTestBase : public content::ContentBrowserTest { | 15 class ContextTestBase : public content::ContentBrowserTest { |
16 public: | 16 public: |
17 virtual void SetUpOnMainThread() OVERRIDE { | 17 virtual void SetUpOnMainThread() OVERRIDE { |
18 CHECK(content::BrowserGpuChannelHostFactory::instance()); | 18 CHECK(content::BrowserGpuChannelHostFactory::instance()); |
19 context_.reset( | 19 context_.reset( |
20 content::WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 20 content::WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
21 content::BrowserGpuChannelHostFactory::instance(), | 21 content::BrowserGpuChannelHostFactory::instance(), |
22 WebKit::WebGraphicsContext3D::Attributes(), | 22 WebKit::WebGraphicsContext3D::Attributes(), |
23 GURL())); | 23 GURL())); |
24 CHECK(context_.get()); | 24 CHECK(context_.get()); |
25 context_->makeContextCurrent(); | 25 context_->makeContextCurrent(); |
26 ContentBrowserTest::SetUpOnMainThread(); | 26 ContentBrowserTest::SetUpOnMainThread(); |
27 } | 27 } |
28 | 28 |
| 29 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 30 // TODO(Hubbe): This code is very similar to some code in |
| 31 // test/gpu/gpu_feature_browsertest.cc, and should really be |
| 32 // shared in a common location. |
| 33 if (!command_line->HasSwitch(switches::kUseGpuInTests)) { |
| 34 CHECK(!command_line->HasSwitch(switches::kUseGL)) |
| 35 << "kUseGL must not be set by test framework code!"; |
| 36 command_line->AppendSwitchASCII(switches::kUseGL, |
| 37 gfx::kGLImplementationOSMesaName); |
| 38 } |
| 39 } |
| 40 |
29 virtual void TearDownOnMainThread() OVERRIDE { | 41 virtual void TearDownOnMainThread() OVERRIDE { |
30 // Must delete the context first. | 42 // Must delete the context first. |
31 context_.reset(NULL); | 43 context_.reset(NULL); |
32 ContentBrowserTest::TearDownOnMainThread(); | 44 ContentBrowserTest::TearDownOnMainThread(); |
33 } | 45 } |
34 | 46 |
35 protected: | 47 protected: |
36 scoped_ptr<WebKit::WebGraphicsContext3D> context_; | 48 scoped_ptr<WebKit::WebGraphicsContext3D> context_; |
37 }; | 49 }; |
38 | 50 |
39 } // namespace | 51 } // namespace |
40 | 52 |
41 // Include the actual tests. | 53 // Include the actual tests. |
42 #define CONTEXT_TEST_F IN_PROC_BROWSER_TEST_F | 54 #define CONTEXT_TEST_F IN_PROC_BROWSER_TEST_F |
43 #include "content/common/gpu/client/gpu_context_tests.h" | 55 #include "content/common/gpu/client/gpu_context_tests.h" |
OLD | NEW |