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: 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
, BindFramebuffer
) {
44 cmds::BindFramebuffer cmd
;
47 expected
.cmd
.Init(GL_FRAMEBUFFER
, 2);
49 gl_
->BindFramebuffer(GL_FRAMEBUFFER
, 2);
50 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
52 gl_
->BindFramebuffer(GL_FRAMEBUFFER
, 2);
53 EXPECT_TRUE(NoCommandsWritten());
56 TEST_F(GLES2ImplementationTest
, BindRenderbuffer
) {
58 cmds::BindRenderbuffer cmd
;
61 expected
.cmd
.Init(GL_RENDERBUFFER
, 2);
63 gl_
->BindRenderbuffer(GL_RENDERBUFFER
, 2);
64 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
66 gl_
->BindRenderbuffer(GL_RENDERBUFFER
, 2);
67 EXPECT_TRUE(NoCommandsWritten());
70 TEST_F(GLES2ImplementationTest
, BlendColor
) {
75 expected
.cmd
.Init(1, 2, 3, 4);
77 gl_
->BlendColor(1, 2, 3, 4);
78 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
81 TEST_F(GLES2ImplementationTest
, BlendEquation
) {
83 cmds::BlendEquation cmd
;
86 expected
.cmd
.Init(GL_FUNC_SUBTRACT
);
88 gl_
->BlendEquation(GL_FUNC_SUBTRACT
);
89 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
92 TEST_F(GLES2ImplementationTest
, BlendEquationSeparate
) {
94 cmds::BlendEquationSeparate cmd
;
97 expected
.cmd
.Init(GL_FUNC_SUBTRACT
, GL_FUNC_ADD
);
99 gl_
->BlendEquationSeparate(GL_FUNC_SUBTRACT
, GL_FUNC_ADD
);
100 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
103 TEST_F(GLES2ImplementationTest
, BlendFunc
) {
108 expected
.cmd
.Init(GL_ZERO
, GL_ZERO
);
110 gl_
->BlendFunc(GL_ZERO
, GL_ZERO
);
111 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
114 TEST_F(GLES2ImplementationTest
, BlendFuncSeparate
) {
116 cmds::BlendFuncSeparate cmd
;
119 expected
.cmd
.Init(GL_ZERO
, GL_ZERO
, GL_ZERO
, GL_ZERO
);
121 gl_
->BlendFuncSeparate(GL_ZERO
, GL_ZERO
, GL_ZERO
, GL_ZERO
);
122 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
125 TEST_F(GLES2ImplementationTest
, CheckFramebufferStatus
) {
127 cmds::CheckFramebufferStatus cmd
;
131 ExpectedMemoryInfo result1
=
132 GetExpectedResultMemory(sizeof(cmds::CheckFramebufferStatus::Result
));
133 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
135 EXPECT_CALL(*command_buffer(), OnFlush())
136 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
137 .RetiresOnSaturation();
139 GLboolean result
= gl_
->CheckFramebufferStatus(1);
140 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
144 TEST_F(GLES2ImplementationTest
, Clear
) {
149 expected
.cmd
.Init(1);
152 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
155 TEST_F(GLES2ImplementationTest
, ClearColor
) {
157 cmds::ClearColor cmd
;
160 expected
.cmd
.Init(1, 2, 3, 4);
162 gl_
->ClearColor(1, 2, 3, 4);
163 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
166 TEST_F(GLES2ImplementationTest
, ClearDepthf
) {
168 cmds::ClearDepthf cmd
;
171 expected
.cmd
.Init(1);
174 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
177 TEST_F(GLES2ImplementationTest
, ClearStencil
) {
179 cmds::ClearStencil cmd
;
182 expected
.cmd
.Init(1);
184 gl_
->ClearStencil(1);
185 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
188 TEST_F(GLES2ImplementationTest
, ColorMask
) {
193 expected
.cmd
.Init(true, true, true, true);
195 gl_
->ColorMask(true, true, true, true);
196 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
199 TEST_F(GLES2ImplementationTest
, CompileShader
) {
201 cmds::CompileShader cmd
;
204 expected
.cmd
.Init(1);
206 gl_
->CompileShader(1);
207 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
209 // TODO: Implement unit test for CompressedTexImage2D
210 // TODO: Implement unit test for CompressedTexSubImage2D
212 TEST_F(GLES2ImplementationTest
, CopyTexImage2D
) {
214 cmds::CopyTexImage2D cmd
;
217 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, GL_ALPHA
, 4, 5, 6, 7, 0);
219 gl_
->CopyTexImage2D(GL_TEXTURE_2D
, 2, GL_ALPHA
, 4, 5, 6, 7, 0);
220 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
223 TEST_F(GLES2ImplementationTest
, CopyTexSubImage2D
) {
225 cmds::CopyTexSubImage2D cmd
;
228 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, 3, 4, 5, 6, 7, 8);
230 gl_
->CopyTexSubImage2D(GL_TEXTURE_2D
, 2, 3, 4, 5, 6, 7, 8);
231 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
234 TEST_F(GLES2ImplementationTest
, CullFace
) {
239 expected
.cmd
.Init(GL_FRONT
);
241 gl_
->CullFace(GL_FRONT
);
242 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
245 TEST_F(GLES2ImplementationTest
, DeleteBuffers
) {
246 GLuint ids
[2] = {kBuffersStartId
, kBuffersStartId
+ 1};
248 cmds::DeleteBuffersImmediate del
;
252 expected
.del
.Init(arraysize(ids
), &ids
[0]);
253 expected
.data
[0] = kBuffersStartId
;
254 expected
.data
[1] = kBuffersStartId
+ 1;
255 gl_
->DeleteBuffers(arraysize(ids
), &ids
[0]);
256 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
259 TEST_F(GLES2ImplementationTest
, DeleteFramebuffers
) {
260 GLuint ids
[2] = {kFramebuffersStartId
, kFramebuffersStartId
+ 1};
262 cmds::DeleteFramebuffersImmediate del
;
266 expected
.del
.Init(arraysize(ids
), &ids
[0]);
267 expected
.data
[0] = kFramebuffersStartId
;
268 expected
.data
[1] = kFramebuffersStartId
+ 1;
269 gl_
->DeleteFramebuffers(arraysize(ids
), &ids
[0]);
270 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
273 TEST_F(GLES2ImplementationTest
, DeleteProgram
) {
275 cmds::DeleteProgram cmd
;
278 expected
.cmd
.Init(1);
280 gl_
->DeleteProgram(1);
281 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
284 TEST_F(GLES2ImplementationTest
, DeleteRenderbuffers
) {
285 GLuint ids
[2] = {kRenderbuffersStartId
, kRenderbuffersStartId
+ 1};
287 cmds::DeleteRenderbuffersImmediate del
;
291 expected
.del
.Init(arraysize(ids
), &ids
[0]);
292 expected
.data
[0] = kRenderbuffersStartId
;
293 expected
.data
[1] = kRenderbuffersStartId
+ 1;
294 gl_
->DeleteRenderbuffers(arraysize(ids
), &ids
[0]);
295 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
298 TEST_F(GLES2ImplementationTest
, DeleteShader
) {
300 cmds::DeleteShader cmd
;
303 expected
.cmd
.Init(1);
305 gl_
->DeleteShader(1);
306 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
309 TEST_F(GLES2ImplementationTest
, DeleteTextures
) {
310 GLuint ids
[2] = {kTexturesStartId
, kTexturesStartId
+ 1};
312 cmds::DeleteTexturesImmediate del
;
316 expected
.del
.Init(arraysize(ids
), &ids
[0]);
317 expected
.data
[0] = kTexturesStartId
;
318 expected
.data
[1] = kTexturesStartId
+ 1;
319 gl_
->DeleteTextures(arraysize(ids
), &ids
[0]);
320 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
323 TEST_F(GLES2ImplementationTest
, DepthFunc
) {
328 expected
.cmd
.Init(GL_NEVER
);
330 gl_
->DepthFunc(GL_NEVER
);
331 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
334 TEST_F(GLES2ImplementationTest
, DepthMask
) {
339 expected
.cmd
.Init(true);
341 gl_
->DepthMask(true);
342 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
345 TEST_F(GLES2ImplementationTest
, DepthRangef
) {
347 cmds::DepthRangef cmd
;
350 expected
.cmd
.Init(1, 2);
352 gl_
->DepthRangef(1, 2);
353 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
356 TEST_F(GLES2ImplementationTest
, DetachShader
) {
358 cmds::DetachShader cmd
;
361 expected
.cmd
.Init(1, 2);
363 gl_
->DetachShader(1, 2);
364 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
367 TEST_F(GLES2ImplementationTest
, DisableVertexAttribArray
) {
369 cmds::DisableVertexAttribArray cmd
;
372 expected
.cmd
.Init(1);
374 gl_
->DisableVertexAttribArray(1);
375 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
378 TEST_F(GLES2ImplementationTest
, DrawArrays
) {
380 cmds::DrawArrays cmd
;
383 expected
.cmd
.Init(GL_POINTS
, 2, 3);
385 gl_
->DrawArrays(GL_POINTS
, 2, 3);
386 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
389 TEST_F(GLES2ImplementationTest
, EnableVertexAttribArray
) {
391 cmds::EnableVertexAttribArray cmd
;
394 expected
.cmd
.Init(1);
396 gl_
->EnableVertexAttribArray(1);
397 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
400 TEST_F(GLES2ImplementationTest
, Flush
) {
408 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
411 TEST_F(GLES2ImplementationTest
, FramebufferRenderbuffer
) {
413 cmds::FramebufferRenderbuffer cmd
;
416 expected
.cmd
.Init(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_RENDERBUFFER
, 4);
418 gl_
->FramebufferRenderbuffer(
419 GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_RENDERBUFFER
, 4);
420 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
423 TEST_F(GLES2ImplementationTest
, FramebufferTexture2D
) {
425 cmds::FramebufferTexture2D cmd
;
428 expected
.cmd
.Init(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 4, 0);
430 gl_
->FramebufferTexture2D(
431 GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 4, 0);
432 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
435 TEST_F(GLES2ImplementationTest
, FrontFace
) {
440 expected
.cmd
.Init(GL_CW
);
442 gl_
->FrontFace(GL_CW
);
443 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
446 TEST_F(GLES2ImplementationTest
, GenBuffers
) {
447 GLuint ids
[2] = {0, };
449 cmds::GenBuffersImmediate gen
;
453 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
454 expected
.data
[0] = kBuffersStartId
;
455 expected
.data
[1] = kBuffersStartId
+ 1;
456 gl_
->GenBuffers(arraysize(ids
), &ids
[0]);
457 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
458 EXPECT_EQ(kBuffersStartId
, ids
[0]);
459 EXPECT_EQ(kBuffersStartId
+ 1, ids
[1]);
462 TEST_F(GLES2ImplementationTest
, GenerateMipmap
) {
464 cmds::GenerateMipmap cmd
;
467 expected
.cmd
.Init(GL_TEXTURE_2D
);
469 gl_
->GenerateMipmap(GL_TEXTURE_2D
);
470 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
473 TEST_F(GLES2ImplementationTest
, GenFramebuffers
) {
474 GLuint ids
[2] = {0, };
476 cmds::GenFramebuffersImmediate gen
;
480 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
481 expected
.data
[0] = kFramebuffersStartId
;
482 expected
.data
[1] = kFramebuffersStartId
+ 1;
483 gl_
->GenFramebuffers(arraysize(ids
), &ids
[0]);
484 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
485 EXPECT_EQ(kFramebuffersStartId
, ids
[0]);
486 EXPECT_EQ(kFramebuffersStartId
+ 1, ids
[1]);
489 TEST_F(GLES2ImplementationTest
, GenRenderbuffers
) {
490 GLuint ids
[2] = {0, };
492 cmds::GenRenderbuffersImmediate gen
;
496 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
497 expected
.data
[0] = kRenderbuffersStartId
;
498 expected
.data
[1] = kRenderbuffersStartId
+ 1;
499 gl_
->GenRenderbuffers(arraysize(ids
), &ids
[0]);
500 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
501 EXPECT_EQ(kRenderbuffersStartId
, ids
[0]);
502 EXPECT_EQ(kRenderbuffersStartId
+ 1, ids
[1]);
505 TEST_F(GLES2ImplementationTest
, GenTextures
) {
506 GLuint ids
[2] = {0, };
508 cmds::GenTexturesImmediate gen
;
512 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
513 expected
.data
[0] = kTexturesStartId
;
514 expected
.data
[1] = kTexturesStartId
+ 1;
515 gl_
->GenTextures(arraysize(ids
), &ids
[0]);
516 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
517 EXPECT_EQ(kTexturesStartId
, ids
[0]);
518 EXPECT_EQ(kTexturesStartId
+ 1, ids
[1]);
520 // TODO: Implement unit test for GetActiveAttrib
521 // TODO: Implement unit test for GetActiveUniform
522 // TODO: Implement unit test for GetAttachedShaders
523 // TODO: Implement unit test for GetAttribLocation
525 TEST_F(GLES2ImplementationTest
, GetBooleanv
) {
527 cmds::GetBooleanv cmd
;
529 typedef cmds::GetBooleanv::Result Result
;
530 Result::Type result
= 0;
532 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
533 expected
.cmd
.Init(123, result1
.id
, result1
.offset
);
534 EXPECT_CALL(*command_buffer(), OnFlush())
535 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
536 .RetiresOnSaturation();
537 gl_
->GetBooleanv(123, &result
);
538 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
539 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
542 TEST_F(GLES2ImplementationTest
, GetBufferParameteriv
) {
544 cmds::GetBufferParameteriv cmd
;
546 typedef cmds::GetBufferParameteriv::Result Result
;
547 Result::Type result
= 0;
549 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
550 expected
.cmd
.Init(123, GL_BUFFER_SIZE
, result1
.id
, result1
.offset
);
551 EXPECT_CALL(*command_buffer(), OnFlush())
552 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
553 .RetiresOnSaturation();
554 gl_
->GetBufferParameteriv(123, GL_BUFFER_SIZE
, &result
);
555 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
556 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
559 TEST_F(GLES2ImplementationTest
, GetFloatv
) {
563 typedef cmds::GetFloatv::Result Result
;
564 Result::Type result
= 0;
566 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
567 expected
.cmd
.Init(123, result1
.id
, result1
.offset
);
568 EXPECT_CALL(*command_buffer(), OnFlush())
569 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
570 .RetiresOnSaturation();
571 gl_
->GetFloatv(123, &result
);
572 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
573 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
576 TEST_F(GLES2ImplementationTest
, GetFramebufferAttachmentParameteriv
) {
578 cmds::GetFramebufferAttachmentParameteriv cmd
;
580 typedef cmds::GetFramebufferAttachmentParameteriv::Result Result
;
581 Result::Type result
= 0;
583 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
584 expected
.cmd
.Init(123,
585 GL_COLOR_ATTACHMENT0
,
586 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
,
589 EXPECT_CALL(*command_buffer(), OnFlush())
590 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
591 .RetiresOnSaturation();
592 gl_
->GetFramebufferAttachmentParameteriv(
594 GL_COLOR_ATTACHMENT0
,
595 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
,
597 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
598 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
601 TEST_F(GLES2ImplementationTest
, GetIntegerv
) {
603 cmds::GetIntegerv cmd
;
605 typedef cmds::GetIntegerv::Result Result
;
606 Result::Type result
= 0;
608 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
609 expected
.cmd
.Init(123, result1
.id
, result1
.offset
);
610 EXPECT_CALL(*command_buffer(), OnFlush())
611 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
612 .RetiresOnSaturation();
613 gl_
->GetIntegerv(123, &result
);
614 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
615 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
618 TEST_F(GLES2ImplementationTest
, GetProgramiv
) {
620 cmds::GetProgramiv cmd
;
622 typedef cmds::GetProgramiv::Result Result
;
623 Result::Type result
= 0;
625 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
626 expected
.cmd
.Init(123, GL_DELETE_STATUS
, result1
.id
, result1
.offset
);
627 EXPECT_CALL(*command_buffer(), OnFlush())
628 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
629 .RetiresOnSaturation();
630 gl_
->GetProgramiv(123, GL_DELETE_STATUS
, &result
);
631 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
632 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
634 // TODO: Implement unit test for GetProgramInfoLog
636 TEST_F(GLES2ImplementationTest
, GetRenderbufferParameteriv
) {
638 cmds::GetRenderbufferParameteriv cmd
;
640 typedef cmds::GetRenderbufferParameteriv::Result Result
;
641 Result::Type result
= 0;
643 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
644 expected
.cmd
.Init(123, GL_RENDERBUFFER_RED_SIZE
, result1
.id
, result1
.offset
);
645 EXPECT_CALL(*command_buffer(), OnFlush())
646 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
647 .RetiresOnSaturation();
648 gl_
->GetRenderbufferParameteriv(123, GL_RENDERBUFFER_RED_SIZE
, &result
);
649 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
650 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
653 TEST_F(GLES2ImplementationTest
, GetShaderiv
) {
655 cmds::GetShaderiv cmd
;
657 typedef cmds::GetShaderiv::Result Result
;
658 Result::Type result
= 0;
660 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
661 expected
.cmd
.Init(123, GL_SHADER_TYPE
, result1
.id
, result1
.offset
);
662 EXPECT_CALL(*command_buffer(), OnFlush())
663 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
664 .RetiresOnSaturation();
665 gl_
->GetShaderiv(123, GL_SHADER_TYPE
, &result
);
666 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
667 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
669 // TODO: Implement unit test for GetShaderInfoLog
670 // TODO: Implement unit test for GetShaderPrecisionFormat
672 TEST_F(GLES2ImplementationTest
, GetTexParameterfv
) {
674 cmds::GetTexParameterfv cmd
;
676 typedef cmds::GetTexParameterfv::Result Result
;
677 Result::Type result
= 0;
679 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
680 expected
.cmd
.Init(123, GL_TEXTURE_MAG_FILTER
, result1
.id
, result1
.offset
);
681 EXPECT_CALL(*command_buffer(), OnFlush())
682 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
683 .RetiresOnSaturation();
684 gl_
->GetTexParameterfv(123, GL_TEXTURE_MAG_FILTER
, &result
);
685 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
686 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
689 TEST_F(GLES2ImplementationTest
, GetTexParameteriv
) {
691 cmds::GetTexParameteriv cmd
;
693 typedef cmds::GetTexParameteriv::Result Result
;
694 Result::Type result
= 0;
696 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
697 expected
.cmd
.Init(123, GL_TEXTURE_MAG_FILTER
, result1
.id
, result1
.offset
);
698 EXPECT_CALL(*command_buffer(), OnFlush())
699 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
700 .RetiresOnSaturation();
701 gl_
->GetTexParameteriv(123, GL_TEXTURE_MAG_FILTER
, &result
);
702 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
703 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
705 // TODO: Implement unit test for GetUniformfv
706 // TODO: Implement unit test for GetUniformiv
707 // TODO: Implement unit test for GetUniformLocation
709 TEST_F(GLES2ImplementationTest
, GetVertexAttribfv
) {
711 cmds::GetVertexAttribfv cmd
;
713 typedef cmds::GetVertexAttribfv::Result Result
;
714 Result::Type result
= 0;
716 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
718 123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, result1
.id
, result1
.offset
);
719 EXPECT_CALL(*command_buffer(), OnFlush())
720 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
721 .RetiresOnSaturation();
722 gl_
->GetVertexAttribfv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, &result
);
723 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
724 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
727 TEST_F(GLES2ImplementationTest
, GetVertexAttribiv
) {
729 cmds::GetVertexAttribiv cmd
;
731 typedef cmds::GetVertexAttribiv::Result Result
;
732 Result::Type result
= 0;
734 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
736 123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, result1
.id
, result1
.offset
);
737 EXPECT_CALL(*command_buffer(), OnFlush())
738 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
739 .RetiresOnSaturation();
740 gl_
->GetVertexAttribiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, &result
);
741 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
742 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
745 TEST_F(GLES2ImplementationTest
, Hint
) {
750 expected
.cmd
.Init(GL_GENERATE_MIPMAP_HINT
, GL_FASTEST
);
752 gl_
->Hint(GL_GENERATE_MIPMAP_HINT
, GL_FASTEST
);
753 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
756 TEST_F(GLES2ImplementationTest
, IsBuffer
) {
762 ExpectedMemoryInfo result1
=
763 GetExpectedResultMemory(sizeof(cmds::IsBuffer::Result
));
764 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
766 EXPECT_CALL(*command_buffer(), OnFlush())
767 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
768 .RetiresOnSaturation();
770 GLboolean result
= gl_
->IsBuffer(1);
771 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
775 TEST_F(GLES2ImplementationTest
, IsEnabled
) {
781 ExpectedMemoryInfo result1
=
782 GetExpectedResultMemory(sizeof(cmds::IsEnabled::Result
));
783 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
785 EXPECT_CALL(*command_buffer(), OnFlush())
786 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
787 .RetiresOnSaturation();
789 GLboolean result
= gl_
->IsEnabled(1);
790 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
794 TEST_F(GLES2ImplementationTest
, IsFramebuffer
) {
796 cmds::IsFramebuffer cmd
;
800 ExpectedMemoryInfo result1
=
801 GetExpectedResultMemory(sizeof(cmds::IsFramebuffer::Result
));
802 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
804 EXPECT_CALL(*command_buffer(), OnFlush())
805 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
806 .RetiresOnSaturation();
808 GLboolean result
= gl_
->IsFramebuffer(1);
809 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
813 TEST_F(GLES2ImplementationTest
, IsProgram
) {
819 ExpectedMemoryInfo result1
=
820 GetExpectedResultMemory(sizeof(cmds::IsProgram::Result
));
821 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
823 EXPECT_CALL(*command_buffer(), OnFlush())
824 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
825 .RetiresOnSaturation();
827 GLboolean result
= gl_
->IsProgram(1);
828 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
832 TEST_F(GLES2ImplementationTest
, IsRenderbuffer
) {
834 cmds::IsRenderbuffer cmd
;
838 ExpectedMemoryInfo result1
=
839 GetExpectedResultMemory(sizeof(cmds::IsRenderbuffer::Result
));
840 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
842 EXPECT_CALL(*command_buffer(), OnFlush())
843 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
844 .RetiresOnSaturation();
846 GLboolean result
= gl_
->IsRenderbuffer(1);
847 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
851 TEST_F(GLES2ImplementationTest
, IsShader
) {
857 ExpectedMemoryInfo result1
=
858 GetExpectedResultMemory(sizeof(cmds::IsShader::Result
));
859 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
861 EXPECT_CALL(*command_buffer(), OnFlush())
862 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
863 .RetiresOnSaturation();
865 GLboolean result
= gl_
->IsShader(1);
866 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
870 TEST_F(GLES2ImplementationTest
, IsTexture
) {
876 ExpectedMemoryInfo result1
=
877 GetExpectedResultMemory(sizeof(cmds::IsTexture::Result
));
878 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
880 EXPECT_CALL(*command_buffer(), OnFlush())
881 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
882 .RetiresOnSaturation();
884 GLboolean result
= gl_
->IsTexture(1);
885 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
889 TEST_F(GLES2ImplementationTest
, LineWidth
) {
894 expected
.cmd
.Init(1);
897 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
900 TEST_F(GLES2ImplementationTest
, LinkProgram
) {
902 cmds::LinkProgram cmd
;
905 expected
.cmd
.Init(1);
908 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
911 TEST_F(GLES2ImplementationTest
, PixelStorei
) {
913 cmds::PixelStorei cmd
;
916 expected
.cmd
.Init(GL_PACK_ALIGNMENT
, 1);
918 gl_
->PixelStorei(GL_PACK_ALIGNMENT
, 1);
919 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
922 TEST_F(GLES2ImplementationTest
, PolygonOffset
) {
924 cmds::PolygonOffset cmd
;
927 expected
.cmd
.Init(1, 2);
929 gl_
->PolygonOffset(1, 2);
930 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
933 TEST_F(GLES2ImplementationTest
, ReleaseShaderCompiler
) {
935 cmds::ReleaseShaderCompiler cmd
;
940 gl_
->ReleaseShaderCompiler();
941 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
944 TEST_F(GLES2ImplementationTest
, RenderbufferStorage
) {
946 cmds::RenderbufferStorage cmd
;
949 expected
.cmd
.Init(GL_RENDERBUFFER
, GL_RGBA4
, 3, 4);
951 gl_
->RenderbufferStorage(GL_RENDERBUFFER
, GL_RGBA4
, 3, 4);
952 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
955 TEST_F(GLES2ImplementationTest
, SampleCoverage
) {
957 cmds::SampleCoverage cmd
;
960 expected
.cmd
.Init(1, true);
962 gl_
->SampleCoverage(1, true);
963 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
966 TEST_F(GLES2ImplementationTest
, Scissor
) {
971 expected
.cmd
.Init(1, 2, 3, 4);
973 gl_
->Scissor(1, 2, 3, 4);
974 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
977 TEST_F(GLES2ImplementationTest
, StencilFunc
) {
979 cmds::StencilFunc cmd
;
982 expected
.cmd
.Init(GL_NEVER
, 2, 3);
984 gl_
->StencilFunc(GL_NEVER
, 2, 3);
985 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
988 TEST_F(GLES2ImplementationTest
, StencilFuncSeparate
) {
990 cmds::StencilFuncSeparate cmd
;
993 expected
.cmd
.Init(GL_FRONT
, GL_NEVER
, 3, 4);
995 gl_
->StencilFuncSeparate(GL_FRONT
, GL_NEVER
, 3, 4);
996 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
999 TEST_F(GLES2ImplementationTest
, StencilMask
) {
1001 cmds::StencilMask cmd
;
1004 expected
.cmd
.Init(1);
1006 gl_
->StencilMask(1);
1007 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1010 TEST_F(GLES2ImplementationTest
, StencilMaskSeparate
) {
1012 cmds::StencilMaskSeparate cmd
;
1015 expected
.cmd
.Init(GL_FRONT
, 2);
1017 gl_
->StencilMaskSeparate(GL_FRONT
, 2);
1018 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1021 TEST_F(GLES2ImplementationTest
, StencilOp
) {
1023 cmds::StencilOp cmd
;
1026 expected
.cmd
.Init(GL_KEEP
, GL_INCR
, GL_KEEP
);
1028 gl_
->StencilOp(GL_KEEP
, GL_INCR
, GL_KEEP
);
1029 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1032 TEST_F(GLES2ImplementationTest
, StencilOpSeparate
) {
1034 cmds::StencilOpSeparate cmd
;
1037 expected
.cmd
.Init(GL_FRONT
, GL_INCR
, GL_KEEP
, GL_KEEP
);
1039 gl_
->StencilOpSeparate(GL_FRONT
, GL_INCR
, GL_KEEP
, GL_KEEP
);
1040 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1043 TEST_F(GLES2ImplementationTest
, TexParameterf
) {
1045 cmds::TexParameterf cmd
;
1048 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, 3);
1050 gl_
->TexParameterf(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, 3);
1051 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1054 TEST_F(GLES2ImplementationTest
, TexParameterfv
) {
1055 GLfloat data
[1] = {0};
1057 cmds::TexParameterfvImmediate cmd
;
1061 for (int jj
= 0; jj
< 1; ++jj
) {
1062 data
[jj
] = static_cast<GLfloat
>(jj
);
1065 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1066 gl_
->TexParameterfv(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1067 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1070 TEST_F(GLES2ImplementationTest
, TexParameteri
) {
1072 cmds::TexParameteri cmd
;
1075 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, 3);
1077 gl_
->TexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, 3);
1078 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1081 TEST_F(GLES2ImplementationTest
, TexParameteriv
) {
1082 GLint data
[1] = {0};
1084 cmds::TexParameterivImmediate cmd
;
1088 for (int jj
= 0; jj
< 1; ++jj
) {
1089 data
[jj
] = static_cast<GLint
>(jj
);
1092 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1093 gl_
->TexParameteriv(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1094 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1097 TEST_F(GLES2ImplementationTest
, Uniform1f
) {
1099 cmds::Uniform1f cmd
;
1102 expected
.cmd
.Init(1, 2);
1104 gl_
->Uniform1f(1, 2);
1105 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1108 TEST_F(GLES2ImplementationTest
, Uniform1fv
) {
1109 GLfloat data
[2][1] = {{0}};
1111 cmds::Uniform1fvImmediate cmd
;
1116 for (int ii
= 0; ii
< 2; ++ii
) {
1117 for (int jj
= 0; jj
< 1; ++jj
) {
1118 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 1 + jj
);
1121 expected
.cmd
.Init(1, 2, &data
[0][0]);
1122 gl_
->Uniform1fv(1, 2, &data
[0][0]);
1123 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1126 TEST_F(GLES2ImplementationTest
, Uniform1i
) {
1128 cmds::Uniform1i cmd
;
1131 expected
.cmd
.Init(1, 2);
1133 gl_
->Uniform1i(1, 2);
1134 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1137 TEST_F(GLES2ImplementationTest
, Uniform1iv
) {
1138 GLint data
[2][1] = {{0}};
1140 cmds::Uniform1ivImmediate cmd
;
1145 for (int ii
= 0; ii
< 2; ++ii
) {
1146 for (int jj
= 0; jj
< 1; ++jj
) {
1147 data
[ii
][jj
] = static_cast<GLint
>(ii
* 1 + jj
);
1150 expected
.cmd
.Init(1, 2, &data
[0][0]);
1151 gl_
->Uniform1iv(1, 2, &data
[0][0]);
1152 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1155 TEST_F(GLES2ImplementationTest
, Uniform2f
) {
1157 cmds::Uniform2f cmd
;
1160 expected
.cmd
.Init(1, 2, 3);
1162 gl_
->Uniform2f(1, 2, 3);
1163 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1166 TEST_F(GLES2ImplementationTest
, Uniform2fv
) {
1167 GLfloat data
[2][2] = {{0}};
1169 cmds::Uniform2fvImmediate cmd
;
1174 for (int ii
= 0; ii
< 2; ++ii
) {
1175 for (int jj
= 0; jj
< 2; ++jj
) {
1176 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 2 + jj
);
1179 expected
.cmd
.Init(1, 2, &data
[0][0]);
1180 gl_
->Uniform2fv(1, 2, &data
[0][0]);
1181 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1184 TEST_F(GLES2ImplementationTest
, Uniform2i
) {
1186 cmds::Uniform2i cmd
;
1189 expected
.cmd
.Init(1, 2, 3);
1191 gl_
->Uniform2i(1, 2, 3);
1192 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1195 TEST_F(GLES2ImplementationTest
, Uniform2iv
) {
1196 GLint data
[2][2] = {{0}};
1198 cmds::Uniform2ivImmediate cmd
;
1203 for (int ii
= 0; ii
< 2; ++ii
) {
1204 for (int jj
= 0; jj
< 2; ++jj
) {
1205 data
[ii
][jj
] = static_cast<GLint
>(ii
* 2 + jj
);
1208 expected
.cmd
.Init(1, 2, &data
[0][0]);
1209 gl_
->Uniform2iv(1, 2, &data
[0][0]);
1210 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1213 TEST_F(GLES2ImplementationTest
, Uniform3f
) {
1215 cmds::Uniform3f cmd
;
1218 expected
.cmd
.Init(1, 2, 3, 4);
1220 gl_
->Uniform3f(1, 2, 3, 4);
1221 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1224 TEST_F(GLES2ImplementationTest
, Uniform3fv
) {
1225 GLfloat data
[2][3] = {{0}};
1227 cmds::Uniform3fvImmediate cmd
;
1232 for (int ii
= 0; ii
< 2; ++ii
) {
1233 for (int jj
= 0; jj
< 3; ++jj
) {
1234 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 3 + jj
);
1237 expected
.cmd
.Init(1, 2, &data
[0][0]);
1238 gl_
->Uniform3fv(1, 2, &data
[0][0]);
1239 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1242 TEST_F(GLES2ImplementationTest
, Uniform3i
) {
1244 cmds::Uniform3i cmd
;
1247 expected
.cmd
.Init(1, 2, 3, 4);
1249 gl_
->Uniform3i(1, 2, 3, 4);
1250 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1253 TEST_F(GLES2ImplementationTest
, Uniform3iv
) {
1254 GLint data
[2][3] = {{0}};
1256 cmds::Uniform3ivImmediate cmd
;
1261 for (int ii
= 0; ii
< 2; ++ii
) {
1262 for (int jj
= 0; jj
< 3; ++jj
) {
1263 data
[ii
][jj
] = static_cast<GLint
>(ii
* 3 + jj
);
1266 expected
.cmd
.Init(1, 2, &data
[0][0]);
1267 gl_
->Uniform3iv(1, 2, &data
[0][0]);
1268 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1271 TEST_F(GLES2ImplementationTest
, Uniform4f
) {
1273 cmds::Uniform4f cmd
;
1276 expected
.cmd
.Init(1, 2, 3, 4, 5);
1278 gl_
->Uniform4f(1, 2, 3, 4, 5);
1279 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1282 TEST_F(GLES2ImplementationTest
, Uniform4fv
) {
1283 GLfloat data
[2][4] = {{0}};
1285 cmds::Uniform4fvImmediate cmd
;
1290 for (int ii
= 0; ii
< 2; ++ii
) {
1291 for (int jj
= 0; jj
< 4; ++jj
) {
1292 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 4 + jj
);
1295 expected
.cmd
.Init(1, 2, &data
[0][0]);
1296 gl_
->Uniform4fv(1, 2, &data
[0][0]);
1297 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1300 TEST_F(GLES2ImplementationTest
, Uniform4i
) {
1302 cmds::Uniform4i cmd
;
1305 expected
.cmd
.Init(1, 2, 3, 4, 5);
1307 gl_
->Uniform4i(1, 2, 3, 4, 5);
1308 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1311 TEST_F(GLES2ImplementationTest
, Uniform4iv
) {
1312 GLint data
[2][4] = {{0}};
1314 cmds::Uniform4ivImmediate cmd
;
1319 for (int ii
= 0; ii
< 2; ++ii
) {
1320 for (int jj
= 0; jj
< 4; ++jj
) {
1321 data
[ii
][jj
] = static_cast<GLint
>(ii
* 4 + jj
);
1324 expected
.cmd
.Init(1, 2, &data
[0][0]);
1325 gl_
->Uniform4iv(1, 2, &data
[0][0]);
1326 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1329 TEST_F(GLES2ImplementationTest
, UniformMatrix2fv
) {
1330 GLfloat data
[2][4] = {{0}};
1332 cmds::UniformMatrix2fvImmediate cmd
;
1337 for (int ii
= 0; ii
< 2; ++ii
) {
1338 for (int jj
= 0; jj
< 4; ++jj
) {
1339 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 4 + jj
);
1342 expected
.cmd
.Init(1, 2, false, &data
[0][0]);
1343 gl_
->UniformMatrix2fv(1, 2, false, &data
[0][0]);
1344 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1347 TEST_F(GLES2ImplementationTest
, UniformMatrix3fv
) {
1348 GLfloat data
[2][9] = {{0}};
1350 cmds::UniformMatrix3fvImmediate cmd
;
1355 for (int ii
= 0; ii
< 2; ++ii
) {
1356 for (int jj
= 0; jj
< 9; ++jj
) {
1357 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 9 + jj
);
1360 expected
.cmd
.Init(1, 2, false, &data
[0][0]);
1361 gl_
->UniformMatrix3fv(1, 2, false, &data
[0][0]);
1362 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1365 TEST_F(GLES2ImplementationTest
, UniformMatrix4fv
) {
1366 GLfloat data
[2][16] = {{0}};
1368 cmds::UniformMatrix4fvImmediate cmd
;
1369 GLfloat data
[2][16];
1373 for (int ii
= 0; ii
< 2; ++ii
) {
1374 for (int jj
= 0; jj
< 16; ++jj
) {
1375 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 16 + jj
);
1378 expected
.cmd
.Init(1, 2, false, &data
[0][0]);
1379 gl_
->UniformMatrix4fv(1, 2, false, &data
[0][0]);
1380 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1383 TEST_F(GLES2ImplementationTest
, UseProgram
) {
1385 cmds::UseProgram cmd
;
1388 expected
.cmd
.Init(1);
1391 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1394 EXPECT_TRUE(NoCommandsWritten());
1397 TEST_F(GLES2ImplementationTest
, ValidateProgram
) {
1399 cmds::ValidateProgram cmd
;
1402 expected
.cmd
.Init(1);
1404 gl_
->ValidateProgram(1);
1405 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1408 TEST_F(GLES2ImplementationTest
, VertexAttrib1f
) {
1410 cmds::VertexAttrib1f cmd
;
1413 expected
.cmd
.Init(1, 2);
1415 gl_
->VertexAttrib1f(1, 2);
1416 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1419 TEST_F(GLES2ImplementationTest
, VertexAttrib1fv
) {
1420 GLfloat data
[1] = {0};
1422 cmds::VertexAttrib1fvImmediate cmd
;
1426 for (int jj
= 0; jj
< 1; ++jj
) {
1427 data
[jj
] = static_cast<GLfloat
>(jj
);
1430 expected
.cmd
.Init(1, &data
[0]);
1431 gl_
->VertexAttrib1fv(1, &data
[0]);
1432 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1435 TEST_F(GLES2ImplementationTest
, VertexAttrib2f
) {
1437 cmds::VertexAttrib2f cmd
;
1440 expected
.cmd
.Init(1, 2, 3);
1442 gl_
->VertexAttrib2f(1, 2, 3);
1443 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1446 TEST_F(GLES2ImplementationTest
, VertexAttrib2fv
) {
1447 GLfloat data
[2] = {0};
1449 cmds::VertexAttrib2fvImmediate cmd
;
1453 for (int jj
= 0; jj
< 2; ++jj
) {
1454 data
[jj
] = static_cast<GLfloat
>(jj
);
1457 expected
.cmd
.Init(1, &data
[0]);
1458 gl_
->VertexAttrib2fv(1, &data
[0]);
1459 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1462 TEST_F(GLES2ImplementationTest
, VertexAttrib3f
) {
1464 cmds::VertexAttrib3f cmd
;
1467 expected
.cmd
.Init(1, 2, 3, 4);
1469 gl_
->VertexAttrib3f(1, 2, 3, 4);
1470 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1473 TEST_F(GLES2ImplementationTest
, VertexAttrib3fv
) {
1474 GLfloat data
[3] = {0};
1476 cmds::VertexAttrib3fvImmediate cmd
;
1480 for (int jj
= 0; jj
< 3; ++jj
) {
1481 data
[jj
] = static_cast<GLfloat
>(jj
);
1484 expected
.cmd
.Init(1, &data
[0]);
1485 gl_
->VertexAttrib3fv(1, &data
[0]);
1486 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1489 TEST_F(GLES2ImplementationTest
, VertexAttrib4f
) {
1491 cmds::VertexAttrib4f cmd
;
1494 expected
.cmd
.Init(1, 2, 3, 4, 5);
1496 gl_
->VertexAttrib4f(1, 2, 3, 4, 5);
1497 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1500 TEST_F(GLES2ImplementationTest
, VertexAttrib4fv
) {
1501 GLfloat data
[4] = {0};
1503 cmds::VertexAttrib4fvImmediate cmd
;
1507 for (int jj
= 0; jj
< 4; ++jj
) {
1508 data
[jj
] = static_cast<GLfloat
>(jj
);
1511 expected
.cmd
.Init(1, &data
[0]);
1512 gl_
->VertexAttrib4fv(1, &data
[0]);
1513 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1516 TEST_F(GLES2ImplementationTest
, Viewport
) {
1521 expected
.cmd
.Init(1, 2, 3, 4);
1523 gl_
->Viewport(1, 2, 3, 4);
1524 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1527 TEST_F(GLES2ImplementationTest
, BlitFramebufferCHROMIUM
) {
1529 cmds::BlitFramebufferCHROMIUM cmd
;
1532 expected
.cmd
.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST
);
1534 gl_
->BlitFramebufferCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST
);
1535 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1538 TEST_F(GLES2ImplementationTest
, RenderbufferStorageMultisampleCHROMIUM
) {
1540 cmds::RenderbufferStorageMultisampleCHROMIUM cmd
;
1543 expected
.cmd
.Init(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
1545 gl_
->RenderbufferStorageMultisampleCHROMIUM(
1546 GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
1547 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1550 TEST_F(GLES2ImplementationTest
, RenderbufferStorageMultisampleEXT
) {
1552 cmds::RenderbufferStorageMultisampleEXT cmd
;
1555 expected
.cmd
.Init(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
1557 gl_
->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
1558 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1561 TEST_F(GLES2ImplementationTest
, FramebufferTexture2DMultisampleEXT
) {
1563 cmds::FramebufferTexture2DMultisampleEXT cmd
;
1567 GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 4, 0, 6);
1569 gl_
->FramebufferTexture2DMultisampleEXT(
1570 GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 4, 0, 6);
1571 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1574 TEST_F(GLES2ImplementationTest
, TexStorage2DEXT
) {
1576 cmds::TexStorage2DEXT cmd
;
1579 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, GL_RGB565
, 4, 5);
1581 gl_
->TexStorage2DEXT(GL_TEXTURE_2D
, 2, GL_RGB565
, 4, 5);
1582 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1585 TEST_F(GLES2ImplementationTest
, GenQueriesEXT
) {
1586 GLuint ids
[2] = {0, };
1588 cmds::GenQueriesEXTImmediate gen
;
1592 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
1593 expected
.data
[0] = kQueriesStartId
;
1594 expected
.data
[1] = kQueriesStartId
+ 1;
1595 gl_
->GenQueriesEXT(arraysize(ids
), &ids
[0]);
1596 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1597 EXPECT_EQ(kQueriesStartId
, ids
[0]);
1598 EXPECT_EQ(kQueriesStartId
+ 1, ids
[1]);
1601 TEST_F(GLES2ImplementationTest
, DeleteQueriesEXT
) {
1602 GLuint ids
[2] = {kQueriesStartId
, kQueriesStartId
+ 1};
1604 cmds::DeleteQueriesEXTImmediate del
;
1608 expected
.del
.Init(arraysize(ids
), &ids
[0]);
1609 expected
.data
[0] = kQueriesStartId
;
1610 expected
.data
[1] = kQueriesStartId
+ 1;
1611 gl_
->DeleteQueriesEXT(arraysize(ids
), &ids
[0]);
1612 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1614 // TODO: Implement unit test for BeginQueryEXT
1615 // TODO: Implement unit test for InsertEventMarkerEXT
1616 // TODO: Implement unit test for PushGroupMarkerEXT
1618 TEST_F(GLES2ImplementationTest
, PopGroupMarkerEXT
) {
1620 cmds::PopGroupMarkerEXT cmd
;
1623 expected
.cmd
.Init();
1625 gl_
->PopGroupMarkerEXT();
1626 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1629 TEST_F(GLES2ImplementationTest
, GenVertexArraysOES
) {
1630 GLuint ids
[2] = {0, };
1632 cmds::GenVertexArraysOESImmediate gen
;
1636 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
1637 expected
.data
[0] = kVertexArraysStartId
;
1638 expected
.data
[1] = kVertexArraysStartId
+ 1;
1639 gl_
->GenVertexArraysOES(arraysize(ids
), &ids
[0]);
1640 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1641 EXPECT_EQ(kVertexArraysStartId
, ids
[0]);
1642 EXPECT_EQ(kVertexArraysStartId
+ 1, ids
[1]);
1645 TEST_F(GLES2ImplementationTest
, DeleteVertexArraysOES
) {
1646 GLuint ids
[2] = {kVertexArraysStartId
, kVertexArraysStartId
+ 1};
1648 cmds::DeleteVertexArraysOESImmediate del
;
1652 expected
.del
.Init(arraysize(ids
), &ids
[0]);
1653 expected
.data
[0] = kVertexArraysStartId
;
1654 expected
.data
[1] = kVertexArraysStartId
+ 1;
1655 gl_
->DeleteVertexArraysOES(arraysize(ids
), &ids
[0]);
1656 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1659 TEST_F(GLES2ImplementationTest
, IsVertexArrayOES
) {
1661 cmds::IsVertexArrayOES cmd
;
1665 ExpectedMemoryInfo result1
=
1666 GetExpectedResultMemory(sizeof(cmds::IsVertexArrayOES::Result
));
1667 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1669 EXPECT_CALL(*command_buffer(), OnFlush())
1670 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
1671 .RetiresOnSaturation();
1673 GLboolean result
= gl_
->IsVertexArrayOES(1);
1674 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1675 EXPECT_TRUE(result
);
1677 // TODO: Implement unit test for GenSharedIdsCHROMIUM
1678 // TODO: Implement unit test for DeleteSharedIdsCHROMIUM
1679 // TODO: Implement unit test for RegisterSharedIdsCHROMIUM
1680 // TODO: Implement unit test for EnableFeatureCHROMIUM
1682 TEST_F(GLES2ImplementationTest
, ResizeCHROMIUM
) {
1684 cmds::ResizeCHROMIUM cmd
;
1687 expected
.cmd
.Init(1, 2, 3);
1689 gl_
->ResizeCHROMIUM(1, 2, 3);
1690 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1692 // TODO: Implement unit test for GetRequestableExtensionsCHROMIUM
1693 // TODO: Implement unit test for CreateStreamTextureCHROMIUM
1694 // TODO: Implement unit test for GetTranslatedShaderSourceANGLE
1696 TEST_F(GLES2ImplementationTest
, TexImageIOSurface2DCHROMIUM
) {
1698 cmds::TexImageIOSurface2DCHROMIUM cmd
;
1701 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, 3, 4, 5);
1703 gl_
->TexImageIOSurface2DCHROMIUM(GL_TEXTURE_2D
, 2, 3, 4, 5);
1704 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1707 TEST_F(GLES2ImplementationTest
, CopyTextureCHROMIUM
) {
1709 cmds::CopyTextureCHROMIUM cmd
;
1712 expected
.cmd
.Init(1, 2, 3, 4, GL_ALPHA
, GL_UNSIGNED_BYTE
);
1714 gl_
->CopyTextureCHROMIUM(1, 2, 3, 4, GL_ALPHA
, GL_UNSIGNED_BYTE
);
1715 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1718 TEST_F(GLES2ImplementationTest
, DrawArraysInstancedANGLE
) {
1720 cmds::DrawArraysInstancedANGLE cmd
;
1723 expected
.cmd
.Init(GL_POINTS
, 2, 3, 4);
1725 gl_
->DrawArraysInstancedANGLE(GL_POINTS
, 2, 3, 4);
1726 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1729 TEST_F(GLES2ImplementationTest
, VertexAttribDivisorANGLE
) {
1731 cmds::VertexAttribDivisorANGLE cmd
;
1734 expected
.cmd
.Init(1, 2);
1736 gl_
->VertexAttribDivisorANGLE(1, 2);
1737 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1739 // TODO: Implement unit test for GenMailboxCHROMIUM
1740 // TODO: Implement unit test for BindUniformLocationCHROMIUM
1742 TEST_F(GLES2ImplementationTest
, BindTexImage2DCHROMIUM
) {
1744 cmds::BindTexImage2DCHROMIUM cmd
;
1747 expected
.cmd
.Init(GL_TEXTURE_2D
, 2);
1749 gl_
->BindTexImage2DCHROMIUM(GL_TEXTURE_2D
, 2);
1750 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1753 TEST_F(GLES2ImplementationTest
, ReleaseTexImage2DCHROMIUM
) {
1755 cmds::ReleaseTexImage2DCHROMIUM cmd
;
1758 expected
.cmd
.Init(GL_TEXTURE_2D
, 2);
1760 gl_
->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D
, 2);
1761 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1764 TEST_F(GLES2ImplementationTest
, DiscardFramebufferEXT
) {
1765 GLenum data
[2][1] = {{0}};
1767 cmds::DiscardFramebufferEXTImmediate cmd
;
1772 for (int ii
= 0; ii
< 2; ++ii
) {
1773 for (int jj
= 0; jj
< 1; ++jj
) {
1774 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
1777 expected
.cmd
.Init(1, 2, &data
[0][0]);
1778 gl_
->DiscardFramebufferEXT(1, 2, &data
[0][0]);
1779 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1782 TEST_F(GLES2ImplementationTest
, LoseContextCHROMIUM
) {
1784 cmds::LoseContextCHROMIUM cmd
;
1787 expected
.cmd
.Init(1, 2);
1789 gl_
->LoseContextCHROMIUM(1, 2);
1790 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1792 // TODO: Implement unit test for InsertSyncPointCHROMIUM
1794 TEST_F(GLES2ImplementationTest
, WaitSyncPointCHROMIUM
) {
1796 cmds::WaitSyncPointCHROMIUM cmd
;
1799 expected
.cmd
.Init(1);
1801 gl_
->WaitSyncPointCHROMIUM(1);
1802 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1805 TEST_F(GLES2ImplementationTest
, DrawBuffersEXT
) {
1806 GLenum data
[1][1] = {{0}};
1808 cmds::DrawBuffersEXTImmediate cmd
;
1813 for (int ii
= 0; ii
< 1; ++ii
) {
1814 for (int jj
= 0; jj
< 1; ++jj
) {
1815 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
1818 expected
.cmd
.Init(1, &data
[0][0]);
1819 gl_
->DrawBuffersEXT(1, &data
[0][0]);
1820 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1823 TEST_F(GLES2ImplementationTest
, DiscardBackbufferCHROMIUM
) {
1825 cmds::DiscardBackbufferCHROMIUM cmd
;
1828 expected
.cmd
.Init();
1830 gl_
->DiscardBackbufferCHROMIUM();
1831 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1833 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_