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
315 // TODO(zmo): Implement unit test for CompressedTexImage3D
316 // TODO(zmo): Implement unit test for CompressedTexSubImage3D
318 TEST_F(GLES2ImplementationTest
, CopyBufferSubData
) {
320 cmds::CopyBufferSubData cmd
;
323 expected
.cmd
.Init(GL_ARRAY_BUFFER
, GL_ARRAY_BUFFER
, 3, 4, 5);
325 gl_
->CopyBufferSubData(GL_ARRAY_BUFFER
, GL_ARRAY_BUFFER
, 3, 4, 5);
326 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
329 TEST_F(GLES2ImplementationTest
, CopyTexImage2D
) {
331 cmds::CopyTexImage2D cmd
;
334 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, GL_ALPHA
, 4, 5, 6, 7);
336 gl_
->CopyTexImage2D(GL_TEXTURE_2D
, 2, GL_ALPHA
, 4, 5, 6, 7, 0);
337 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
340 TEST_F(GLES2ImplementationTest
, CopyTexImage2DInvalidConstantArg7
) {
341 gl_
->CopyTexImage2D(GL_TEXTURE_2D
, 2, GL_ALPHA
, 4, 5, 6, 7, 1);
342 EXPECT_TRUE(NoCommandsWritten());
343 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
346 TEST_F(GLES2ImplementationTest
, CopyTexSubImage2D
) {
348 cmds::CopyTexSubImage2D cmd
;
351 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, 3, 4, 5, 6, 7, 8);
353 gl_
->CopyTexSubImage2D(GL_TEXTURE_2D
, 2, 3, 4, 5, 6, 7, 8);
354 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
357 TEST_F(GLES2ImplementationTest
, CopyTexSubImage3D
) {
359 cmds::CopyTexSubImage3D cmd
;
362 expected
.cmd
.Init(GL_TEXTURE_3D
, 2, 3, 4, 5, 6, 7, 8, 9);
364 gl_
->CopyTexSubImage3D(GL_TEXTURE_3D
, 2, 3, 4, 5, 6, 7, 8, 9);
365 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
368 TEST_F(GLES2ImplementationTest
, CullFace
) {
373 expected
.cmd
.Init(GL_FRONT
);
375 gl_
->CullFace(GL_FRONT
);
376 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
379 TEST_F(GLES2ImplementationTest
, DeleteBuffers
) {
380 GLuint ids
[2] = {kBuffersStartId
, kBuffersStartId
+ 1};
382 cmds::DeleteBuffersImmediate del
;
386 expected
.del
.Init(arraysize(ids
), &ids
[0]);
387 expected
.data
[0] = kBuffersStartId
;
388 expected
.data
[1] = kBuffersStartId
+ 1;
389 gl_
->DeleteBuffers(arraysize(ids
), &ids
[0]);
390 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
393 TEST_F(GLES2ImplementationTest
, DeleteFramebuffers
) {
394 GLuint ids
[2] = {kFramebuffersStartId
, kFramebuffersStartId
+ 1};
396 cmds::DeleteFramebuffersImmediate del
;
400 expected
.del
.Init(arraysize(ids
), &ids
[0]);
401 expected
.data
[0] = kFramebuffersStartId
;
402 expected
.data
[1] = kFramebuffersStartId
+ 1;
403 gl_
->DeleteFramebuffers(arraysize(ids
), &ids
[0]);
404 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
407 TEST_F(GLES2ImplementationTest
, DeleteProgram
) {
409 cmds::DeleteProgram cmd
;
412 expected
.cmd
.Init(1);
414 gl_
->DeleteProgram(1);
415 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
418 TEST_F(GLES2ImplementationTest
, DeleteRenderbuffers
) {
419 GLuint ids
[2] = {kRenderbuffersStartId
, kRenderbuffersStartId
+ 1};
421 cmds::DeleteRenderbuffersImmediate del
;
425 expected
.del
.Init(arraysize(ids
), &ids
[0]);
426 expected
.data
[0] = kRenderbuffersStartId
;
427 expected
.data
[1] = kRenderbuffersStartId
+ 1;
428 gl_
->DeleteRenderbuffers(arraysize(ids
), &ids
[0]);
429 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
432 TEST_F(GLES2ImplementationTest
, DeleteSamplers
) {
433 GLuint ids
[2] = {kSamplersStartId
, kSamplersStartId
+ 1};
435 cmds::DeleteSamplersImmediate del
;
439 expected
.del
.Init(arraysize(ids
), &ids
[0]);
440 expected
.data
[0] = kSamplersStartId
;
441 expected
.data
[1] = kSamplersStartId
+ 1;
442 gl_
->DeleteSamplers(arraysize(ids
), &ids
[0]);
443 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
446 TEST_F(GLES2ImplementationTest
, DeleteSync
) {
448 cmds::DeleteSync cmd
;
451 expected
.cmd
.Init(1);
453 gl_
->DeleteSync(reinterpret_cast<GLsync
>(1));
454 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
457 TEST_F(GLES2ImplementationTest
, DeleteShader
) {
459 cmds::DeleteShader cmd
;
462 expected
.cmd
.Init(1);
464 gl_
->DeleteShader(1);
465 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
468 TEST_F(GLES2ImplementationTest
, DeleteTextures
) {
469 GLuint ids
[2] = {kTexturesStartId
, kTexturesStartId
+ 1};
471 cmds::DeleteTexturesImmediate del
;
475 expected
.del
.Init(arraysize(ids
), &ids
[0]);
476 expected
.data
[0] = kTexturesStartId
;
477 expected
.data
[1] = kTexturesStartId
+ 1;
478 gl_
->DeleteTextures(arraysize(ids
), &ids
[0]);
479 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
482 TEST_F(GLES2ImplementationTest
, DeleteTransformFeedbacks
) {
483 GLuint ids
[2] = {kTransformFeedbacksStartId
, kTransformFeedbacksStartId
+ 1};
485 cmds::DeleteTransformFeedbacksImmediate del
;
489 expected
.del
.Init(arraysize(ids
), &ids
[0]);
490 expected
.data
[0] = kTransformFeedbacksStartId
;
491 expected
.data
[1] = kTransformFeedbacksStartId
+ 1;
492 gl_
->DeleteTransformFeedbacks(arraysize(ids
), &ids
[0]);
493 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
496 TEST_F(GLES2ImplementationTest
, DepthFunc
) {
501 expected
.cmd
.Init(GL_NEVER
);
503 gl_
->DepthFunc(GL_NEVER
);
504 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
507 TEST_F(GLES2ImplementationTest
, DepthMask
) {
512 expected
.cmd
.Init(true);
514 gl_
->DepthMask(true);
515 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
518 TEST_F(GLES2ImplementationTest
, DepthRangef
) {
520 cmds::DepthRangef cmd
;
523 expected
.cmd
.Init(1, 2);
525 gl_
->DepthRangef(1, 2);
526 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
529 TEST_F(GLES2ImplementationTest
, DetachShader
) {
531 cmds::DetachShader cmd
;
534 expected
.cmd
.Init(1, 2);
536 gl_
->DetachShader(1, 2);
537 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
540 TEST_F(GLES2ImplementationTest
, DisableVertexAttribArray
) {
542 cmds::DisableVertexAttribArray cmd
;
545 expected
.cmd
.Init(1);
547 gl_
->DisableVertexAttribArray(1);
548 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
551 TEST_F(GLES2ImplementationTest
, DrawArrays
) {
553 cmds::DrawArrays cmd
;
556 expected
.cmd
.Init(GL_POINTS
, 2, 3);
558 gl_
->DrawArrays(GL_POINTS
, 2, 3);
559 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
561 // TODO(zmo): Implement unit test for DrawRangeElements
563 TEST_F(GLES2ImplementationTest
, EnableVertexAttribArray
) {
565 cmds::EnableVertexAttribArray cmd
;
568 expected
.cmd
.Init(1);
570 gl_
->EnableVertexAttribArray(1);
571 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
574 TEST_F(GLES2ImplementationTest
, Flush
) {
582 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
585 TEST_F(GLES2ImplementationTest
, FramebufferRenderbuffer
) {
587 cmds::FramebufferRenderbuffer cmd
;
590 expected
.cmd
.Init(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_RENDERBUFFER
, 4);
592 gl_
->FramebufferRenderbuffer(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
,
594 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
597 TEST_F(GLES2ImplementationTest
, FramebufferTexture2D
) {
599 cmds::FramebufferTexture2D cmd
;
602 expected
.cmd
.Init(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 4);
604 gl_
->FramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
,
606 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
609 TEST_F(GLES2ImplementationTest
, FramebufferTexture2DInvalidConstantArg4
) {
610 gl_
->FramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
,
612 EXPECT_TRUE(NoCommandsWritten());
613 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
616 TEST_F(GLES2ImplementationTest
, FramebufferTextureLayer
) {
618 cmds::FramebufferTextureLayer cmd
;
621 expected
.cmd
.Init(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, 3, 4, 5);
623 gl_
->FramebufferTextureLayer(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, 3, 4, 5);
624 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
627 TEST_F(GLES2ImplementationTest
, FrontFace
) {
632 expected
.cmd
.Init(GL_CW
);
634 gl_
->FrontFace(GL_CW
);
635 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
638 TEST_F(GLES2ImplementationTest
, GenBuffers
) {
643 cmds::GenBuffersImmediate gen
;
647 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
648 expected
.data
[0] = kBuffersStartId
;
649 expected
.data
[1] = kBuffersStartId
+ 1;
650 gl_
->GenBuffers(arraysize(ids
), &ids
[0]);
651 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
652 EXPECT_EQ(kBuffersStartId
, ids
[0]);
653 EXPECT_EQ(kBuffersStartId
+ 1, ids
[1]);
656 TEST_F(GLES2ImplementationTest
, GenerateMipmap
) {
658 cmds::GenerateMipmap cmd
;
661 expected
.cmd
.Init(GL_TEXTURE_2D
);
663 gl_
->GenerateMipmap(GL_TEXTURE_2D
);
664 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
667 TEST_F(GLES2ImplementationTest
, GenFramebuffers
) {
672 cmds::GenFramebuffersImmediate gen
;
676 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
677 expected
.data
[0] = kFramebuffersStartId
;
678 expected
.data
[1] = kFramebuffersStartId
+ 1;
679 gl_
->GenFramebuffers(arraysize(ids
), &ids
[0]);
680 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
681 EXPECT_EQ(kFramebuffersStartId
, ids
[0]);
682 EXPECT_EQ(kFramebuffersStartId
+ 1, ids
[1]);
685 TEST_F(GLES2ImplementationTest
, GenRenderbuffers
) {
690 cmds::GenRenderbuffersImmediate gen
;
694 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
695 expected
.data
[0] = kRenderbuffersStartId
;
696 expected
.data
[1] = kRenderbuffersStartId
+ 1;
697 gl_
->GenRenderbuffers(arraysize(ids
), &ids
[0]);
698 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
699 EXPECT_EQ(kRenderbuffersStartId
, ids
[0]);
700 EXPECT_EQ(kRenderbuffersStartId
+ 1, ids
[1]);
703 TEST_F(GLES2ImplementationTest
, GenSamplers
) {
708 cmds::GenSamplersImmediate gen
;
712 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
713 expected
.data
[0] = kSamplersStartId
;
714 expected
.data
[1] = kSamplersStartId
+ 1;
715 gl_
->GenSamplers(arraysize(ids
), &ids
[0]);
716 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
717 EXPECT_EQ(kSamplersStartId
, ids
[0]);
718 EXPECT_EQ(kSamplersStartId
+ 1, ids
[1]);
721 TEST_F(GLES2ImplementationTest
, GenTextures
) {
726 cmds::GenTexturesImmediate gen
;
730 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
731 expected
.data
[0] = kTexturesStartId
;
732 expected
.data
[1] = kTexturesStartId
+ 1;
733 gl_
->GenTextures(arraysize(ids
), &ids
[0]);
734 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
735 EXPECT_EQ(kTexturesStartId
, ids
[0]);
736 EXPECT_EQ(kTexturesStartId
+ 1, ids
[1]);
739 TEST_F(GLES2ImplementationTest
, GenTransformFeedbacks
) {
744 cmds::GenTransformFeedbacksImmediate gen
;
748 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
749 expected
.data
[0] = kTransformFeedbacksStartId
;
750 expected
.data
[1] = kTransformFeedbacksStartId
+ 1;
751 gl_
->GenTransformFeedbacks(arraysize(ids
), &ids
[0]);
752 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
753 EXPECT_EQ(kTransformFeedbacksStartId
, ids
[0]);
754 EXPECT_EQ(kTransformFeedbacksStartId
+ 1, ids
[1]);
756 // TODO(zmo): Implement unit test for GetActiveAttrib
757 // TODO(zmo): Implement unit test for GetActiveUniform
758 // TODO(zmo): Implement unit test for GetActiveUniformBlockiv
759 // TODO(zmo): Implement unit test for GetActiveUniformBlockName
760 // TODO(zmo): Implement unit test for GetActiveUniformsiv
761 // TODO(zmo): Implement unit test for GetAttachedShaders
762 // TODO(zmo): Implement unit test for GetAttribLocation
764 TEST_F(GLES2ImplementationTest
, GetBooleanv
) {
766 cmds::GetBooleanv cmd
;
768 typedef cmds::GetBooleanv::Result::Type ResultType
;
769 ResultType result
= 0;
771 ExpectedMemoryInfo result1
=
772 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
773 expected
.cmd
.Init(123, result1
.id
, result1
.offset
);
774 EXPECT_CALL(*command_buffer(), OnFlush())
775 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
776 .RetiresOnSaturation();
777 gl_
->GetBooleanv(123, &result
);
778 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
779 EXPECT_EQ(static_cast<ResultType
>(1), result
);
782 TEST_F(GLES2ImplementationTest
, GetBufferParameteriv
) {
784 cmds::GetBufferParameteriv cmd
;
786 typedef cmds::GetBufferParameteriv::Result::Type ResultType
;
787 ResultType result
= 0;
789 ExpectedMemoryInfo result1
=
790 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
791 expected
.cmd
.Init(123, GL_BUFFER_SIZE
, result1
.id
, result1
.offset
);
792 EXPECT_CALL(*command_buffer(), OnFlush())
793 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
794 .RetiresOnSaturation();
795 gl_
->GetBufferParameteriv(123, GL_BUFFER_SIZE
, &result
);
796 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
797 EXPECT_EQ(static_cast<ResultType
>(1), result
);
800 TEST_F(GLES2ImplementationTest
, GetFloatv
) {
804 typedef cmds::GetFloatv::Result::Type ResultType
;
805 ResultType result
= 0;
807 ExpectedMemoryInfo result1
=
808 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
809 expected
.cmd
.Init(123, result1
.id
, result1
.offset
);
810 EXPECT_CALL(*command_buffer(), OnFlush())
811 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
812 .RetiresOnSaturation();
813 gl_
->GetFloatv(123, &result
);
814 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
815 EXPECT_EQ(static_cast<ResultType
>(1), result
);
817 // TODO(zmo): Implement unit test for GetFragDataLocation
819 TEST_F(GLES2ImplementationTest
, GetFramebufferAttachmentParameteriv
) {
821 cmds::GetFramebufferAttachmentParameteriv cmd
;
823 typedef cmds::GetFramebufferAttachmentParameteriv::Result::Type ResultType
;
824 ResultType result
= 0;
826 ExpectedMemoryInfo result1
=
827 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
828 expected
.cmd
.Init(123, GL_COLOR_ATTACHMENT0
,
829 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
, result1
.id
,
831 EXPECT_CALL(*command_buffer(), OnFlush())
832 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
833 .RetiresOnSaturation();
834 gl_
->GetFramebufferAttachmentParameteriv(
835 123, GL_COLOR_ATTACHMENT0
, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
,
837 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
838 EXPECT_EQ(static_cast<ResultType
>(1), result
);
841 TEST_F(GLES2ImplementationTest
, GetInteger64v
) {
843 cmds::GetInteger64v cmd
;
845 typedef cmds::GetInteger64v::Result::Type ResultType
;
846 ResultType result
= 0;
848 ExpectedMemoryInfo result1
=
849 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
850 expected
.cmd
.Init(123, result1
.id
, result1
.offset
);
851 EXPECT_CALL(*command_buffer(), OnFlush())
852 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
853 .RetiresOnSaturation();
854 gl_
->GetInteger64v(123, &result
);
855 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
856 EXPECT_EQ(static_cast<ResultType
>(1), result
);
859 TEST_F(GLES2ImplementationTest
, GetIntegeri_v
) {
861 cmds::GetIntegeri_v cmd
;
863 typedef cmds::GetIntegeri_v::Result::Type ResultType
;
864 ResultType result
= 0;
866 ExpectedMemoryInfo result1
=
867 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
868 expected
.cmd
.Init(123, 2, result1
.id
, result1
.offset
);
869 EXPECT_CALL(*command_buffer(), OnFlush())
870 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
871 .RetiresOnSaturation();
872 gl_
->GetIntegeri_v(123, 2, &result
);
873 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
874 EXPECT_EQ(static_cast<ResultType
>(1), result
);
877 TEST_F(GLES2ImplementationTest
, GetInteger64i_v
) {
879 cmds::GetInteger64i_v cmd
;
881 typedef cmds::GetInteger64i_v::Result::Type ResultType
;
882 ResultType result
= 0;
884 ExpectedMemoryInfo result1
=
885 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
886 expected
.cmd
.Init(123, 2, result1
.id
, result1
.offset
);
887 EXPECT_CALL(*command_buffer(), OnFlush())
888 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
889 .RetiresOnSaturation();
890 gl_
->GetInteger64i_v(123, 2, &result
);
891 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
892 EXPECT_EQ(static_cast<ResultType
>(1), result
);
895 TEST_F(GLES2ImplementationTest
, GetIntegerv
) {
897 cmds::GetIntegerv cmd
;
899 typedef cmds::GetIntegerv::Result::Type ResultType
;
900 ResultType result
= 0;
902 ExpectedMemoryInfo result1
=
903 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
904 expected
.cmd
.Init(123, result1
.id
, result1
.offset
);
905 EXPECT_CALL(*command_buffer(), OnFlush())
906 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
907 .RetiresOnSaturation();
908 gl_
->GetIntegerv(123, &result
);
909 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
910 EXPECT_EQ(static_cast<ResultType
>(1), result
);
912 // TODO(zmo): Implement unit test for GetInternalformativ
914 TEST_F(GLES2ImplementationTest
, GetProgramiv
) {
916 cmds::GetProgramiv cmd
;
918 typedef cmds::GetProgramiv::Result::Type ResultType
;
919 ResultType result
= 0;
921 ExpectedMemoryInfo result1
=
922 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
923 expected
.cmd
.Init(123, GL_DELETE_STATUS
, result1
.id
, result1
.offset
);
924 EXPECT_CALL(*command_buffer(), OnFlush())
925 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
926 .RetiresOnSaturation();
927 gl_
->GetProgramiv(123, GL_DELETE_STATUS
, &result
);
928 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
929 EXPECT_EQ(static_cast<ResultType
>(1), result
);
931 // TODO(zmo): Implement unit test for GetProgramInfoLog
933 TEST_F(GLES2ImplementationTest
, GetRenderbufferParameteriv
) {
935 cmds::GetRenderbufferParameteriv cmd
;
937 typedef cmds::GetRenderbufferParameteriv::Result::Type ResultType
;
938 ResultType result
= 0;
940 ExpectedMemoryInfo result1
=
941 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
942 expected
.cmd
.Init(123, GL_RENDERBUFFER_RED_SIZE
, result1
.id
, result1
.offset
);
943 EXPECT_CALL(*command_buffer(), OnFlush())
944 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
945 .RetiresOnSaturation();
946 gl_
->GetRenderbufferParameteriv(123, GL_RENDERBUFFER_RED_SIZE
, &result
);
947 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
948 EXPECT_EQ(static_cast<ResultType
>(1), result
);
951 TEST_F(GLES2ImplementationTest
, GetSamplerParameterfv
) {
953 cmds::GetSamplerParameterfv cmd
;
955 typedef cmds::GetSamplerParameterfv::Result::Type ResultType
;
956 ResultType result
= 0;
958 ExpectedMemoryInfo result1
=
959 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
960 expected
.cmd
.Init(123, GL_TEXTURE_MAG_FILTER
, result1
.id
, result1
.offset
);
961 EXPECT_CALL(*command_buffer(), OnFlush())
962 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
963 .RetiresOnSaturation();
964 gl_
->GetSamplerParameterfv(123, GL_TEXTURE_MAG_FILTER
, &result
);
965 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
966 EXPECT_EQ(static_cast<ResultType
>(1), result
);
969 TEST_F(GLES2ImplementationTest
, GetSamplerParameteriv
) {
971 cmds::GetSamplerParameteriv cmd
;
973 typedef cmds::GetSamplerParameteriv::Result::Type ResultType
;
974 ResultType result
= 0;
976 ExpectedMemoryInfo result1
=
977 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
978 expected
.cmd
.Init(123, GL_TEXTURE_MAG_FILTER
, result1
.id
, result1
.offset
);
979 EXPECT_CALL(*command_buffer(), OnFlush())
980 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
981 .RetiresOnSaturation();
982 gl_
->GetSamplerParameteriv(123, GL_TEXTURE_MAG_FILTER
, &result
);
983 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
984 EXPECT_EQ(static_cast<ResultType
>(1), result
);
987 TEST_F(GLES2ImplementationTest
, GetShaderiv
) {
989 cmds::GetShaderiv cmd
;
991 typedef cmds::GetShaderiv::Result::Type ResultType
;
992 ResultType result
= 0;
994 ExpectedMemoryInfo result1
=
995 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
996 expected
.cmd
.Init(123, GL_SHADER_TYPE
, result1
.id
, result1
.offset
);
997 EXPECT_CALL(*command_buffer(), OnFlush())
998 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
999 .RetiresOnSaturation();
1000 gl_
->GetShaderiv(123, GL_SHADER_TYPE
, &result
);
1001 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1002 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1004 // TODO(zmo): Implement unit test for GetShaderInfoLog
1005 // TODO(zmo): Implement unit test for GetShaderPrecisionFormat
1007 TEST_F(GLES2ImplementationTest
, GetSynciv
) {
1009 cmds::GetSynciv cmd
;
1011 typedef cmds::GetSynciv::Result::Type ResultType
;
1012 ResultType result
= 0;
1014 ExpectedMemoryInfo result1
=
1015 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
1016 expected
.cmd
.Init(123, GL_SYNC_STATUS
, result1
.id
, result1
.offset
);
1017 EXPECT_CALL(*command_buffer(), OnFlush())
1018 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
1019 .RetiresOnSaturation();
1020 gl_
->GetSynciv(reinterpret_cast<GLsync
>(123), GL_SYNC_STATUS
, 3, nullptr,
1022 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1023 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1026 TEST_F(GLES2ImplementationTest
, GetTexParameterfv
) {
1028 cmds::GetTexParameterfv cmd
;
1030 typedef cmds::GetTexParameterfv::Result::Type ResultType
;
1031 ResultType result
= 0;
1033 ExpectedMemoryInfo result1
=
1034 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
1035 expected
.cmd
.Init(123, GL_TEXTURE_MAG_FILTER
, result1
.id
, result1
.offset
);
1036 EXPECT_CALL(*command_buffer(), OnFlush())
1037 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
1038 .RetiresOnSaturation();
1039 gl_
->GetTexParameterfv(123, GL_TEXTURE_MAG_FILTER
, &result
);
1040 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1041 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1044 TEST_F(GLES2ImplementationTest
, GetTexParameteriv
) {
1046 cmds::GetTexParameteriv cmd
;
1048 typedef cmds::GetTexParameteriv::Result::Type ResultType
;
1049 ResultType result
= 0;
1051 ExpectedMemoryInfo result1
=
1052 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
1053 expected
.cmd
.Init(123, GL_TEXTURE_MAG_FILTER
, result1
.id
, result1
.offset
);
1054 EXPECT_CALL(*command_buffer(), OnFlush())
1055 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
1056 .RetiresOnSaturation();
1057 gl_
->GetTexParameteriv(123, GL_TEXTURE_MAG_FILTER
, &result
);
1058 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1059 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1061 // TODO(zmo): Implement unit test for GetTransformFeedbackVarying
1062 // TODO(zmo): Implement unit test for GetUniformBlockIndex
1063 // TODO(zmo): Implement unit test for GetUniformfv
1064 // TODO(zmo): Implement unit test for GetUniformiv
1065 // TODO(zmo): Implement unit test for GetUniformuiv
1066 // TODO(zmo): Implement unit test for GetUniformIndices
1067 // TODO(zmo): Implement unit test for GetUniformLocation
1069 TEST_F(GLES2ImplementationTest
, GetVertexAttribfv
) {
1071 cmds::GetVertexAttribfv cmd
;
1073 typedef cmds::GetVertexAttribfv::Result::Type ResultType
;
1074 ResultType result
= 0;
1076 ExpectedMemoryInfo result1
=
1077 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
1078 expected
.cmd
.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, result1
.id
,
1080 EXPECT_CALL(*command_buffer(), OnFlush())
1081 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
1082 .RetiresOnSaturation();
1083 gl_
->GetVertexAttribfv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, &result
);
1084 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1085 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1088 TEST_F(GLES2ImplementationTest
, GetVertexAttribiv
) {
1090 cmds::GetVertexAttribiv cmd
;
1092 typedef cmds::GetVertexAttribiv::Result::Type ResultType
;
1093 ResultType result
= 0;
1095 ExpectedMemoryInfo result1
=
1096 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
1097 expected
.cmd
.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, result1
.id
,
1099 EXPECT_CALL(*command_buffer(), OnFlush())
1100 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
1101 .RetiresOnSaturation();
1102 gl_
->GetVertexAttribiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, &result
);
1103 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1104 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1107 TEST_F(GLES2ImplementationTest
, GetVertexAttribIiv
) {
1109 cmds::GetVertexAttribIiv cmd
;
1111 typedef cmds::GetVertexAttribIiv::Result::Type ResultType
;
1112 ResultType result
= 0;
1114 ExpectedMemoryInfo result1
=
1115 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
1116 expected
.cmd
.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, result1
.id
,
1118 EXPECT_CALL(*command_buffer(), OnFlush())
1119 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
1120 .RetiresOnSaturation();
1121 gl_
->GetVertexAttribIiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, &result
);
1122 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1123 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1126 TEST_F(GLES2ImplementationTest
, GetVertexAttribIuiv
) {
1128 cmds::GetVertexAttribIuiv cmd
;
1130 typedef cmds::GetVertexAttribIuiv::Result::Type ResultType
;
1131 ResultType result
= 0;
1133 ExpectedMemoryInfo result1
=
1134 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
1135 expected
.cmd
.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, result1
.id
,
1137 EXPECT_CALL(*command_buffer(), OnFlush())
1138 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
1139 .RetiresOnSaturation();
1140 gl_
->GetVertexAttribIuiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, &result
);
1141 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1142 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1145 TEST_F(GLES2ImplementationTest
, Hint
) {
1150 expected
.cmd
.Init(GL_GENERATE_MIPMAP_HINT
, GL_FASTEST
);
1152 gl_
->Hint(GL_GENERATE_MIPMAP_HINT
, GL_FASTEST
);
1153 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1156 TEST_F(GLES2ImplementationTest
, InvalidateFramebuffer
) {
1157 GLenum data
[2][1] = {{0}};
1159 cmds::InvalidateFramebufferImmediate cmd
;
1164 for (int ii
= 0; ii
< 2; ++ii
) {
1165 for (int jj
= 0; jj
< 1; ++jj
) {
1166 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
1169 expected
.cmd
.Init(GL_FRAMEBUFFER
, 2, &data
[0][0]);
1170 gl_
->InvalidateFramebuffer(GL_FRAMEBUFFER
, 2, &data
[0][0]);
1171 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1174 TEST_F(GLES2ImplementationTest
, InvalidateSubFramebuffer
) {
1175 GLenum data
[2][1] = {{0}};
1177 cmds::InvalidateSubFramebufferImmediate cmd
;
1182 for (int ii
= 0; ii
< 2; ++ii
) {
1183 for (int jj
= 0; jj
< 1; ++jj
) {
1184 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
1187 expected
.cmd
.Init(GL_FRAMEBUFFER
, 2, &data
[0][0], 4, 5, 6, 7);
1188 gl_
->InvalidateSubFramebuffer(GL_FRAMEBUFFER
, 2, &data
[0][0], 4, 5, 6, 7);
1189 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1192 TEST_F(GLES2ImplementationTest
, IsBuffer
) {
1198 ExpectedMemoryInfo result1
=
1199 GetExpectedResultMemory(sizeof(cmds::IsBuffer::Result
));
1200 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1202 EXPECT_CALL(*command_buffer(), OnFlush())
1203 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1204 .RetiresOnSaturation();
1206 GLboolean result
= gl_
->IsBuffer(1);
1207 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1208 EXPECT_TRUE(result
);
1211 TEST_F(GLES2ImplementationTest
, IsFramebuffer
) {
1213 cmds::IsFramebuffer cmd
;
1217 ExpectedMemoryInfo result1
=
1218 GetExpectedResultMemory(sizeof(cmds::IsFramebuffer::Result
));
1219 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1221 EXPECT_CALL(*command_buffer(), OnFlush())
1222 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1223 .RetiresOnSaturation();
1225 GLboolean result
= gl_
->IsFramebuffer(1);
1226 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1227 EXPECT_TRUE(result
);
1230 TEST_F(GLES2ImplementationTest
, IsProgram
) {
1232 cmds::IsProgram cmd
;
1236 ExpectedMemoryInfo result1
=
1237 GetExpectedResultMemory(sizeof(cmds::IsProgram::Result
));
1238 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1240 EXPECT_CALL(*command_buffer(), OnFlush())
1241 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1242 .RetiresOnSaturation();
1244 GLboolean result
= gl_
->IsProgram(1);
1245 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1246 EXPECT_TRUE(result
);
1249 TEST_F(GLES2ImplementationTest
, IsRenderbuffer
) {
1251 cmds::IsRenderbuffer cmd
;
1255 ExpectedMemoryInfo result1
=
1256 GetExpectedResultMemory(sizeof(cmds::IsRenderbuffer::Result
));
1257 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1259 EXPECT_CALL(*command_buffer(), OnFlush())
1260 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1261 .RetiresOnSaturation();
1263 GLboolean result
= gl_
->IsRenderbuffer(1);
1264 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1265 EXPECT_TRUE(result
);
1268 TEST_F(GLES2ImplementationTest
, IsSampler
) {
1270 cmds::IsSampler cmd
;
1274 ExpectedMemoryInfo result1
=
1275 GetExpectedResultMemory(sizeof(cmds::IsSampler::Result
));
1276 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1278 EXPECT_CALL(*command_buffer(), OnFlush())
1279 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1280 .RetiresOnSaturation();
1282 GLboolean result
= gl_
->IsSampler(1);
1283 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1284 EXPECT_TRUE(result
);
1287 TEST_F(GLES2ImplementationTest
, IsShader
) {
1293 ExpectedMemoryInfo result1
=
1294 GetExpectedResultMemory(sizeof(cmds::IsShader::Result
));
1295 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1297 EXPECT_CALL(*command_buffer(), OnFlush())
1298 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1299 .RetiresOnSaturation();
1301 GLboolean result
= gl_
->IsShader(1);
1302 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1303 EXPECT_TRUE(result
);
1306 TEST_F(GLES2ImplementationTest
, IsSync
) {
1312 ExpectedMemoryInfo result1
=
1313 GetExpectedResultMemory(sizeof(cmds::IsSync::Result
));
1314 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1316 EXPECT_CALL(*command_buffer(), OnFlush())
1317 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1318 .RetiresOnSaturation();
1320 GLboolean result
= gl_
->IsSync(reinterpret_cast<GLsync
>(1));
1321 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1322 EXPECT_TRUE(result
);
1325 TEST_F(GLES2ImplementationTest
, IsTexture
) {
1327 cmds::IsTexture cmd
;
1331 ExpectedMemoryInfo result1
=
1332 GetExpectedResultMemory(sizeof(cmds::IsTexture::Result
));
1333 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1335 EXPECT_CALL(*command_buffer(), OnFlush())
1336 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1337 .RetiresOnSaturation();
1339 GLboolean result
= gl_
->IsTexture(1);
1340 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1341 EXPECT_TRUE(result
);
1344 TEST_F(GLES2ImplementationTest
, IsTransformFeedback
) {
1346 cmds::IsTransformFeedback cmd
;
1350 ExpectedMemoryInfo result1
=
1351 GetExpectedResultMemory(sizeof(cmds::IsTransformFeedback::Result
));
1352 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1354 EXPECT_CALL(*command_buffer(), OnFlush())
1355 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1356 .RetiresOnSaturation();
1358 GLboolean result
= gl_
->IsTransformFeedback(1);
1359 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1360 EXPECT_TRUE(result
);
1363 TEST_F(GLES2ImplementationTest
, LineWidth
) {
1365 cmds::LineWidth cmd
;
1368 expected
.cmd
.Init(0.5f
);
1370 gl_
->LineWidth(0.5f
);
1371 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1374 TEST_F(GLES2ImplementationTest
, LinkProgram
) {
1376 cmds::LinkProgram cmd
;
1379 expected
.cmd
.Init(1);
1381 gl_
->LinkProgram(1);
1382 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1385 TEST_F(GLES2ImplementationTest
, PauseTransformFeedback
) {
1387 cmds::PauseTransformFeedback cmd
;
1390 expected
.cmd
.Init();
1392 gl_
->PauseTransformFeedback();
1393 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1396 TEST_F(GLES2ImplementationTest
, PixelStorei
) {
1398 cmds::PixelStorei cmd
;
1401 expected
.cmd
.Init(GL_PACK_ALIGNMENT
, 1);
1403 gl_
->PixelStorei(GL_PACK_ALIGNMENT
, 1);
1404 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1407 TEST_F(GLES2ImplementationTest
, PolygonOffset
) {
1409 cmds::PolygonOffset cmd
;
1412 expected
.cmd
.Init(1, 2);
1414 gl_
->PolygonOffset(1, 2);
1415 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1418 TEST_F(GLES2ImplementationTest
, ReadBuffer
) {
1420 cmds::ReadBuffer cmd
;
1423 expected
.cmd
.Init(1);
1426 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1429 TEST_F(GLES2ImplementationTest
, ReleaseShaderCompiler
) {
1431 cmds::ReleaseShaderCompiler cmd
;
1434 expected
.cmd
.Init();
1436 gl_
->ReleaseShaderCompiler();
1437 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1440 TEST_F(GLES2ImplementationTest
, RenderbufferStorage
) {
1442 cmds::RenderbufferStorage cmd
;
1445 expected
.cmd
.Init(GL_RENDERBUFFER
, GL_RGBA4
, 3, 4);
1447 gl_
->RenderbufferStorage(GL_RENDERBUFFER
, GL_RGBA4
, 3, 4);
1448 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1451 TEST_F(GLES2ImplementationTest
, ResumeTransformFeedback
) {
1453 cmds::ResumeTransformFeedback cmd
;
1456 expected
.cmd
.Init();
1458 gl_
->ResumeTransformFeedback();
1459 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1462 TEST_F(GLES2ImplementationTest
, SampleCoverage
) {
1464 cmds::SampleCoverage cmd
;
1467 expected
.cmd
.Init(1, true);
1469 gl_
->SampleCoverage(1, true);
1470 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1473 TEST_F(GLES2ImplementationTest
, SamplerParameterf
) {
1475 cmds::SamplerParameterf cmd
;
1478 expected
.cmd
.Init(1, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1480 gl_
->SamplerParameterf(1, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1481 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1484 TEST_F(GLES2ImplementationTest
, SamplerParameterfv
) {
1485 GLfloat data
[1] = {0};
1487 cmds::SamplerParameterfvImmediate cmd
;
1491 for (int jj
= 0; jj
< 1; ++jj
) {
1492 data
[jj
] = static_cast<GLfloat
>(jj
);
1495 expected
.cmd
.Init(1, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1496 gl_
->SamplerParameterfv(1, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1497 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1500 TEST_F(GLES2ImplementationTest
, SamplerParameteri
) {
1502 cmds::SamplerParameteri cmd
;
1505 expected
.cmd
.Init(1, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1507 gl_
->SamplerParameteri(1, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1508 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1511 TEST_F(GLES2ImplementationTest
, SamplerParameteriv
) {
1512 GLint data
[1] = {0};
1514 cmds::SamplerParameterivImmediate cmd
;
1518 for (int jj
= 0; jj
< 1; ++jj
) {
1519 data
[jj
] = static_cast<GLint
>(jj
);
1522 expected
.cmd
.Init(1, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1523 gl_
->SamplerParameteriv(1, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1524 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1527 TEST_F(GLES2ImplementationTest
, Scissor
) {
1532 expected
.cmd
.Init(1, 2, 3, 4);
1534 gl_
->Scissor(1, 2, 3, 4);
1535 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1538 TEST_F(GLES2ImplementationTest
, ShaderSource
) {
1539 const uint32 kBucketId
= GLES2Implementation::kResultBucketId
;
1540 const char* kString1
= "happy";
1541 const char* kString2
= "ending";
1542 const size_t kString1Size
= ::strlen(kString1
) + 1;
1543 const size_t kString2Size
= ::strlen(kString2
) + 1;
1544 const size_t kHeaderSize
= sizeof(GLint
) * 3;
1545 const size_t kSourceSize
= kHeaderSize
+ kString1Size
+ kString2Size
;
1546 const size_t kPaddedHeaderSize
=
1547 transfer_buffer_
->RoundToAlignment(kHeaderSize
);
1548 const size_t kPaddedString1Size
=
1549 transfer_buffer_
->RoundToAlignment(kString1Size
);
1550 const size_t kPaddedString2Size
=
1551 transfer_buffer_
->RoundToAlignment(kString2Size
);
1553 cmd::SetBucketSize set_bucket_size
;
1554 cmd::SetBucketData set_bucket_header
;
1555 cmd::SetToken set_token1
;
1556 cmd::SetBucketData set_bucket_data1
;
1557 cmd::SetToken set_token2
;
1558 cmd::SetBucketData set_bucket_data2
;
1559 cmd::SetToken set_token3
;
1560 cmds::ShaderSourceBucket cmd_bucket
;
1561 cmd::SetBucketSize clear_bucket_size
;
1564 ExpectedMemoryInfo mem0
= GetExpectedMemory(kPaddedHeaderSize
);
1565 ExpectedMemoryInfo mem1
= GetExpectedMemory(kPaddedString1Size
);
1566 ExpectedMemoryInfo mem2
= GetExpectedMemory(kPaddedString2Size
);
1569 expected
.set_bucket_size
.Init(kBucketId
, kSourceSize
);
1570 expected
.set_bucket_header
.Init(kBucketId
, 0, kHeaderSize
, mem0
.id
,
1572 expected
.set_token1
.Init(GetNextToken());
1573 expected
.set_bucket_data1
.Init(kBucketId
, kHeaderSize
, kString1Size
, mem1
.id
,
1575 expected
.set_token2
.Init(GetNextToken());
1576 expected
.set_bucket_data2
.Init(kBucketId
, kHeaderSize
+ kString1Size
,
1577 kString2Size
, mem2
.id
, mem2
.offset
);
1578 expected
.set_token3
.Init(GetNextToken());
1579 expected
.cmd_bucket
.Init(1, kBucketId
);
1580 expected
.clear_bucket_size
.Init(kBucketId
, 0);
1581 const char* kStrings
[] = {kString1
, kString2
};
1582 gl_
->ShaderSource(1, 2, kStrings
, NULL
);
1583 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1586 TEST_F(GLES2ImplementationTest
, ShaderSourceWithLength
) {
1587 const uint32 kBucketId
= GLES2Implementation::kResultBucketId
;
1588 const char* kString
= "foobar******";
1589 const size_t kStringSize
= 6; // We only need "foobar".
1590 const size_t kHeaderSize
= sizeof(GLint
) * 2;
1591 const size_t kSourceSize
= kHeaderSize
+ kStringSize
+ 1;
1592 const size_t kPaddedHeaderSize
=
1593 transfer_buffer_
->RoundToAlignment(kHeaderSize
);
1594 const size_t kPaddedStringSize
=
1595 transfer_buffer_
->RoundToAlignment(kStringSize
+ 1);
1597 cmd::SetBucketSize set_bucket_size
;
1598 cmd::SetBucketData set_bucket_header
;
1599 cmd::SetToken set_token1
;
1600 cmd::SetBucketData set_bucket_data
;
1601 cmd::SetToken set_token2
;
1602 cmds::ShaderSourceBucket shader_source_bucket
;
1603 cmd::SetBucketSize clear_bucket_size
;
1606 ExpectedMemoryInfo mem0
= GetExpectedMemory(kPaddedHeaderSize
);
1607 ExpectedMemoryInfo mem1
= GetExpectedMemory(kPaddedStringSize
);
1610 expected
.set_bucket_size
.Init(kBucketId
, kSourceSize
);
1611 expected
.set_bucket_header
.Init(kBucketId
, 0, kHeaderSize
, mem0
.id
,
1613 expected
.set_token1
.Init(GetNextToken());
1614 expected
.set_bucket_data
.Init(kBucketId
, kHeaderSize
, kStringSize
+ 1,
1615 mem1
.id
, mem1
.offset
);
1616 expected
.set_token2
.Init(GetNextToken());
1617 expected
.shader_source_bucket
.Init(1, kBucketId
);
1618 expected
.clear_bucket_size
.Init(kBucketId
, 0);
1619 const char* kStrings
[] = {kString
};
1620 const GLint kLength
[] = {kStringSize
};
1621 gl_
->ShaderSource(1, 1, kStrings
, kLength
);
1622 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1625 TEST_F(GLES2ImplementationTest
, StencilFunc
) {
1627 cmds::StencilFunc cmd
;
1630 expected
.cmd
.Init(GL_NEVER
, 2, 3);
1632 gl_
->StencilFunc(GL_NEVER
, 2, 3);
1633 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1636 TEST_F(GLES2ImplementationTest
, StencilFuncSeparate
) {
1638 cmds::StencilFuncSeparate cmd
;
1641 expected
.cmd
.Init(GL_FRONT
, GL_NEVER
, 3, 4);
1643 gl_
->StencilFuncSeparate(GL_FRONT
, GL_NEVER
, 3, 4);
1644 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1647 TEST_F(GLES2ImplementationTest
, StencilMask
) {
1649 cmds::StencilMask cmd
;
1652 expected
.cmd
.Init(1);
1654 gl_
->StencilMask(1);
1655 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1658 TEST_F(GLES2ImplementationTest
, StencilMaskSeparate
) {
1660 cmds::StencilMaskSeparate cmd
;
1663 expected
.cmd
.Init(GL_FRONT
, 2);
1665 gl_
->StencilMaskSeparate(GL_FRONT
, 2);
1666 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1669 TEST_F(GLES2ImplementationTest
, StencilOp
) {
1671 cmds::StencilOp cmd
;
1674 expected
.cmd
.Init(GL_KEEP
, GL_INCR
, GL_KEEP
);
1676 gl_
->StencilOp(GL_KEEP
, GL_INCR
, GL_KEEP
);
1677 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1680 TEST_F(GLES2ImplementationTest
, StencilOpSeparate
) {
1682 cmds::StencilOpSeparate cmd
;
1685 expected
.cmd
.Init(GL_FRONT
, GL_INCR
, GL_KEEP
, GL_KEEP
);
1687 gl_
->StencilOpSeparate(GL_FRONT
, GL_INCR
, GL_KEEP
, GL_KEEP
);
1688 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1691 TEST_F(GLES2ImplementationTest
, TexParameterf
) {
1693 cmds::TexParameterf cmd
;
1696 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1698 gl_
->TexParameterf(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1699 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1702 TEST_F(GLES2ImplementationTest
, TexParameterfv
) {
1703 GLfloat data
[1] = {0};
1705 cmds::TexParameterfvImmediate cmd
;
1709 for (int jj
= 0; jj
< 1; ++jj
) {
1710 data
[jj
] = static_cast<GLfloat
>(jj
);
1713 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1714 gl_
->TexParameterfv(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1715 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1718 TEST_F(GLES2ImplementationTest
, TexParameteri
) {
1720 cmds::TexParameteri cmd
;
1723 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1725 gl_
->TexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1726 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1729 TEST_F(GLES2ImplementationTest
, TexParameteriv
) {
1730 GLint data
[1] = {0};
1732 cmds::TexParameterivImmediate cmd
;
1736 for (int jj
= 0; jj
< 1; ++jj
) {
1737 data
[jj
] = static_cast<GLint
>(jj
);
1740 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1741 gl_
->TexParameteriv(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1742 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1745 TEST_F(GLES2ImplementationTest
, TexStorage3D
) {
1747 cmds::TexStorage3D cmd
;
1750 expected
.cmd
.Init(GL_TEXTURE_3D
, 2, GL_RGB565
, 4, 5, 6);
1752 gl_
->TexStorage3D(GL_TEXTURE_3D
, 2, GL_RGB565
, 4, 5, 6);
1753 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1756 TEST_F(GLES2ImplementationTest
, TransformFeedbackVaryings
) {
1757 const uint32 kBucketId
= GLES2Implementation::kResultBucketId
;
1758 const char* kString1
= "happy";
1759 const char* kString2
= "ending";
1760 const size_t kString1Size
= ::strlen(kString1
) + 1;
1761 const size_t kString2Size
= ::strlen(kString2
) + 1;
1762 const size_t kHeaderSize
= sizeof(GLint
) * 3;
1763 const size_t kSourceSize
= kHeaderSize
+ kString1Size
+ kString2Size
;
1764 const size_t kPaddedHeaderSize
=
1765 transfer_buffer_
->RoundToAlignment(kHeaderSize
);
1766 const size_t kPaddedString1Size
=
1767 transfer_buffer_
->RoundToAlignment(kString1Size
);
1768 const size_t kPaddedString2Size
=
1769 transfer_buffer_
->RoundToAlignment(kString2Size
);
1771 cmd::SetBucketSize set_bucket_size
;
1772 cmd::SetBucketData set_bucket_header
;
1773 cmd::SetToken set_token1
;
1774 cmd::SetBucketData set_bucket_data1
;
1775 cmd::SetToken set_token2
;
1776 cmd::SetBucketData set_bucket_data2
;
1777 cmd::SetToken set_token3
;
1778 cmds::TransformFeedbackVaryingsBucket cmd_bucket
;
1779 cmd::SetBucketSize clear_bucket_size
;
1782 ExpectedMemoryInfo mem0
= GetExpectedMemory(kPaddedHeaderSize
);
1783 ExpectedMemoryInfo mem1
= GetExpectedMemory(kPaddedString1Size
);
1784 ExpectedMemoryInfo mem2
= GetExpectedMemory(kPaddedString2Size
);
1787 expected
.set_bucket_size
.Init(kBucketId
, kSourceSize
);
1788 expected
.set_bucket_header
.Init(kBucketId
, 0, kHeaderSize
, mem0
.id
,
1790 expected
.set_token1
.Init(GetNextToken());
1791 expected
.set_bucket_data1
.Init(kBucketId
, kHeaderSize
, kString1Size
, mem1
.id
,
1793 expected
.set_token2
.Init(GetNextToken());
1794 expected
.set_bucket_data2
.Init(kBucketId
, kHeaderSize
+ kString1Size
,
1795 kString2Size
, mem2
.id
, mem2
.offset
);
1796 expected
.set_token3
.Init(GetNextToken());
1797 expected
.cmd_bucket
.Init(1, kBucketId
, GL_INTERLEAVED_ATTRIBS
);
1798 expected
.clear_bucket_size
.Init(kBucketId
, 0);
1799 const char* kStrings
[] = {kString1
, kString2
};
1800 gl_
->TransformFeedbackVaryings(1, 2, kStrings
, GL_INTERLEAVED_ATTRIBS
);
1801 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1804 TEST_F(GLES2ImplementationTest
, Uniform1f
) {
1806 cmds::Uniform1f cmd
;
1809 expected
.cmd
.Init(1, 2);
1811 gl_
->Uniform1f(1, 2);
1812 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1815 TEST_F(GLES2ImplementationTest
, Uniform1fv
) {
1816 GLfloat data
[2][1] = {{0}};
1818 cmds::Uniform1fvImmediate cmd
;
1823 for (int ii
= 0; ii
< 2; ++ii
) {
1824 for (int jj
= 0; jj
< 1; ++jj
) {
1825 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 1 + jj
);
1828 expected
.cmd
.Init(1, 2, &data
[0][0]);
1829 gl_
->Uniform1fv(1, 2, &data
[0][0]);
1830 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1833 TEST_F(GLES2ImplementationTest
, Uniform1i
) {
1835 cmds::Uniform1i cmd
;
1838 expected
.cmd
.Init(1, 2);
1840 gl_
->Uniform1i(1, 2);
1841 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1844 TEST_F(GLES2ImplementationTest
, Uniform1iv
) {
1845 GLint data
[2][1] = {{0}};
1847 cmds::Uniform1ivImmediate cmd
;
1852 for (int ii
= 0; ii
< 2; ++ii
) {
1853 for (int jj
= 0; jj
< 1; ++jj
) {
1854 data
[ii
][jj
] = static_cast<GLint
>(ii
* 1 + jj
);
1857 expected
.cmd
.Init(1, 2, &data
[0][0]);
1858 gl_
->Uniform1iv(1, 2, &data
[0][0]);
1859 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1862 TEST_F(GLES2ImplementationTest
, Uniform1ui
) {
1864 cmds::Uniform1ui cmd
;
1867 expected
.cmd
.Init(1, 2);
1869 gl_
->Uniform1ui(1, 2);
1870 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1873 TEST_F(GLES2ImplementationTest
, Uniform1uiv
) {
1874 GLuint data
[2][1] = {{0}};
1876 cmds::Uniform1uivImmediate cmd
;
1881 for (int ii
= 0; ii
< 2; ++ii
) {
1882 for (int jj
= 0; jj
< 1; ++jj
) {
1883 data
[ii
][jj
] = static_cast<GLuint
>(ii
* 1 + jj
);
1886 expected
.cmd
.Init(1, 2, &data
[0][0]);
1887 gl_
->Uniform1uiv(1, 2, &data
[0][0]);
1888 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1891 TEST_F(GLES2ImplementationTest
, Uniform2f
) {
1893 cmds::Uniform2f cmd
;
1896 expected
.cmd
.Init(1, 2, 3);
1898 gl_
->Uniform2f(1, 2, 3);
1899 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1902 TEST_F(GLES2ImplementationTest
, Uniform2fv
) {
1903 GLfloat data
[2][2] = {{0}};
1905 cmds::Uniform2fvImmediate cmd
;
1910 for (int ii
= 0; ii
< 2; ++ii
) {
1911 for (int jj
= 0; jj
< 2; ++jj
) {
1912 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 2 + jj
);
1915 expected
.cmd
.Init(1, 2, &data
[0][0]);
1916 gl_
->Uniform2fv(1, 2, &data
[0][0]);
1917 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1920 TEST_F(GLES2ImplementationTest
, Uniform2i
) {
1922 cmds::Uniform2i cmd
;
1925 expected
.cmd
.Init(1, 2, 3);
1927 gl_
->Uniform2i(1, 2, 3);
1928 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1931 TEST_F(GLES2ImplementationTest
, Uniform2iv
) {
1932 GLint data
[2][2] = {{0}};
1934 cmds::Uniform2ivImmediate cmd
;
1939 for (int ii
= 0; ii
< 2; ++ii
) {
1940 for (int jj
= 0; jj
< 2; ++jj
) {
1941 data
[ii
][jj
] = static_cast<GLint
>(ii
* 2 + jj
);
1944 expected
.cmd
.Init(1, 2, &data
[0][0]);
1945 gl_
->Uniform2iv(1, 2, &data
[0][0]);
1946 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1949 TEST_F(GLES2ImplementationTest
, Uniform2ui
) {
1951 cmds::Uniform2ui cmd
;
1954 expected
.cmd
.Init(1, 2, 3);
1956 gl_
->Uniform2ui(1, 2, 3);
1957 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1960 TEST_F(GLES2ImplementationTest
, Uniform2uiv
) {
1961 GLuint data
[2][2] = {{0}};
1963 cmds::Uniform2uivImmediate cmd
;
1968 for (int ii
= 0; ii
< 2; ++ii
) {
1969 for (int jj
= 0; jj
< 2; ++jj
) {
1970 data
[ii
][jj
] = static_cast<GLuint
>(ii
* 2 + jj
);
1973 expected
.cmd
.Init(1, 2, &data
[0][0]);
1974 gl_
->Uniform2uiv(1, 2, &data
[0][0]);
1975 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1978 TEST_F(GLES2ImplementationTest
, Uniform3f
) {
1980 cmds::Uniform3f cmd
;
1983 expected
.cmd
.Init(1, 2, 3, 4);
1985 gl_
->Uniform3f(1, 2, 3, 4);
1986 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1989 TEST_F(GLES2ImplementationTest
, Uniform3fv
) {
1990 GLfloat data
[2][3] = {{0}};
1992 cmds::Uniform3fvImmediate cmd
;
1997 for (int ii
= 0; ii
< 2; ++ii
) {
1998 for (int jj
= 0; jj
< 3; ++jj
) {
1999 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 3 + jj
);
2002 expected
.cmd
.Init(1, 2, &data
[0][0]);
2003 gl_
->Uniform3fv(1, 2, &data
[0][0]);
2004 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2007 TEST_F(GLES2ImplementationTest
, Uniform3i
) {
2009 cmds::Uniform3i cmd
;
2012 expected
.cmd
.Init(1, 2, 3, 4);
2014 gl_
->Uniform3i(1, 2, 3, 4);
2015 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2018 TEST_F(GLES2ImplementationTest
, Uniform3iv
) {
2019 GLint data
[2][3] = {{0}};
2021 cmds::Uniform3ivImmediate cmd
;
2026 for (int ii
= 0; ii
< 2; ++ii
) {
2027 for (int jj
= 0; jj
< 3; ++jj
) {
2028 data
[ii
][jj
] = static_cast<GLint
>(ii
* 3 + jj
);
2031 expected
.cmd
.Init(1, 2, &data
[0][0]);
2032 gl_
->Uniform3iv(1, 2, &data
[0][0]);
2033 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2036 TEST_F(GLES2ImplementationTest
, Uniform3ui
) {
2038 cmds::Uniform3ui cmd
;
2041 expected
.cmd
.Init(1, 2, 3, 4);
2043 gl_
->Uniform3ui(1, 2, 3, 4);
2044 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2047 TEST_F(GLES2ImplementationTest
, Uniform3uiv
) {
2048 GLuint data
[2][3] = {{0}};
2050 cmds::Uniform3uivImmediate cmd
;
2055 for (int ii
= 0; ii
< 2; ++ii
) {
2056 for (int jj
= 0; jj
< 3; ++jj
) {
2057 data
[ii
][jj
] = static_cast<GLuint
>(ii
* 3 + jj
);
2060 expected
.cmd
.Init(1, 2, &data
[0][0]);
2061 gl_
->Uniform3uiv(1, 2, &data
[0][0]);
2062 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2065 TEST_F(GLES2ImplementationTest
, Uniform4f
) {
2067 cmds::Uniform4f cmd
;
2070 expected
.cmd
.Init(1, 2, 3, 4, 5);
2072 gl_
->Uniform4f(1, 2, 3, 4, 5);
2073 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2076 TEST_F(GLES2ImplementationTest
, Uniform4fv
) {
2077 GLfloat data
[2][4] = {{0}};
2079 cmds::Uniform4fvImmediate cmd
;
2084 for (int ii
= 0; ii
< 2; ++ii
) {
2085 for (int jj
= 0; jj
< 4; ++jj
) {
2086 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 4 + jj
);
2089 expected
.cmd
.Init(1, 2, &data
[0][0]);
2090 gl_
->Uniform4fv(1, 2, &data
[0][0]);
2091 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2094 TEST_F(GLES2ImplementationTest
, Uniform4i
) {
2096 cmds::Uniform4i cmd
;
2099 expected
.cmd
.Init(1, 2, 3, 4, 5);
2101 gl_
->Uniform4i(1, 2, 3, 4, 5);
2102 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2105 TEST_F(GLES2ImplementationTest
, Uniform4iv
) {
2106 GLint data
[2][4] = {{0}};
2108 cmds::Uniform4ivImmediate cmd
;
2113 for (int ii
= 0; ii
< 2; ++ii
) {
2114 for (int jj
= 0; jj
< 4; ++jj
) {
2115 data
[ii
][jj
] = static_cast<GLint
>(ii
* 4 + jj
);
2118 expected
.cmd
.Init(1, 2, &data
[0][0]);
2119 gl_
->Uniform4iv(1, 2, &data
[0][0]);
2120 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2123 TEST_F(GLES2ImplementationTest
, Uniform4ui
) {
2125 cmds::Uniform4ui cmd
;
2128 expected
.cmd
.Init(1, 2, 3, 4, 5);
2130 gl_
->Uniform4ui(1, 2, 3, 4, 5);
2131 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2134 TEST_F(GLES2ImplementationTest
, Uniform4uiv
) {
2135 GLuint data
[2][4] = {{0}};
2137 cmds::Uniform4uivImmediate cmd
;
2142 for (int ii
= 0; ii
< 2; ++ii
) {
2143 for (int jj
= 0; jj
< 4; ++jj
) {
2144 data
[ii
][jj
] = static_cast<GLuint
>(ii
* 4 + jj
);
2147 expected
.cmd
.Init(1, 2, &data
[0][0]);
2148 gl_
->Uniform4uiv(1, 2, &data
[0][0]);
2149 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2152 TEST_F(GLES2ImplementationTest
, UniformBlockBinding
) {
2154 cmds::UniformBlockBinding cmd
;
2157 expected
.cmd
.Init(1, 2, 3);
2159 gl_
->UniformBlockBinding(1, 2, 3);
2160 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2163 TEST_F(GLES2ImplementationTest
, UniformMatrix2fv
) {
2164 GLfloat data
[2][4] = {{0}};
2166 cmds::UniformMatrix2fvImmediate cmd
;
2171 for (int ii
= 0; ii
< 2; ++ii
) {
2172 for (int jj
= 0; jj
< 4; ++jj
) {
2173 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 4 + jj
);
2176 expected
.cmd
.Init(1, 2, &data
[0][0]);
2177 gl_
->UniformMatrix2fv(1, 2, false, &data
[0][0]);
2178 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2181 TEST_F(GLES2ImplementationTest
, UniformMatrix2fvInvalidConstantArg2
) {
2182 GLfloat data
[2][4] = {{0}};
2183 for (int ii
= 0; ii
< 2; ++ii
) {
2184 for (int jj
= 0; jj
< 4; ++jj
) {
2185 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 4 + jj
);
2188 gl_
->UniformMatrix2fv(1, 2, true, &data
[0][0]);
2189 EXPECT_TRUE(NoCommandsWritten());
2190 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2193 TEST_F(GLES2ImplementationTest
, UniformMatrix2x3fv
) {
2194 GLfloat data
[2][6] = {{0}};
2196 cmds::UniformMatrix2x3fvImmediate cmd
;
2201 for (int ii
= 0; ii
< 2; ++ii
) {
2202 for (int jj
= 0; jj
< 6; ++jj
) {
2203 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 6 + jj
);
2206 expected
.cmd
.Init(1, 2, &data
[0][0]);
2207 gl_
->UniformMatrix2x3fv(1, 2, false, &data
[0][0]);
2208 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2211 TEST_F(GLES2ImplementationTest
, UniformMatrix2x3fvInvalidConstantArg2
) {
2212 GLfloat data
[2][6] = {{0}};
2213 for (int ii
= 0; ii
< 2; ++ii
) {
2214 for (int jj
= 0; jj
< 6; ++jj
) {
2215 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 6 + jj
);
2218 gl_
->UniformMatrix2x3fv(1, 2, true, &data
[0][0]);
2219 EXPECT_TRUE(NoCommandsWritten());
2220 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2223 TEST_F(GLES2ImplementationTest
, UniformMatrix2x4fv
) {
2224 GLfloat data
[2][8] = {{0}};
2226 cmds::UniformMatrix2x4fvImmediate cmd
;
2231 for (int ii
= 0; ii
< 2; ++ii
) {
2232 for (int jj
= 0; jj
< 8; ++jj
) {
2233 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 8 + jj
);
2236 expected
.cmd
.Init(1, 2, &data
[0][0]);
2237 gl_
->UniformMatrix2x4fv(1, 2, false, &data
[0][0]);
2238 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2241 TEST_F(GLES2ImplementationTest
, UniformMatrix2x4fvInvalidConstantArg2
) {
2242 GLfloat data
[2][8] = {{0}};
2243 for (int ii
= 0; ii
< 2; ++ii
) {
2244 for (int jj
= 0; jj
< 8; ++jj
) {
2245 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 8 + jj
);
2248 gl_
->UniformMatrix2x4fv(1, 2, true, &data
[0][0]);
2249 EXPECT_TRUE(NoCommandsWritten());
2250 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2253 TEST_F(GLES2ImplementationTest
, UniformMatrix3fv
) {
2254 GLfloat data
[2][9] = {{0}};
2256 cmds::UniformMatrix3fvImmediate cmd
;
2261 for (int ii
= 0; ii
< 2; ++ii
) {
2262 for (int jj
= 0; jj
< 9; ++jj
) {
2263 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 9 + jj
);
2266 expected
.cmd
.Init(1, 2, &data
[0][0]);
2267 gl_
->UniformMatrix3fv(1, 2, false, &data
[0][0]);
2268 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2271 TEST_F(GLES2ImplementationTest
, UniformMatrix3fvInvalidConstantArg2
) {
2272 GLfloat data
[2][9] = {{0}};
2273 for (int ii
= 0; ii
< 2; ++ii
) {
2274 for (int jj
= 0; jj
< 9; ++jj
) {
2275 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 9 + jj
);
2278 gl_
->UniformMatrix3fv(1, 2, true, &data
[0][0]);
2279 EXPECT_TRUE(NoCommandsWritten());
2280 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2283 TEST_F(GLES2ImplementationTest
, UniformMatrix3x2fv
) {
2284 GLfloat data
[2][6] = {{0}};
2286 cmds::UniformMatrix3x2fvImmediate cmd
;
2291 for (int ii
= 0; ii
< 2; ++ii
) {
2292 for (int jj
= 0; jj
< 6; ++jj
) {
2293 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 6 + jj
);
2296 expected
.cmd
.Init(1, 2, &data
[0][0]);
2297 gl_
->UniformMatrix3x2fv(1, 2, false, &data
[0][0]);
2298 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2301 TEST_F(GLES2ImplementationTest
, UniformMatrix3x2fvInvalidConstantArg2
) {
2302 GLfloat data
[2][6] = {{0}};
2303 for (int ii
= 0; ii
< 2; ++ii
) {
2304 for (int jj
= 0; jj
< 6; ++jj
) {
2305 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 6 + jj
);
2308 gl_
->UniformMatrix3x2fv(1, 2, true, &data
[0][0]);
2309 EXPECT_TRUE(NoCommandsWritten());
2310 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2313 TEST_F(GLES2ImplementationTest
, UniformMatrix3x4fv
) {
2314 GLfloat data
[2][12] = {{0}};
2316 cmds::UniformMatrix3x4fvImmediate cmd
;
2317 GLfloat data
[2][12];
2321 for (int ii
= 0; ii
< 2; ++ii
) {
2322 for (int jj
= 0; jj
< 12; ++jj
) {
2323 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 12 + jj
);
2326 expected
.cmd
.Init(1, 2, &data
[0][0]);
2327 gl_
->UniformMatrix3x4fv(1, 2, false, &data
[0][0]);
2328 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2331 TEST_F(GLES2ImplementationTest
, UniformMatrix3x4fvInvalidConstantArg2
) {
2332 GLfloat data
[2][12] = {{0}};
2333 for (int ii
= 0; ii
< 2; ++ii
) {
2334 for (int jj
= 0; jj
< 12; ++jj
) {
2335 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 12 + jj
);
2338 gl_
->UniformMatrix3x4fv(1, 2, true, &data
[0][0]);
2339 EXPECT_TRUE(NoCommandsWritten());
2340 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2343 TEST_F(GLES2ImplementationTest
, UniformMatrix4fv
) {
2344 GLfloat data
[2][16] = {{0}};
2346 cmds::UniformMatrix4fvImmediate cmd
;
2347 GLfloat data
[2][16];
2351 for (int ii
= 0; ii
< 2; ++ii
) {
2352 for (int jj
= 0; jj
< 16; ++jj
) {
2353 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 16 + jj
);
2356 expected
.cmd
.Init(1, 2, &data
[0][0]);
2357 gl_
->UniformMatrix4fv(1, 2, false, &data
[0][0]);
2358 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2361 TEST_F(GLES2ImplementationTest
, UniformMatrix4fvInvalidConstantArg2
) {
2362 GLfloat data
[2][16] = {{0}};
2363 for (int ii
= 0; ii
< 2; ++ii
) {
2364 for (int jj
= 0; jj
< 16; ++jj
) {
2365 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 16 + jj
);
2368 gl_
->UniformMatrix4fv(1, 2, true, &data
[0][0]);
2369 EXPECT_TRUE(NoCommandsWritten());
2370 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2373 TEST_F(GLES2ImplementationTest
, UniformMatrix4x2fv
) {
2374 GLfloat data
[2][8] = {{0}};
2376 cmds::UniformMatrix4x2fvImmediate cmd
;
2381 for (int ii
= 0; ii
< 2; ++ii
) {
2382 for (int jj
= 0; jj
< 8; ++jj
) {
2383 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 8 + jj
);
2386 expected
.cmd
.Init(1, 2, &data
[0][0]);
2387 gl_
->UniformMatrix4x2fv(1, 2, false, &data
[0][0]);
2388 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2391 TEST_F(GLES2ImplementationTest
, UniformMatrix4x2fvInvalidConstantArg2
) {
2392 GLfloat data
[2][8] = {{0}};
2393 for (int ii
= 0; ii
< 2; ++ii
) {
2394 for (int jj
= 0; jj
< 8; ++jj
) {
2395 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 8 + jj
);
2398 gl_
->UniformMatrix4x2fv(1, 2, true, &data
[0][0]);
2399 EXPECT_TRUE(NoCommandsWritten());
2400 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2403 TEST_F(GLES2ImplementationTest
, UniformMatrix4x3fv
) {
2404 GLfloat data
[2][12] = {{0}};
2406 cmds::UniformMatrix4x3fvImmediate cmd
;
2407 GLfloat data
[2][12];
2411 for (int ii
= 0; ii
< 2; ++ii
) {
2412 for (int jj
= 0; jj
< 12; ++jj
) {
2413 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 12 + jj
);
2416 expected
.cmd
.Init(1, 2, &data
[0][0]);
2417 gl_
->UniformMatrix4x3fv(1, 2, false, &data
[0][0]);
2418 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2421 TEST_F(GLES2ImplementationTest
, UniformMatrix4x3fvInvalidConstantArg2
) {
2422 GLfloat data
[2][12] = {{0}};
2423 for (int ii
= 0; ii
< 2; ++ii
) {
2424 for (int jj
= 0; jj
< 12; ++jj
) {
2425 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 12 + jj
);
2428 gl_
->UniformMatrix4x3fv(1, 2, true, &data
[0][0]);
2429 EXPECT_TRUE(NoCommandsWritten());
2430 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2433 TEST_F(GLES2ImplementationTest
, UseProgram
) {
2435 cmds::UseProgram cmd
;
2438 expected
.cmd
.Init(1);
2441 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2444 EXPECT_TRUE(NoCommandsWritten());
2447 TEST_F(GLES2ImplementationTest
, ValidateProgram
) {
2449 cmds::ValidateProgram cmd
;
2452 expected
.cmd
.Init(1);
2454 gl_
->ValidateProgram(1);
2455 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2458 TEST_F(GLES2ImplementationTest
, VertexAttrib1f
) {
2460 cmds::VertexAttrib1f cmd
;
2463 expected
.cmd
.Init(1, 2);
2465 gl_
->VertexAttrib1f(1, 2);
2466 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2469 TEST_F(GLES2ImplementationTest
, VertexAttrib1fv
) {
2470 GLfloat data
[1] = {0};
2472 cmds::VertexAttrib1fvImmediate cmd
;
2476 for (int jj
= 0; jj
< 1; ++jj
) {
2477 data
[jj
] = static_cast<GLfloat
>(jj
);
2480 expected
.cmd
.Init(1, &data
[0]);
2481 gl_
->VertexAttrib1fv(1, &data
[0]);
2482 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2485 TEST_F(GLES2ImplementationTest
, VertexAttrib2f
) {
2487 cmds::VertexAttrib2f cmd
;
2490 expected
.cmd
.Init(1, 2, 3);
2492 gl_
->VertexAttrib2f(1, 2, 3);
2493 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2496 TEST_F(GLES2ImplementationTest
, VertexAttrib2fv
) {
2497 GLfloat data
[2] = {0};
2499 cmds::VertexAttrib2fvImmediate cmd
;
2503 for (int jj
= 0; jj
< 2; ++jj
) {
2504 data
[jj
] = static_cast<GLfloat
>(jj
);
2507 expected
.cmd
.Init(1, &data
[0]);
2508 gl_
->VertexAttrib2fv(1, &data
[0]);
2509 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2512 TEST_F(GLES2ImplementationTest
, VertexAttrib3f
) {
2514 cmds::VertexAttrib3f cmd
;
2517 expected
.cmd
.Init(1, 2, 3, 4);
2519 gl_
->VertexAttrib3f(1, 2, 3, 4);
2520 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2523 TEST_F(GLES2ImplementationTest
, VertexAttrib3fv
) {
2524 GLfloat data
[3] = {0};
2526 cmds::VertexAttrib3fvImmediate cmd
;
2530 for (int jj
= 0; jj
< 3; ++jj
) {
2531 data
[jj
] = static_cast<GLfloat
>(jj
);
2534 expected
.cmd
.Init(1, &data
[0]);
2535 gl_
->VertexAttrib3fv(1, &data
[0]);
2536 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2539 TEST_F(GLES2ImplementationTest
, VertexAttrib4f
) {
2541 cmds::VertexAttrib4f cmd
;
2544 expected
.cmd
.Init(1, 2, 3, 4, 5);
2546 gl_
->VertexAttrib4f(1, 2, 3, 4, 5);
2547 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2550 TEST_F(GLES2ImplementationTest
, VertexAttrib4fv
) {
2551 GLfloat data
[4] = {0};
2553 cmds::VertexAttrib4fvImmediate cmd
;
2557 for (int jj
= 0; jj
< 4; ++jj
) {
2558 data
[jj
] = static_cast<GLfloat
>(jj
);
2561 expected
.cmd
.Init(1, &data
[0]);
2562 gl_
->VertexAttrib4fv(1, &data
[0]);
2563 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2566 TEST_F(GLES2ImplementationTest
, VertexAttribI4i
) {
2568 cmds::VertexAttribI4i cmd
;
2571 expected
.cmd
.Init(1, 2, 3, 4, 5);
2573 gl_
->VertexAttribI4i(1, 2, 3, 4, 5);
2574 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2577 TEST_F(GLES2ImplementationTest
, VertexAttribI4iv
) {
2578 GLint data
[4] = {0};
2580 cmds::VertexAttribI4ivImmediate cmd
;
2584 for (int jj
= 0; jj
< 4; ++jj
) {
2585 data
[jj
] = static_cast<GLint
>(jj
);
2588 expected
.cmd
.Init(1, &data
[0]);
2589 gl_
->VertexAttribI4iv(1, &data
[0]);
2590 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2593 TEST_F(GLES2ImplementationTest
, VertexAttribI4ui
) {
2595 cmds::VertexAttribI4ui cmd
;
2598 expected
.cmd
.Init(1, 2, 3, 4, 5);
2600 gl_
->VertexAttribI4ui(1, 2, 3, 4, 5);
2601 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2604 TEST_F(GLES2ImplementationTest
, VertexAttribI4uiv
) {
2605 GLuint data
[4] = {0};
2607 cmds::VertexAttribI4uivImmediate cmd
;
2611 for (int jj
= 0; jj
< 4; ++jj
) {
2612 data
[jj
] = static_cast<GLuint
>(jj
);
2615 expected
.cmd
.Init(1, &data
[0]);
2616 gl_
->VertexAttribI4uiv(1, &data
[0]);
2617 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2620 TEST_F(GLES2ImplementationTest
, Viewport
) {
2625 expected
.cmd
.Init(1, 2, 3, 4);
2627 gl_
->Viewport(1, 2, 3, 4);
2628 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2631 TEST_F(GLES2ImplementationTest
, BlitFramebufferCHROMIUM
) {
2633 cmds::BlitFramebufferCHROMIUM cmd
;
2636 expected
.cmd
.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST
);
2638 gl_
->BlitFramebufferCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST
);
2639 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2642 TEST_F(GLES2ImplementationTest
, RenderbufferStorageMultisampleCHROMIUM
) {
2644 cmds::RenderbufferStorageMultisampleCHROMIUM cmd
;
2647 expected
.cmd
.Init(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
2649 gl_
->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4,
2651 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2654 TEST_F(GLES2ImplementationTest
, RenderbufferStorageMultisampleEXT
) {
2656 cmds::RenderbufferStorageMultisampleEXT cmd
;
2659 expected
.cmd
.Init(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
2661 gl_
->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
2662 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2665 TEST_F(GLES2ImplementationTest
, FramebufferTexture2DMultisampleEXT
) {
2667 cmds::FramebufferTexture2DMultisampleEXT cmd
;
2670 expected
.cmd
.Init(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 4, 6);
2672 gl_
->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
,
2673 GL_TEXTURE_2D
, 4, 0, 6);
2674 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2677 TEST_F(GLES2ImplementationTest
,
2678 FramebufferTexture2DMultisampleEXTInvalidConstantArg4
) {
2679 gl_
->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
,
2680 GL_TEXTURE_2D
, 4, 1, 6);
2681 EXPECT_TRUE(NoCommandsWritten());
2682 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2685 TEST_F(GLES2ImplementationTest
, TexStorage2DEXT
) {
2687 cmds::TexStorage2DEXT cmd
;
2690 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, GL_RGB565
, 4, 5);
2692 gl_
->TexStorage2DEXT(GL_TEXTURE_2D
, 2, GL_RGB565
, 4, 5);
2693 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2696 TEST_F(GLES2ImplementationTest
, GenQueriesEXT
) {
2701 cmds::GenQueriesEXTImmediate gen
;
2705 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
2706 expected
.data
[0] = kQueriesStartId
;
2707 expected
.data
[1] = kQueriesStartId
+ 1;
2708 gl_
->GenQueriesEXT(arraysize(ids
), &ids
[0]);
2709 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2710 EXPECT_EQ(kQueriesStartId
, ids
[0]);
2711 EXPECT_EQ(kQueriesStartId
+ 1, ids
[1]);
2714 TEST_F(GLES2ImplementationTest
, DeleteQueriesEXT
) {
2715 GLuint ids
[2] = {kQueriesStartId
, kQueriesStartId
+ 1};
2717 cmds::DeleteQueriesEXTImmediate del
;
2721 expected
.del
.Init(arraysize(ids
), &ids
[0]);
2722 expected
.data
[0] = kQueriesStartId
;
2723 expected
.data
[1] = kQueriesStartId
+ 1;
2724 gl_
->DeleteQueriesEXT(arraysize(ids
), &ids
[0]);
2725 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2727 // TODO(zmo): Implement unit test for QueryCounterEXT
2728 // TODO(zmo): Implement unit test for BeginQueryEXT
2730 TEST_F(GLES2ImplementationTest
, BeginTransformFeedback
) {
2732 cmds::BeginTransformFeedback cmd
;
2735 expected
.cmd
.Init(GL_POINTS
);
2737 gl_
->BeginTransformFeedback(GL_POINTS
);
2738 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2741 TEST_F(GLES2ImplementationTest
, EndTransformFeedback
) {
2743 cmds::EndTransformFeedback cmd
;
2746 expected
.cmd
.Init();
2748 gl_
->EndTransformFeedback();
2749 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2751 // TODO(zmo): Implement unit test for InsertEventMarkerEXT
2752 // TODO(zmo): Implement unit test for PushGroupMarkerEXT
2754 TEST_F(GLES2ImplementationTest
, PopGroupMarkerEXT
) {
2756 cmds::PopGroupMarkerEXT cmd
;
2759 expected
.cmd
.Init();
2761 gl_
->PopGroupMarkerEXT();
2762 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2765 TEST_F(GLES2ImplementationTest
, GenVertexArraysOES
) {
2770 cmds::GenVertexArraysOESImmediate gen
;
2774 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
2775 expected
.data
[0] = kVertexArraysStartId
;
2776 expected
.data
[1] = kVertexArraysStartId
+ 1;
2777 gl_
->GenVertexArraysOES(arraysize(ids
), &ids
[0]);
2778 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2779 EXPECT_EQ(kVertexArraysStartId
, ids
[0]);
2780 EXPECT_EQ(kVertexArraysStartId
+ 1, ids
[1]);
2783 TEST_F(GLES2ImplementationTest
, DeleteVertexArraysOES
) {
2784 GLuint ids
[2] = {kVertexArraysStartId
, kVertexArraysStartId
+ 1};
2786 cmds::DeleteVertexArraysOESImmediate del
;
2790 expected
.del
.Init(arraysize(ids
), &ids
[0]);
2791 expected
.data
[0] = kVertexArraysStartId
;
2792 expected
.data
[1] = kVertexArraysStartId
+ 1;
2793 gl_
->DeleteVertexArraysOES(arraysize(ids
), &ids
[0]);
2794 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2797 TEST_F(GLES2ImplementationTest
, IsVertexArrayOES
) {
2799 cmds::IsVertexArrayOES cmd
;
2803 ExpectedMemoryInfo result1
=
2804 GetExpectedResultMemory(sizeof(cmds::IsVertexArrayOES::Result
));
2805 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
2807 EXPECT_CALL(*command_buffer(), OnFlush())
2808 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
2809 .RetiresOnSaturation();
2811 GLboolean result
= gl_
->IsVertexArrayOES(1);
2812 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2813 EXPECT_TRUE(result
);
2815 // TODO(zmo): Implement unit test for EnableFeatureCHROMIUM
2816 // TODO(zmo): Implement unit test for MapBufferRange
2817 // TODO(zmo): Implement unit test for UnmapBuffer
2819 TEST_F(GLES2ImplementationTest
, ResizeCHROMIUM
) {
2821 cmds::ResizeCHROMIUM cmd
;
2824 expected
.cmd
.Init(1, 2, 3);
2826 gl_
->ResizeCHROMIUM(1, 2, 3);
2827 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2829 // TODO(zmo): Implement unit test for GetRequestableExtensionsCHROMIUM
2830 // TODO(zmo): Implement unit test for CreateStreamTextureCHROMIUM
2831 // TODO(zmo): Implement unit test for GetTranslatedShaderSourceANGLE
2833 TEST_F(GLES2ImplementationTest
, TexImageIOSurface2DCHROMIUM
) {
2835 cmds::TexImageIOSurface2DCHROMIUM cmd
;
2838 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, 3, 4, 5);
2840 gl_
->TexImageIOSurface2DCHROMIUM(GL_TEXTURE_2D
, 2, 3, 4, 5);
2841 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2844 TEST_F(GLES2ImplementationTest
, CopyTextureCHROMIUM
) {
2846 cmds::CopyTextureCHROMIUM cmd
;
2849 expected
.cmd
.Init(1, 2, 3, GL_ALPHA
, GL_UNSIGNED_BYTE
, true, true, true);
2851 gl_
->CopyTextureCHROMIUM(1, 2, 3, GL_ALPHA
, GL_UNSIGNED_BYTE
, true, true,
2853 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2856 TEST_F(GLES2ImplementationTest
, CopySubTextureCHROMIUM
) {
2858 cmds::CopySubTextureCHROMIUM cmd
;
2861 expected
.cmd
.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, true, true, true);
2863 gl_
->CopySubTextureCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, true, true, true);
2864 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2867 TEST_F(GLES2ImplementationTest
, CompressedCopyTextureCHROMIUM
) {
2869 cmds::CompressedCopyTextureCHROMIUM cmd
;
2872 expected
.cmd
.Init(1, 2, 3);
2874 gl_
->CompressedCopyTextureCHROMIUM(1, 2, 3);
2875 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2878 TEST_F(GLES2ImplementationTest
, DrawArraysInstancedANGLE
) {
2880 cmds::DrawArraysInstancedANGLE cmd
;
2883 expected
.cmd
.Init(GL_POINTS
, 2, 3, 4);
2885 gl_
->DrawArraysInstancedANGLE(GL_POINTS
, 2, 3, 4);
2886 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2889 TEST_F(GLES2ImplementationTest
, VertexAttribDivisorANGLE
) {
2891 cmds::VertexAttribDivisorANGLE cmd
;
2894 expected
.cmd
.Init(1, 2);
2896 gl_
->VertexAttribDivisorANGLE(1, 2);
2897 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2899 // TODO(zmo): Implement unit test for GenMailboxCHROMIUM
2900 // TODO(zmo): Implement unit test for BindUniformLocationCHROMIUM
2902 TEST_F(GLES2ImplementationTest
, GenValuebuffersCHROMIUM
) {
2907 cmds::GenValuebuffersCHROMIUMImmediate gen
;
2911 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
2912 expected
.data
[0] = kValuebuffersStartId
;
2913 expected
.data
[1] = kValuebuffersStartId
+ 1;
2914 gl_
->GenValuebuffersCHROMIUM(arraysize(ids
), &ids
[0]);
2915 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2916 EXPECT_EQ(kValuebuffersStartId
, ids
[0]);
2917 EXPECT_EQ(kValuebuffersStartId
+ 1, ids
[1]);
2920 TEST_F(GLES2ImplementationTest
, DeleteValuebuffersCHROMIUM
) {
2921 GLuint ids
[2] = {kValuebuffersStartId
, kValuebuffersStartId
+ 1};
2923 cmds::DeleteValuebuffersCHROMIUMImmediate del
;
2927 expected
.del
.Init(arraysize(ids
), &ids
[0]);
2928 expected
.data
[0] = kValuebuffersStartId
;
2929 expected
.data
[1] = kValuebuffersStartId
+ 1;
2930 gl_
->DeleteValuebuffersCHROMIUM(arraysize(ids
), &ids
[0]);
2931 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2934 TEST_F(GLES2ImplementationTest
, IsValuebufferCHROMIUM
) {
2936 cmds::IsValuebufferCHROMIUM cmd
;
2940 ExpectedMemoryInfo result1
=
2941 GetExpectedResultMemory(sizeof(cmds::IsValuebufferCHROMIUM::Result
));
2942 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
2944 EXPECT_CALL(*command_buffer(), OnFlush())
2945 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
2946 .RetiresOnSaturation();
2948 GLboolean result
= gl_
->IsValuebufferCHROMIUM(1);
2949 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2950 EXPECT_TRUE(result
);
2953 TEST_F(GLES2ImplementationTest
, BindValuebufferCHROMIUM
) {
2955 cmds::BindValuebufferCHROMIUM cmd
;
2958 expected
.cmd
.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
, 2);
2960 gl_
->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
, 2);
2961 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2963 gl_
->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
, 2);
2964 EXPECT_TRUE(NoCommandsWritten());
2967 TEST_F(GLES2ImplementationTest
, SubscribeValueCHROMIUM
) {
2969 cmds::SubscribeValueCHROMIUM cmd
;
2972 expected
.cmd
.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
,
2973 GL_MOUSE_POSITION_CHROMIUM
);
2975 gl_
->SubscribeValueCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
,
2976 GL_MOUSE_POSITION_CHROMIUM
);
2977 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2980 TEST_F(GLES2ImplementationTest
, PopulateSubscribedValuesCHROMIUM
) {
2982 cmds::PopulateSubscribedValuesCHROMIUM cmd
;
2985 expected
.cmd
.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
);
2987 gl_
->PopulateSubscribedValuesCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
);
2988 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2991 TEST_F(GLES2ImplementationTest
, UniformValuebufferCHROMIUM
) {
2993 cmds::UniformValuebufferCHROMIUM cmd
;
2996 expected
.cmd
.Init(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
,
2997 GL_MOUSE_POSITION_CHROMIUM
);
2999 gl_
->UniformValuebufferCHROMIUM(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
,
3000 GL_MOUSE_POSITION_CHROMIUM
);
3001 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3004 TEST_F(GLES2ImplementationTest
, BindTexImage2DCHROMIUM
) {
3006 cmds::BindTexImage2DCHROMIUM cmd
;
3009 expected
.cmd
.Init(GL_TEXTURE_2D
, 2);
3011 gl_
->BindTexImage2DCHROMIUM(GL_TEXTURE_2D
, 2);
3012 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3015 TEST_F(GLES2ImplementationTest
, ReleaseTexImage2DCHROMIUM
) {
3017 cmds::ReleaseTexImage2DCHROMIUM cmd
;
3020 expected
.cmd
.Init(GL_TEXTURE_2D
, 2);
3022 gl_
->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D
, 2);
3023 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3026 TEST_F(GLES2ImplementationTest
, DiscardFramebufferEXT
) {
3027 GLenum data
[2][1] = {{0}};
3029 cmds::DiscardFramebufferEXTImmediate cmd
;
3034 for (int ii
= 0; ii
< 2; ++ii
) {
3035 for (int jj
= 0; jj
< 1; ++jj
) {
3036 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
3039 expected
.cmd
.Init(1, 2, &data
[0][0]);
3040 gl_
->DiscardFramebufferEXT(1, 2, &data
[0][0]);
3041 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3044 TEST_F(GLES2ImplementationTest
, LoseContextCHROMIUM
) {
3046 cmds::LoseContextCHROMIUM cmd
;
3049 expected
.cmd
.Init(GL_GUILTY_CONTEXT_RESET_ARB
, GL_GUILTY_CONTEXT_RESET_ARB
);
3051 gl_
->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB
,
3052 GL_GUILTY_CONTEXT_RESET_ARB
);
3053 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3055 // TODO(zmo): Implement unit test for InsertSyncPointCHROMIUM
3057 TEST_F(GLES2ImplementationTest
, WaitSyncPointCHROMIUM
) {
3059 cmds::WaitSyncPointCHROMIUM cmd
;
3062 expected
.cmd
.Init(1);
3064 gl_
->WaitSyncPointCHROMIUM(1);
3065 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3068 TEST_F(GLES2ImplementationTest
, DrawBuffersEXT
) {
3069 GLenum data
[1][1] = {{0}};
3071 cmds::DrawBuffersEXTImmediate cmd
;
3076 for (int ii
= 0; ii
< 1; ++ii
) {
3077 for (int jj
= 0; jj
< 1; ++jj
) {
3078 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
3081 expected
.cmd
.Init(1, &data
[0][0]);
3082 gl_
->DrawBuffersEXT(1, &data
[0][0]);
3083 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3086 TEST_F(GLES2ImplementationTest
, DiscardBackbufferCHROMIUM
) {
3088 cmds::DiscardBackbufferCHROMIUM cmd
;
3091 expected
.cmd
.Init();
3093 gl_
->DiscardBackbufferCHROMIUM();
3094 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3097 TEST_F(GLES2ImplementationTest
, FlushDriverCachesCHROMIUM
) {
3099 cmds::FlushDriverCachesCHROMIUM cmd
;
3102 expected
.cmd
.Init();
3104 gl_
->FlushDriverCachesCHROMIUM();
3105 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3108 TEST_F(GLES2ImplementationTest
, MatrixLoadfCHROMIUM
) {
3109 GLfloat data
[16] = {0};
3111 cmds::MatrixLoadfCHROMIUMImmediate cmd
;
3115 for (int jj
= 0; jj
< 16; ++jj
) {
3116 data
[jj
] = static_cast<GLfloat
>(jj
);
3119 expected
.cmd
.Init(GL_PATH_PROJECTION_CHROMIUM
, &data
[0]);
3120 gl_
->MatrixLoadfCHROMIUM(GL_PATH_PROJECTION_CHROMIUM
, &data
[0]);
3121 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3124 TEST_F(GLES2ImplementationTest
, MatrixLoadIdentityCHROMIUM
) {
3126 cmds::MatrixLoadIdentityCHROMIUM cmd
;
3129 expected
.cmd
.Init(GL_PATH_PROJECTION_CHROMIUM
);
3131 gl_
->MatrixLoadIdentityCHROMIUM(GL_PATH_PROJECTION_CHROMIUM
);
3132 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3134 // TODO(zmo): Implement unit test for GenPathsCHROMIUM
3136 TEST_F(GLES2ImplementationTest
, DeletePathsCHROMIUM
) {
3138 cmds::DeletePathsCHROMIUM cmd
;
3141 expected
.cmd
.Init(1, 2);
3143 gl_
->DeletePathsCHROMIUM(1, 2);
3144 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3147 TEST_F(GLES2ImplementationTest
, IsPathCHROMIUM
) {
3149 cmds::IsPathCHROMIUM cmd
;
3153 ExpectedMemoryInfo result1
=
3154 GetExpectedResultMemory(sizeof(cmds::IsPathCHROMIUM::Result
));
3155 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
3157 EXPECT_CALL(*command_buffer(), OnFlush())
3158 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
3159 .RetiresOnSaturation();
3161 GLboolean result
= gl_
->IsPathCHROMIUM(1);
3162 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3163 EXPECT_TRUE(result
);
3165 // TODO(zmo): Implement unit test for PathCommandsCHROMIUM
3167 TEST_F(GLES2ImplementationTest
, PathParameterfCHROMIUM
) {
3169 cmds::PathParameterfCHROMIUM cmd
;
3172 expected
.cmd
.Init(1, GL_PATH_STROKE_WIDTH_CHROMIUM
, 3);
3174 gl_
->PathParameterfCHROMIUM(1, GL_PATH_STROKE_WIDTH_CHROMIUM
, 3);
3175 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3178 TEST_F(GLES2ImplementationTest
, PathParameteriCHROMIUM
) {
3180 cmds::PathParameteriCHROMIUM cmd
;
3183 expected
.cmd
.Init(1, GL_PATH_STROKE_WIDTH_CHROMIUM
, 3);
3185 gl_
->PathParameteriCHROMIUM(1, GL_PATH_STROKE_WIDTH_CHROMIUM
, 3);
3186 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3189 TEST_F(GLES2ImplementationTest
, PathStencilFuncCHROMIUM
) {
3191 cmds::PathStencilFuncCHROMIUM cmd
;
3194 expected
.cmd
.Init(GL_NEVER
, 2, 3);
3196 gl_
->PathStencilFuncCHROMIUM(GL_NEVER
, 2, 3);
3197 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3200 TEST_F(GLES2ImplementationTest
, StencilFillPathCHROMIUM
) {
3202 cmds::StencilFillPathCHROMIUM cmd
;
3205 expected
.cmd
.Init(1, GL_INVERT
, 3);
3207 gl_
->StencilFillPathCHROMIUM(1, GL_INVERT
, 3);
3208 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3211 TEST_F(GLES2ImplementationTest
, StencilStrokePathCHROMIUM
) {
3213 cmds::StencilStrokePathCHROMIUM cmd
;
3216 expected
.cmd
.Init(1, 2, 3);
3218 gl_
->StencilStrokePathCHROMIUM(1, 2, 3);
3219 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3222 TEST_F(GLES2ImplementationTest
, CoverFillPathCHROMIUM
) {
3224 cmds::CoverFillPathCHROMIUM cmd
;
3227 expected
.cmd
.Init(1, GL_CONVEX_HULL_CHROMIUM
);
3229 gl_
->CoverFillPathCHROMIUM(1, GL_CONVEX_HULL_CHROMIUM
);
3230 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3233 TEST_F(GLES2ImplementationTest
, CoverStrokePathCHROMIUM
) {
3235 cmds::CoverStrokePathCHROMIUM cmd
;
3238 expected
.cmd
.Init(1, GL_CONVEX_HULL_CHROMIUM
);
3240 gl_
->CoverStrokePathCHROMIUM(1, GL_CONVEX_HULL_CHROMIUM
);
3241 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3244 TEST_F(GLES2ImplementationTest
, StencilThenCoverFillPathCHROMIUM
) {
3246 cmds::StencilThenCoverFillPathCHROMIUM cmd
;
3249 expected
.cmd
.Init(1, GL_INVERT
, 3, GL_CONVEX_HULL_CHROMIUM
);
3251 gl_
->StencilThenCoverFillPathCHROMIUM(1, GL_INVERT
, 3,
3252 GL_CONVEX_HULL_CHROMIUM
);
3253 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3256 TEST_F(GLES2ImplementationTest
, StencilThenCoverStrokePathCHROMIUM
) {
3258 cmds::StencilThenCoverStrokePathCHROMIUM cmd
;
3261 expected
.cmd
.Init(1, 2, 3, GL_CONVEX_HULL_CHROMIUM
);
3263 gl_
->StencilThenCoverStrokePathCHROMIUM(1, 2, 3, GL_CONVEX_HULL_CHROMIUM
);
3264 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3266 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_