1 // Copyright 2014 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.
5 // This file is auto-generated from
6 // gpu/command_buffer/build_gles2_cmd_buffer.py
7 // It's formatted by clang-format using chromium coding style:
8 // clang-format -i -style=chromium filename
11 // This file is included by gles2_implementation.h to declare the
13 #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_
14 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_
16 TEST_F(GLES2ImplementationTest
, AttachShader
) {
18 cmds::AttachShader cmd
;
21 expected
.cmd
.Init(1, 2);
23 gl_
->AttachShader(1, 2);
24 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
26 // TODO(zmo): Implement unit test for BindAttribLocation
28 TEST_F(GLES2ImplementationTest
, BindBuffer
) {
33 expected
.cmd
.Init(GL_ARRAY_BUFFER
, 2);
35 gl_
->BindBuffer(GL_ARRAY_BUFFER
, 2);
36 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
38 gl_
->BindBuffer(GL_ARRAY_BUFFER
, 2);
39 EXPECT_TRUE(NoCommandsWritten());
42 TEST_F(GLES2ImplementationTest
, BindBufferBase
) {
44 cmds::BindBufferBase cmd
;
47 expected
.cmd
.Init(GL_TRANSFORM_FEEDBACK_BUFFER
, 2, 3);
49 gl_
->BindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER
, 2, 3);
50 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
53 TEST_F(GLES2ImplementationTest
, BindBufferRange
) {
55 cmds::BindBufferRange cmd
;
58 expected
.cmd
.Init(GL_TRANSFORM_FEEDBACK_BUFFER
, 2, 3, 4, 4);
60 gl_
->BindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER
, 2, 3, 4, 4);
61 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
64 TEST_F(GLES2ImplementationTest
, BindFramebuffer
) {
66 cmds::BindFramebuffer cmd
;
69 expected
.cmd
.Init(GL_FRAMEBUFFER
, 2);
71 gl_
->BindFramebuffer(GL_FRAMEBUFFER
, 2);
72 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
74 gl_
->BindFramebuffer(GL_FRAMEBUFFER
, 2);
75 EXPECT_TRUE(NoCommandsWritten());
78 TEST_F(GLES2ImplementationTest
, BindRenderbuffer
) {
80 cmds::BindRenderbuffer cmd
;
83 expected
.cmd
.Init(GL_RENDERBUFFER
, 2);
85 gl_
->BindRenderbuffer(GL_RENDERBUFFER
, 2);
86 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
88 gl_
->BindRenderbuffer(GL_RENDERBUFFER
, 2);
89 EXPECT_TRUE(NoCommandsWritten());
92 TEST_F(GLES2ImplementationTest
, BindSampler
) {
94 cmds::BindSampler cmd
;
97 expected
.cmd
.Init(1, 2);
99 gl_
->BindSampler(1, 2);
100 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
103 TEST_F(GLES2ImplementationTest
, BindTransformFeedback
) {
105 cmds::BindTransformFeedback cmd
;
108 expected
.cmd
.Init(GL_TRANSFORM_FEEDBACK
, 2);
110 gl_
->BindTransformFeedback(GL_TRANSFORM_FEEDBACK
, 2);
111 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
114 TEST_F(GLES2ImplementationTest
, BlendColor
) {
116 cmds::BlendColor cmd
;
119 expected
.cmd
.Init(1, 2, 3, 4);
121 gl_
->BlendColor(1, 2, 3, 4);
122 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
125 TEST_F(GLES2ImplementationTest
, BlendEquation
) {
127 cmds::BlendEquation cmd
;
130 expected
.cmd
.Init(GL_FUNC_SUBTRACT
);
132 gl_
->BlendEquation(GL_FUNC_SUBTRACT
);
133 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
136 TEST_F(GLES2ImplementationTest
, BlendEquationSeparate
) {
138 cmds::BlendEquationSeparate cmd
;
141 expected
.cmd
.Init(GL_FUNC_SUBTRACT
, GL_FUNC_ADD
);
143 gl_
->BlendEquationSeparate(GL_FUNC_SUBTRACT
, GL_FUNC_ADD
);
144 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
147 TEST_F(GLES2ImplementationTest
, BlendFunc
) {
152 expected
.cmd
.Init(GL_ZERO
, GL_ZERO
);
154 gl_
->BlendFunc(GL_ZERO
, GL_ZERO
);
155 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
158 TEST_F(GLES2ImplementationTest
, BlendFuncSeparate
) {
160 cmds::BlendFuncSeparate cmd
;
163 expected
.cmd
.Init(GL_ZERO
, GL_ZERO
, GL_ZERO
, GL_ZERO
);
165 gl_
->BlendFuncSeparate(GL_ZERO
, GL_ZERO
, GL_ZERO
, GL_ZERO
);
166 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
169 TEST_F(GLES2ImplementationTest
, CheckFramebufferStatus
) {
171 cmds::CheckFramebufferStatus cmd
;
175 ExpectedMemoryInfo result1
=
176 GetExpectedResultMemory(sizeof(cmds::CheckFramebufferStatus::Result
));
177 expected
.cmd
.Init(GL_FRAMEBUFFER
, result1
.id
, result1
.offset
);
179 EXPECT_CALL(*command_buffer(), OnFlush())
180 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
181 .RetiresOnSaturation();
183 GLboolean result
= gl_
->CheckFramebufferStatus(GL_FRAMEBUFFER
);
184 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
188 TEST_F(GLES2ImplementationTest
, Clear
) {
193 expected
.cmd
.Init(1);
196 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
199 TEST_F(GLES2ImplementationTest
, ClearBufferfi
) {
201 cmds::ClearBufferfi cmd
;
204 expected
.cmd
.Init(GL_COLOR
, 2, 3, 4);
206 gl_
->ClearBufferfi(GL_COLOR
, 2, 3, 4);
207 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
210 TEST_F(GLES2ImplementationTest
, ClearBufferfv
) {
211 GLfloat data
[4] = {0};
213 cmds::ClearBufferfvImmediate cmd
;
217 for (int jj
= 0; jj
< 4; ++jj
) {
218 data
[jj
] = static_cast<GLfloat
>(jj
);
221 expected
.cmd
.Init(GL_COLOR
, 2, &data
[0]);
222 gl_
->ClearBufferfv(GL_COLOR
, 2, &data
[0]);
223 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
226 TEST_F(GLES2ImplementationTest
, ClearBufferiv
) {
229 cmds::ClearBufferivImmediate cmd
;
233 for (int jj
= 0; jj
< 4; ++jj
) {
234 data
[jj
] = static_cast<GLint
>(jj
);
237 expected
.cmd
.Init(GL_COLOR
, 2, &data
[0]);
238 gl_
->ClearBufferiv(GL_COLOR
, 2, &data
[0]);
239 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
242 TEST_F(GLES2ImplementationTest
, ClearBufferuiv
) {
243 GLuint data
[4] = {0};
245 cmds::ClearBufferuivImmediate cmd
;
249 for (int jj
= 0; jj
< 4; ++jj
) {
250 data
[jj
] = static_cast<GLuint
>(jj
);
253 expected
.cmd
.Init(GL_COLOR
, 2, &data
[0]);
254 gl_
->ClearBufferuiv(GL_COLOR
, 2, &data
[0]);
255 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
258 TEST_F(GLES2ImplementationTest
, ClearColor
) {
260 cmds::ClearColor cmd
;
263 expected
.cmd
.Init(1, 2, 3, 4);
265 gl_
->ClearColor(1, 2, 3, 4);
266 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
269 TEST_F(GLES2ImplementationTest
, ClearDepthf
) {
271 cmds::ClearDepthf cmd
;
274 expected
.cmd
.Init(0.5f
);
276 gl_
->ClearDepthf(0.5f
);
277 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
280 TEST_F(GLES2ImplementationTest
, ClearStencil
) {
282 cmds::ClearStencil cmd
;
285 expected
.cmd
.Init(1);
287 gl_
->ClearStencil(1);
288 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
290 // TODO(zmo): Implement unit test for ClientWaitSync
292 TEST_F(GLES2ImplementationTest
, ColorMask
) {
297 expected
.cmd
.Init(true, true, true, true);
299 gl_
->ColorMask(true, true, true, true);
300 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
303 TEST_F(GLES2ImplementationTest
, CompileShader
) {
305 cmds::CompileShader cmd
;
308 expected
.cmd
.Init(1);
310 gl_
->CompileShader(1);
311 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
313 // TODO(zmo): Implement unit test for CompressedTexImage2D
314 // TODO(zmo): Implement unit test for CompressedTexSubImage2D
316 TEST_F(GLES2ImplementationTest
, CopyBufferSubData
) {
318 cmds::CopyBufferSubData cmd
;
321 expected
.cmd
.Init(GL_ARRAY_BUFFER
, GL_ARRAY_BUFFER
, 3, 4, 5);
323 gl_
->CopyBufferSubData(GL_ARRAY_BUFFER
, GL_ARRAY_BUFFER
, 3, 4, 5);
324 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
327 TEST_F(GLES2ImplementationTest
, CopyTexImage2D
) {
329 cmds::CopyTexImage2D cmd
;
332 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, GL_ALPHA
, 4, 5, 6, 7);
334 gl_
->CopyTexImage2D(GL_TEXTURE_2D
, 2, GL_ALPHA
, 4, 5, 6, 7, 0);
335 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
338 TEST_F(GLES2ImplementationTest
, CopyTexImage2DInvalidConstantArg7
) {
339 gl_
->CopyTexImage2D(GL_TEXTURE_2D
, 2, GL_ALPHA
, 4, 5, 6, 7, 1);
340 EXPECT_TRUE(NoCommandsWritten());
341 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
344 TEST_F(GLES2ImplementationTest
, CopyTexSubImage2D
) {
346 cmds::CopyTexSubImage2D cmd
;
349 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, 3, 4, 5, 6, 7, 8);
351 gl_
->CopyTexSubImage2D(GL_TEXTURE_2D
, 2, 3, 4, 5, 6, 7, 8);
352 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
355 TEST_F(GLES2ImplementationTest
, CopyTexSubImage3D
) {
357 cmds::CopyTexSubImage3D cmd
;
360 expected
.cmd
.Init(GL_TEXTURE_3D
, 2, 3, 4, 5, 6, 7, 8, 9);
362 gl_
->CopyTexSubImage3D(GL_TEXTURE_3D
, 2, 3, 4, 5, 6, 7, 8, 9);
363 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
366 TEST_F(GLES2ImplementationTest
, CullFace
) {
371 expected
.cmd
.Init(GL_FRONT
);
373 gl_
->CullFace(GL_FRONT
);
374 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
377 TEST_F(GLES2ImplementationTest
, DeleteBuffers
) {
378 GLuint ids
[2] = {kBuffersStartId
, kBuffersStartId
+ 1};
380 cmds::DeleteBuffersImmediate del
;
384 expected
.del
.Init(arraysize(ids
), &ids
[0]);
385 expected
.data
[0] = kBuffersStartId
;
386 expected
.data
[1] = kBuffersStartId
+ 1;
387 gl_
->DeleteBuffers(arraysize(ids
), &ids
[0]);
388 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
391 TEST_F(GLES2ImplementationTest
, DeleteFramebuffers
) {
392 GLuint ids
[2] = {kFramebuffersStartId
, kFramebuffersStartId
+ 1};
394 cmds::DeleteFramebuffersImmediate del
;
398 expected
.del
.Init(arraysize(ids
), &ids
[0]);
399 expected
.data
[0] = kFramebuffersStartId
;
400 expected
.data
[1] = kFramebuffersStartId
+ 1;
401 gl_
->DeleteFramebuffers(arraysize(ids
), &ids
[0]);
402 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
405 TEST_F(GLES2ImplementationTest
, DeleteProgram
) {
407 cmds::DeleteProgram cmd
;
410 expected
.cmd
.Init(1);
412 gl_
->DeleteProgram(1);
413 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
416 TEST_F(GLES2ImplementationTest
, DeleteRenderbuffers
) {
417 GLuint ids
[2] = {kRenderbuffersStartId
, kRenderbuffersStartId
+ 1};
419 cmds::DeleteRenderbuffersImmediate del
;
423 expected
.del
.Init(arraysize(ids
), &ids
[0]);
424 expected
.data
[0] = kRenderbuffersStartId
;
425 expected
.data
[1] = kRenderbuffersStartId
+ 1;
426 gl_
->DeleteRenderbuffers(arraysize(ids
), &ids
[0]);
427 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
430 TEST_F(GLES2ImplementationTest
, DeleteSamplers
) {
431 GLuint ids
[2] = {kSamplersStartId
, kSamplersStartId
+ 1};
433 cmds::DeleteSamplersImmediate del
;
437 expected
.del
.Init(arraysize(ids
), &ids
[0]);
438 expected
.data
[0] = kSamplersStartId
;
439 expected
.data
[1] = kSamplersStartId
+ 1;
440 gl_
->DeleteSamplers(arraysize(ids
), &ids
[0]);
441 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
444 TEST_F(GLES2ImplementationTest
, DeleteSync
) {
446 cmds::DeleteSync cmd
;
449 expected
.cmd
.Init(1);
451 gl_
->DeleteSync(reinterpret_cast<GLsync
>(1));
452 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
455 TEST_F(GLES2ImplementationTest
, DeleteShader
) {
457 cmds::DeleteShader cmd
;
460 expected
.cmd
.Init(1);
462 gl_
->DeleteShader(1);
463 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
466 TEST_F(GLES2ImplementationTest
, DeleteTextures
) {
467 GLuint ids
[2] = {kTexturesStartId
, kTexturesStartId
+ 1};
469 cmds::DeleteTexturesImmediate del
;
473 expected
.del
.Init(arraysize(ids
), &ids
[0]);
474 expected
.data
[0] = kTexturesStartId
;
475 expected
.data
[1] = kTexturesStartId
+ 1;
476 gl_
->DeleteTextures(arraysize(ids
), &ids
[0]);
477 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
480 TEST_F(GLES2ImplementationTest
, DeleteTransformFeedbacks
) {
481 GLuint ids
[2] = {kTransformFeedbacksStartId
, kTransformFeedbacksStartId
+ 1};
483 cmds::DeleteTransformFeedbacksImmediate del
;
487 expected
.del
.Init(arraysize(ids
), &ids
[0]);
488 expected
.data
[0] = kTransformFeedbacksStartId
;
489 expected
.data
[1] = kTransformFeedbacksStartId
+ 1;
490 gl_
->DeleteTransformFeedbacks(arraysize(ids
), &ids
[0]);
491 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
494 TEST_F(GLES2ImplementationTest
, DepthFunc
) {
499 expected
.cmd
.Init(GL_NEVER
);
501 gl_
->DepthFunc(GL_NEVER
);
502 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
505 TEST_F(GLES2ImplementationTest
, DepthMask
) {
510 expected
.cmd
.Init(true);
512 gl_
->DepthMask(true);
513 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
516 TEST_F(GLES2ImplementationTest
, DepthRangef
) {
518 cmds::DepthRangef cmd
;
521 expected
.cmd
.Init(1, 2);
523 gl_
->DepthRangef(1, 2);
524 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
527 TEST_F(GLES2ImplementationTest
, DetachShader
) {
529 cmds::DetachShader cmd
;
532 expected
.cmd
.Init(1, 2);
534 gl_
->DetachShader(1, 2);
535 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
538 TEST_F(GLES2ImplementationTest
, DisableVertexAttribArray
) {
540 cmds::DisableVertexAttribArray cmd
;
543 expected
.cmd
.Init(1);
545 gl_
->DisableVertexAttribArray(1);
546 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
549 TEST_F(GLES2ImplementationTest
, DrawArrays
) {
551 cmds::DrawArrays cmd
;
554 expected
.cmd
.Init(GL_POINTS
, 2, 3);
556 gl_
->DrawArrays(GL_POINTS
, 2, 3);
557 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
560 TEST_F(GLES2ImplementationTest
, EnableVertexAttribArray
) {
562 cmds::EnableVertexAttribArray cmd
;
565 expected
.cmd
.Init(1);
567 gl_
->EnableVertexAttribArray(1);
568 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
571 TEST_F(GLES2ImplementationTest
, Flush
) {
579 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
582 TEST_F(GLES2ImplementationTest
, FramebufferRenderbuffer
) {
584 cmds::FramebufferRenderbuffer cmd
;
587 expected
.cmd
.Init(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_RENDERBUFFER
, 4);
589 gl_
->FramebufferRenderbuffer(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
,
591 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
594 TEST_F(GLES2ImplementationTest
, FramebufferTexture2D
) {
596 cmds::FramebufferTexture2D cmd
;
599 expected
.cmd
.Init(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 4);
601 gl_
->FramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
,
603 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
606 TEST_F(GLES2ImplementationTest
, FramebufferTexture2DInvalidConstantArg4
) {
607 gl_
->FramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
,
609 EXPECT_TRUE(NoCommandsWritten());
610 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
613 TEST_F(GLES2ImplementationTest
, FramebufferTextureLayer
) {
615 cmds::FramebufferTextureLayer cmd
;
618 expected
.cmd
.Init(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, 3, 4, 5);
620 gl_
->FramebufferTextureLayer(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, 3, 4, 5);
621 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
624 TEST_F(GLES2ImplementationTest
, FrontFace
) {
629 expected
.cmd
.Init(GL_CW
);
631 gl_
->FrontFace(GL_CW
);
632 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
635 TEST_F(GLES2ImplementationTest
, GenBuffers
) {
640 cmds::GenBuffersImmediate gen
;
644 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
645 expected
.data
[0] = kBuffersStartId
;
646 expected
.data
[1] = kBuffersStartId
+ 1;
647 gl_
->GenBuffers(arraysize(ids
), &ids
[0]);
648 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
649 EXPECT_EQ(kBuffersStartId
, ids
[0]);
650 EXPECT_EQ(kBuffersStartId
+ 1, ids
[1]);
653 TEST_F(GLES2ImplementationTest
, GenerateMipmap
) {
655 cmds::GenerateMipmap cmd
;
658 expected
.cmd
.Init(GL_TEXTURE_2D
);
660 gl_
->GenerateMipmap(GL_TEXTURE_2D
);
661 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
664 TEST_F(GLES2ImplementationTest
, GenFramebuffers
) {
669 cmds::GenFramebuffersImmediate gen
;
673 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
674 expected
.data
[0] = kFramebuffersStartId
;
675 expected
.data
[1] = kFramebuffersStartId
+ 1;
676 gl_
->GenFramebuffers(arraysize(ids
), &ids
[0]);
677 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
678 EXPECT_EQ(kFramebuffersStartId
, ids
[0]);
679 EXPECT_EQ(kFramebuffersStartId
+ 1, ids
[1]);
682 TEST_F(GLES2ImplementationTest
, GenRenderbuffers
) {
687 cmds::GenRenderbuffersImmediate gen
;
691 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
692 expected
.data
[0] = kRenderbuffersStartId
;
693 expected
.data
[1] = kRenderbuffersStartId
+ 1;
694 gl_
->GenRenderbuffers(arraysize(ids
), &ids
[0]);
695 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
696 EXPECT_EQ(kRenderbuffersStartId
, ids
[0]);
697 EXPECT_EQ(kRenderbuffersStartId
+ 1, ids
[1]);
700 TEST_F(GLES2ImplementationTest
, GenSamplers
) {
705 cmds::GenSamplersImmediate gen
;
709 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
710 expected
.data
[0] = kSamplersStartId
;
711 expected
.data
[1] = kSamplersStartId
+ 1;
712 gl_
->GenSamplers(arraysize(ids
), &ids
[0]);
713 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
714 EXPECT_EQ(kSamplersStartId
, ids
[0]);
715 EXPECT_EQ(kSamplersStartId
+ 1, ids
[1]);
718 TEST_F(GLES2ImplementationTest
, GenTextures
) {
723 cmds::GenTexturesImmediate gen
;
727 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
728 expected
.data
[0] = kTexturesStartId
;
729 expected
.data
[1] = kTexturesStartId
+ 1;
730 gl_
->GenTextures(arraysize(ids
), &ids
[0]);
731 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
732 EXPECT_EQ(kTexturesStartId
, ids
[0]);
733 EXPECT_EQ(kTexturesStartId
+ 1, ids
[1]);
736 TEST_F(GLES2ImplementationTest
, GenTransformFeedbacks
) {
741 cmds::GenTransformFeedbacksImmediate gen
;
745 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
746 expected
.data
[0] = kTransformFeedbacksStartId
;
747 expected
.data
[1] = kTransformFeedbacksStartId
+ 1;
748 gl_
->GenTransformFeedbacks(arraysize(ids
), &ids
[0]);
749 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
750 EXPECT_EQ(kTransformFeedbacksStartId
, ids
[0]);
751 EXPECT_EQ(kTransformFeedbacksStartId
+ 1, ids
[1]);
753 // TODO(zmo): Implement unit test for GetActiveAttrib
754 // TODO(zmo): Implement unit test for GetActiveUniform
755 // TODO(zmo): Implement unit test for GetActiveUniformBlockiv
756 // TODO(zmo): Implement unit test for GetActiveUniformBlockName
757 // TODO(zmo): Implement unit test for GetActiveUniformsiv
758 // TODO(zmo): Implement unit test for GetAttachedShaders
759 // TODO(zmo): Implement unit test for GetAttribLocation
761 TEST_F(GLES2ImplementationTest
, GetBooleanv
) {
763 cmds::GetBooleanv cmd
;
765 typedef cmds::GetBooleanv::Result Result
;
766 Result::Type result
= 0;
768 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
769 expected
.cmd
.Init(123, result1
.id
, result1
.offset
);
770 EXPECT_CALL(*command_buffer(), OnFlush())
771 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
772 .RetiresOnSaturation();
773 gl_
->GetBooleanv(123, &result
);
774 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
775 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
778 TEST_F(GLES2ImplementationTest
, GetBufferParameteriv
) {
780 cmds::GetBufferParameteriv cmd
;
782 typedef cmds::GetBufferParameteriv::Result Result
;
783 Result::Type result
= 0;
785 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
786 expected
.cmd
.Init(123, GL_BUFFER_SIZE
, result1
.id
, result1
.offset
);
787 EXPECT_CALL(*command_buffer(), OnFlush())
788 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
789 .RetiresOnSaturation();
790 gl_
->GetBufferParameteriv(123, GL_BUFFER_SIZE
, &result
);
791 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
792 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
795 TEST_F(GLES2ImplementationTest
, GetFloatv
) {
799 typedef cmds::GetFloatv::Result Result
;
800 Result::Type result
= 0;
802 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
803 expected
.cmd
.Init(123, result1
.id
, result1
.offset
);
804 EXPECT_CALL(*command_buffer(), OnFlush())
805 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
806 .RetiresOnSaturation();
807 gl_
->GetFloatv(123, &result
);
808 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
809 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
811 // TODO(zmo): Implement unit test for GetFragDataLocation
813 TEST_F(GLES2ImplementationTest
, GetFramebufferAttachmentParameteriv
) {
815 cmds::GetFramebufferAttachmentParameteriv cmd
;
817 typedef cmds::GetFramebufferAttachmentParameteriv::Result Result
;
818 Result::Type result
= 0;
820 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
821 expected
.cmd
.Init(123, GL_COLOR_ATTACHMENT0
,
822 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
, result1
.id
,
824 EXPECT_CALL(*command_buffer(), OnFlush())
825 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
826 .RetiresOnSaturation();
827 gl_
->GetFramebufferAttachmentParameteriv(
828 123, GL_COLOR_ATTACHMENT0
, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
,
830 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
831 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
834 TEST_F(GLES2ImplementationTest
, GetIntegerv
) {
836 cmds::GetIntegerv cmd
;
838 typedef cmds::GetIntegerv::Result Result
;
839 Result::Type result
= 0;
841 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
842 expected
.cmd
.Init(123, result1
.id
, result1
.offset
);
843 EXPECT_CALL(*command_buffer(), OnFlush())
844 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
845 .RetiresOnSaturation();
846 gl_
->GetIntegerv(123, &result
);
847 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
848 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
851 TEST_F(GLES2ImplementationTest
, GetInternalformativ
) {
853 cmds::GetInternalformativ cmd
;
855 typedef cmds::GetInternalformativ::Result Result
;
856 Result::Type result
= 0;
858 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
859 expected
.cmd
.Init(123, GL_RGBA4
, GL_RENDERBUFFER_RED_SIZE
, 4, result1
.id
,
861 EXPECT_CALL(*command_buffer(), OnFlush())
862 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
863 .RetiresOnSaturation();
864 gl_
->GetInternalformativ(123, GL_RGBA4
, GL_RENDERBUFFER_RED_SIZE
, 4, &result
);
865 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
866 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
869 TEST_F(GLES2ImplementationTest
, GetProgramiv
) {
871 cmds::GetProgramiv cmd
;
873 typedef cmds::GetProgramiv::Result Result
;
874 Result::Type result
= 0;
876 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
877 expected
.cmd
.Init(123, GL_DELETE_STATUS
, result1
.id
, result1
.offset
);
878 EXPECT_CALL(*command_buffer(), OnFlush())
879 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
880 .RetiresOnSaturation();
881 gl_
->GetProgramiv(123, GL_DELETE_STATUS
, &result
);
882 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
883 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
885 // TODO(zmo): Implement unit test for GetProgramInfoLog
887 TEST_F(GLES2ImplementationTest
, GetRenderbufferParameteriv
) {
889 cmds::GetRenderbufferParameteriv cmd
;
891 typedef cmds::GetRenderbufferParameteriv::Result Result
;
892 Result::Type result
= 0;
894 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
895 expected
.cmd
.Init(123, GL_RENDERBUFFER_RED_SIZE
, result1
.id
, result1
.offset
);
896 EXPECT_CALL(*command_buffer(), OnFlush())
897 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
898 .RetiresOnSaturation();
899 gl_
->GetRenderbufferParameteriv(123, GL_RENDERBUFFER_RED_SIZE
, &result
);
900 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
901 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
904 TEST_F(GLES2ImplementationTest
, GetSamplerParameterfv
) {
906 cmds::GetSamplerParameterfv cmd
;
908 typedef cmds::GetSamplerParameterfv::Result Result
;
909 Result::Type result
= 0;
911 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
912 expected
.cmd
.Init(123, GL_TEXTURE_MAG_FILTER
, result1
.id
, result1
.offset
);
913 EXPECT_CALL(*command_buffer(), OnFlush())
914 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
915 .RetiresOnSaturation();
916 gl_
->GetSamplerParameterfv(123, GL_TEXTURE_MAG_FILTER
, &result
);
917 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
918 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
921 TEST_F(GLES2ImplementationTest
, GetSamplerParameteriv
) {
923 cmds::GetSamplerParameteriv cmd
;
925 typedef cmds::GetSamplerParameteriv::Result Result
;
926 Result::Type result
= 0;
928 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
929 expected
.cmd
.Init(123, GL_TEXTURE_MAG_FILTER
, result1
.id
, result1
.offset
);
930 EXPECT_CALL(*command_buffer(), OnFlush())
931 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
932 .RetiresOnSaturation();
933 gl_
->GetSamplerParameteriv(123, GL_TEXTURE_MAG_FILTER
, &result
);
934 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
935 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
938 TEST_F(GLES2ImplementationTest
, GetShaderiv
) {
940 cmds::GetShaderiv cmd
;
942 typedef cmds::GetShaderiv::Result Result
;
943 Result::Type result
= 0;
945 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
946 expected
.cmd
.Init(123, GL_SHADER_TYPE
, result1
.id
, result1
.offset
);
947 EXPECT_CALL(*command_buffer(), OnFlush())
948 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
949 .RetiresOnSaturation();
950 gl_
->GetShaderiv(123, GL_SHADER_TYPE
, &result
);
951 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
952 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
954 // TODO(zmo): Implement unit test for GetShaderInfoLog
955 // TODO(zmo): Implement unit test for GetShaderPrecisionFormat
957 TEST_F(GLES2ImplementationTest
, GetSynciv
) {
961 typedef cmds::GetSynciv::Result Result
;
962 Result::Type result
= 0;
964 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
965 expected
.cmd
.Init(123, GL_SYNC_STATUS
, result1
.id
, result1
.offset
);
966 EXPECT_CALL(*command_buffer(), OnFlush())
967 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
968 .RetiresOnSaturation();
969 gl_
->GetSynciv(reinterpret_cast<GLsync
>(123), GL_SYNC_STATUS
, 3, nullptr,
971 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
972 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
975 TEST_F(GLES2ImplementationTest
, GetTexParameterfv
) {
977 cmds::GetTexParameterfv cmd
;
979 typedef cmds::GetTexParameterfv::Result Result
;
980 Result::Type result
= 0;
982 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
983 expected
.cmd
.Init(123, GL_TEXTURE_MAG_FILTER
, result1
.id
, result1
.offset
);
984 EXPECT_CALL(*command_buffer(), OnFlush())
985 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
986 .RetiresOnSaturation();
987 gl_
->GetTexParameterfv(123, GL_TEXTURE_MAG_FILTER
, &result
);
988 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
989 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
992 TEST_F(GLES2ImplementationTest
, GetTexParameteriv
) {
994 cmds::GetTexParameteriv cmd
;
996 typedef cmds::GetTexParameteriv::Result Result
;
997 Result::Type result
= 0;
999 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
1000 expected
.cmd
.Init(123, GL_TEXTURE_MAG_FILTER
, result1
.id
, result1
.offset
);
1001 EXPECT_CALL(*command_buffer(), OnFlush())
1002 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
1003 .RetiresOnSaturation();
1004 gl_
->GetTexParameteriv(123, GL_TEXTURE_MAG_FILTER
, &result
);
1005 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1006 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
1008 // TODO(zmo): Implement unit test for GetTransformFeedbackVarying
1009 // TODO(zmo): Implement unit test for GetUniformBlockIndex
1010 // TODO(zmo): Implement unit test for GetUniformfv
1011 // TODO(zmo): Implement unit test for GetUniformiv
1012 // TODO(zmo): Implement unit test for GetUniformIndices
1013 // TODO(zmo): Implement unit test for GetUniformLocation
1015 TEST_F(GLES2ImplementationTest
, GetVertexAttribfv
) {
1017 cmds::GetVertexAttribfv cmd
;
1019 typedef cmds::GetVertexAttribfv::Result Result
;
1020 Result::Type result
= 0;
1022 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
1023 expected
.cmd
.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, result1
.id
,
1025 EXPECT_CALL(*command_buffer(), OnFlush())
1026 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
1027 .RetiresOnSaturation();
1028 gl_
->GetVertexAttribfv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, &result
);
1029 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1030 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
1033 TEST_F(GLES2ImplementationTest
, GetVertexAttribiv
) {
1035 cmds::GetVertexAttribiv cmd
;
1037 typedef cmds::GetVertexAttribiv::Result Result
;
1038 Result::Type result
= 0;
1040 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
1041 expected
.cmd
.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, result1
.id
,
1043 EXPECT_CALL(*command_buffer(), OnFlush())
1044 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
1045 .RetiresOnSaturation();
1046 gl_
->GetVertexAttribiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, &result
);
1047 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1048 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
1051 TEST_F(GLES2ImplementationTest
, Hint
) {
1056 expected
.cmd
.Init(GL_GENERATE_MIPMAP_HINT
, GL_FASTEST
);
1058 gl_
->Hint(GL_GENERATE_MIPMAP_HINT
, GL_FASTEST
);
1059 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1062 TEST_F(GLES2ImplementationTest
, InvalidateFramebuffer
) {
1063 GLenum data
[2][1] = {{0}};
1065 cmds::InvalidateFramebufferImmediate cmd
;
1070 for (int ii
= 0; ii
< 2; ++ii
) {
1071 for (int jj
= 0; jj
< 1; ++jj
) {
1072 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
1075 expected
.cmd
.Init(GL_FRAMEBUFFER
, 2, &data
[0][0]);
1076 gl_
->InvalidateFramebuffer(GL_FRAMEBUFFER
, 2, &data
[0][0]);
1077 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1080 TEST_F(GLES2ImplementationTest
, InvalidateSubFramebuffer
) {
1081 GLenum data
[2][1] = {{0}};
1083 cmds::InvalidateSubFramebufferImmediate cmd
;
1088 for (int ii
= 0; ii
< 2; ++ii
) {
1089 for (int jj
= 0; jj
< 1; ++jj
) {
1090 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
1093 expected
.cmd
.Init(GL_FRAMEBUFFER
, 2, &data
[0][0], 4, 5, 6, 7);
1094 gl_
->InvalidateSubFramebuffer(GL_FRAMEBUFFER
, 2, &data
[0][0], 4, 5, 6, 7);
1095 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1098 TEST_F(GLES2ImplementationTest
, IsBuffer
) {
1104 ExpectedMemoryInfo result1
=
1105 GetExpectedResultMemory(sizeof(cmds::IsBuffer::Result
));
1106 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1108 EXPECT_CALL(*command_buffer(), OnFlush())
1109 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1110 .RetiresOnSaturation();
1112 GLboolean result
= gl_
->IsBuffer(1);
1113 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1114 EXPECT_TRUE(result
);
1117 TEST_F(GLES2ImplementationTest
, IsFramebuffer
) {
1119 cmds::IsFramebuffer cmd
;
1123 ExpectedMemoryInfo result1
=
1124 GetExpectedResultMemory(sizeof(cmds::IsFramebuffer::Result
));
1125 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1127 EXPECT_CALL(*command_buffer(), OnFlush())
1128 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1129 .RetiresOnSaturation();
1131 GLboolean result
= gl_
->IsFramebuffer(1);
1132 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1133 EXPECT_TRUE(result
);
1136 TEST_F(GLES2ImplementationTest
, IsProgram
) {
1138 cmds::IsProgram cmd
;
1142 ExpectedMemoryInfo result1
=
1143 GetExpectedResultMemory(sizeof(cmds::IsProgram::Result
));
1144 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1146 EXPECT_CALL(*command_buffer(), OnFlush())
1147 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1148 .RetiresOnSaturation();
1150 GLboolean result
= gl_
->IsProgram(1);
1151 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1152 EXPECT_TRUE(result
);
1155 TEST_F(GLES2ImplementationTest
, IsRenderbuffer
) {
1157 cmds::IsRenderbuffer cmd
;
1161 ExpectedMemoryInfo result1
=
1162 GetExpectedResultMemory(sizeof(cmds::IsRenderbuffer::Result
));
1163 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1165 EXPECT_CALL(*command_buffer(), OnFlush())
1166 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1167 .RetiresOnSaturation();
1169 GLboolean result
= gl_
->IsRenderbuffer(1);
1170 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1171 EXPECT_TRUE(result
);
1174 TEST_F(GLES2ImplementationTest
, IsSampler
) {
1176 cmds::IsSampler cmd
;
1180 ExpectedMemoryInfo result1
=
1181 GetExpectedResultMemory(sizeof(cmds::IsSampler::Result
));
1182 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1184 EXPECT_CALL(*command_buffer(), OnFlush())
1185 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1186 .RetiresOnSaturation();
1188 GLboolean result
= gl_
->IsSampler(1);
1189 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1190 EXPECT_TRUE(result
);
1193 TEST_F(GLES2ImplementationTest
, IsShader
) {
1199 ExpectedMemoryInfo result1
=
1200 GetExpectedResultMemory(sizeof(cmds::IsShader::Result
));
1201 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1203 EXPECT_CALL(*command_buffer(), OnFlush())
1204 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1205 .RetiresOnSaturation();
1207 GLboolean result
= gl_
->IsShader(1);
1208 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1209 EXPECT_TRUE(result
);
1212 TEST_F(GLES2ImplementationTest
, IsSync
) {
1218 ExpectedMemoryInfo result1
=
1219 GetExpectedResultMemory(sizeof(cmds::IsSync::Result
));
1220 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1222 EXPECT_CALL(*command_buffer(), OnFlush())
1223 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1224 .RetiresOnSaturation();
1226 GLboolean result
= gl_
->IsSync(reinterpret_cast<GLsync
>(1));
1227 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1228 EXPECT_TRUE(result
);
1231 TEST_F(GLES2ImplementationTest
, IsTexture
) {
1233 cmds::IsTexture cmd
;
1237 ExpectedMemoryInfo result1
=
1238 GetExpectedResultMemory(sizeof(cmds::IsTexture::Result
));
1239 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1241 EXPECT_CALL(*command_buffer(), OnFlush())
1242 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1243 .RetiresOnSaturation();
1245 GLboolean result
= gl_
->IsTexture(1);
1246 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1247 EXPECT_TRUE(result
);
1250 TEST_F(GLES2ImplementationTest
, IsTransformFeedback
) {
1252 cmds::IsTransformFeedback cmd
;
1256 ExpectedMemoryInfo result1
=
1257 GetExpectedResultMemory(sizeof(cmds::IsTransformFeedback::Result
));
1258 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1260 EXPECT_CALL(*command_buffer(), OnFlush())
1261 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1262 .RetiresOnSaturation();
1264 GLboolean result
= gl_
->IsTransformFeedback(1);
1265 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1266 EXPECT_TRUE(result
);
1269 TEST_F(GLES2ImplementationTest
, LineWidth
) {
1271 cmds::LineWidth cmd
;
1274 expected
.cmd
.Init(0.5f
);
1276 gl_
->LineWidth(0.5f
);
1277 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1280 TEST_F(GLES2ImplementationTest
, LinkProgram
) {
1282 cmds::LinkProgram cmd
;
1285 expected
.cmd
.Init(1);
1287 gl_
->LinkProgram(1);
1288 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1291 TEST_F(GLES2ImplementationTest
, PauseTransformFeedback
) {
1293 cmds::PauseTransformFeedback cmd
;
1296 expected
.cmd
.Init();
1298 gl_
->PauseTransformFeedback();
1299 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1302 TEST_F(GLES2ImplementationTest
, PixelStorei
) {
1304 cmds::PixelStorei cmd
;
1307 expected
.cmd
.Init(GL_PACK_ALIGNMENT
, 1);
1309 gl_
->PixelStorei(GL_PACK_ALIGNMENT
, 1);
1310 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1313 TEST_F(GLES2ImplementationTest
, PolygonOffset
) {
1315 cmds::PolygonOffset cmd
;
1318 expected
.cmd
.Init(1, 2);
1320 gl_
->PolygonOffset(1, 2);
1321 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1324 TEST_F(GLES2ImplementationTest
, ReadBuffer
) {
1326 cmds::ReadBuffer cmd
;
1329 expected
.cmd
.Init(1);
1332 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1335 TEST_F(GLES2ImplementationTest
, ReleaseShaderCompiler
) {
1337 cmds::ReleaseShaderCompiler cmd
;
1340 expected
.cmd
.Init();
1342 gl_
->ReleaseShaderCompiler();
1343 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1346 TEST_F(GLES2ImplementationTest
, RenderbufferStorage
) {
1348 cmds::RenderbufferStorage cmd
;
1351 expected
.cmd
.Init(GL_RENDERBUFFER
, GL_RGBA4
, 3, 4);
1353 gl_
->RenderbufferStorage(GL_RENDERBUFFER
, GL_RGBA4
, 3, 4);
1354 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1357 TEST_F(GLES2ImplementationTest
, ResumeTransformFeedback
) {
1359 cmds::ResumeTransformFeedback cmd
;
1362 expected
.cmd
.Init();
1364 gl_
->ResumeTransformFeedback();
1365 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1368 TEST_F(GLES2ImplementationTest
, SampleCoverage
) {
1370 cmds::SampleCoverage cmd
;
1373 expected
.cmd
.Init(1, true);
1375 gl_
->SampleCoverage(1, true);
1376 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1379 TEST_F(GLES2ImplementationTest
, SamplerParameterf
) {
1381 cmds::SamplerParameterf cmd
;
1384 expected
.cmd
.Init(1, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1386 gl_
->SamplerParameterf(1, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1387 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1390 TEST_F(GLES2ImplementationTest
, SamplerParameterfv
) {
1391 GLfloat data
[1] = {0};
1393 cmds::SamplerParameterfvImmediate cmd
;
1397 for (int jj
= 0; jj
< 1; ++jj
) {
1398 data
[jj
] = static_cast<GLfloat
>(jj
);
1401 expected
.cmd
.Init(1, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1402 gl_
->SamplerParameterfv(1, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1403 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1406 TEST_F(GLES2ImplementationTest
, SamplerParameteri
) {
1408 cmds::SamplerParameteri cmd
;
1411 expected
.cmd
.Init(1, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1413 gl_
->SamplerParameteri(1, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1414 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1417 TEST_F(GLES2ImplementationTest
, SamplerParameteriv
) {
1418 GLint data
[1] = {0};
1420 cmds::SamplerParameterivImmediate cmd
;
1424 for (int jj
= 0; jj
< 1; ++jj
) {
1425 data
[jj
] = static_cast<GLint
>(jj
);
1428 expected
.cmd
.Init(1, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1429 gl_
->SamplerParameteriv(1, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1430 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1433 TEST_F(GLES2ImplementationTest
, Scissor
) {
1438 expected
.cmd
.Init(1, 2, 3, 4);
1440 gl_
->Scissor(1, 2, 3, 4);
1441 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1444 TEST_F(GLES2ImplementationTest
, ShaderSource
) {
1445 const uint32 kBucketId
= GLES2Implementation::kResultBucketId
;
1446 const char* kString1
= "happy";
1447 const char* kString2
= "ending";
1448 const size_t kString1Size
= ::strlen(kString1
) + 1;
1449 const size_t kString2Size
= ::strlen(kString2
) + 1;
1450 const size_t kHeaderSize
= sizeof(GLint
) * 3;
1451 const size_t kSourceSize
= kHeaderSize
+ kString1Size
+ kString2Size
;
1452 const size_t kPaddedHeaderSize
=
1453 transfer_buffer_
->RoundToAlignment(kHeaderSize
);
1454 const size_t kPaddedString1Size
=
1455 transfer_buffer_
->RoundToAlignment(kString1Size
);
1456 const size_t kPaddedString2Size
=
1457 transfer_buffer_
->RoundToAlignment(kString2Size
);
1459 cmd::SetBucketSize set_bucket_size
;
1460 cmd::SetBucketData set_bucket_header
;
1461 cmd::SetToken set_token1
;
1462 cmd::SetBucketData set_bucket_data1
;
1463 cmd::SetToken set_token2
;
1464 cmd::SetBucketData set_bucket_data2
;
1465 cmd::SetToken set_token3
;
1466 cmds::ShaderSourceBucket cmd_bucket
;
1467 cmd::SetBucketSize clear_bucket_size
;
1470 ExpectedMemoryInfo mem0
= GetExpectedMemory(kPaddedHeaderSize
);
1471 ExpectedMemoryInfo mem1
= GetExpectedMemory(kPaddedString1Size
);
1472 ExpectedMemoryInfo mem2
= GetExpectedMemory(kPaddedString2Size
);
1475 expected
.set_bucket_size
.Init(kBucketId
, kSourceSize
);
1476 expected
.set_bucket_header
.Init(kBucketId
, 0, kHeaderSize
, mem0
.id
,
1478 expected
.set_token1
.Init(GetNextToken());
1479 expected
.set_bucket_data1
.Init(kBucketId
, kHeaderSize
, kString1Size
, mem1
.id
,
1481 expected
.set_token2
.Init(GetNextToken());
1482 expected
.set_bucket_data2
.Init(kBucketId
, kHeaderSize
+ kString1Size
,
1483 kString2Size
, mem2
.id
, mem2
.offset
);
1484 expected
.set_token3
.Init(GetNextToken());
1485 expected
.cmd_bucket
.Init(1, kBucketId
);
1486 expected
.clear_bucket_size
.Init(kBucketId
, 0);
1487 const char* kStrings
[] = {kString1
, kString2
};
1488 gl_
->ShaderSource(1, 2, kStrings
, NULL
);
1489 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1492 TEST_F(GLES2ImplementationTest
, ShaderSourceWithLength
) {
1493 const uint32 kBucketId
= GLES2Implementation::kResultBucketId
;
1494 const char* kString
= "foobar******";
1495 const size_t kStringSize
= 6; // We only need "foobar".
1496 const size_t kHeaderSize
= sizeof(GLint
) * 2;
1497 const size_t kSourceSize
= kHeaderSize
+ kStringSize
+ 1;
1498 const size_t kPaddedHeaderSize
=
1499 transfer_buffer_
->RoundToAlignment(kHeaderSize
);
1500 const size_t kPaddedStringSize
=
1501 transfer_buffer_
->RoundToAlignment(kStringSize
+ 1);
1503 cmd::SetBucketSize set_bucket_size
;
1504 cmd::SetBucketData set_bucket_header
;
1505 cmd::SetToken set_token1
;
1506 cmd::SetBucketData set_bucket_data
;
1507 cmd::SetToken set_token2
;
1508 cmds::ShaderSourceBucket shader_source_bucket
;
1509 cmd::SetBucketSize clear_bucket_size
;
1512 ExpectedMemoryInfo mem0
= GetExpectedMemory(kPaddedHeaderSize
);
1513 ExpectedMemoryInfo mem1
= GetExpectedMemory(kPaddedStringSize
);
1516 expected
.set_bucket_size
.Init(kBucketId
, kSourceSize
);
1517 expected
.set_bucket_header
.Init(kBucketId
, 0, kHeaderSize
, mem0
.id
,
1519 expected
.set_token1
.Init(GetNextToken());
1520 expected
.set_bucket_data
.Init(kBucketId
, kHeaderSize
, kStringSize
+ 1,
1521 mem1
.id
, mem1
.offset
);
1522 expected
.set_token2
.Init(GetNextToken());
1523 expected
.shader_source_bucket
.Init(1, kBucketId
);
1524 expected
.clear_bucket_size
.Init(kBucketId
, 0);
1525 const char* kStrings
[] = {kString
};
1526 const GLint kLength
[] = {kStringSize
};
1527 gl_
->ShaderSource(1, 1, kStrings
, kLength
);
1528 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1531 TEST_F(GLES2ImplementationTest
, StencilFunc
) {
1533 cmds::StencilFunc cmd
;
1536 expected
.cmd
.Init(GL_NEVER
, 2, 3);
1538 gl_
->StencilFunc(GL_NEVER
, 2, 3);
1539 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1542 TEST_F(GLES2ImplementationTest
, StencilFuncSeparate
) {
1544 cmds::StencilFuncSeparate cmd
;
1547 expected
.cmd
.Init(GL_FRONT
, GL_NEVER
, 3, 4);
1549 gl_
->StencilFuncSeparate(GL_FRONT
, GL_NEVER
, 3, 4);
1550 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1553 TEST_F(GLES2ImplementationTest
, StencilMask
) {
1555 cmds::StencilMask cmd
;
1558 expected
.cmd
.Init(1);
1560 gl_
->StencilMask(1);
1561 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1564 TEST_F(GLES2ImplementationTest
, StencilMaskSeparate
) {
1566 cmds::StencilMaskSeparate cmd
;
1569 expected
.cmd
.Init(GL_FRONT
, 2);
1571 gl_
->StencilMaskSeparate(GL_FRONT
, 2);
1572 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1575 TEST_F(GLES2ImplementationTest
, StencilOp
) {
1577 cmds::StencilOp cmd
;
1580 expected
.cmd
.Init(GL_KEEP
, GL_INCR
, GL_KEEP
);
1582 gl_
->StencilOp(GL_KEEP
, GL_INCR
, GL_KEEP
);
1583 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1586 TEST_F(GLES2ImplementationTest
, StencilOpSeparate
) {
1588 cmds::StencilOpSeparate cmd
;
1591 expected
.cmd
.Init(GL_FRONT
, GL_INCR
, GL_KEEP
, GL_KEEP
);
1593 gl_
->StencilOpSeparate(GL_FRONT
, GL_INCR
, GL_KEEP
, GL_KEEP
);
1594 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1597 TEST_F(GLES2ImplementationTest
, TexParameterf
) {
1599 cmds::TexParameterf cmd
;
1602 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1604 gl_
->TexParameterf(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1605 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1608 TEST_F(GLES2ImplementationTest
, TexParameterfv
) {
1609 GLfloat data
[1] = {0};
1611 cmds::TexParameterfvImmediate cmd
;
1615 for (int jj
= 0; jj
< 1; ++jj
) {
1616 data
[jj
] = static_cast<GLfloat
>(jj
);
1619 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1620 gl_
->TexParameterfv(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1621 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1624 TEST_F(GLES2ImplementationTest
, TexParameteri
) {
1626 cmds::TexParameteri cmd
;
1629 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1631 gl_
->TexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1632 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1635 TEST_F(GLES2ImplementationTest
, TexParameteriv
) {
1636 GLint data
[1] = {0};
1638 cmds::TexParameterivImmediate cmd
;
1642 for (int jj
= 0; jj
< 1; ++jj
) {
1643 data
[jj
] = static_cast<GLint
>(jj
);
1646 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1647 gl_
->TexParameteriv(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1648 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1651 TEST_F(GLES2ImplementationTest
, TexStorage3D
) {
1653 cmds::TexStorage3D cmd
;
1656 expected
.cmd
.Init(GL_TEXTURE_3D
, 2, GL_RGB565
, 4, 5, 6);
1658 gl_
->TexStorage3D(GL_TEXTURE_3D
, 2, GL_RGB565
, 4, 5, 6);
1659 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1662 TEST_F(GLES2ImplementationTest
, TransformFeedbackVaryings
) {
1663 const uint32 kBucketId
= GLES2Implementation::kResultBucketId
;
1664 const char* kString1
= "happy";
1665 const char* kString2
= "ending";
1666 const size_t kString1Size
= ::strlen(kString1
) + 1;
1667 const size_t kString2Size
= ::strlen(kString2
) + 1;
1668 const size_t kHeaderSize
= sizeof(GLint
) * 3;
1669 const size_t kSourceSize
= kHeaderSize
+ kString1Size
+ kString2Size
;
1670 const size_t kPaddedHeaderSize
=
1671 transfer_buffer_
->RoundToAlignment(kHeaderSize
);
1672 const size_t kPaddedString1Size
=
1673 transfer_buffer_
->RoundToAlignment(kString1Size
);
1674 const size_t kPaddedString2Size
=
1675 transfer_buffer_
->RoundToAlignment(kString2Size
);
1677 cmd::SetBucketSize set_bucket_size
;
1678 cmd::SetBucketData set_bucket_header
;
1679 cmd::SetToken set_token1
;
1680 cmd::SetBucketData set_bucket_data1
;
1681 cmd::SetToken set_token2
;
1682 cmd::SetBucketData set_bucket_data2
;
1683 cmd::SetToken set_token3
;
1684 cmds::TransformFeedbackVaryingsBucket cmd_bucket
;
1685 cmd::SetBucketSize clear_bucket_size
;
1688 ExpectedMemoryInfo mem0
= GetExpectedMemory(kPaddedHeaderSize
);
1689 ExpectedMemoryInfo mem1
= GetExpectedMemory(kPaddedString1Size
);
1690 ExpectedMemoryInfo mem2
= GetExpectedMemory(kPaddedString2Size
);
1693 expected
.set_bucket_size
.Init(kBucketId
, kSourceSize
);
1694 expected
.set_bucket_header
.Init(kBucketId
, 0, kHeaderSize
, mem0
.id
,
1696 expected
.set_token1
.Init(GetNextToken());
1697 expected
.set_bucket_data1
.Init(kBucketId
, kHeaderSize
, kString1Size
, mem1
.id
,
1699 expected
.set_token2
.Init(GetNextToken());
1700 expected
.set_bucket_data2
.Init(kBucketId
, kHeaderSize
+ kString1Size
,
1701 kString2Size
, mem2
.id
, mem2
.offset
);
1702 expected
.set_token3
.Init(GetNextToken());
1703 expected
.cmd_bucket
.Init(1, kBucketId
, GL_INTERLEAVED_ATTRIBS
);
1704 expected
.clear_bucket_size
.Init(kBucketId
, 0);
1705 const char* kStrings
[] = {kString1
, kString2
};
1706 gl_
->TransformFeedbackVaryings(1, 2, kStrings
, GL_INTERLEAVED_ATTRIBS
);
1707 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1710 TEST_F(GLES2ImplementationTest
, Uniform1f
) {
1712 cmds::Uniform1f cmd
;
1715 expected
.cmd
.Init(1, 2);
1717 gl_
->Uniform1f(1, 2);
1718 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1721 TEST_F(GLES2ImplementationTest
, Uniform1fv
) {
1722 GLfloat data
[2][1] = {{0}};
1724 cmds::Uniform1fvImmediate cmd
;
1729 for (int ii
= 0; ii
< 2; ++ii
) {
1730 for (int jj
= 0; jj
< 1; ++jj
) {
1731 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 1 + jj
);
1734 expected
.cmd
.Init(1, 2, &data
[0][0]);
1735 gl_
->Uniform1fv(1, 2, &data
[0][0]);
1736 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1739 TEST_F(GLES2ImplementationTest
, Uniform1i
) {
1741 cmds::Uniform1i cmd
;
1744 expected
.cmd
.Init(1, 2);
1746 gl_
->Uniform1i(1, 2);
1747 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1750 TEST_F(GLES2ImplementationTest
, Uniform1iv
) {
1751 GLint data
[2][1] = {{0}};
1753 cmds::Uniform1ivImmediate cmd
;
1758 for (int ii
= 0; ii
< 2; ++ii
) {
1759 for (int jj
= 0; jj
< 1; ++jj
) {
1760 data
[ii
][jj
] = static_cast<GLint
>(ii
* 1 + jj
);
1763 expected
.cmd
.Init(1, 2, &data
[0][0]);
1764 gl_
->Uniform1iv(1, 2, &data
[0][0]);
1765 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1768 TEST_F(GLES2ImplementationTest
, Uniform1ui
) {
1770 cmds::Uniform1ui cmd
;
1773 expected
.cmd
.Init(1, 2);
1775 gl_
->Uniform1ui(1, 2);
1776 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1779 TEST_F(GLES2ImplementationTest
, Uniform1uiv
) {
1780 GLuint data
[2][1] = {{0}};
1782 cmds::Uniform1uivImmediate cmd
;
1787 for (int ii
= 0; ii
< 2; ++ii
) {
1788 for (int jj
= 0; jj
< 1; ++jj
) {
1789 data
[ii
][jj
] = static_cast<GLuint
>(ii
* 1 + jj
);
1792 expected
.cmd
.Init(1, 2, &data
[0][0]);
1793 gl_
->Uniform1uiv(1, 2, &data
[0][0]);
1794 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1797 TEST_F(GLES2ImplementationTest
, Uniform2f
) {
1799 cmds::Uniform2f cmd
;
1802 expected
.cmd
.Init(1, 2, 3);
1804 gl_
->Uniform2f(1, 2, 3);
1805 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1808 TEST_F(GLES2ImplementationTest
, Uniform2fv
) {
1809 GLfloat data
[2][2] = {{0}};
1811 cmds::Uniform2fvImmediate cmd
;
1816 for (int ii
= 0; ii
< 2; ++ii
) {
1817 for (int jj
= 0; jj
< 2; ++jj
) {
1818 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 2 + jj
);
1821 expected
.cmd
.Init(1, 2, &data
[0][0]);
1822 gl_
->Uniform2fv(1, 2, &data
[0][0]);
1823 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1826 TEST_F(GLES2ImplementationTest
, Uniform2i
) {
1828 cmds::Uniform2i cmd
;
1831 expected
.cmd
.Init(1, 2, 3);
1833 gl_
->Uniform2i(1, 2, 3);
1834 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1837 TEST_F(GLES2ImplementationTest
, Uniform2iv
) {
1838 GLint data
[2][2] = {{0}};
1840 cmds::Uniform2ivImmediate cmd
;
1845 for (int ii
= 0; ii
< 2; ++ii
) {
1846 for (int jj
= 0; jj
< 2; ++jj
) {
1847 data
[ii
][jj
] = static_cast<GLint
>(ii
* 2 + jj
);
1850 expected
.cmd
.Init(1, 2, &data
[0][0]);
1851 gl_
->Uniform2iv(1, 2, &data
[0][0]);
1852 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1855 TEST_F(GLES2ImplementationTest
, Uniform2ui
) {
1857 cmds::Uniform2ui cmd
;
1860 expected
.cmd
.Init(1, 2, 3);
1862 gl_
->Uniform2ui(1, 2, 3);
1863 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1866 TEST_F(GLES2ImplementationTest
, Uniform2uiv
) {
1867 GLuint data
[2][2] = {{0}};
1869 cmds::Uniform2uivImmediate cmd
;
1874 for (int ii
= 0; ii
< 2; ++ii
) {
1875 for (int jj
= 0; jj
< 2; ++jj
) {
1876 data
[ii
][jj
] = static_cast<GLuint
>(ii
* 2 + jj
);
1879 expected
.cmd
.Init(1, 2, &data
[0][0]);
1880 gl_
->Uniform2uiv(1, 2, &data
[0][0]);
1881 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1884 TEST_F(GLES2ImplementationTest
, Uniform3f
) {
1886 cmds::Uniform3f cmd
;
1889 expected
.cmd
.Init(1, 2, 3, 4);
1891 gl_
->Uniform3f(1, 2, 3, 4);
1892 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1895 TEST_F(GLES2ImplementationTest
, Uniform3fv
) {
1896 GLfloat data
[2][3] = {{0}};
1898 cmds::Uniform3fvImmediate cmd
;
1903 for (int ii
= 0; ii
< 2; ++ii
) {
1904 for (int jj
= 0; jj
< 3; ++jj
) {
1905 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 3 + jj
);
1908 expected
.cmd
.Init(1, 2, &data
[0][0]);
1909 gl_
->Uniform3fv(1, 2, &data
[0][0]);
1910 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1913 TEST_F(GLES2ImplementationTest
, Uniform3i
) {
1915 cmds::Uniform3i cmd
;
1918 expected
.cmd
.Init(1, 2, 3, 4);
1920 gl_
->Uniform3i(1, 2, 3, 4);
1921 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1924 TEST_F(GLES2ImplementationTest
, Uniform3iv
) {
1925 GLint data
[2][3] = {{0}};
1927 cmds::Uniform3ivImmediate cmd
;
1932 for (int ii
= 0; ii
< 2; ++ii
) {
1933 for (int jj
= 0; jj
< 3; ++jj
) {
1934 data
[ii
][jj
] = static_cast<GLint
>(ii
* 3 + jj
);
1937 expected
.cmd
.Init(1, 2, &data
[0][0]);
1938 gl_
->Uniform3iv(1, 2, &data
[0][0]);
1939 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1942 TEST_F(GLES2ImplementationTest
, Uniform3ui
) {
1944 cmds::Uniform3ui cmd
;
1947 expected
.cmd
.Init(1, 2, 3, 4);
1949 gl_
->Uniform3ui(1, 2, 3, 4);
1950 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1953 TEST_F(GLES2ImplementationTest
, Uniform3uiv
) {
1954 GLuint data
[2][3] = {{0}};
1956 cmds::Uniform3uivImmediate cmd
;
1961 for (int ii
= 0; ii
< 2; ++ii
) {
1962 for (int jj
= 0; jj
< 3; ++jj
) {
1963 data
[ii
][jj
] = static_cast<GLuint
>(ii
* 3 + jj
);
1966 expected
.cmd
.Init(1, 2, &data
[0][0]);
1967 gl_
->Uniform3uiv(1, 2, &data
[0][0]);
1968 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1971 TEST_F(GLES2ImplementationTest
, Uniform4f
) {
1973 cmds::Uniform4f cmd
;
1976 expected
.cmd
.Init(1, 2, 3, 4, 5);
1978 gl_
->Uniform4f(1, 2, 3, 4, 5);
1979 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1982 TEST_F(GLES2ImplementationTest
, Uniform4fv
) {
1983 GLfloat data
[2][4] = {{0}};
1985 cmds::Uniform4fvImmediate cmd
;
1990 for (int ii
= 0; ii
< 2; ++ii
) {
1991 for (int jj
= 0; jj
< 4; ++jj
) {
1992 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 4 + jj
);
1995 expected
.cmd
.Init(1, 2, &data
[0][0]);
1996 gl_
->Uniform4fv(1, 2, &data
[0][0]);
1997 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2000 TEST_F(GLES2ImplementationTest
, Uniform4i
) {
2002 cmds::Uniform4i cmd
;
2005 expected
.cmd
.Init(1, 2, 3, 4, 5);
2007 gl_
->Uniform4i(1, 2, 3, 4, 5);
2008 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2011 TEST_F(GLES2ImplementationTest
, Uniform4iv
) {
2012 GLint data
[2][4] = {{0}};
2014 cmds::Uniform4ivImmediate cmd
;
2019 for (int ii
= 0; ii
< 2; ++ii
) {
2020 for (int jj
= 0; jj
< 4; ++jj
) {
2021 data
[ii
][jj
] = static_cast<GLint
>(ii
* 4 + jj
);
2024 expected
.cmd
.Init(1, 2, &data
[0][0]);
2025 gl_
->Uniform4iv(1, 2, &data
[0][0]);
2026 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2029 TEST_F(GLES2ImplementationTest
, Uniform4ui
) {
2031 cmds::Uniform4ui cmd
;
2034 expected
.cmd
.Init(1, 2, 3, 4, 5);
2036 gl_
->Uniform4ui(1, 2, 3, 4, 5);
2037 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2040 TEST_F(GLES2ImplementationTest
, Uniform4uiv
) {
2041 GLuint data
[2][4] = {{0}};
2043 cmds::Uniform4uivImmediate cmd
;
2048 for (int ii
= 0; ii
< 2; ++ii
) {
2049 for (int jj
= 0; jj
< 4; ++jj
) {
2050 data
[ii
][jj
] = static_cast<GLuint
>(ii
* 4 + jj
);
2053 expected
.cmd
.Init(1, 2, &data
[0][0]);
2054 gl_
->Uniform4uiv(1, 2, &data
[0][0]);
2055 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2058 TEST_F(GLES2ImplementationTest
, UniformBlockBinding
) {
2060 cmds::UniformBlockBinding cmd
;
2063 expected
.cmd
.Init(1, 2, 3);
2065 gl_
->UniformBlockBinding(1, 2, 3);
2066 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2069 TEST_F(GLES2ImplementationTest
, UniformMatrix2fv
) {
2070 GLfloat data
[2][4] = {{0}};
2072 cmds::UniformMatrix2fvImmediate cmd
;
2077 for (int ii
= 0; ii
< 2; ++ii
) {
2078 for (int jj
= 0; jj
< 4; ++jj
) {
2079 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 4 + jj
);
2082 expected
.cmd
.Init(1, 2, &data
[0][0]);
2083 gl_
->UniformMatrix2fv(1, 2, false, &data
[0][0]);
2084 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2087 TEST_F(GLES2ImplementationTest
, UniformMatrix2fvInvalidConstantArg2
) {
2088 GLfloat data
[2][4] = {{0}};
2089 for (int ii
= 0; ii
< 2; ++ii
) {
2090 for (int jj
= 0; jj
< 4; ++jj
) {
2091 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 4 + jj
);
2094 gl_
->UniformMatrix2fv(1, 2, true, &data
[0][0]);
2095 EXPECT_TRUE(NoCommandsWritten());
2096 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2099 TEST_F(GLES2ImplementationTest
, UniformMatrix2x3fv
) {
2100 GLfloat data
[2][6] = {{0}};
2102 cmds::UniformMatrix2x3fvImmediate cmd
;
2107 for (int ii
= 0; ii
< 2; ++ii
) {
2108 for (int jj
= 0; jj
< 6; ++jj
) {
2109 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 6 + jj
);
2112 expected
.cmd
.Init(1, 2, &data
[0][0]);
2113 gl_
->UniformMatrix2x3fv(1, 2, false, &data
[0][0]);
2114 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2117 TEST_F(GLES2ImplementationTest
, UniformMatrix2x3fvInvalidConstantArg2
) {
2118 GLfloat data
[2][6] = {{0}};
2119 for (int ii
= 0; ii
< 2; ++ii
) {
2120 for (int jj
= 0; jj
< 6; ++jj
) {
2121 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 6 + jj
);
2124 gl_
->UniformMatrix2x3fv(1, 2, true, &data
[0][0]);
2125 EXPECT_TRUE(NoCommandsWritten());
2126 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2129 TEST_F(GLES2ImplementationTest
, UniformMatrix2x4fv
) {
2130 GLfloat data
[2][8] = {{0}};
2132 cmds::UniformMatrix2x4fvImmediate cmd
;
2137 for (int ii
= 0; ii
< 2; ++ii
) {
2138 for (int jj
= 0; jj
< 8; ++jj
) {
2139 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 8 + jj
);
2142 expected
.cmd
.Init(1, 2, &data
[0][0]);
2143 gl_
->UniformMatrix2x4fv(1, 2, false, &data
[0][0]);
2144 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2147 TEST_F(GLES2ImplementationTest
, UniformMatrix2x4fvInvalidConstantArg2
) {
2148 GLfloat data
[2][8] = {{0}};
2149 for (int ii
= 0; ii
< 2; ++ii
) {
2150 for (int jj
= 0; jj
< 8; ++jj
) {
2151 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 8 + jj
);
2154 gl_
->UniformMatrix2x4fv(1, 2, true, &data
[0][0]);
2155 EXPECT_TRUE(NoCommandsWritten());
2156 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2159 TEST_F(GLES2ImplementationTest
, UniformMatrix3fv
) {
2160 GLfloat data
[2][9] = {{0}};
2162 cmds::UniformMatrix3fvImmediate cmd
;
2167 for (int ii
= 0; ii
< 2; ++ii
) {
2168 for (int jj
= 0; jj
< 9; ++jj
) {
2169 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 9 + jj
);
2172 expected
.cmd
.Init(1, 2, &data
[0][0]);
2173 gl_
->UniformMatrix3fv(1, 2, false, &data
[0][0]);
2174 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2177 TEST_F(GLES2ImplementationTest
, UniformMatrix3fvInvalidConstantArg2
) {
2178 GLfloat data
[2][9] = {{0}};
2179 for (int ii
= 0; ii
< 2; ++ii
) {
2180 for (int jj
= 0; jj
< 9; ++jj
) {
2181 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 9 + jj
);
2184 gl_
->UniformMatrix3fv(1, 2, true, &data
[0][0]);
2185 EXPECT_TRUE(NoCommandsWritten());
2186 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2189 TEST_F(GLES2ImplementationTest
, UniformMatrix3x2fv
) {
2190 GLfloat data
[2][6] = {{0}};
2192 cmds::UniformMatrix3x2fvImmediate cmd
;
2197 for (int ii
= 0; ii
< 2; ++ii
) {
2198 for (int jj
= 0; jj
< 6; ++jj
) {
2199 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 6 + jj
);
2202 expected
.cmd
.Init(1, 2, &data
[0][0]);
2203 gl_
->UniformMatrix3x2fv(1, 2, false, &data
[0][0]);
2204 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2207 TEST_F(GLES2ImplementationTest
, UniformMatrix3x2fvInvalidConstantArg2
) {
2208 GLfloat data
[2][6] = {{0}};
2209 for (int ii
= 0; ii
< 2; ++ii
) {
2210 for (int jj
= 0; jj
< 6; ++jj
) {
2211 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 6 + jj
);
2214 gl_
->UniformMatrix3x2fv(1, 2, true, &data
[0][0]);
2215 EXPECT_TRUE(NoCommandsWritten());
2216 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2219 TEST_F(GLES2ImplementationTest
, UniformMatrix3x4fv
) {
2220 GLfloat data
[2][12] = {{0}};
2222 cmds::UniformMatrix3x4fvImmediate cmd
;
2223 GLfloat data
[2][12];
2227 for (int ii
= 0; ii
< 2; ++ii
) {
2228 for (int jj
= 0; jj
< 12; ++jj
) {
2229 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 12 + jj
);
2232 expected
.cmd
.Init(1, 2, &data
[0][0]);
2233 gl_
->UniformMatrix3x4fv(1, 2, false, &data
[0][0]);
2234 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2237 TEST_F(GLES2ImplementationTest
, UniformMatrix3x4fvInvalidConstantArg2
) {
2238 GLfloat data
[2][12] = {{0}};
2239 for (int ii
= 0; ii
< 2; ++ii
) {
2240 for (int jj
= 0; jj
< 12; ++jj
) {
2241 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 12 + jj
);
2244 gl_
->UniformMatrix3x4fv(1, 2, true, &data
[0][0]);
2245 EXPECT_TRUE(NoCommandsWritten());
2246 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2249 TEST_F(GLES2ImplementationTest
, UniformMatrix4fv
) {
2250 GLfloat data
[2][16] = {{0}};
2252 cmds::UniformMatrix4fvImmediate cmd
;
2253 GLfloat data
[2][16];
2257 for (int ii
= 0; ii
< 2; ++ii
) {
2258 for (int jj
= 0; jj
< 16; ++jj
) {
2259 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 16 + jj
);
2262 expected
.cmd
.Init(1, 2, &data
[0][0]);
2263 gl_
->UniformMatrix4fv(1, 2, false, &data
[0][0]);
2264 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2267 TEST_F(GLES2ImplementationTest
, UniformMatrix4fvInvalidConstantArg2
) {
2268 GLfloat data
[2][16] = {{0}};
2269 for (int ii
= 0; ii
< 2; ++ii
) {
2270 for (int jj
= 0; jj
< 16; ++jj
) {
2271 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 16 + jj
);
2274 gl_
->UniformMatrix4fv(1, 2, true, &data
[0][0]);
2275 EXPECT_TRUE(NoCommandsWritten());
2276 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2279 TEST_F(GLES2ImplementationTest
, UniformMatrix4x2fv
) {
2280 GLfloat data
[2][8] = {{0}};
2282 cmds::UniformMatrix4x2fvImmediate cmd
;
2287 for (int ii
= 0; ii
< 2; ++ii
) {
2288 for (int jj
= 0; jj
< 8; ++jj
) {
2289 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 8 + jj
);
2292 expected
.cmd
.Init(1, 2, &data
[0][0]);
2293 gl_
->UniformMatrix4x2fv(1, 2, false, &data
[0][0]);
2294 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2297 TEST_F(GLES2ImplementationTest
, UniformMatrix4x2fvInvalidConstantArg2
) {
2298 GLfloat data
[2][8] = {{0}};
2299 for (int ii
= 0; ii
< 2; ++ii
) {
2300 for (int jj
= 0; jj
< 8; ++jj
) {
2301 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 8 + jj
);
2304 gl_
->UniformMatrix4x2fv(1, 2, true, &data
[0][0]);
2305 EXPECT_TRUE(NoCommandsWritten());
2306 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2309 TEST_F(GLES2ImplementationTest
, UniformMatrix4x3fv
) {
2310 GLfloat data
[2][12] = {{0}};
2312 cmds::UniformMatrix4x3fvImmediate cmd
;
2313 GLfloat data
[2][12];
2317 for (int ii
= 0; ii
< 2; ++ii
) {
2318 for (int jj
= 0; jj
< 12; ++jj
) {
2319 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 12 + jj
);
2322 expected
.cmd
.Init(1, 2, &data
[0][0]);
2323 gl_
->UniformMatrix4x3fv(1, 2, false, &data
[0][0]);
2324 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2327 TEST_F(GLES2ImplementationTest
, UniformMatrix4x3fvInvalidConstantArg2
) {
2328 GLfloat data
[2][12] = {{0}};
2329 for (int ii
= 0; ii
< 2; ++ii
) {
2330 for (int jj
= 0; jj
< 12; ++jj
) {
2331 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 12 + jj
);
2334 gl_
->UniformMatrix4x3fv(1, 2, true, &data
[0][0]);
2335 EXPECT_TRUE(NoCommandsWritten());
2336 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2339 TEST_F(GLES2ImplementationTest
, UseProgram
) {
2341 cmds::UseProgram cmd
;
2344 expected
.cmd
.Init(1);
2347 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2350 EXPECT_TRUE(NoCommandsWritten());
2353 TEST_F(GLES2ImplementationTest
, ValidateProgram
) {
2355 cmds::ValidateProgram cmd
;
2358 expected
.cmd
.Init(1);
2360 gl_
->ValidateProgram(1);
2361 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2364 TEST_F(GLES2ImplementationTest
, VertexAttrib1f
) {
2366 cmds::VertexAttrib1f cmd
;
2369 expected
.cmd
.Init(1, 2);
2371 gl_
->VertexAttrib1f(1, 2);
2372 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2375 TEST_F(GLES2ImplementationTest
, VertexAttrib1fv
) {
2376 GLfloat data
[1] = {0};
2378 cmds::VertexAttrib1fvImmediate cmd
;
2382 for (int jj
= 0; jj
< 1; ++jj
) {
2383 data
[jj
] = static_cast<GLfloat
>(jj
);
2386 expected
.cmd
.Init(1, &data
[0]);
2387 gl_
->VertexAttrib1fv(1, &data
[0]);
2388 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2391 TEST_F(GLES2ImplementationTest
, VertexAttrib2f
) {
2393 cmds::VertexAttrib2f cmd
;
2396 expected
.cmd
.Init(1, 2, 3);
2398 gl_
->VertexAttrib2f(1, 2, 3);
2399 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2402 TEST_F(GLES2ImplementationTest
, VertexAttrib2fv
) {
2403 GLfloat data
[2] = {0};
2405 cmds::VertexAttrib2fvImmediate cmd
;
2409 for (int jj
= 0; jj
< 2; ++jj
) {
2410 data
[jj
] = static_cast<GLfloat
>(jj
);
2413 expected
.cmd
.Init(1, &data
[0]);
2414 gl_
->VertexAttrib2fv(1, &data
[0]);
2415 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2418 TEST_F(GLES2ImplementationTest
, VertexAttrib3f
) {
2420 cmds::VertexAttrib3f cmd
;
2423 expected
.cmd
.Init(1, 2, 3, 4);
2425 gl_
->VertexAttrib3f(1, 2, 3, 4);
2426 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2429 TEST_F(GLES2ImplementationTest
, VertexAttrib3fv
) {
2430 GLfloat data
[3] = {0};
2432 cmds::VertexAttrib3fvImmediate cmd
;
2436 for (int jj
= 0; jj
< 3; ++jj
) {
2437 data
[jj
] = static_cast<GLfloat
>(jj
);
2440 expected
.cmd
.Init(1, &data
[0]);
2441 gl_
->VertexAttrib3fv(1, &data
[0]);
2442 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2445 TEST_F(GLES2ImplementationTest
, VertexAttrib4f
) {
2447 cmds::VertexAttrib4f cmd
;
2450 expected
.cmd
.Init(1, 2, 3, 4, 5);
2452 gl_
->VertexAttrib4f(1, 2, 3, 4, 5);
2453 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2456 TEST_F(GLES2ImplementationTest
, VertexAttrib4fv
) {
2457 GLfloat data
[4] = {0};
2459 cmds::VertexAttrib4fvImmediate cmd
;
2463 for (int jj
= 0; jj
< 4; ++jj
) {
2464 data
[jj
] = static_cast<GLfloat
>(jj
);
2467 expected
.cmd
.Init(1, &data
[0]);
2468 gl_
->VertexAttrib4fv(1, &data
[0]);
2469 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2472 TEST_F(GLES2ImplementationTest
, VertexAttribI4i
) {
2474 cmds::VertexAttribI4i cmd
;
2477 expected
.cmd
.Init(1, 2, 3, 4, 5);
2479 gl_
->VertexAttribI4i(1, 2, 3, 4, 5);
2480 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2483 TEST_F(GLES2ImplementationTest
, VertexAttribI4iv
) {
2484 GLint data
[4] = {0};
2486 cmds::VertexAttribI4ivImmediate cmd
;
2490 for (int jj
= 0; jj
< 4; ++jj
) {
2491 data
[jj
] = static_cast<GLint
>(jj
);
2494 expected
.cmd
.Init(1, &data
[0]);
2495 gl_
->VertexAttribI4iv(1, &data
[0]);
2496 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2499 TEST_F(GLES2ImplementationTest
, VertexAttribI4ui
) {
2501 cmds::VertexAttribI4ui cmd
;
2504 expected
.cmd
.Init(1, 2, 3, 4, 5);
2506 gl_
->VertexAttribI4ui(1, 2, 3, 4, 5);
2507 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2510 TEST_F(GLES2ImplementationTest
, VertexAttribI4uiv
) {
2511 GLuint data
[4] = {0};
2513 cmds::VertexAttribI4uivImmediate cmd
;
2517 for (int jj
= 0; jj
< 4; ++jj
) {
2518 data
[jj
] = static_cast<GLuint
>(jj
);
2521 expected
.cmd
.Init(1, &data
[0]);
2522 gl_
->VertexAttribI4uiv(1, &data
[0]);
2523 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2526 TEST_F(GLES2ImplementationTest
, Viewport
) {
2531 expected
.cmd
.Init(1, 2, 3, 4);
2533 gl_
->Viewport(1, 2, 3, 4);
2534 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2537 TEST_F(GLES2ImplementationTest
, BlitFramebufferCHROMIUM
) {
2539 cmds::BlitFramebufferCHROMIUM cmd
;
2542 expected
.cmd
.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST
);
2544 gl_
->BlitFramebufferCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST
);
2545 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2548 TEST_F(GLES2ImplementationTest
, RenderbufferStorageMultisampleCHROMIUM
) {
2550 cmds::RenderbufferStorageMultisampleCHROMIUM cmd
;
2553 expected
.cmd
.Init(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
2555 gl_
->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4,
2557 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2560 TEST_F(GLES2ImplementationTest
, RenderbufferStorageMultisampleEXT
) {
2562 cmds::RenderbufferStorageMultisampleEXT cmd
;
2565 expected
.cmd
.Init(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
2567 gl_
->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
2568 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2571 TEST_F(GLES2ImplementationTest
, FramebufferTexture2DMultisampleEXT
) {
2573 cmds::FramebufferTexture2DMultisampleEXT cmd
;
2576 expected
.cmd
.Init(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 4, 6);
2578 gl_
->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
,
2579 GL_TEXTURE_2D
, 4, 0, 6);
2580 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2583 TEST_F(GLES2ImplementationTest
,
2584 FramebufferTexture2DMultisampleEXTInvalidConstantArg4
) {
2585 gl_
->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
,
2586 GL_TEXTURE_2D
, 4, 1, 6);
2587 EXPECT_TRUE(NoCommandsWritten());
2588 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2591 TEST_F(GLES2ImplementationTest
, TexStorage2DEXT
) {
2593 cmds::TexStorage2DEXT cmd
;
2596 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, GL_RGB565
, 4, 5);
2598 gl_
->TexStorage2DEXT(GL_TEXTURE_2D
, 2, GL_RGB565
, 4, 5);
2599 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2602 TEST_F(GLES2ImplementationTest
, GenQueriesEXT
) {
2607 cmds::GenQueriesEXTImmediate gen
;
2611 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
2612 expected
.data
[0] = kQueriesStartId
;
2613 expected
.data
[1] = kQueriesStartId
+ 1;
2614 gl_
->GenQueriesEXT(arraysize(ids
), &ids
[0]);
2615 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2616 EXPECT_EQ(kQueriesStartId
, ids
[0]);
2617 EXPECT_EQ(kQueriesStartId
+ 1, ids
[1]);
2620 TEST_F(GLES2ImplementationTest
, DeleteQueriesEXT
) {
2621 GLuint ids
[2] = {kQueriesStartId
, kQueriesStartId
+ 1};
2623 cmds::DeleteQueriesEXTImmediate del
;
2627 expected
.del
.Init(arraysize(ids
), &ids
[0]);
2628 expected
.data
[0] = kQueriesStartId
;
2629 expected
.data
[1] = kQueriesStartId
+ 1;
2630 gl_
->DeleteQueriesEXT(arraysize(ids
), &ids
[0]);
2631 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2633 // TODO(zmo): Implement unit test for BeginQueryEXT
2635 TEST_F(GLES2ImplementationTest
, BeginTransformFeedback
) {
2637 cmds::BeginTransformFeedback cmd
;
2640 expected
.cmd
.Init(GL_POINTS
);
2642 gl_
->BeginTransformFeedback(GL_POINTS
);
2643 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2646 TEST_F(GLES2ImplementationTest
, EndTransformFeedback
) {
2648 cmds::EndTransformFeedback cmd
;
2651 expected
.cmd
.Init();
2653 gl_
->EndTransformFeedback();
2654 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2656 // TODO(zmo): Implement unit test for InsertEventMarkerEXT
2657 // TODO(zmo): Implement unit test for PushGroupMarkerEXT
2659 TEST_F(GLES2ImplementationTest
, PopGroupMarkerEXT
) {
2661 cmds::PopGroupMarkerEXT cmd
;
2664 expected
.cmd
.Init();
2666 gl_
->PopGroupMarkerEXT();
2667 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2670 TEST_F(GLES2ImplementationTest
, GenVertexArraysOES
) {
2675 cmds::GenVertexArraysOESImmediate gen
;
2679 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
2680 expected
.data
[0] = kVertexArraysStartId
;
2681 expected
.data
[1] = kVertexArraysStartId
+ 1;
2682 gl_
->GenVertexArraysOES(arraysize(ids
), &ids
[0]);
2683 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2684 EXPECT_EQ(kVertexArraysStartId
, ids
[0]);
2685 EXPECT_EQ(kVertexArraysStartId
+ 1, ids
[1]);
2688 TEST_F(GLES2ImplementationTest
, DeleteVertexArraysOES
) {
2689 GLuint ids
[2] = {kVertexArraysStartId
, kVertexArraysStartId
+ 1};
2691 cmds::DeleteVertexArraysOESImmediate del
;
2695 expected
.del
.Init(arraysize(ids
), &ids
[0]);
2696 expected
.data
[0] = kVertexArraysStartId
;
2697 expected
.data
[1] = kVertexArraysStartId
+ 1;
2698 gl_
->DeleteVertexArraysOES(arraysize(ids
), &ids
[0]);
2699 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2702 TEST_F(GLES2ImplementationTest
, IsVertexArrayOES
) {
2704 cmds::IsVertexArrayOES cmd
;
2708 ExpectedMemoryInfo result1
=
2709 GetExpectedResultMemory(sizeof(cmds::IsVertexArrayOES::Result
));
2710 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
2712 EXPECT_CALL(*command_buffer(), OnFlush())
2713 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
2714 .RetiresOnSaturation();
2716 GLboolean result
= gl_
->IsVertexArrayOES(1);
2717 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2718 EXPECT_TRUE(result
);
2720 // TODO(zmo): Implement unit test for EnableFeatureCHROMIUM
2722 TEST_F(GLES2ImplementationTest
, ResizeCHROMIUM
) {
2724 cmds::ResizeCHROMIUM cmd
;
2727 expected
.cmd
.Init(1, 2, 3);
2729 gl_
->ResizeCHROMIUM(1, 2, 3);
2730 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2732 // TODO(zmo): Implement unit test for GetRequestableExtensionsCHROMIUM
2733 // TODO(zmo): Implement unit test for CreateStreamTextureCHROMIUM
2734 // TODO(zmo): Implement unit test for GetTranslatedShaderSourceANGLE
2736 TEST_F(GLES2ImplementationTest
, TexImageIOSurface2DCHROMIUM
) {
2738 cmds::TexImageIOSurface2DCHROMIUM cmd
;
2741 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, 3, 4, 5);
2743 gl_
->TexImageIOSurface2DCHROMIUM(GL_TEXTURE_2D
, 2, 3, 4, 5);
2744 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2747 TEST_F(GLES2ImplementationTest
, CopyTextureCHROMIUM
) {
2749 cmds::CopyTextureCHROMIUM cmd
;
2752 expected
.cmd
.Init(1, 2, 3, 4, GL_ALPHA
, GL_UNSIGNED_BYTE
);
2754 gl_
->CopyTextureCHROMIUM(1, 2, 3, 4, GL_ALPHA
, GL_UNSIGNED_BYTE
);
2755 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2758 TEST_F(GLES2ImplementationTest
, DrawArraysInstancedANGLE
) {
2760 cmds::DrawArraysInstancedANGLE cmd
;
2763 expected
.cmd
.Init(GL_POINTS
, 2, 3, 4);
2765 gl_
->DrawArraysInstancedANGLE(GL_POINTS
, 2, 3, 4);
2766 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2769 TEST_F(GLES2ImplementationTest
, VertexAttribDivisorANGLE
) {
2771 cmds::VertexAttribDivisorANGLE cmd
;
2774 expected
.cmd
.Init(1, 2);
2776 gl_
->VertexAttribDivisorANGLE(1, 2);
2777 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2779 // TODO(zmo): Implement unit test for GenMailboxCHROMIUM
2780 // TODO(zmo): Implement unit test for BindUniformLocationCHROMIUM
2782 TEST_F(GLES2ImplementationTest
, GenValuebuffersCHROMIUM
) {
2787 cmds::GenValuebuffersCHROMIUMImmediate gen
;
2791 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
2792 expected
.data
[0] = kValuebuffersStartId
;
2793 expected
.data
[1] = kValuebuffersStartId
+ 1;
2794 gl_
->GenValuebuffersCHROMIUM(arraysize(ids
), &ids
[0]);
2795 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2796 EXPECT_EQ(kValuebuffersStartId
, ids
[0]);
2797 EXPECT_EQ(kValuebuffersStartId
+ 1, ids
[1]);
2800 TEST_F(GLES2ImplementationTest
, DeleteValuebuffersCHROMIUM
) {
2801 GLuint ids
[2] = {kValuebuffersStartId
, kValuebuffersStartId
+ 1};
2803 cmds::DeleteValuebuffersCHROMIUMImmediate del
;
2807 expected
.del
.Init(arraysize(ids
), &ids
[0]);
2808 expected
.data
[0] = kValuebuffersStartId
;
2809 expected
.data
[1] = kValuebuffersStartId
+ 1;
2810 gl_
->DeleteValuebuffersCHROMIUM(arraysize(ids
), &ids
[0]);
2811 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2814 TEST_F(GLES2ImplementationTest
, IsValuebufferCHROMIUM
) {
2816 cmds::IsValuebufferCHROMIUM cmd
;
2820 ExpectedMemoryInfo result1
=
2821 GetExpectedResultMemory(sizeof(cmds::IsValuebufferCHROMIUM::Result
));
2822 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
2824 EXPECT_CALL(*command_buffer(), OnFlush())
2825 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
2826 .RetiresOnSaturation();
2828 GLboolean result
= gl_
->IsValuebufferCHROMIUM(1);
2829 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2830 EXPECT_TRUE(result
);
2833 TEST_F(GLES2ImplementationTest
, BindValuebufferCHROMIUM
) {
2835 cmds::BindValuebufferCHROMIUM cmd
;
2838 expected
.cmd
.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
, 2);
2840 gl_
->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
, 2);
2841 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2843 gl_
->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
, 2);
2844 EXPECT_TRUE(NoCommandsWritten());
2847 TEST_F(GLES2ImplementationTest
, SubscribeValueCHROMIUM
) {
2849 cmds::SubscribeValueCHROMIUM cmd
;
2852 expected
.cmd
.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
,
2853 GL_MOUSE_POSITION_CHROMIUM
);
2855 gl_
->SubscribeValueCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
,
2856 GL_MOUSE_POSITION_CHROMIUM
);
2857 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2860 TEST_F(GLES2ImplementationTest
, PopulateSubscribedValuesCHROMIUM
) {
2862 cmds::PopulateSubscribedValuesCHROMIUM cmd
;
2865 expected
.cmd
.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
);
2867 gl_
->PopulateSubscribedValuesCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
);
2868 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2871 TEST_F(GLES2ImplementationTest
, UniformValuebufferCHROMIUM
) {
2873 cmds::UniformValuebufferCHROMIUM cmd
;
2876 expected
.cmd
.Init(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
,
2877 GL_MOUSE_POSITION_CHROMIUM
);
2879 gl_
->UniformValuebufferCHROMIUM(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
,
2880 GL_MOUSE_POSITION_CHROMIUM
);
2881 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2884 TEST_F(GLES2ImplementationTest
, BindTexImage2DCHROMIUM
) {
2886 cmds::BindTexImage2DCHROMIUM cmd
;
2889 expected
.cmd
.Init(GL_TEXTURE_2D
, 2);
2891 gl_
->BindTexImage2DCHROMIUM(GL_TEXTURE_2D
, 2);
2892 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2895 TEST_F(GLES2ImplementationTest
, ReleaseTexImage2DCHROMIUM
) {
2897 cmds::ReleaseTexImage2DCHROMIUM cmd
;
2900 expected
.cmd
.Init(GL_TEXTURE_2D
, 2);
2902 gl_
->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D
, 2);
2903 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2906 TEST_F(GLES2ImplementationTest
, DiscardFramebufferEXT
) {
2907 GLenum data
[2][1] = {{0}};
2909 cmds::DiscardFramebufferEXTImmediate cmd
;
2914 for (int ii
= 0; ii
< 2; ++ii
) {
2915 for (int jj
= 0; jj
< 1; ++jj
) {
2916 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
2919 expected
.cmd
.Init(1, 2, &data
[0][0]);
2920 gl_
->DiscardFramebufferEXT(1, 2, &data
[0][0]);
2921 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2924 TEST_F(GLES2ImplementationTest
, LoseContextCHROMIUM
) {
2926 cmds::LoseContextCHROMIUM cmd
;
2929 expected
.cmd
.Init(GL_GUILTY_CONTEXT_RESET_ARB
, GL_GUILTY_CONTEXT_RESET_ARB
);
2931 gl_
->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB
,
2932 GL_GUILTY_CONTEXT_RESET_ARB
);
2933 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2935 // TODO(zmo): Implement unit test for InsertSyncPointCHROMIUM
2937 TEST_F(GLES2ImplementationTest
, WaitSyncPointCHROMIUM
) {
2939 cmds::WaitSyncPointCHROMIUM cmd
;
2942 expected
.cmd
.Init(1);
2944 gl_
->WaitSyncPointCHROMIUM(1);
2945 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2948 TEST_F(GLES2ImplementationTest
, DrawBuffersEXT
) {
2949 GLenum data
[1][1] = {{0}};
2951 cmds::DrawBuffersEXTImmediate cmd
;
2956 for (int ii
= 0; ii
< 1; ++ii
) {
2957 for (int jj
= 0; jj
< 1; ++jj
) {
2958 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
2961 expected
.cmd
.Init(1, &data
[0][0]);
2962 gl_
->DrawBuffersEXT(1, &data
[0][0]);
2963 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2966 TEST_F(GLES2ImplementationTest
, DiscardBackbufferCHROMIUM
) {
2968 cmds::DiscardBackbufferCHROMIUM cmd
;
2971 expected
.cmd
.Init();
2973 gl_
->DiscardBackbufferCHROMIUM();
2974 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2977 TEST_F(GLES2ImplementationTest
, MatrixLoadfCHROMIUM
) {
2978 GLfloat data
[16] = {0};
2980 cmds::MatrixLoadfCHROMIUMImmediate cmd
;
2984 for (int jj
= 0; jj
< 16; ++jj
) {
2985 data
[jj
] = static_cast<GLfloat
>(jj
);
2988 expected
.cmd
.Init(GL_PATH_PROJECTION_CHROMIUM
, &data
[0]);
2989 gl_
->MatrixLoadfCHROMIUM(GL_PATH_PROJECTION_CHROMIUM
, &data
[0]);
2990 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2993 TEST_F(GLES2ImplementationTest
, MatrixLoadIdentityCHROMIUM
) {
2995 cmds::MatrixLoadIdentityCHROMIUM cmd
;
2998 expected
.cmd
.Init(GL_PATH_PROJECTION_CHROMIUM
);
3000 gl_
->MatrixLoadIdentityCHROMIUM(GL_PATH_PROJECTION_CHROMIUM
);
3001 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3003 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_