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

Side by Side Diff: content/common/gpu/client/gpu_context_tests.h

Issue 1867873002: Move unittests in content/common/gpu/client to gpu/ipc/client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 4 years, 7 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // These tests are run twice:
6 // Once in a gpu test with an in-process WebGraphicsContext3D.
7 // Once in a browsertest with a gpu-process WebGraphicsContext3D.
8
9 #include "base/bind.h"
10 #include "base/run_loop.h"
11 #include "gpu/GLES2/gl2extchromium.h"
12 #include "gpu/command_buffer/client/context_support.h"
13 #include "gpu/command_buffer/client/gles2_interface.h"
14 #include "gpu/command_buffer/common/sync_token.h"
15
16 namespace {
17
18 class SignalTest : public ContextTestBase {
19 public:
20 static void RunOnlyOnce(base::Closure cb, int* tmp) {
21 CHECK_EQ(*tmp, 0);
22 ++*tmp;
23 cb.Run();
24 }
25
26 // These tests should time out if the callback doesn't get called.
27 void TestSignalSyncToken(const gpu::SyncToken& sync_token) {
28 base::RunLoop run_loop;
29 context_support_->SignalSyncToken(sync_token, run_loop.QuitClosure());
30 run_loop.Run();
31 }
32
33 // These tests should time out if the callback doesn't get called.
34 void TestSignalQuery(GLuint query) {
35 base::RunLoop run_loop;
36 context_support_->SignalQuery(
37 query, base::Bind(&RunOnlyOnce, run_loop.QuitClosure(),
38 base::Owned(new int(0))));
39 run_loop.Run();
40 }
41 };
42
43 CONTEXT_TEST_F(SignalTest, BasicSignalSyncTokenTest) {
44 #if defined(OS_WIN)
45 // The IPC version of ContextTestBase::SetUpOnMainThread does not succeed on
46 // some platforms.
47 if (!gl_)
48 return;
49 #endif
50
51 const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM();
52 gl_->ShallowFlushCHROMIUM();
53
54 gpu::SyncToken sync_token;
55 gl_->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
56
57 TestSignalSyncToken(sync_token);
58 };
59
60 CONTEXT_TEST_F(SignalTest, EmptySignalSyncTokenTest) {
61 #if defined(OS_WIN)
62 // The IPC version of ContextTestBase::SetUpOnMainThread does not succeed on
63 // some platforms.
64 if (!gl_)
65 return;
66 #endif
67
68 // Signalling something that doesn't exist should run the callback
69 // immediately.
70 gpu::SyncToken sync_token;
71 TestSignalSyncToken(sync_token);
72 };
73
74 CONTEXT_TEST_F(SignalTest, InvalidSignalSyncTokenTest) {
75 #if defined(OS_WIN)
76 // The IPC version of ContextTestBase::SetUpOnMainThread does not succeed on
77 // some platforms.
78 if (!gl_)
79 return;
80 #endif
81
82 // Signalling something that doesn't exist should run the callback
83 // immediately.
84 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
85 gpu::CommandBufferId::FromUnsafeValue(1297824234),
86 9123743439);
87 TestSignalSyncToken(sync_token);
88 };
89
90 CONTEXT_TEST_F(SignalTest, BasicSignalQueryTest) {
91 #if defined(OS_WIN)
92 // The IPC version of ContextTestBase::SetUpOnMainThread does not succeed on
93 // some platforms.
94 if (!gl_)
95 return;
96 #endif
97
98 unsigned query;
99 gl_->GenQueriesEXT(1, &query);
100 gl_->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, query);
101 gl_->Finish();
102 gl_->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
103 TestSignalQuery(query);
104 gl_->DeleteQueriesEXT(1, &query);
105 };
106
107 CONTEXT_TEST_F(SignalTest, SignalQueryUnboundTest) {
108 #if defined(OS_WIN)
109 // The IPC version of ContextTestBase::SetUpOnMainThread does not succeed on
110 // some platforms.
111 if (!gl_)
112 return;
113 #endif
114
115 GLuint query;
116 gl_->GenQueriesEXT(1, &query);
117 TestSignalQuery(query);
118 gl_->DeleteQueriesEXT(1, &query);
119 };
120
121 CONTEXT_TEST_F(SignalTest, InvalidSignalQueryUnboundTest) {
122 #if defined(OS_WIN)
123 // The IPC version of ContextTestBase::SetUpOnMainThread does not succeed on
124 // some platforms.
125 if (!gl_)
126 return;
127 #endif
128
129 // Signalling something that doesn't exist should run the callback
130 // immediately.
131 TestSignalQuery(928729087);
132 TestSignalQuery(928729086);
133 TestSignalQuery(928729085);
134 TestSignalQuery(928729083);
135 TestSignalQuery(928729082);
136 TestSignalQuery(928729081);
137 };
138 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698