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
, GetBufferParameteri64v
) {
784 cmds::GetBufferParameteri64v cmd
;
786 typedef cmds::GetBufferParameteri64v::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_
->GetBufferParameteri64v(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
, GetBufferParameteriv
) {
802 cmds::GetBufferParameteriv cmd
;
804 typedef cmds::GetBufferParameteriv::Result::Type ResultType
;
805 ResultType result
= 0;
807 ExpectedMemoryInfo result1
=
808 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
809 expected
.cmd
.Init(123, GL_BUFFER_SIZE
, result1
.id
, result1
.offset
);
810 EXPECT_CALL(*command_buffer(), OnFlush())
811 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
812 .RetiresOnSaturation();
813 gl_
->GetBufferParameteriv(123, GL_BUFFER_SIZE
, &result
);
814 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
815 EXPECT_EQ(static_cast<ResultType
>(1), result
);
818 TEST_F(GLES2ImplementationTest
, GetFloatv
) {
822 typedef cmds::GetFloatv::Result::Type ResultType
;
823 ResultType result
= 0;
825 ExpectedMemoryInfo result1
=
826 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
827 expected
.cmd
.Init(123, result1
.id
, result1
.offset
);
828 EXPECT_CALL(*command_buffer(), OnFlush())
829 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
830 .RetiresOnSaturation();
831 gl_
->GetFloatv(123, &result
);
832 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
833 EXPECT_EQ(static_cast<ResultType
>(1), result
);
835 // TODO(zmo): Implement unit test for GetFragDataLocation
837 TEST_F(GLES2ImplementationTest
, GetFramebufferAttachmentParameteriv
) {
839 cmds::GetFramebufferAttachmentParameteriv cmd
;
841 typedef cmds::GetFramebufferAttachmentParameteriv::Result::Type ResultType
;
842 ResultType result
= 0;
844 ExpectedMemoryInfo result1
=
845 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
846 expected
.cmd
.Init(123, GL_COLOR_ATTACHMENT0
,
847 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
, result1
.id
,
849 EXPECT_CALL(*command_buffer(), OnFlush())
850 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
851 .RetiresOnSaturation();
852 gl_
->GetFramebufferAttachmentParameteriv(
853 123, GL_COLOR_ATTACHMENT0
, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
,
855 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
856 EXPECT_EQ(static_cast<ResultType
>(1), result
);
859 TEST_F(GLES2ImplementationTest
, GetInteger64v
) {
861 cmds::GetInteger64v cmd
;
863 typedef cmds::GetInteger64v::Result::Type ResultType
;
864 ResultType result
= 0;
866 ExpectedMemoryInfo result1
=
867 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
868 expected
.cmd
.Init(123, result1
.id
, result1
.offset
);
869 EXPECT_CALL(*command_buffer(), OnFlush())
870 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
871 .RetiresOnSaturation();
872 gl_
->GetInteger64v(123, &result
);
873 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
874 EXPECT_EQ(static_cast<ResultType
>(1), result
);
877 TEST_F(GLES2ImplementationTest
, GetIntegeri_v
) {
879 cmds::GetIntegeri_v cmd
;
881 typedef cmds::GetIntegeri_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_
->GetIntegeri_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
, GetInteger64i_v
) {
897 cmds::GetInteger64i_v cmd
;
899 typedef cmds::GetInteger64i_v::Result::Type ResultType
;
900 ResultType result
= 0;
902 ExpectedMemoryInfo result1
=
903 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
904 expected
.cmd
.Init(123, 2, result1
.id
, result1
.offset
);
905 EXPECT_CALL(*command_buffer(), OnFlush())
906 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
907 .RetiresOnSaturation();
908 gl_
->GetInteger64i_v(123, 2, &result
);
909 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
910 EXPECT_EQ(static_cast<ResultType
>(1), result
);
913 TEST_F(GLES2ImplementationTest
, GetIntegerv
) {
915 cmds::GetIntegerv cmd
;
917 typedef cmds::GetIntegerv::Result::Type ResultType
;
918 ResultType result
= 0;
920 ExpectedMemoryInfo result1
=
921 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
922 expected
.cmd
.Init(123, result1
.id
, result1
.offset
);
923 EXPECT_CALL(*command_buffer(), OnFlush())
924 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
925 .RetiresOnSaturation();
926 gl_
->GetIntegerv(123, &result
);
927 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
928 EXPECT_EQ(static_cast<ResultType
>(1), result
);
930 // TODO(zmo): Implement unit test for GetInternalformativ
932 TEST_F(GLES2ImplementationTest
, GetProgramiv
) {
934 cmds::GetProgramiv cmd
;
936 typedef cmds::GetProgramiv::Result::Type ResultType
;
937 ResultType result
= 0;
939 ExpectedMemoryInfo result1
=
940 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
941 expected
.cmd
.Init(123, GL_DELETE_STATUS
, result1
.id
, result1
.offset
);
942 EXPECT_CALL(*command_buffer(), OnFlush())
943 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
944 .RetiresOnSaturation();
945 gl_
->GetProgramiv(123, GL_DELETE_STATUS
, &result
);
946 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
947 EXPECT_EQ(static_cast<ResultType
>(1), result
);
949 // TODO(zmo): Implement unit test for GetProgramInfoLog
951 TEST_F(GLES2ImplementationTest
, GetRenderbufferParameteriv
) {
953 cmds::GetRenderbufferParameteriv cmd
;
955 typedef cmds::GetRenderbufferParameteriv::Result::Type ResultType
;
956 ResultType result
= 0;
958 ExpectedMemoryInfo result1
=
959 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
960 expected
.cmd
.Init(123, GL_RENDERBUFFER_RED_SIZE
, result1
.id
, result1
.offset
);
961 EXPECT_CALL(*command_buffer(), OnFlush())
962 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
963 .RetiresOnSaturation();
964 gl_
->GetRenderbufferParameteriv(123, GL_RENDERBUFFER_RED_SIZE
, &result
);
965 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
966 EXPECT_EQ(static_cast<ResultType
>(1), result
);
969 TEST_F(GLES2ImplementationTest
, GetSamplerParameterfv
) {
971 cmds::GetSamplerParameterfv cmd
;
973 typedef cmds::GetSamplerParameterfv::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_
->GetSamplerParameterfv(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
, GetSamplerParameteriv
) {
989 cmds::GetSamplerParameteriv cmd
;
991 typedef cmds::GetSamplerParameteriv::Result::Type ResultType
;
992 ResultType result
= 0;
994 ExpectedMemoryInfo result1
=
995 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
996 expected
.cmd
.Init(123, GL_TEXTURE_MAG_FILTER
, result1
.id
, result1
.offset
);
997 EXPECT_CALL(*command_buffer(), OnFlush())
998 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
999 .RetiresOnSaturation();
1000 gl_
->GetSamplerParameteriv(123, GL_TEXTURE_MAG_FILTER
, &result
);
1001 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1002 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1005 TEST_F(GLES2ImplementationTest
, GetShaderiv
) {
1007 cmds::GetShaderiv cmd
;
1009 typedef cmds::GetShaderiv::Result::Type ResultType
;
1010 ResultType result
= 0;
1012 ExpectedMemoryInfo result1
=
1013 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
1014 expected
.cmd
.Init(123, GL_SHADER_TYPE
, result1
.id
, result1
.offset
);
1015 EXPECT_CALL(*command_buffer(), OnFlush())
1016 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
1017 .RetiresOnSaturation();
1018 gl_
->GetShaderiv(123, GL_SHADER_TYPE
, &result
);
1019 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1020 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1022 // TODO(zmo): Implement unit test for GetShaderInfoLog
1023 // TODO(zmo): Implement unit test for GetShaderPrecisionFormat
1025 TEST_F(GLES2ImplementationTest
, GetSynciv
) {
1027 cmds::GetSynciv cmd
;
1029 typedef cmds::GetSynciv::Result::Type ResultType
;
1030 ResultType result
= 0;
1032 ExpectedMemoryInfo result1
=
1033 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
1034 expected
.cmd
.Init(123, GL_SYNC_STATUS
, result1
.id
, result1
.offset
);
1035 EXPECT_CALL(*command_buffer(), OnFlush())
1036 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
1037 .RetiresOnSaturation();
1038 gl_
->GetSynciv(reinterpret_cast<GLsync
>(123), GL_SYNC_STATUS
, 3, nullptr,
1040 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1041 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1044 TEST_F(GLES2ImplementationTest
, GetTexParameterfv
) {
1046 cmds::GetTexParameterfv cmd
;
1048 typedef cmds::GetTexParameterfv::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_
->GetTexParameterfv(123, GL_TEXTURE_MAG_FILTER
, &result
);
1058 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1059 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1062 TEST_F(GLES2ImplementationTest
, GetTexParameteriv
) {
1064 cmds::GetTexParameteriv cmd
;
1066 typedef cmds::GetTexParameteriv::Result::Type ResultType
;
1067 ResultType result
= 0;
1069 ExpectedMemoryInfo result1
=
1070 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
1071 expected
.cmd
.Init(123, GL_TEXTURE_MAG_FILTER
, result1
.id
, result1
.offset
);
1072 EXPECT_CALL(*command_buffer(), OnFlush())
1073 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
1074 .RetiresOnSaturation();
1075 gl_
->GetTexParameteriv(123, GL_TEXTURE_MAG_FILTER
, &result
);
1076 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1077 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1079 // TODO(zmo): Implement unit test for GetTransformFeedbackVarying
1080 // TODO(zmo): Implement unit test for GetUniformBlockIndex
1081 // TODO(zmo): Implement unit test for GetUniformfv
1082 // TODO(zmo): Implement unit test for GetUniformiv
1083 // TODO(zmo): Implement unit test for GetUniformuiv
1084 // TODO(zmo): Implement unit test for GetUniformIndices
1085 // TODO(zmo): Implement unit test for GetUniformLocation
1087 TEST_F(GLES2ImplementationTest
, GetVertexAttribfv
) {
1089 cmds::GetVertexAttribfv cmd
;
1091 typedef cmds::GetVertexAttribfv::Result::Type ResultType
;
1092 ResultType result
= 0;
1094 ExpectedMemoryInfo result1
=
1095 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
1096 expected
.cmd
.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, result1
.id
,
1098 EXPECT_CALL(*command_buffer(), OnFlush())
1099 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
1100 .RetiresOnSaturation();
1101 gl_
->GetVertexAttribfv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, &result
);
1102 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1103 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1106 TEST_F(GLES2ImplementationTest
, GetVertexAttribiv
) {
1108 cmds::GetVertexAttribiv cmd
;
1110 typedef cmds::GetVertexAttribiv::Result::Type ResultType
;
1111 ResultType result
= 0;
1113 ExpectedMemoryInfo result1
=
1114 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
1115 expected
.cmd
.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, result1
.id
,
1117 EXPECT_CALL(*command_buffer(), OnFlush())
1118 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
1119 .RetiresOnSaturation();
1120 gl_
->GetVertexAttribiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, &result
);
1121 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1122 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1125 TEST_F(GLES2ImplementationTest
, GetVertexAttribIiv
) {
1127 cmds::GetVertexAttribIiv cmd
;
1129 typedef cmds::GetVertexAttribIiv::Result::Type ResultType
;
1130 ResultType result
= 0;
1132 ExpectedMemoryInfo result1
=
1133 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
1134 expected
.cmd
.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, result1
.id
,
1136 EXPECT_CALL(*command_buffer(), OnFlush())
1137 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
1138 .RetiresOnSaturation();
1139 gl_
->GetVertexAttribIiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, &result
);
1140 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1141 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1144 TEST_F(GLES2ImplementationTest
, GetVertexAttribIuiv
) {
1146 cmds::GetVertexAttribIuiv cmd
;
1148 typedef cmds::GetVertexAttribIuiv::Result::Type ResultType
;
1149 ResultType result
= 0;
1151 ExpectedMemoryInfo result1
=
1152 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType
));
1153 expected
.cmd
.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, result1
.id
,
1155 EXPECT_CALL(*command_buffer(), OnFlush())
1156 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<ResultType
>(1)))
1157 .RetiresOnSaturation();
1158 gl_
->GetVertexAttribIuiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, &result
);
1159 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1160 EXPECT_EQ(static_cast<ResultType
>(1), result
);
1163 TEST_F(GLES2ImplementationTest
, Hint
) {
1168 expected
.cmd
.Init(GL_GENERATE_MIPMAP_HINT
, GL_FASTEST
);
1170 gl_
->Hint(GL_GENERATE_MIPMAP_HINT
, GL_FASTEST
);
1171 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1174 TEST_F(GLES2ImplementationTest
, InvalidateFramebuffer
) {
1175 GLenum data
[2][1] = {{0}};
1177 cmds::InvalidateFramebufferImmediate 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]);
1188 gl_
->InvalidateFramebuffer(GL_FRAMEBUFFER
, 2, &data
[0][0]);
1189 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1192 TEST_F(GLES2ImplementationTest
, InvalidateSubFramebuffer
) {
1193 GLenum data
[2][1] = {{0}};
1195 cmds::InvalidateSubFramebufferImmediate cmd
;
1200 for (int ii
= 0; ii
< 2; ++ii
) {
1201 for (int jj
= 0; jj
< 1; ++jj
) {
1202 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
1205 expected
.cmd
.Init(GL_FRAMEBUFFER
, 2, &data
[0][0], 4, 5, 6, 7);
1206 gl_
->InvalidateSubFramebuffer(GL_FRAMEBUFFER
, 2, &data
[0][0], 4, 5, 6, 7);
1207 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1210 TEST_F(GLES2ImplementationTest
, IsBuffer
) {
1216 ExpectedMemoryInfo result1
=
1217 GetExpectedResultMemory(sizeof(cmds::IsBuffer::Result
));
1218 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1220 EXPECT_CALL(*command_buffer(), OnFlush())
1221 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1222 .RetiresOnSaturation();
1224 GLboolean result
= gl_
->IsBuffer(1);
1225 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1226 EXPECT_TRUE(result
);
1229 TEST_F(GLES2ImplementationTest
, IsFramebuffer
) {
1231 cmds::IsFramebuffer cmd
;
1235 ExpectedMemoryInfo result1
=
1236 GetExpectedResultMemory(sizeof(cmds::IsFramebuffer::Result
));
1237 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1239 EXPECT_CALL(*command_buffer(), OnFlush())
1240 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1241 .RetiresOnSaturation();
1243 GLboolean result
= gl_
->IsFramebuffer(1);
1244 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1245 EXPECT_TRUE(result
);
1248 TEST_F(GLES2ImplementationTest
, IsProgram
) {
1250 cmds::IsProgram cmd
;
1254 ExpectedMemoryInfo result1
=
1255 GetExpectedResultMemory(sizeof(cmds::IsProgram::Result
));
1256 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1258 EXPECT_CALL(*command_buffer(), OnFlush())
1259 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1260 .RetiresOnSaturation();
1262 GLboolean result
= gl_
->IsProgram(1);
1263 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1264 EXPECT_TRUE(result
);
1267 TEST_F(GLES2ImplementationTest
, IsRenderbuffer
) {
1269 cmds::IsRenderbuffer cmd
;
1273 ExpectedMemoryInfo result1
=
1274 GetExpectedResultMemory(sizeof(cmds::IsRenderbuffer::Result
));
1275 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1277 EXPECT_CALL(*command_buffer(), OnFlush())
1278 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1279 .RetiresOnSaturation();
1281 GLboolean result
= gl_
->IsRenderbuffer(1);
1282 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1283 EXPECT_TRUE(result
);
1286 TEST_F(GLES2ImplementationTest
, IsSampler
) {
1288 cmds::IsSampler cmd
;
1292 ExpectedMemoryInfo result1
=
1293 GetExpectedResultMemory(sizeof(cmds::IsSampler::Result
));
1294 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1296 EXPECT_CALL(*command_buffer(), OnFlush())
1297 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1298 .RetiresOnSaturation();
1300 GLboolean result
= gl_
->IsSampler(1);
1301 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1302 EXPECT_TRUE(result
);
1305 TEST_F(GLES2ImplementationTest
, IsShader
) {
1311 ExpectedMemoryInfo result1
=
1312 GetExpectedResultMemory(sizeof(cmds::IsShader::Result
));
1313 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1315 EXPECT_CALL(*command_buffer(), OnFlush())
1316 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1317 .RetiresOnSaturation();
1319 GLboolean result
= gl_
->IsShader(1);
1320 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1321 EXPECT_TRUE(result
);
1324 TEST_F(GLES2ImplementationTest
, IsSync
) {
1330 ExpectedMemoryInfo result1
=
1331 GetExpectedResultMemory(sizeof(cmds::IsSync::Result
));
1332 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1334 EXPECT_CALL(*command_buffer(), OnFlush())
1335 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1336 .RetiresOnSaturation();
1338 GLboolean result
= gl_
->IsSync(reinterpret_cast<GLsync
>(1));
1339 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1340 EXPECT_TRUE(result
);
1343 TEST_F(GLES2ImplementationTest
, IsTexture
) {
1345 cmds::IsTexture cmd
;
1349 ExpectedMemoryInfo result1
=
1350 GetExpectedResultMemory(sizeof(cmds::IsTexture::Result
));
1351 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1353 EXPECT_CALL(*command_buffer(), OnFlush())
1354 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1355 .RetiresOnSaturation();
1357 GLboolean result
= gl_
->IsTexture(1);
1358 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1359 EXPECT_TRUE(result
);
1362 TEST_F(GLES2ImplementationTest
, IsTransformFeedback
) {
1364 cmds::IsTransformFeedback cmd
;
1368 ExpectedMemoryInfo result1
=
1369 GetExpectedResultMemory(sizeof(cmds::IsTransformFeedback::Result
));
1370 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1372 EXPECT_CALL(*command_buffer(), OnFlush())
1373 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
1374 .RetiresOnSaturation();
1376 GLboolean result
= gl_
->IsTransformFeedback(1);
1377 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1378 EXPECT_TRUE(result
);
1381 TEST_F(GLES2ImplementationTest
, LineWidth
) {
1383 cmds::LineWidth cmd
;
1386 expected
.cmd
.Init(0.5f
);
1388 gl_
->LineWidth(0.5f
);
1389 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1392 TEST_F(GLES2ImplementationTest
, LinkProgram
) {
1394 cmds::LinkProgram cmd
;
1397 expected
.cmd
.Init(1);
1399 gl_
->LinkProgram(1);
1400 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1403 TEST_F(GLES2ImplementationTest
, PauseTransformFeedback
) {
1405 cmds::PauseTransformFeedback cmd
;
1408 expected
.cmd
.Init();
1410 gl_
->PauseTransformFeedback();
1411 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1414 TEST_F(GLES2ImplementationTest
, PixelStorei
) {
1416 cmds::PixelStorei cmd
;
1419 expected
.cmd
.Init(GL_PACK_ALIGNMENT
, 1);
1421 gl_
->PixelStorei(GL_PACK_ALIGNMENT
, 1);
1422 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1425 TEST_F(GLES2ImplementationTest
, PolygonOffset
) {
1427 cmds::PolygonOffset cmd
;
1430 expected
.cmd
.Init(1, 2);
1432 gl_
->PolygonOffset(1, 2);
1433 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1436 TEST_F(GLES2ImplementationTest
, ReadBuffer
) {
1438 cmds::ReadBuffer cmd
;
1441 expected
.cmd
.Init(GL_NONE
);
1443 gl_
->ReadBuffer(GL_NONE
);
1444 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1447 TEST_F(GLES2ImplementationTest
, ReleaseShaderCompiler
) {
1449 cmds::ReleaseShaderCompiler cmd
;
1452 expected
.cmd
.Init();
1454 gl_
->ReleaseShaderCompiler();
1455 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1458 TEST_F(GLES2ImplementationTest
, RenderbufferStorage
) {
1460 cmds::RenderbufferStorage cmd
;
1463 expected
.cmd
.Init(GL_RENDERBUFFER
, GL_RGBA4
, 3, 4);
1465 gl_
->RenderbufferStorage(GL_RENDERBUFFER
, GL_RGBA4
, 3, 4);
1466 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1469 TEST_F(GLES2ImplementationTest
, ResumeTransformFeedback
) {
1471 cmds::ResumeTransformFeedback cmd
;
1474 expected
.cmd
.Init();
1476 gl_
->ResumeTransformFeedback();
1477 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1480 TEST_F(GLES2ImplementationTest
, SampleCoverage
) {
1482 cmds::SampleCoverage cmd
;
1485 expected
.cmd
.Init(1, true);
1487 gl_
->SampleCoverage(1, true);
1488 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1491 TEST_F(GLES2ImplementationTest
, SamplerParameterf
) {
1493 cmds::SamplerParameterf cmd
;
1496 expected
.cmd
.Init(1, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1498 gl_
->SamplerParameterf(1, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1499 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1502 TEST_F(GLES2ImplementationTest
, SamplerParameterfv
) {
1503 GLfloat data
[1] = {0};
1505 cmds::SamplerParameterfvImmediate cmd
;
1509 for (int jj
= 0; jj
< 1; ++jj
) {
1510 data
[jj
] = static_cast<GLfloat
>(jj
);
1513 expected
.cmd
.Init(1, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1514 gl_
->SamplerParameterfv(1, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1515 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1518 TEST_F(GLES2ImplementationTest
, SamplerParameteri
) {
1520 cmds::SamplerParameteri cmd
;
1523 expected
.cmd
.Init(1, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1525 gl_
->SamplerParameteri(1, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1526 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1529 TEST_F(GLES2ImplementationTest
, SamplerParameteriv
) {
1530 GLint data
[1] = {0};
1532 cmds::SamplerParameterivImmediate cmd
;
1536 for (int jj
= 0; jj
< 1; ++jj
) {
1537 data
[jj
] = static_cast<GLint
>(jj
);
1540 expected
.cmd
.Init(1, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1541 gl_
->SamplerParameteriv(1, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1542 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1545 TEST_F(GLES2ImplementationTest
, Scissor
) {
1550 expected
.cmd
.Init(1, 2, 3, 4);
1552 gl_
->Scissor(1, 2, 3, 4);
1553 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1556 TEST_F(GLES2ImplementationTest
, ShaderSource
) {
1557 const uint32 kBucketId
= GLES2Implementation::kResultBucketId
;
1558 const char* kString1
= "happy";
1559 const char* kString2
= "ending";
1560 const size_t kString1Size
= ::strlen(kString1
) + 1;
1561 const size_t kString2Size
= ::strlen(kString2
) + 1;
1562 const size_t kHeaderSize
= sizeof(GLint
) * 3;
1563 const size_t kSourceSize
= kHeaderSize
+ kString1Size
+ kString2Size
;
1564 const size_t kPaddedHeaderSize
=
1565 transfer_buffer_
->RoundToAlignment(kHeaderSize
);
1566 const size_t kPaddedString1Size
=
1567 transfer_buffer_
->RoundToAlignment(kString1Size
);
1568 const size_t kPaddedString2Size
=
1569 transfer_buffer_
->RoundToAlignment(kString2Size
);
1571 cmd::SetBucketSize set_bucket_size
;
1572 cmd::SetBucketData set_bucket_header
;
1573 cmd::SetToken set_token1
;
1574 cmd::SetBucketData set_bucket_data1
;
1575 cmd::SetToken set_token2
;
1576 cmd::SetBucketData set_bucket_data2
;
1577 cmd::SetToken set_token3
;
1578 cmds::ShaderSourceBucket cmd_bucket
;
1579 cmd::SetBucketSize clear_bucket_size
;
1582 ExpectedMemoryInfo mem0
= GetExpectedMemory(kPaddedHeaderSize
);
1583 ExpectedMemoryInfo mem1
= GetExpectedMemory(kPaddedString1Size
);
1584 ExpectedMemoryInfo mem2
= GetExpectedMemory(kPaddedString2Size
);
1587 expected
.set_bucket_size
.Init(kBucketId
, kSourceSize
);
1588 expected
.set_bucket_header
.Init(kBucketId
, 0, kHeaderSize
, mem0
.id
,
1590 expected
.set_token1
.Init(GetNextToken());
1591 expected
.set_bucket_data1
.Init(kBucketId
, kHeaderSize
, kString1Size
, mem1
.id
,
1593 expected
.set_token2
.Init(GetNextToken());
1594 expected
.set_bucket_data2
.Init(kBucketId
, kHeaderSize
+ kString1Size
,
1595 kString2Size
, mem2
.id
, mem2
.offset
);
1596 expected
.set_token3
.Init(GetNextToken());
1597 expected
.cmd_bucket
.Init(1, kBucketId
);
1598 expected
.clear_bucket_size
.Init(kBucketId
, 0);
1599 const char* kStrings
[] = {kString1
, kString2
};
1600 gl_
->ShaderSource(1, 2, kStrings
, NULL
);
1601 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1604 TEST_F(GLES2ImplementationTest
, ShaderSourceWithLength
) {
1605 const uint32 kBucketId
= GLES2Implementation::kResultBucketId
;
1606 const char* kString
= "foobar******";
1607 const size_t kStringSize
= 6; // We only need "foobar".
1608 const size_t kHeaderSize
= sizeof(GLint
) * 2;
1609 const size_t kSourceSize
= kHeaderSize
+ kStringSize
+ 1;
1610 const size_t kPaddedHeaderSize
=
1611 transfer_buffer_
->RoundToAlignment(kHeaderSize
);
1612 const size_t kPaddedStringSize
=
1613 transfer_buffer_
->RoundToAlignment(kStringSize
+ 1);
1615 cmd::SetBucketSize set_bucket_size
;
1616 cmd::SetBucketData set_bucket_header
;
1617 cmd::SetToken set_token1
;
1618 cmd::SetBucketData set_bucket_data
;
1619 cmd::SetToken set_token2
;
1620 cmds::ShaderSourceBucket shader_source_bucket
;
1621 cmd::SetBucketSize clear_bucket_size
;
1624 ExpectedMemoryInfo mem0
= GetExpectedMemory(kPaddedHeaderSize
);
1625 ExpectedMemoryInfo mem1
= GetExpectedMemory(kPaddedStringSize
);
1628 expected
.set_bucket_size
.Init(kBucketId
, kSourceSize
);
1629 expected
.set_bucket_header
.Init(kBucketId
, 0, kHeaderSize
, mem0
.id
,
1631 expected
.set_token1
.Init(GetNextToken());
1632 expected
.set_bucket_data
.Init(kBucketId
, kHeaderSize
, kStringSize
+ 1,
1633 mem1
.id
, mem1
.offset
);
1634 expected
.set_token2
.Init(GetNextToken());
1635 expected
.shader_source_bucket
.Init(1, kBucketId
);
1636 expected
.clear_bucket_size
.Init(kBucketId
, 0);
1637 const char* kStrings
[] = {kString
};
1638 const GLint kLength
[] = {kStringSize
};
1639 gl_
->ShaderSource(1, 1, kStrings
, kLength
);
1640 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1643 TEST_F(GLES2ImplementationTest
, StencilFunc
) {
1645 cmds::StencilFunc cmd
;
1648 expected
.cmd
.Init(GL_NEVER
, 2, 3);
1650 gl_
->StencilFunc(GL_NEVER
, 2, 3);
1651 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1654 TEST_F(GLES2ImplementationTest
, StencilFuncSeparate
) {
1656 cmds::StencilFuncSeparate cmd
;
1659 expected
.cmd
.Init(GL_FRONT
, GL_NEVER
, 3, 4);
1661 gl_
->StencilFuncSeparate(GL_FRONT
, GL_NEVER
, 3, 4);
1662 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1665 TEST_F(GLES2ImplementationTest
, StencilMask
) {
1667 cmds::StencilMask cmd
;
1670 expected
.cmd
.Init(1);
1672 gl_
->StencilMask(1);
1673 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1676 TEST_F(GLES2ImplementationTest
, StencilMaskSeparate
) {
1678 cmds::StencilMaskSeparate cmd
;
1681 expected
.cmd
.Init(GL_FRONT
, 2);
1683 gl_
->StencilMaskSeparate(GL_FRONT
, 2);
1684 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1687 TEST_F(GLES2ImplementationTest
, StencilOp
) {
1689 cmds::StencilOp cmd
;
1692 expected
.cmd
.Init(GL_KEEP
, GL_INCR
, GL_KEEP
);
1694 gl_
->StencilOp(GL_KEEP
, GL_INCR
, GL_KEEP
);
1695 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1698 TEST_F(GLES2ImplementationTest
, StencilOpSeparate
) {
1700 cmds::StencilOpSeparate cmd
;
1703 expected
.cmd
.Init(GL_FRONT
, GL_INCR
, GL_KEEP
, GL_KEEP
);
1705 gl_
->StencilOpSeparate(GL_FRONT
, GL_INCR
, GL_KEEP
, GL_KEEP
);
1706 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1709 TEST_F(GLES2ImplementationTest
, TexParameterf
) {
1711 cmds::TexParameterf cmd
;
1714 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1716 gl_
->TexParameterf(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1717 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1720 TEST_F(GLES2ImplementationTest
, TexParameterfv
) {
1721 GLfloat data
[1] = {0};
1723 cmds::TexParameterfvImmediate cmd
;
1727 for (int jj
= 0; jj
< 1; ++jj
) {
1728 data
[jj
] = static_cast<GLfloat
>(jj
);
1731 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1732 gl_
->TexParameterfv(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1733 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1736 TEST_F(GLES2ImplementationTest
, TexParameteri
) {
1738 cmds::TexParameteri cmd
;
1741 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1743 gl_
->TexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1744 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1747 TEST_F(GLES2ImplementationTest
, TexParameteriv
) {
1748 GLint data
[1] = {0};
1750 cmds::TexParameterivImmediate cmd
;
1754 for (int jj
= 0; jj
< 1; ++jj
) {
1755 data
[jj
] = static_cast<GLint
>(jj
);
1758 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1759 gl_
->TexParameteriv(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1760 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1763 TEST_F(GLES2ImplementationTest
, TexStorage3D
) {
1765 cmds::TexStorage3D cmd
;
1768 expected
.cmd
.Init(GL_TEXTURE_3D
, 2, GL_RGB565
, 4, 5, 6);
1770 gl_
->TexStorage3D(GL_TEXTURE_3D
, 2, GL_RGB565
, 4, 5, 6);
1771 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1774 TEST_F(GLES2ImplementationTest
, TransformFeedbackVaryings
) {
1775 const uint32 kBucketId
= GLES2Implementation::kResultBucketId
;
1776 const char* kString1
= "happy";
1777 const char* kString2
= "ending";
1778 const size_t kString1Size
= ::strlen(kString1
) + 1;
1779 const size_t kString2Size
= ::strlen(kString2
) + 1;
1780 const size_t kHeaderSize
= sizeof(GLint
) * 3;
1781 const size_t kSourceSize
= kHeaderSize
+ kString1Size
+ kString2Size
;
1782 const size_t kPaddedHeaderSize
=
1783 transfer_buffer_
->RoundToAlignment(kHeaderSize
);
1784 const size_t kPaddedString1Size
=
1785 transfer_buffer_
->RoundToAlignment(kString1Size
);
1786 const size_t kPaddedString2Size
=
1787 transfer_buffer_
->RoundToAlignment(kString2Size
);
1789 cmd::SetBucketSize set_bucket_size
;
1790 cmd::SetBucketData set_bucket_header
;
1791 cmd::SetToken set_token1
;
1792 cmd::SetBucketData set_bucket_data1
;
1793 cmd::SetToken set_token2
;
1794 cmd::SetBucketData set_bucket_data2
;
1795 cmd::SetToken set_token3
;
1796 cmds::TransformFeedbackVaryingsBucket cmd_bucket
;
1797 cmd::SetBucketSize clear_bucket_size
;
1800 ExpectedMemoryInfo mem0
= GetExpectedMemory(kPaddedHeaderSize
);
1801 ExpectedMemoryInfo mem1
= GetExpectedMemory(kPaddedString1Size
);
1802 ExpectedMemoryInfo mem2
= GetExpectedMemory(kPaddedString2Size
);
1805 expected
.set_bucket_size
.Init(kBucketId
, kSourceSize
);
1806 expected
.set_bucket_header
.Init(kBucketId
, 0, kHeaderSize
, mem0
.id
,
1808 expected
.set_token1
.Init(GetNextToken());
1809 expected
.set_bucket_data1
.Init(kBucketId
, kHeaderSize
, kString1Size
, mem1
.id
,
1811 expected
.set_token2
.Init(GetNextToken());
1812 expected
.set_bucket_data2
.Init(kBucketId
, kHeaderSize
+ kString1Size
,
1813 kString2Size
, mem2
.id
, mem2
.offset
);
1814 expected
.set_token3
.Init(GetNextToken());
1815 expected
.cmd_bucket
.Init(1, kBucketId
, GL_INTERLEAVED_ATTRIBS
);
1816 expected
.clear_bucket_size
.Init(kBucketId
, 0);
1817 const char* kStrings
[] = {kString1
, kString2
};
1818 gl_
->TransformFeedbackVaryings(1, 2, kStrings
, GL_INTERLEAVED_ATTRIBS
);
1819 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1822 TEST_F(GLES2ImplementationTest
, Uniform1f
) {
1824 cmds::Uniform1f cmd
;
1827 expected
.cmd
.Init(1, 2);
1829 gl_
->Uniform1f(1, 2);
1830 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1833 TEST_F(GLES2ImplementationTest
, Uniform1fv
) {
1834 GLfloat data
[2][1] = {{0}};
1836 cmds::Uniform1fvImmediate cmd
;
1841 for (int ii
= 0; ii
< 2; ++ii
) {
1842 for (int jj
= 0; jj
< 1; ++jj
) {
1843 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 1 + jj
);
1846 expected
.cmd
.Init(1, 2, &data
[0][0]);
1847 gl_
->Uniform1fv(1, 2, &data
[0][0]);
1848 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1851 TEST_F(GLES2ImplementationTest
, Uniform1i
) {
1853 cmds::Uniform1i cmd
;
1856 expected
.cmd
.Init(1, 2);
1858 gl_
->Uniform1i(1, 2);
1859 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1862 TEST_F(GLES2ImplementationTest
, Uniform1iv
) {
1863 GLint data
[2][1] = {{0}};
1865 cmds::Uniform1ivImmediate cmd
;
1870 for (int ii
= 0; ii
< 2; ++ii
) {
1871 for (int jj
= 0; jj
< 1; ++jj
) {
1872 data
[ii
][jj
] = static_cast<GLint
>(ii
* 1 + jj
);
1875 expected
.cmd
.Init(1, 2, &data
[0][0]);
1876 gl_
->Uniform1iv(1, 2, &data
[0][0]);
1877 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1880 TEST_F(GLES2ImplementationTest
, Uniform1ui
) {
1882 cmds::Uniform1ui cmd
;
1885 expected
.cmd
.Init(1, 2);
1887 gl_
->Uniform1ui(1, 2);
1888 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1891 TEST_F(GLES2ImplementationTest
, Uniform1uiv
) {
1892 GLuint data
[2][1] = {{0}};
1894 cmds::Uniform1uivImmediate cmd
;
1899 for (int ii
= 0; ii
< 2; ++ii
) {
1900 for (int jj
= 0; jj
< 1; ++jj
) {
1901 data
[ii
][jj
] = static_cast<GLuint
>(ii
* 1 + jj
);
1904 expected
.cmd
.Init(1, 2, &data
[0][0]);
1905 gl_
->Uniform1uiv(1, 2, &data
[0][0]);
1906 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1909 TEST_F(GLES2ImplementationTest
, Uniform2f
) {
1911 cmds::Uniform2f cmd
;
1914 expected
.cmd
.Init(1, 2, 3);
1916 gl_
->Uniform2f(1, 2, 3);
1917 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1920 TEST_F(GLES2ImplementationTest
, Uniform2fv
) {
1921 GLfloat data
[2][2] = {{0}};
1923 cmds::Uniform2fvImmediate cmd
;
1928 for (int ii
= 0; ii
< 2; ++ii
) {
1929 for (int jj
= 0; jj
< 2; ++jj
) {
1930 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 2 + jj
);
1933 expected
.cmd
.Init(1, 2, &data
[0][0]);
1934 gl_
->Uniform2fv(1, 2, &data
[0][0]);
1935 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1938 TEST_F(GLES2ImplementationTest
, Uniform2i
) {
1940 cmds::Uniform2i cmd
;
1943 expected
.cmd
.Init(1, 2, 3);
1945 gl_
->Uniform2i(1, 2, 3);
1946 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1949 TEST_F(GLES2ImplementationTest
, Uniform2iv
) {
1950 GLint data
[2][2] = {{0}};
1952 cmds::Uniform2ivImmediate cmd
;
1957 for (int ii
= 0; ii
< 2; ++ii
) {
1958 for (int jj
= 0; jj
< 2; ++jj
) {
1959 data
[ii
][jj
] = static_cast<GLint
>(ii
* 2 + jj
);
1962 expected
.cmd
.Init(1, 2, &data
[0][0]);
1963 gl_
->Uniform2iv(1, 2, &data
[0][0]);
1964 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1967 TEST_F(GLES2ImplementationTest
, Uniform2ui
) {
1969 cmds::Uniform2ui cmd
;
1972 expected
.cmd
.Init(1, 2, 3);
1974 gl_
->Uniform2ui(1, 2, 3);
1975 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1978 TEST_F(GLES2ImplementationTest
, Uniform2uiv
) {
1979 GLuint data
[2][2] = {{0}};
1981 cmds::Uniform2uivImmediate cmd
;
1986 for (int ii
= 0; ii
< 2; ++ii
) {
1987 for (int jj
= 0; jj
< 2; ++jj
) {
1988 data
[ii
][jj
] = static_cast<GLuint
>(ii
* 2 + jj
);
1991 expected
.cmd
.Init(1, 2, &data
[0][0]);
1992 gl_
->Uniform2uiv(1, 2, &data
[0][0]);
1993 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1996 TEST_F(GLES2ImplementationTest
, Uniform3f
) {
1998 cmds::Uniform3f cmd
;
2001 expected
.cmd
.Init(1, 2, 3, 4);
2003 gl_
->Uniform3f(1, 2, 3, 4);
2004 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2007 TEST_F(GLES2ImplementationTest
, Uniform3fv
) {
2008 GLfloat data
[2][3] = {{0}};
2010 cmds::Uniform3fvImmediate cmd
;
2015 for (int ii
= 0; ii
< 2; ++ii
) {
2016 for (int jj
= 0; jj
< 3; ++jj
) {
2017 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 3 + jj
);
2020 expected
.cmd
.Init(1, 2, &data
[0][0]);
2021 gl_
->Uniform3fv(1, 2, &data
[0][0]);
2022 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2025 TEST_F(GLES2ImplementationTest
, Uniform3i
) {
2027 cmds::Uniform3i cmd
;
2030 expected
.cmd
.Init(1, 2, 3, 4);
2032 gl_
->Uniform3i(1, 2, 3, 4);
2033 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2036 TEST_F(GLES2ImplementationTest
, Uniform3iv
) {
2037 GLint data
[2][3] = {{0}};
2039 cmds::Uniform3ivImmediate cmd
;
2044 for (int ii
= 0; ii
< 2; ++ii
) {
2045 for (int jj
= 0; jj
< 3; ++jj
) {
2046 data
[ii
][jj
] = static_cast<GLint
>(ii
* 3 + jj
);
2049 expected
.cmd
.Init(1, 2, &data
[0][0]);
2050 gl_
->Uniform3iv(1, 2, &data
[0][0]);
2051 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2054 TEST_F(GLES2ImplementationTest
, Uniform3ui
) {
2056 cmds::Uniform3ui cmd
;
2059 expected
.cmd
.Init(1, 2, 3, 4);
2061 gl_
->Uniform3ui(1, 2, 3, 4);
2062 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2065 TEST_F(GLES2ImplementationTest
, Uniform3uiv
) {
2066 GLuint data
[2][3] = {{0}};
2068 cmds::Uniform3uivImmediate cmd
;
2073 for (int ii
= 0; ii
< 2; ++ii
) {
2074 for (int jj
= 0; jj
< 3; ++jj
) {
2075 data
[ii
][jj
] = static_cast<GLuint
>(ii
* 3 + jj
);
2078 expected
.cmd
.Init(1, 2, &data
[0][0]);
2079 gl_
->Uniform3uiv(1, 2, &data
[0][0]);
2080 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2083 TEST_F(GLES2ImplementationTest
, Uniform4f
) {
2085 cmds::Uniform4f cmd
;
2088 expected
.cmd
.Init(1, 2, 3, 4, 5);
2090 gl_
->Uniform4f(1, 2, 3, 4, 5);
2091 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2094 TEST_F(GLES2ImplementationTest
, Uniform4fv
) {
2095 GLfloat data
[2][4] = {{0}};
2097 cmds::Uniform4fvImmediate cmd
;
2102 for (int ii
= 0; ii
< 2; ++ii
) {
2103 for (int jj
= 0; jj
< 4; ++jj
) {
2104 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 4 + jj
);
2107 expected
.cmd
.Init(1, 2, &data
[0][0]);
2108 gl_
->Uniform4fv(1, 2, &data
[0][0]);
2109 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2112 TEST_F(GLES2ImplementationTest
, Uniform4i
) {
2114 cmds::Uniform4i cmd
;
2117 expected
.cmd
.Init(1, 2, 3, 4, 5);
2119 gl_
->Uniform4i(1, 2, 3, 4, 5);
2120 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2123 TEST_F(GLES2ImplementationTest
, Uniform4iv
) {
2124 GLint data
[2][4] = {{0}};
2126 cmds::Uniform4ivImmediate cmd
;
2131 for (int ii
= 0; ii
< 2; ++ii
) {
2132 for (int jj
= 0; jj
< 4; ++jj
) {
2133 data
[ii
][jj
] = static_cast<GLint
>(ii
* 4 + jj
);
2136 expected
.cmd
.Init(1, 2, &data
[0][0]);
2137 gl_
->Uniform4iv(1, 2, &data
[0][0]);
2138 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2141 TEST_F(GLES2ImplementationTest
, Uniform4ui
) {
2143 cmds::Uniform4ui cmd
;
2146 expected
.cmd
.Init(1, 2, 3, 4, 5);
2148 gl_
->Uniform4ui(1, 2, 3, 4, 5);
2149 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2152 TEST_F(GLES2ImplementationTest
, Uniform4uiv
) {
2153 GLuint data
[2][4] = {{0}};
2155 cmds::Uniform4uivImmediate cmd
;
2160 for (int ii
= 0; ii
< 2; ++ii
) {
2161 for (int jj
= 0; jj
< 4; ++jj
) {
2162 data
[ii
][jj
] = static_cast<GLuint
>(ii
* 4 + jj
);
2165 expected
.cmd
.Init(1, 2, &data
[0][0]);
2166 gl_
->Uniform4uiv(1, 2, &data
[0][0]);
2167 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2170 TEST_F(GLES2ImplementationTest
, UniformBlockBinding
) {
2172 cmds::UniformBlockBinding cmd
;
2175 expected
.cmd
.Init(1, 2, 3);
2177 gl_
->UniformBlockBinding(1, 2, 3);
2178 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2181 TEST_F(GLES2ImplementationTest
, UniformMatrix2fv
) {
2182 GLfloat data
[2][4] = {{0}};
2184 cmds::UniformMatrix2fvImmediate cmd
;
2189 for (int ii
= 0; ii
< 2; ++ii
) {
2190 for (int jj
= 0; jj
< 4; ++jj
) {
2191 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 4 + jj
);
2194 expected
.cmd
.Init(1, 2, &data
[0][0]);
2195 gl_
->UniformMatrix2fv(1, 2, false, &data
[0][0]);
2196 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2199 TEST_F(GLES2ImplementationTest
, UniformMatrix2fvInvalidConstantArg2
) {
2200 GLfloat data
[2][4] = {{0}};
2201 for (int ii
= 0; ii
< 2; ++ii
) {
2202 for (int jj
= 0; jj
< 4; ++jj
) {
2203 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 4 + jj
);
2206 gl_
->UniformMatrix2fv(1, 2, true, &data
[0][0]);
2207 EXPECT_TRUE(NoCommandsWritten());
2208 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2211 TEST_F(GLES2ImplementationTest
, UniformMatrix2x3fv
) {
2212 GLfloat data
[2][6] = {{0}};
2214 cmds::UniformMatrix2x3fvImmediate cmd
;
2219 for (int ii
= 0; ii
< 2; ++ii
) {
2220 for (int jj
= 0; jj
< 6; ++jj
) {
2221 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 6 + jj
);
2224 expected
.cmd
.Init(1, 2, &data
[0][0]);
2225 gl_
->UniformMatrix2x3fv(1, 2, false, &data
[0][0]);
2226 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2229 TEST_F(GLES2ImplementationTest
, UniformMatrix2x3fvInvalidConstantArg2
) {
2230 GLfloat data
[2][6] = {{0}};
2231 for (int ii
= 0; ii
< 2; ++ii
) {
2232 for (int jj
= 0; jj
< 6; ++jj
) {
2233 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 6 + jj
);
2236 gl_
->UniformMatrix2x3fv(1, 2, true, &data
[0][0]);
2237 EXPECT_TRUE(NoCommandsWritten());
2238 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2241 TEST_F(GLES2ImplementationTest
, UniformMatrix2x4fv
) {
2242 GLfloat data
[2][8] = {{0}};
2244 cmds::UniformMatrix2x4fvImmediate cmd
;
2249 for (int ii
= 0; ii
< 2; ++ii
) {
2250 for (int jj
= 0; jj
< 8; ++jj
) {
2251 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 8 + jj
);
2254 expected
.cmd
.Init(1, 2, &data
[0][0]);
2255 gl_
->UniformMatrix2x4fv(1, 2, false, &data
[0][0]);
2256 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2259 TEST_F(GLES2ImplementationTest
, UniformMatrix2x4fvInvalidConstantArg2
) {
2260 GLfloat data
[2][8] = {{0}};
2261 for (int ii
= 0; ii
< 2; ++ii
) {
2262 for (int jj
= 0; jj
< 8; ++jj
) {
2263 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 8 + jj
);
2266 gl_
->UniformMatrix2x4fv(1, 2, true, &data
[0][0]);
2267 EXPECT_TRUE(NoCommandsWritten());
2268 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2271 TEST_F(GLES2ImplementationTest
, UniformMatrix3fv
) {
2272 GLfloat data
[2][9] = {{0}};
2274 cmds::UniformMatrix3fvImmediate cmd
;
2279 for (int ii
= 0; ii
< 2; ++ii
) {
2280 for (int jj
= 0; jj
< 9; ++jj
) {
2281 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 9 + jj
);
2284 expected
.cmd
.Init(1, 2, &data
[0][0]);
2285 gl_
->UniformMatrix3fv(1, 2, false, &data
[0][0]);
2286 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2289 TEST_F(GLES2ImplementationTest
, UniformMatrix3fvInvalidConstantArg2
) {
2290 GLfloat data
[2][9] = {{0}};
2291 for (int ii
= 0; ii
< 2; ++ii
) {
2292 for (int jj
= 0; jj
< 9; ++jj
) {
2293 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 9 + jj
);
2296 gl_
->UniformMatrix3fv(1, 2, true, &data
[0][0]);
2297 EXPECT_TRUE(NoCommandsWritten());
2298 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2301 TEST_F(GLES2ImplementationTest
, UniformMatrix3x2fv
) {
2302 GLfloat data
[2][6] = {{0}};
2304 cmds::UniformMatrix3x2fvImmediate cmd
;
2309 for (int ii
= 0; ii
< 2; ++ii
) {
2310 for (int jj
= 0; jj
< 6; ++jj
) {
2311 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 6 + jj
);
2314 expected
.cmd
.Init(1, 2, &data
[0][0]);
2315 gl_
->UniformMatrix3x2fv(1, 2, false, &data
[0][0]);
2316 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2319 TEST_F(GLES2ImplementationTest
, UniformMatrix3x2fvInvalidConstantArg2
) {
2320 GLfloat data
[2][6] = {{0}};
2321 for (int ii
= 0; ii
< 2; ++ii
) {
2322 for (int jj
= 0; jj
< 6; ++jj
) {
2323 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 6 + jj
);
2326 gl_
->UniformMatrix3x2fv(1, 2, true, &data
[0][0]);
2327 EXPECT_TRUE(NoCommandsWritten());
2328 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2331 TEST_F(GLES2ImplementationTest
, UniformMatrix3x4fv
) {
2332 GLfloat data
[2][12] = {{0}};
2334 cmds::UniformMatrix3x4fvImmediate cmd
;
2335 GLfloat data
[2][12];
2339 for (int ii
= 0; ii
< 2; ++ii
) {
2340 for (int jj
= 0; jj
< 12; ++jj
) {
2341 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 12 + jj
);
2344 expected
.cmd
.Init(1, 2, &data
[0][0]);
2345 gl_
->UniformMatrix3x4fv(1, 2, false, &data
[0][0]);
2346 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2349 TEST_F(GLES2ImplementationTest
, UniformMatrix3x4fvInvalidConstantArg2
) {
2350 GLfloat data
[2][12] = {{0}};
2351 for (int ii
= 0; ii
< 2; ++ii
) {
2352 for (int jj
= 0; jj
< 12; ++jj
) {
2353 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 12 + jj
);
2356 gl_
->UniformMatrix3x4fv(1, 2, true, &data
[0][0]);
2357 EXPECT_TRUE(NoCommandsWritten());
2358 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2361 TEST_F(GLES2ImplementationTest
, UniformMatrix4fv
) {
2362 GLfloat data
[2][16] = {{0}};
2364 cmds::UniformMatrix4fvImmediate cmd
;
2365 GLfloat data
[2][16];
2369 for (int ii
= 0; ii
< 2; ++ii
) {
2370 for (int jj
= 0; jj
< 16; ++jj
) {
2371 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 16 + jj
);
2374 expected
.cmd
.Init(1, 2, &data
[0][0]);
2375 gl_
->UniformMatrix4fv(1, 2, false, &data
[0][0]);
2376 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2379 TEST_F(GLES2ImplementationTest
, UniformMatrix4fvInvalidConstantArg2
) {
2380 GLfloat data
[2][16] = {{0}};
2381 for (int ii
= 0; ii
< 2; ++ii
) {
2382 for (int jj
= 0; jj
< 16; ++jj
) {
2383 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 16 + jj
);
2386 gl_
->UniformMatrix4fv(1, 2, true, &data
[0][0]);
2387 EXPECT_TRUE(NoCommandsWritten());
2388 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2391 TEST_F(GLES2ImplementationTest
, UniformMatrix4x2fv
) {
2392 GLfloat data
[2][8] = {{0}};
2394 cmds::UniformMatrix4x2fvImmediate cmd
;
2399 for (int ii
= 0; ii
< 2; ++ii
) {
2400 for (int jj
= 0; jj
< 8; ++jj
) {
2401 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 8 + jj
);
2404 expected
.cmd
.Init(1, 2, &data
[0][0]);
2405 gl_
->UniformMatrix4x2fv(1, 2, false, &data
[0][0]);
2406 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2409 TEST_F(GLES2ImplementationTest
, UniformMatrix4x2fvInvalidConstantArg2
) {
2410 GLfloat data
[2][8] = {{0}};
2411 for (int ii
= 0; ii
< 2; ++ii
) {
2412 for (int jj
= 0; jj
< 8; ++jj
) {
2413 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 8 + jj
);
2416 gl_
->UniformMatrix4x2fv(1, 2, true, &data
[0][0]);
2417 EXPECT_TRUE(NoCommandsWritten());
2418 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2421 TEST_F(GLES2ImplementationTest
, UniformMatrix4x3fv
) {
2422 GLfloat data
[2][12] = {{0}};
2424 cmds::UniformMatrix4x3fvImmediate cmd
;
2425 GLfloat data
[2][12];
2429 for (int ii
= 0; ii
< 2; ++ii
) {
2430 for (int jj
= 0; jj
< 12; ++jj
) {
2431 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 12 + jj
);
2434 expected
.cmd
.Init(1, 2, &data
[0][0]);
2435 gl_
->UniformMatrix4x3fv(1, 2, false, &data
[0][0]);
2436 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2439 TEST_F(GLES2ImplementationTest
, UniformMatrix4x3fvInvalidConstantArg2
) {
2440 GLfloat data
[2][12] = {{0}};
2441 for (int ii
= 0; ii
< 2; ++ii
) {
2442 for (int jj
= 0; jj
< 12; ++jj
) {
2443 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 12 + jj
);
2446 gl_
->UniformMatrix4x3fv(1, 2, true, &data
[0][0]);
2447 EXPECT_TRUE(NoCommandsWritten());
2448 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2451 TEST_F(GLES2ImplementationTest
, UseProgram
) {
2453 cmds::UseProgram cmd
;
2456 expected
.cmd
.Init(1);
2459 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2462 EXPECT_TRUE(NoCommandsWritten());
2465 TEST_F(GLES2ImplementationTest
, ValidateProgram
) {
2467 cmds::ValidateProgram cmd
;
2470 expected
.cmd
.Init(1);
2472 gl_
->ValidateProgram(1);
2473 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2476 TEST_F(GLES2ImplementationTest
, VertexAttrib1f
) {
2478 cmds::VertexAttrib1f cmd
;
2481 expected
.cmd
.Init(1, 2);
2483 gl_
->VertexAttrib1f(1, 2);
2484 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2487 TEST_F(GLES2ImplementationTest
, VertexAttrib1fv
) {
2488 GLfloat data
[1] = {0};
2490 cmds::VertexAttrib1fvImmediate cmd
;
2494 for (int jj
= 0; jj
< 1; ++jj
) {
2495 data
[jj
] = static_cast<GLfloat
>(jj
);
2498 expected
.cmd
.Init(1, &data
[0]);
2499 gl_
->VertexAttrib1fv(1, &data
[0]);
2500 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2503 TEST_F(GLES2ImplementationTest
, VertexAttrib2f
) {
2505 cmds::VertexAttrib2f cmd
;
2508 expected
.cmd
.Init(1, 2, 3);
2510 gl_
->VertexAttrib2f(1, 2, 3);
2511 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2514 TEST_F(GLES2ImplementationTest
, VertexAttrib2fv
) {
2515 GLfloat data
[2] = {0};
2517 cmds::VertexAttrib2fvImmediate cmd
;
2521 for (int jj
= 0; jj
< 2; ++jj
) {
2522 data
[jj
] = static_cast<GLfloat
>(jj
);
2525 expected
.cmd
.Init(1, &data
[0]);
2526 gl_
->VertexAttrib2fv(1, &data
[0]);
2527 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2530 TEST_F(GLES2ImplementationTest
, VertexAttrib3f
) {
2532 cmds::VertexAttrib3f cmd
;
2535 expected
.cmd
.Init(1, 2, 3, 4);
2537 gl_
->VertexAttrib3f(1, 2, 3, 4);
2538 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2541 TEST_F(GLES2ImplementationTest
, VertexAttrib3fv
) {
2542 GLfloat data
[3] = {0};
2544 cmds::VertexAttrib3fvImmediate cmd
;
2548 for (int jj
= 0; jj
< 3; ++jj
) {
2549 data
[jj
] = static_cast<GLfloat
>(jj
);
2552 expected
.cmd
.Init(1, &data
[0]);
2553 gl_
->VertexAttrib3fv(1, &data
[0]);
2554 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2557 TEST_F(GLES2ImplementationTest
, VertexAttrib4f
) {
2559 cmds::VertexAttrib4f cmd
;
2562 expected
.cmd
.Init(1, 2, 3, 4, 5);
2564 gl_
->VertexAttrib4f(1, 2, 3, 4, 5);
2565 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2568 TEST_F(GLES2ImplementationTest
, VertexAttrib4fv
) {
2569 GLfloat data
[4] = {0};
2571 cmds::VertexAttrib4fvImmediate cmd
;
2575 for (int jj
= 0; jj
< 4; ++jj
) {
2576 data
[jj
] = static_cast<GLfloat
>(jj
);
2579 expected
.cmd
.Init(1, &data
[0]);
2580 gl_
->VertexAttrib4fv(1, &data
[0]);
2581 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2584 TEST_F(GLES2ImplementationTest
, VertexAttribI4i
) {
2586 cmds::VertexAttribI4i cmd
;
2589 expected
.cmd
.Init(1, 2, 3, 4, 5);
2591 gl_
->VertexAttribI4i(1, 2, 3, 4, 5);
2592 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2595 TEST_F(GLES2ImplementationTest
, VertexAttribI4iv
) {
2596 GLint data
[4] = {0};
2598 cmds::VertexAttribI4ivImmediate cmd
;
2602 for (int jj
= 0; jj
< 4; ++jj
) {
2603 data
[jj
] = static_cast<GLint
>(jj
);
2606 expected
.cmd
.Init(1, &data
[0]);
2607 gl_
->VertexAttribI4iv(1, &data
[0]);
2608 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2611 TEST_F(GLES2ImplementationTest
, VertexAttribI4ui
) {
2613 cmds::VertexAttribI4ui cmd
;
2616 expected
.cmd
.Init(1, 2, 3, 4, 5);
2618 gl_
->VertexAttribI4ui(1, 2, 3, 4, 5);
2619 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2622 TEST_F(GLES2ImplementationTest
, VertexAttribI4uiv
) {
2623 GLuint data
[4] = {0};
2625 cmds::VertexAttribI4uivImmediate cmd
;
2629 for (int jj
= 0; jj
< 4; ++jj
) {
2630 data
[jj
] = static_cast<GLuint
>(jj
);
2633 expected
.cmd
.Init(1, &data
[0]);
2634 gl_
->VertexAttribI4uiv(1, &data
[0]);
2635 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2638 TEST_F(GLES2ImplementationTest
, Viewport
) {
2643 expected
.cmd
.Init(1, 2, 3, 4);
2645 gl_
->Viewport(1, 2, 3, 4);
2646 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2649 TEST_F(GLES2ImplementationTest
, BlitFramebufferCHROMIUM
) {
2651 cmds::BlitFramebufferCHROMIUM cmd
;
2654 expected
.cmd
.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST
);
2656 gl_
->BlitFramebufferCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST
);
2657 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2660 TEST_F(GLES2ImplementationTest
, RenderbufferStorageMultisampleCHROMIUM
) {
2662 cmds::RenderbufferStorageMultisampleCHROMIUM cmd
;
2665 expected
.cmd
.Init(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
2667 gl_
->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4,
2669 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2672 TEST_F(GLES2ImplementationTest
, RenderbufferStorageMultisampleEXT
) {
2674 cmds::RenderbufferStorageMultisampleEXT cmd
;
2677 expected
.cmd
.Init(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
2679 gl_
->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
2680 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2683 TEST_F(GLES2ImplementationTest
, FramebufferTexture2DMultisampleEXT
) {
2685 cmds::FramebufferTexture2DMultisampleEXT cmd
;
2688 expected
.cmd
.Init(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 4, 6);
2690 gl_
->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
,
2691 GL_TEXTURE_2D
, 4, 0, 6);
2692 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2695 TEST_F(GLES2ImplementationTest
,
2696 FramebufferTexture2DMultisampleEXTInvalidConstantArg4
) {
2697 gl_
->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
,
2698 GL_TEXTURE_2D
, 4, 1, 6);
2699 EXPECT_TRUE(NoCommandsWritten());
2700 EXPECT_EQ(GL_INVALID_VALUE
, CheckError());
2703 TEST_F(GLES2ImplementationTest
, TexStorage2DEXT
) {
2705 cmds::TexStorage2DEXT cmd
;
2708 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, GL_RGB565
, 4, 5);
2710 gl_
->TexStorage2DEXT(GL_TEXTURE_2D
, 2, GL_RGB565
, 4, 5);
2711 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2714 TEST_F(GLES2ImplementationTest
, GenQueriesEXT
) {
2719 cmds::GenQueriesEXTImmediate gen
;
2723 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
2724 expected
.data
[0] = kQueriesStartId
;
2725 expected
.data
[1] = kQueriesStartId
+ 1;
2726 gl_
->GenQueriesEXT(arraysize(ids
), &ids
[0]);
2727 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2728 EXPECT_EQ(kQueriesStartId
, ids
[0]);
2729 EXPECT_EQ(kQueriesStartId
+ 1, ids
[1]);
2732 TEST_F(GLES2ImplementationTest
, DeleteQueriesEXT
) {
2733 GLuint ids
[2] = {kQueriesStartId
, kQueriesStartId
+ 1};
2735 cmds::DeleteQueriesEXTImmediate del
;
2739 expected
.del
.Init(arraysize(ids
), &ids
[0]);
2740 expected
.data
[0] = kQueriesStartId
;
2741 expected
.data
[1] = kQueriesStartId
+ 1;
2742 gl_
->DeleteQueriesEXT(arraysize(ids
), &ids
[0]);
2743 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2745 // TODO(zmo): Implement unit test for QueryCounterEXT
2746 // TODO(zmo): Implement unit test for BeginQueryEXT
2748 TEST_F(GLES2ImplementationTest
, BeginTransformFeedback
) {
2750 cmds::BeginTransformFeedback cmd
;
2753 expected
.cmd
.Init(GL_POINTS
);
2755 gl_
->BeginTransformFeedback(GL_POINTS
);
2756 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2759 TEST_F(GLES2ImplementationTest
, EndTransformFeedback
) {
2761 cmds::EndTransformFeedback cmd
;
2764 expected
.cmd
.Init();
2766 gl_
->EndTransformFeedback();
2767 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2769 // TODO(zmo): Implement unit test for InsertEventMarkerEXT
2770 // TODO(zmo): Implement unit test for PushGroupMarkerEXT
2772 TEST_F(GLES2ImplementationTest
, PopGroupMarkerEXT
) {
2774 cmds::PopGroupMarkerEXT cmd
;
2777 expected
.cmd
.Init();
2779 gl_
->PopGroupMarkerEXT();
2780 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2783 TEST_F(GLES2ImplementationTest
, GenVertexArraysOES
) {
2788 cmds::GenVertexArraysOESImmediate gen
;
2792 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
2793 expected
.data
[0] = kVertexArraysStartId
;
2794 expected
.data
[1] = kVertexArraysStartId
+ 1;
2795 gl_
->GenVertexArraysOES(arraysize(ids
), &ids
[0]);
2796 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2797 EXPECT_EQ(kVertexArraysStartId
, ids
[0]);
2798 EXPECT_EQ(kVertexArraysStartId
+ 1, ids
[1]);
2801 TEST_F(GLES2ImplementationTest
, DeleteVertexArraysOES
) {
2802 GLuint ids
[2] = {kVertexArraysStartId
, kVertexArraysStartId
+ 1};
2804 cmds::DeleteVertexArraysOESImmediate del
;
2808 expected
.del
.Init(arraysize(ids
), &ids
[0]);
2809 expected
.data
[0] = kVertexArraysStartId
;
2810 expected
.data
[1] = kVertexArraysStartId
+ 1;
2811 gl_
->DeleteVertexArraysOES(arraysize(ids
), &ids
[0]);
2812 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2815 TEST_F(GLES2ImplementationTest
, IsVertexArrayOES
) {
2817 cmds::IsVertexArrayOES cmd
;
2821 ExpectedMemoryInfo result1
=
2822 GetExpectedResultMemory(sizeof(cmds::IsVertexArrayOES::Result
));
2823 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
2825 EXPECT_CALL(*command_buffer(), OnFlush())
2826 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
2827 .RetiresOnSaturation();
2829 GLboolean result
= gl_
->IsVertexArrayOES(1);
2830 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2831 EXPECT_TRUE(result
);
2833 // TODO(zmo): Implement unit test for EnableFeatureCHROMIUM
2834 // TODO(zmo): Implement unit test for MapBufferRange
2835 // TODO(zmo): Implement unit test for UnmapBuffer
2837 TEST_F(GLES2ImplementationTest
, ResizeCHROMIUM
) {
2839 cmds::ResizeCHROMIUM cmd
;
2842 expected
.cmd
.Init(1, 2, 3);
2844 gl_
->ResizeCHROMIUM(1, 2, 3);
2845 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2847 // TODO(zmo): Implement unit test for GetRequestableExtensionsCHROMIUM
2848 // TODO(zmo): Implement unit test for CreateStreamTextureCHROMIUM
2849 // TODO(zmo): Implement unit test for GetTranslatedShaderSourceANGLE
2851 TEST_F(GLES2ImplementationTest
, TexImageIOSurface2DCHROMIUM
) {
2853 cmds::TexImageIOSurface2DCHROMIUM cmd
;
2856 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, 3, 4, 5);
2858 gl_
->TexImageIOSurface2DCHROMIUM(GL_TEXTURE_2D
, 2, 3, 4, 5);
2859 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2862 TEST_F(GLES2ImplementationTest
, CopyTextureCHROMIUM
) {
2864 cmds::CopyTextureCHROMIUM cmd
;
2867 expected
.cmd
.Init(1, 2, 3, GL_ALPHA
, GL_UNSIGNED_BYTE
, true, true, true);
2869 gl_
->CopyTextureCHROMIUM(1, 2, 3, GL_ALPHA
, GL_UNSIGNED_BYTE
, true, true,
2871 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2874 TEST_F(GLES2ImplementationTest
, CopySubTextureCHROMIUM
) {
2876 cmds::CopySubTextureCHROMIUM cmd
;
2879 expected
.cmd
.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, true, true, true);
2881 gl_
->CopySubTextureCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, true, true, true);
2882 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2885 TEST_F(GLES2ImplementationTest
, CompressedCopyTextureCHROMIUM
) {
2887 cmds::CompressedCopyTextureCHROMIUM cmd
;
2890 expected
.cmd
.Init(1, 2, 3);
2892 gl_
->CompressedCopyTextureCHROMIUM(1, 2, 3);
2893 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2896 TEST_F(GLES2ImplementationTest
, DrawArraysInstancedANGLE
) {
2898 cmds::DrawArraysInstancedANGLE cmd
;
2901 expected
.cmd
.Init(GL_POINTS
, 2, 3, 4);
2903 gl_
->DrawArraysInstancedANGLE(GL_POINTS
, 2, 3, 4);
2904 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2907 TEST_F(GLES2ImplementationTest
, VertexAttribDivisorANGLE
) {
2909 cmds::VertexAttribDivisorANGLE cmd
;
2912 expected
.cmd
.Init(1, 2);
2914 gl_
->VertexAttribDivisorANGLE(1, 2);
2915 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2917 // TODO(zmo): Implement unit test for GenMailboxCHROMIUM
2918 // TODO(zmo): Implement unit test for BindUniformLocationCHROMIUM
2920 TEST_F(GLES2ImplementationTest
, GenValuebuffersCHROMIUM
) {
2925 cmds::GenValuebuffersCHROMIUMImmediate gen
;
2929 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
2930 expected
.data
[0] = kValuebuffersStartId
;
2931 expected
.data
[1] = kValuebuffersStartId
+ 1;
2932 gl_
->GenValuebuffersCHROMIUM(arraysize(ids
), &ids
[0]);
2933 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2934 EXPECT_EQ(kValuebuffersStartId
, ids
[0]);
2935 EXPECT_EQ(kValuebuffersStartId
+ 1, ids
[1]);
2938 TEST_F(GLES2ImplementationTest
, DeleteValuebuffersCHROMIUM
) {
2939 GLuint ids
[2] = {kValuebuffersStartId
, kValuebuffersStartId
+ 1};
2941 cmds::DeleteValuebuffersCHROMIUMImmediate del
;
2945 expected
.del
.Init(arraysize(ids
), &ids
[0]);
2946 expected
.data
[0] = kValuebuffersStartId
;
2947 expected
.data
[1] = kValuebuffersStartId
+ 1;
2948 gl_
->DeleteValuebuffersCHROMIUM(arraysize(ids
), &ids
[0]);
2949 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2952 TEST_F(GLES2ImplementationTest
, IsValuebufferCHROMIUM
) {
2954 cmds::IsValuebufferCHROMIUM cmd
;
2958 ExpectedMemoryInfo result1
=
2959 GetExpectedResultMemory(sizeof(cmds::IsValuebufferCHROMIUM::Result
));
2960 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
2962 EXPECT_CALL(*command_buffer(), OnFlush())
2963 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
2964 .RetiresOnSaturation();
2966 GLboolean result
= gl_
->IsValuebufferCHROMIUM(1);
2967 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2968 EXPECT_TRUE(result
);
2971 TEST_F(GLES2ImplementationTest
, BindValuebufferCHROMIUM
) {
2973 cmds::BindValuebufferCHROMIUM cmd
;
2976 expected
.cmd
.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
, 2);
2978 gl_
->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
, 2);
2979 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2981 gl_
->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
, 2);
2982 EXPECT_TRUE(NoCommandsWritten());
2985 TEST_F(GLES2ImplementationTest
, SubscribeValueCHROMIUM
) {
2987 cmds::SubscribeValueCHROMIUM cmd
;
2990 expected
.cmd
.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
,
2991 GL_MOUSE_POSITION_CHROMIUM
);
2993 gl_
->SubscribeValueCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
,
2994 GL_MOUSE_POSITION_CHROMIUM
);
2995 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
2998 TEST_F(GLES2ImplementationTest
, PopulateSubscribedValuesCHROMIUM
) {
3000 cmds::PopulateSubscribedValuesCHROMIUM cmd
;
3003 expected
.cmd
.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
);
3005 gl_
->PopulateSubscribedValuesCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
);
3006 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3009 TEST_F(GLES2ImplementationTest
, UniformValuebufferCHROMIUM
) {
3011 cmds::UniformValuebufferCHROMIUM cmd
;
3014 expected
.cmd
.Init(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
,
3015 GL_MOUSE_POSITION_CHROMIUM
);
3017 gl_
->UniformValuebufferCHROMIUM(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM
,
3018 GL_MOUSE_POSITION_CHROMIUM
);
3019 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3022 TEST_F(GLES2ImplementationTest
, BindTexImage2DCHROMIUM
) {
3024 cmds::BindTexImage2DCHROMIUM cmd
;
3027 expected
.cmd
.Init(GL_TEXTURE_2D
, 2);
3029 gl_
->BindTexImage2DCHROMIUM(GL_TEXTURE_2D
, 2);
3030 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3033 TEST_F(GLES2ImplementationTest
, ReleaseTexImage2DCHROMIUM
) {
3035 cmds::ReleaseTexImage2DCHROMIUM cmd
;
3038 expected
.cmd
.Init(GL_TEXTURE_2D
, 2);
3040 gl_
->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D
, 2);
3041 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3044 TEST_F(GLES2ImplementationTest
, DiscardFramebufferEXT
) {
3045 GLenum data
[2][1] = {{0}};
3047 cmds::DiscardFramebufferEXTImmediate cmd
;
3052 for (int ii
= 0; ii
< 2; ++ii
) {
3053 for (int jj
= 0; jj
< 1; ++jj
) {
3054 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
3057 expected
.cmd
.Init(1, 2, &data
[0][0]);
3058 gl_
->DiscardFramebufferEXT(1, 2, &data
[0][0]);
3059 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3062 TEST_F(GLES2ImplementationTest
, LoseContextCHROMIUM
) {
3064 cmds::LoseContextCHROMIUM cmd
;
3067 expected
.cmd
.Init(GL_GUILTY_CONTEXT_RESET_ARB
, GL_GUILTY_CONTEXT_RESET_ARB
);
3069 gl_
->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB
,
3070 GL_GUILTY_CONTEXT_RESET_ARB
);
3071 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3073 // TODO(zmo): Implement unit test for InsertSyncPointCHROMIUM
3075 TEST_F(GLES2ImplementationTest
, WaitSyncPointCHROMIUM
) {
3077 cmds::WaitSyncPointCHROMIUM cmd
;
3080 expected
.cmd
.Init(1);
3082 gl_
->WaitSyncPointCHROMIUM(1);
3083 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3086 TEST_F(GLES2ImplementationTest
, DrawBuffersEXT
) {
3087 GLenum data
[1][1] = {{0}};
3089 cmds::DrawBuffersEXTImmediate cmd
;
3094 for (int ii
= 0; ii
< 1; ++ii
) {
3095 for (int jj
= 0; jj
< 1; ++jj
) {
3096 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
3099 expected
.cmd
.Init(1, &data
[0][0]);
3100 gl_
->DrawBuffersEXT(1, &data
[0][0]);
3101 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3104 TEST_F(GLES2ImplementationTest
, DiscardBackbufferCHROMIUM
) {
3106 cmds::DiscardBackbufferCHROMIUM cmd
;
3109 expected
.cmd
.Init();
3111 gl_
->DiscardBackbufferCHROMIUM();
3112 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3115 TEST_F(GLES2ImplementationTest
, FlushDriverCachesCHROMIUM
) {
3117 cmds::FlushDriverCachesCHROMIUM cmd
;
3120 expected
.cmd
.Init();
3122 gl_
->FlushDriverCachesCHROMIUM();
3123 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3126 TEST_F(GLES2ImplementationTest
, MatrixLoadfCHROMIUM
) {
3127 GLfloat data
[16] = {0};
3129 cmds::MatrixLoadfCHROMIUMImmediate cmd
;
3133 for (int jj
= 0; jj
< 16; ++jj
) {
3134 data
[jj
] = static_cast<GLfloat
>(jj
);
3137 expected
.cmd
.Init(GL_PATH_PROJECTION_CHROMIUM
, &data
[0]);
3138 gl_
->MatrixLoadfCHROMIUM(GL_PATH_PROJECTION_CHROMIUM
, &data
[0]);
3139 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3142 TEST_F(GLES2ImplementationTest
, MatrixLoadIdentityCHROMIUM
) {
3144 cmds::MatrixLoadIdentityCHROMIUM cmd
;
3147 expected
.cmd
.Init(GL_PATH_PROJECTION_CHROMIUM
);
3149 gl_
->MatrixLoadIdentityCHROMIUM(GL_PATH_PROJECTION_CHROMIUM
);
3150 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3152 // TODO(zmo): Implement unit test for GenPathsCHROMIUM
3154 TEST_F(GLES2ImplementationTest
, DeletePathsCHROMIUM
) {
3156 cmds::DeletePathsCHROMIUM cmd
;
3159 expected
.cmd
.Init(1, 2);
3161 gl_
->DeletePathsCHROMIUM(1, 2);
3162 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3165 TEST_F(GLES2ImplementationTest
, IsPathCHROMIUM
) {
3167 cmds::IsPathCHROMIUM cmd
;
3171 ExpectedMemoryInfo result1
=
3172 GetExpectedResultMemory(sizeof(cmds::IsPathCHROMIUM::Result
));
3173 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
3175 EXPECT_CALL(*command_buffer(), OnFlush())
3176 .WillOnce(SetMemory(result1
.ptr
, uint32_t(GL_TRUE
)))
3177 .RetiresOnSaturation();
3179 GLboolean result
= gl_
->IsPathCHROMIUM(1);
3180 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3181 EXPECT_TRUE(result
);
3183 // TODO(zmo): Implement unit test for PathCommandsCHROMIUM
3185 TEST_F(GLES2ImplementationTest
, PathParameterfCHROMIUM
) {
3187 cmds::PathParameterfCHROMIUM cmd
;
3190 expected
.cmd
.Init(1, GL_PATH_STROKE_WIDTH_CHROMIUM
, 3);
3192 gl_
->PathParameterfCHROMIUM(1, GL_PATH_STROKE_WIDTH_CHROMIUM
, 3);
3193 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3196 TEST_F(GLES2ImplementationTest
, PathParameteriCHROMIUM
) {
3198 cmds::PathParameteriCHROMIUM cmd
;
3201 expected
.cmd
.Init(1, GL_PATH_STROKE_WIDTH_CHROMIUM
, 3);
3203 gl_
->PathParameteriCHROMIUM(1, GL_PATH_STROKE_WIDTH_CHROMIUM
, 3);
3204 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3207 TEST_F(GLES2ImplementationTest
, PathStencilFuncCHROMIUM
) {
3209 cmds::PathStencilFuncCHROMIUM cmd
;
3212 expected
.cmd
.Init(GL_NEVER
, 2, 3);
3214 gl_
->PathStencilFuncCHROMIUM(GL_NEVER
, 2, 3);
3215 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3218 TEST_F(GLES2ImplementationTest
, StencilFillPathCHROMIUM
) {
3220 cmds::StencilFillPathCHROMIUM cmd
;
3223 expected
.cmd
.Init(1, GL_INVERT
, 3);
3225 gl_
->StencilFillPathCHROMIUM(1, GL_INVERT
, 3);
3226 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3229 TEST_F(GLES2ImplementationTest
, StencilStrokePathCHROMIUM
) {
3231 cmds::StencilStrokePathCHROMIUM cmd
;
3234 expected
.cmd
.Init(1, 2, 3);
3236 gl_
->StencilStrokePathCHROMIUM(1, 2, 3);
3237 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3240 TEST_F(GLES2ImplementationTest
, CoverFillPathCHROMIUM
) {
3242 cmds::CoverFillPathCHROMIUM cmd
;
3245 expected
.cmd
.Init(1, GL_CONVEX_HULL_CHROMIUM
);
3247 gl_
->CoverFillPathCHROMIUM(1, GL_CONVEX_HULL_CHROMIUM
);
3248 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3251 TEST_F(GLES2ImplementationTest
, CoverStrokePathCHROMIUM
) {
3253 cmds::CoverStrokePathCHROMIUM cmd
;
3256 expected
.cmd
.Init(1, GL_CONVEX_HULL_CHROMIUM
);
3258 gl_
->CoverStrokePathCHROMIUM(1, GL_CONVEX_HULL_CHROMIUM
);
3259 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3262 TEST_F(GLES2ImplementationTest
, StencilThenCoverFillPathCHROMIUM
) {
3264 cmds::StencilThenCoverFillPathCHROMIUM cmd
;
3267 expected
.cmd
.Init(1, GL_INVERT
, 3, GL_CONVEX_HULL_CHROMIUM
);
3269 gl_
->StencilThenCoverFillPathCHROMIUM(1, GL_INVERT
, 3,
3270 GL_CONVEX_HULL_CHROMIUM
);
3271 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3274 TEST_F(GLES2ImplementationTest
, StencilThenCoverStrokePathCHROMIUM
) {
3276 cmds::StencilThenCoverStrokePathCHROMIUM cmd
;
3279 expected
.cmd
.Init(1, 2, 3, GL_CONVEX_HULL_CHROMIUM
);
3281 gl_
->StencilThenCoverStrokePathCHROMIUM(1, 2, 3, GL_CONVEX_HULL_CHROMIUM
);
3282 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
3284 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_