Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: content/browser/gpu/gpu_ipc_browsertests.cc

Issue 17904008: Fixing gpu_ipc_browsertests.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bogus merge artifact reverted Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/run_loop.h"
6 #include "cc/resources/sync_point_helper.h"
7 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" 5 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
8 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 6 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
9 #include "content/test/content_browser_test.h" 7 #include "content/test/content_browser_test.h"
10 #include "gpu/GLES2/gl2extchromium.h"
11 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h" 8 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h"
12 9
13 namespace content {
14 namespace { 10 namespace {
15 11
16 enum ContextType { 12 class ContextTestBase : public content::ContentBrowserTest {
17 GPU_SERVICE_CONTEXT,
18 IN_PROCESS_CONTEXT,
19 };
20
21 class SignalBrowserTest
22 : public ContentBrowserTest,
23 public ::testing::WithParamInterface<ContextType> {
24 public: 13 public:
25 virtual void SetUp() { 14 virtual void SetUpOnMainThread() OVERRIDE {
26 switch (GetParam()) { 15 context_.reset(
27 case GPU_SERVICE_CONTEXT: 16 content::WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
28 context_.reset( 17 content::BrowserGpuChannelHostFactory::instance(),
29 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( 18 WebKit::WebGraphicsContext3D::Attributes(),
30 BrowserGpuChannelHostFactory::instance(), 19 GURL()));
31 WebKit::WebGraphicsContext3D::Attributes(), 20 context_->makeContextCurrent();
32 GURL())); 21 ContentBrowserTest::SetUpOnMainThread();
33 break;
34 case IN_PROCESS_CONTEXT:
35 context_ =
36 webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl::
37 CreateOffscreenContext(WebKit::WebGraphicsContext3D::Attributes());
38 break;
39 }
40 } 22 }
41 23
42 // These tests should time out if the callback doesn't get called. 24 virtual void TearDownOnMainThread() OVERRIDE {
43 void testSignalSyncPoint(unsigned sync_point) { 25 // Must delete the context first.
44 base::RunLoop run_loop; 26 context_.reset(NULL);
45 cc::SyncPointHelper::SignalSyncPoint( 27 ContentBrowserTest::TearDownOnMainThread();
46 context_.get(), sync_point, run_loop.QuitClosure());
47 run_loop.Run();
48 }
49
50 // These tests should time out if the callback doesn't get called.
51 void testSignalQuery(WebKit::WebGLId query) {
52 base::RunLoop run_loop;
53 cc::SyncPointHelper::SignalQuery(
54 context_.get(), query, run_loop.QuitClosure());
55 run_loop.Run();
56 } 28 }
57 29
58 protected: 30 protected:
59 scoped_ptr<WebKit::WebGraphicsContext3D> context_; 31 scoped_ptr<WebKit::WebGraphicsContext3D> context_;
60 }; 32 };
61 33
62 IN_PROC_BROWSER_TEST_P(SignalBrowserTest, BasicSignalSyncPointTest) { 34 } // namespace
63 testSignalSyncPoint(context_->insertSyncPoint());
64 };
65 35
66 IN_PROC_BROWSER_TEST_P(SignalBrowserTest, InvalidSignalSyncPointTest) { 36 // Include the actual tests.
67 // Signalling something that doesn't exist should run the callback 37 #define CONTEXT_TEST_F IN_PROC_BROWSER_TEST_F
68 // immediately. 38 #include "content/browser/gpu/gpu_context_tests.h"
69 testSignalSyncPoint(1297824234);
70 };
71
72 IN_PROC_BROWSER_TEST_P(SignalBrowserTest, BasicSignalQueryTest) {
73 unsigned query = context_->createQueryEXT();
74 context_->beginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, query);
75 context_->finish();
76 context_->endQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
77 testSignalQuery(query);
78 context_->deleteQueryEXT(query);
79 };
80
81 IN_PROC_BROWSER_TEST_P(SignalBrowserTest, SignalQueryUnboundTest) {
82 WebKit::WebGLId query = context_->createQueryEXT();
83 testSignalQuery(query);
84 context_->deleteQueryEXT(query);
85 };
86
87 IN_PROC_BROWSER_TEST_P(SignalBrowserTest, InvalidSignalQueryUnboundTest) {
88 // Signalling something that doesn't exist should run the callback
89 // immediately.
90 testSignalQuery(928729087);
91 };
92
93 INSTANTIATE_TEST_CASE_P(, SignalBrowserTest,
94 ::testing::Values(GPU_SERVICE_CONTEXT,
95 IN_PROCESS_CONTEXT));
96
97 } // namespace
98 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698