1 // Copyright (c) 2012 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
9 // This file is included by gles2_implementation.h to declare the
11 #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_
12 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_
15 TEST_F(GLES2ImplementationTest
, AttachShader
) {
17 cmds::AttachShader cmd
;
20 expected
.cmd
.Init(1, 2);
22 gl_
->AttachShader(1, 2);
23 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
25 // TODO: Implement unit test for BindAttribLocation
27 TEST_F(GLES2ImplementationTest
, BindBuffer
) {
32 expected
.cmd
.Init(GL_ARRAY_BUFFER
, 2);
34 gl_
->BindBuffer(GL_ARRAY_BUFFER
, 2);
35 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
37 gl_
->BindBuffer(GL_ARRAY_BUFFER
, 2);
38 EXPECT_TRUE(NoCommandsWritten());
41 TEST_F(GLES2ImplementationTest
, BindFramebuffer
) {
43 cmds::BindFramebuffer cmd
;
46 expected
.cmd
.Init(GL_FRAMEBUFFER
, 2);
48 gl_
->BindFramebuffer(GL_FRAMEBUFFER
, 2);
49 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
51 gl_
->BindFramebuffer(GL_FRAMEBUFFER
, 2);
52 EXPECT_TRUE(NoCommandsWritten());
55 TEST_F(GLES2ImplementationTest
, BindRenderbuffer
) {
57 cmds::BindRenderbuffer cmd
;
60 expected
.cmd
.Init(GL_RENDERBUFFER
, 2);
62 gl_
->BindRenderbuffer(GL_RENDERBUFFER
, 2);
63 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
65 gl_
->BindRenderbuffer(GL_RENDERBUFFER
, 2);
66 EXPECT_TRUE(NoCommandsWritten());
69 TEST_F(GLES2ImplementationTest
, BlendColor
) {
74 expected
.cmd
.Init(1, 2, 3, 4);
76 gl_
->BlendColor(1, 2, 3, 4);
77 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
80 TEST_F(GLES2ImplementationTest
, BlendEquation
) {
82 cmds::BlendEquation cmd
;
85 expected
.cmd
.Init(GL_FUNC_SUBTRACT
);
87 gl_
->BlendEquation(GL_FUNC_SUBTRACT
);
88 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
91 TEST_F(GLES2ImplementationTest
, BlendEquationSeparate
) {
93 cmds::BlendEquationSeparate cmd
;
96 expected
.cmd
.Init(GL_FUNC_SUBTRACT
, GL_FUNC_ADD
);
98 gl_
->BlendEquationSeparate(GL_FUNC_SUBTRACT
, GL_FUNC_ADD
);
99 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
102 TEST_F(GLES2ImplementationTest
, BlendFunc
) {
107 expected
.cmd
.Init(GL_ZERO
, GL_ZERO
);
109 gl_
->BlendFunc(GL_ZERO
, GL_ZERO
);
110 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
113 TEST_F(GLES2ImplementationTest
, BlendFuncSeparate
) {
115 cmds::BlendFuncSeparate cmd
;
118 expected
.cmd
.Init(GL_ZERO
, GL_ZERO
, GL_ZERO
, GL_ZERO
);
120 gl_
->BlendFuncSeparate(GL_ZERO
, GL_ZERO
, GL_ZERO
, GL_ZERO
);
121 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
124 TEST_F(GLES2ImplementationTest
, CheckFramebufferStatus
) {
126 cmds::CheckFramebufferStatus cmd
;
129 typedef cmds::CheckFramebufferStatus::Result Result
;
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);
585 123, GL_COLOR_ATTACHMENT0
, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
,
586 result1
.id
, result1
.offset
);
587 EXPECT_CALL(*command_buffer(), OnFlush())
588 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
589 .RetiresOnSaturation();
590 gl_
->GetFramebufferAttachmentParameteriv(
591 123, GL_COLOR_ATTACHMENT0
, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
,
593 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
594 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
597 TEST_F(GLES2ImplementationTest
, GetIntegerv
) {
599 cmds::GetIntegerv cmd
;
601 typedef cmds::GetIntegerv::Result Result
;
602 Result::Type result
= 0;
604 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
605 expected
.cmd
.Init(123, result1
.id
, result1
.offset
);
606 EXPECT_CALL(*command_buffer(), OnFlush())
607 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
608 .RetiresOnSaturation();
609 gl_
->GetIntegerv(123, &result
);
610 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
611 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
614 TEST_F(GLES2ImplementationTest
, GetProgramiv
) {
616 cmds::GetProgramiv cmd
;
618 typedef cmds::GetProgramiv::Result Result
;
619 Result::Type result
= 0;
621 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
622 expected
.cmd
.Init(123, GL_DELETE_STATUS
, result1
.id
, result1
.offset
);
623 EXPECT_CALL(*command_buffer(), OnFlush())
624 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
625 .RetiresOnSaturation();
626 gl_
->GetProgramiv(123, GL_DELETE_STATUS
, &result
);
627 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
628 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
630 // TODO: Implement unit test for GetProgramInfoLog
632 TEST_F(GLES2ImplementationTest
, GetRenderbufferParameteriv
) {
634 cmds::GetRenderbufferParameteriv cmd
;
636 typedef cmds::GetRenderbufferParameteriv::Result Result
;
637 Result::Type result
= 0;
639 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
640 expected
.cmd
.Init(123, GL_RENDERBUFFER_RED_SIZE
, result1
.id
, result1
.offset
);
641 EXPECT_CALL(*command_buffer(), OnFlush())
642 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
643 .RetiresOnSaturation();
644 gl_
->GetRenderbufferParameteriv(123, GL_RENDERBUFFER_RED_SIZE
, &result
);
645 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
646 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
649 TEST_F(GLES2ImplementationTest
, GetShaderiv
) {
651 cmds::GetShaderiv cmd
;
653 typedef cmds::GetShaderiv::Result Result
;
654 Result::Type result
= 0;
656 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
657 expected
.cmd
.Init(123, GL_SHADER_TYPE
, result1
.id
, result1
.offset
);
658 EXPECT_CALL(*command_buffer(), OnFlush())
659 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
660 .RetiresOnSaturation();
661 gl_
->GetShaderiv(123, GL_SHADER_TYPE
, &result
);
662 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
663 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
665 // TODO: Implement unit test for GetShaderInfoLog
666 // TODO: Implement unit test for GetShaderPrecisionFormat
668 TEST_F(GLES2ImplementationTest
, GetTexParameterfv
) {
670 cmds::GetTexParameterfv cmd
;
672 typedef cmds::GetTexParameterfv::Result Result
;
673 Result::Type result
= 0;
675 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
676 expected
.cmd
.Init(123, GL_TEXTURE_MAG_FILTER
, result1
.id
, result1
.offset
);
677 EXPECT_CALL(*command_buffer(), OnFlush())
678 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
679 .RetiresOnSaturation();
680 gl_
->GetTexParameterfv(123, GL_TEXTURE_MAG_FILTER
, &result
);
681 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
682 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
685 TEST_F(GLES2ImplementationTest
, GetTexParameteriv
) {
687 cmds::GetTexParameteriv cmd
;
689 typedef cmds::GetTexParameteriv::Result Result
;
690 Result::Type result
= 0;
692 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
693 expected
.cmd
.Init(123, GL_TEXTURE_MAG_FILTER
, result1
.id
, result1
.offset
);
694 EXPECT_CALL(*command_buffer(), OnFlush())
695 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
696 .RetiresOnSaturation();
697 gl_
->GetTexParameteriv(123, GL_TEXTURE_MAG_FILTER
, &result
);
698 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
699 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
701 // TODO: Implement unit test for GetUniformfv
702 // TODO: Implement unit test for GetUniformiv
703 // TODO: Implement unit test for GetUniformLocation
705 TEST_F(GLES2ImplementationTest
, GetVertexAttribfv
) {
707 cmds::GetVertexAttribfv cmd
;
709 typedef cmds::GetVertexAttribfv::Result Result
;
710 Result::Type result
= 0;
712 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
714 123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, result1
.id
, result1
.offset
);
715 EXPECT_CALL(*command_buffer(), OnFlush())
716 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
717 .RetiresOnSaturation();
718 gl_
->GetVertexAttribfv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, &result
);
719 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
720 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
723 TEST_F(GLES2ImplementationTest
, GetVertexAttribiv
) {
725 cmds::GetVertexAttribiv cmd
;
727 typedef cmds::GetVertexAttribiv::Result Result
;
728 Result::Type result
= 0;
730 ExpectedMemoryInfo result1
= GetExpectedResultMemory(4);
732 123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, result1
.id
, result1
.offset
);
733 EXPECT_CALL(*command_buffer(), OnFlush())
734 .WillOnce(SetMemory(result1
.ptr
, SizedResultHelper
<Result::Type
>(1)))
735 .RetiresOnSaturation();
736 gl_
->GetVertexAttribiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
, &result
);
737 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
738 EXPECT_EQ(static_cast<Result::Type
>(1), result
);
741 TEST_F(GLES2ImplementationTest
, Hint
) {
746 expected
.cmd
.Init(GL_GENERATE_MIPMAP_HINT
, GL_FASTEST
);
748 gl_
->Hint(GL_GENERATE_MIPMAP_HINT
, GL_FASTEST
);
749 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
752 TEST_F(GLES2ImplementationTest
, IsBuffer
) {
757 typedef cmds::IsBuffer::Result Result
;
759 ExpectedMemoryInfo result1
=
760 GetExpectedResultMemory(sizeof(cmds::IsBuffer::Result
));
761 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
763 EXPECT_CALL(*command_buffer(), OnFlush())
764 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
765 .RetiresOnSaturation();
767 GLboolean result
= gl_
->IsBuffer(1);
768 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
772 TEST_F(GLES2ImplementationTest
, IsEnabled
) {
777 typedef cmds::IsEnabled::Result Result
;
779 ExpectedMemoryInfo result1
=
780 GetExpectedResultMemory(sizeof(cmds::IsEnabled::Result
));
781 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
783 EXPECT_CALL(*command_buffer(), OnFlush())
784 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
785 .RetiresOnSaturation();
787 GLboolean result
= gl_
->IsEnabled(1);
788 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
792 TEST_F(GLES2ImplementationTest
, IsFramebuffer
) {
794 cmds::IsFramebuffer cmd
;
797 typedef cmds::IsFramebuffer::Result Result
;
799 ExpectedMemoryInfo result1
=
800 GetExpectedResultMemory(sizeof(cmds::IsFramebuffer::Result
));
801 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
803 EXPECT_CALL(*command_buffer(), OnFlush())
804 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
805 .RetiresOnSaturation();
807 GLboolean result
= gl_
->IsFramebuffer(1);
808 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
812 TEST_F(GLES2ImplementationTest
, IsProgram
) {
817 typedef cmds::IsProgram::Result Result
;
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
;
837 typedef cmds::IsRenderbuffer::Result Result
;
839 ExpectedMemoryInfo result1
=
840 GetExpectedResultMemory(sizeof(cmds::IsRenderbuffer::Result
));
841 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
843 EXPECT_CALL(*command_buffer(), OnFlush())
844 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
845 .RetiresOnSaturation();
847 GLboolean result
= gl_
->IsRenderbuffer(1);
848 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
852 TEST_F(GLES2ImplementationTest
, IsShader
) {
857 typedef cmds::IsShader::Result Result
;
859 ExpectedMemoryInfo result1
=
860 GetExpectedResultMemory(sizeof(cmds::IsShader::Result
));
861 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
863 EXPECT_CALL(*command_buffer(), OnFlush())
864 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
865 .RetiresOnSaturation();
867 GLboolean result
= gl_
->IsShader(1);
868 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
872 TEST_F(GLES2ImplementationTest
, IsTexture
) {
877 typedef cmds::IsTexture::Result Result
;
879 ExpectedMemoryInfo result1
=
880 GetExpectedResultMemory(sizeof(cmds::IsTexture::Result
));
881 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
883 EXPECT_CALL(*command_buffer(), OnFlush())
884 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
885 .RetiresOnSaturation();
887 GLboolean result
= gl_
->IsTexture(1);
888 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
892 TEST_F(GLES2ImplementationTest
, LineWidth
) {
897 expected
.cmd
.Init(1);
900 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
903 TEST_F(GLES2ImplementationTest
, LinkProgram
) {
905 cmds::LinkProgram cmd
;
908 expected
.cmd
.Init(1);
911 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
914 TEST_F(GLES2ImplementationTest
, PixelStorei
) {
916 cmds::PixelStorei cmd
;
919 expected
.cmd
.Init(GL_PACK_ALIGNMENT
, 1);
921 gl_
->PixelStorei(GL_PACK_ALIGNMENT
, 1);
922 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
925 TEST_F(GLES2ImplementationTest
, PolygonOffset
) {
927 cmds::PolygonOffset cmd
;
930 expected
.cmd
.Init(1, 2);
932 gl_
->PolygonOffset(1, 2);
933 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
936 TEST_F(GLES2ImplementationTest
, ReleaseShaderCompiler
) {
938 cmds::ReleaseShaderCompiler cmd
;
943 gl_
->ReleaseShaderCompiler();
944 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
947 TEST_F(GLES2ImplementationTest
, RenderbufferStorage
) {
949 cmds::RenderbufferStorage cmd
;
952 expected
.cmd
.Init(GL_RENDERBUFFER
, GL_RGBA4
, 3, 4);
954 gl_
->RenderbufferStorage(GL_RENDERBUFFER
, GL_RGBA4
, 3, 4);
955 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
958 TEST_F(GLES2ImplementationTest
, SampleCoverage
) {
960 cmds::SampleCoverage cmd
;
963 expected
.cmd
.Init(1, true);
965 gl_
->SampleCoverage(1, true);
966 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
969 TEST_F(GLES2ImplementationTest
, Scissor
) {
974 expected
.cmd
.Init(1, 2, 3, 4);
976 gl_
->Scissor(1, 2, 3, 4);
977 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
980 TEST_F(GLES2ImplementationTest
, StencilFunc
) {
982 cmds::StencilFunc cmd
;
985 expected
.cmd
.Init(GL_NEVER
, 2, 3);
987 gl_
->StencilFunc(GL_NEVER
, 2, 3);
988 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
991 TEST_F(GLES2ImplementationTest
, StencilFuncSeparate
) {
993 cmds::StencilFuncSeparate cmd
;
996 expected
.cmd
.Init(GL_FRONT
, GL_NEVER
, 3, 4);
998 gl_
->StencilFuncSeparate(GL_FRONT
, GL_NEVER
, 3, 4);
999 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1002 TEST_F(GLES2ImplementationTest
, StencilMask
) {
1004 cmds::StencilMask cmd
;
1007 expected
.cmd
.Init(1);
1009 gl_
->StencilMask(1);
1010 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1013 TEST_F(GLES2ImplementationTest
, StencilMaskSeparate
) {
1015 cmds::StencilMaskSeparate cmd
;
1018 expected
.cmd
.Init(GL_FRONT
, 2);
1020 gl_
->StencilMaskSeparate(GL_FRONT
, 2);
1021 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1024 TEST_F(GLES2ImplementationTest
, StencilOp
) {
1026 cmds::StencilOp cmd
;
1029 expected
.cmd
.Init(GL_KEEP
, GL_INCR
, GL_KEEP
);
1031 gl_
->StencilOp(GL_KEEP
, GL_INCR
, GL_KEEP
);
1032 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1035 TEST_F(GLES2ImplementationTest
, StencilOpSeparate
) {
1037 cmds::StencilOpSeparate cmd
;
1040 expected
.cmd
.Init(GL_FRONT
, GL_INCR
, GL_KEEP
, GL_KEEP
);
1042 gl_
->StencilOpSeparate(GL_FRONT
, GL_INCR
, GL_KEEP
, GL_KEEP
);
1043 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1046 TEST_F(GLES2ImplementationTest
, TexParameterf
) {
1048 cmds::TexParameterf cmd
;
1051 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, 3);
1053 gl_
->TexParameterf(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, 3);
1054 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1057 TEST_F(GLES2ImplementationTest
, TexParameterfv
) {
1058 GLfloat data
[1] = {0};
1060 cmds::TexParameterfvImmediate cmd
;
1064 for (int jj
= 0; jj
< 1; ++jj
) {
1065 data
[jj
] = static_cast<GLfloat
>(jj
);
1068 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1069 gl_
->TexParameterfv(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1070 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1073 TEST_F(GLES2ImplementationTest
, TexParameteri
) {
1075 cmds::TexParameteri cmd
;
1078 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, 3);
1080 gl_
->TexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, 3);
1081 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1084 TEST_F(GLES2ImplementationTest
, TexParameteriv
) {
1085 GLint data
[1] = {0};
1087 cmds::TexParameterivImmediate cmd
;
1091 for (int jj
= 0; jj
< 1; ++jj
) {
1092 data
[jj
] = static_cast<GLint
>(jj
);
1095 expected
.cmd
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1096 gl_
->TexParameteriv(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, &data
[0]);
1097 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1100 TEST_F(GLES2ImplementationTest
, Uniform1f
) {
1102 cmds::Uniform1f cmd
;
1105 expected
.cmd
.Init(1, 2);
1107 gl_
->Uniform1f(1, 2);
1108 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1111 TEST_F(GLES2ImplementationTest
, Uniform1fv
) {
1112 GLfloat data
[2][1] = {{0}};
1114 cmds::Uniform1fvImmediate cmd
;
1119 for (int ii
= 0; ii
< 2; ++ii
) {
1120 for (int jj
= 0; jj
< 1; ++jj
) {
1121 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 1 + jj
);
1124 expected
.cmd
.Init(1, 2, &data
[0][0]);
1125 gl_
->Uniform1fv(1, 2, &data
[0][0]);
1126 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1129 TEST_F(GLES2ImplementationTest
, Uniform1i
) {
1131 cmds::Uniform1i cmd
;
1134 expected
.cmd
.Init(1, 2);
1136 gl_
->Uniform1i(1, 2);
1137 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1140 TEST_F(GLES2ImplementationTest
, Uniform1iv
) {
1141 GLint data
[2][1] = {{0}};
1143 cmds::Uniform1ivImmediate cmd
;
1148 for (int ii
= 0; ii
< 2; ++ii
) {
1149 for (int jj
= 0; jj
< 1; ++jj
) {
1150 data
[ii
][jj
] = static_cast<GLint
>(ii
* 1 + jj
);
1153 expected
.cmd
.Init(1, 2, &data
[0][0]);
1154 gl_
->Uniform1iv(1, 2, &data
[0][0]);
1155 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1158 TEST_F(GLES2ImplementationTest
, Uniform2f
) {
1160 cmds::Uniform2f cmd
;
1163 expected
.cmd
.Init(1, 2, 3);
1165 gl_
->Uniform2f(1, 2, 3);
1166 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1169 TEST_F(GLES2ImplementationTest
, Uniform2fv
) {
1170 GLfloat data
[2][2] = {{0}};
1172 cmds::Uniform2fvImmediate cmd
;
1177 for (int ii
= 0; ii
< 2; ++ii
) {
1178 for (int jj
= 0; jj
< 2; ++jj
) {
1179 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 2 + jj
);
1182 expected
.cmd
.Init(1, 2, &data
[0][0]);
1183 gl_
->Uniform2fv(1, 2, &data
[0][0]);
1184 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1187 TEST_F(GLES2ImplementationTest
, Uniform2i
) {
1189 cmds::Uniform2i cmd
;
1192 expected
.cmd
.Init(1, 2, 3);
1194 gl_
->Uniform2i(1, 2, 3);
1195 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1198 TEST_F(GLES2ImplementationTest
, Uniform2iv
) {
1199 GLint data
[2][2] = {{0}};
1201 cmds::Uniform2ivImmediate cmd
;
1206 for (int ii
= 0; ii
< 2; ++ii
) {
1207 for (int jj
= 0; jj
< 2; ++jj
) {
1208 data
[ii
][jj
] = static_cast<GLint
>(ii
* 2 + jj
);
1211 expected
.cmd
.Init(1, 2, &data
[0][0]);
1212 gl_
->Uniform2iv(1, 2, &data
[0][0]);
1213 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1216 TEST_F(GLES2ImplementationTest
, Uniform3f
) {
1218 cmds::Uniform3f cmd
;
1221 expected
.cmd
.Init(1, 2, 3, 4);
1223 gl_
->Uniform3f(1, 2, 3, 4);
1224 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1227 TEST_F(GLES2ImplementationTest
, Uniform3fv
) {
1228 GLfloat data
[2][3] = {{0}};
1230 cmds::Uniform3fvImmediate cmd
;
1235 for (int ii
= 0; ii
< 2; ++ii
) {
1236 for (int jj
= 0; jj
< 3; ++jj
) {
1237 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 3 + jj
);
1240 expected
.cmd
.Init(1, 2, &data
[0][0]);
1241 gl_
->Uniform3fv(1, 2, &data
[0][0]);
1242 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1245 TEST_F(GLES2ImplementationTest
, Uniform3i
) {
1247 cmds::Uniform3i cmd
;
1250 expected
.cmd
.Init(1, 2, 3, 4);
1252 gl_
->Uniform3i(1, 2, 3, 4);
1253 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1256 TEST_F(GLES2ImplementationTest
, Uniform3iv
) {
1257 GLint data
[2][3] = {{0}};
1259 cmds::Uniform3ivImmediate cmd
;
1264 for (int ii
= 0; ii
< 2; ++ii
) {
1265 for (int jj
= 0; jj
< 3; ++jj
) {
1266 data
[ii
][jj
] = static_cast<GLint
>(ii
* 3 + jj
);
1269 expected
.cmd
.Init(1, 2, &data
[0][0]);
1270 gl_
->Uniform3iv(1, 2, &data
[0][0]);
1271 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1274 TEST_F(GLES2ImplementationTest
, Uniform4f
) {
1276 cmds::Uniform4f cmd
;
1279 expected
.cmd
.Init(1, 2, 3, 4, 5);
1281 gl_
->Uniform4f(1, 2, 3, 4, 5);
1282 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1285 TEST_F(GLES2ImplementationTest
, Uniform4fv
) {
1286 GLfloat data
[2][4] = {{0}};
1288 cmds::Uniform4fvImmediate cmd
;
1293 for (int ii
= 0; ii
< 2; ++ii
) {
1294 for (int jj
= 0; jj
< 4; ++jj
) {
1295 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 4 + jj
);
1298 expected
.cmd
.Init(1, 2, &data
[0][0]);
1299 gl_
->Uniform4fv(1, 2, &data
[0][0]);
1300 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1303 TEST_F(GLES2ImplementationTest
, Uniform4i
) {
1305 cmds::Uniform4i cmd
;
1308 expected
.cmd
.Init(1, 2, 3, 4, 5);
1310 gl_
->Uniform4i(1, 2, 3, 4, 5);
1311 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1314 TEST_F(GLES2ImplementationTest
, Uniform4iv
) {
1315 GLint data
[2][4] = {{0}};
1317 cmds::Uniform4ivImmediate cmd
;
1322 for (int ii
= 0; ii
< 2; ++ii
) {
1323 for (int jj
= 0; jj
< 4; ++jj
) {
1324 data
[ii
][jj
] = static_cast<GLint
>(ii
* 4 + jj
);
1327 expected
.cmd
.Init(1, 2, &data
[0][0]);
1328 gl_
->Uniform4iv(1, 2, &data
[0][0]);
1329 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1332 TEST_F(GLES2ImplementationTest
, UniformMatrix2fv
) {
1333 GLfloat data
[2][4] = {{0}};
1335 cmds::UniformMatrix2fvImmediate cmd
;
1340 for (int ii
= 0; ii
< 2; ++ii
) {
1341 for (int jj
= 0; jj
< 4; ++jj
) {
1342 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 4 + jj
);
1345 expected
.cmd
.Init(1, 2, false, &data
[0][0]);
1346 gl_
->UniformMatrix2fv(1, 2, false, &data
[0][0]);
1347 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1350 TEST_F(GLES2ImplementationTest
, UniformMatrix3fv
) {
1351 GLfloat data
[2][9] = {{0}};
1353 cmds::UniformMatrix3fvImmediate cmd
;
1358 for (int ii
= 0; ii
< 2; ++ii
) {
1359 for (int jj
= 0; jj
< 9; ++jj
) {
1360 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 9 + jj
);
1363 expected
.cmd
.Init(1, 2, false, &data
[0][0]);
1364 gl_
->UniformMatrix3fv(1, 2, false, &data
[0][0]);
1365 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1368 TEST_F(GLES2ImplementationTest
, UniformMatrix4fv
) {
1369 GLfloat data
[2][16] = {{0}};
1371 cmds::UniformMatrix4fvImmediate cmd
;
1372 GLfloat data
[2][16];
1376 for (int ii
= 0; ii
< 2; ++ii
) {
1377 for (int jj
= 0; jj
< 16; ++jj
) {
1378 data
[ii
][jj
] = static_cast<GLfloat
>(ii
* 16 + jj
);
1381 expected
.cmd
.Init(1, 2, false, &data
[0][0]);
1382 gl_
->UniformMatrix4fv(1, 2, false, &data
[0][0]);
1383 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1386 TEST_F(GLES2ImplementationTest
, UseProgram
) {
1388 cmds::UseProgram cmd
;
1391 expected
.cmd
.Init(1);
1394 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
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
, BlitFramebufferEXT
) {
1529 cmds::BlitFramebufferEXT cmd
;
1532 expected
.cmd
.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST
);
1534 gl_
->BlitFramebufferEXT(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST
);
1535 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1538 TEST_F(GLES2ImplementationTest
, RenderbufferStorageMultisampleEXT
) {
1540 cmds::RenderbufferStorageMultisampleEXT cmd
;
1543 expected
.cmd
.Init(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
1545 gl_
->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER
, 2, GL_RGBA4
, 4, 5);
1546 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1549 TEST_F(GLES2ImplementationTest
, FramebufferTexture2DMultisampleEXT
) {
1551 cmds::FramebufferTexture2DMultisampleEXT cmd
;
1555 GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 4, 0, 6);
1557 gl_
->FramebufferTexture2DMultisampleEXT(
1558 GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 4, 0, 6);
1559 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1562 TEST_F(GLES2ImplementationTest
, TexStorage2DEXT
) {
1564 cmds::TexStorage2DEXT cmd
;
1567 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, GL_RGB565
, 4, 5);
1569 gl_
->TexStorage2DEXT(GL_TEXTURE_2D
, 2, GL_RGB565
, 4, 5);
1570 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1573 TEST_F(GLES2ImplementationTest
, GenQueriesEXT
) {
1574 GLuint ids
[2] = { 0, };
1576 cmds::GenQueriesEXTImmediate gen
;
1580 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
1581 expected
.data
[0] = kQueriesStartId
;
1582 expected
.data
[1] = kQueriesStartId
+ 1;
1583 gl_
->GenQueriesEXT(arraysize(ids
), &ids
[0]);
1584 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1585 EXPECT_EQ(kQueriesStartId
, ids
[0]);
1586 EXPECT_EQ(kQueriesStartId
+ 1, ids
[1]);
1589 TEST_F(GLES2ImplementationTest
, DeleteQueriesEXT
) {
1590 GLuint ids
[2] = { kQueriesStartId
, kQueriesStartId
+ 1 };
1592 cmds::DeleteQueriesEXTImmediate del
;
1596 expected
.del
.Init(arraysize(ids
), &ids
[0]);
1597 expected
.data
[0] = kQueriesStartId
;
1598 expected
.data
[1] = kQueriesStartId
+ 1;
1599 gl_
->DeleteQueriesEXT(arraysize(ids
), &ids
[0]);
1600 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1602 // TODO: Implement unit test for BeginQueryEXT
1603 // TODO: Implement unit test for InsertEventMarkerEXT
1604 // TODO: Implement unit test for PushGroupMarkerEXT
1606 TEST_F(GLES2ImplementationTest
, PopGroupMarkerEXT
) {
1608 cmds::PopGroupMarkerEXT cmd
;
1611 expected
.cmd
.Init();
1613 gl_
->PopGroupMarkerEXT();
1614 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1617 TEST_F(GLES2ImplementationTest
, GenVertexArraysOES
) {
1618 GLuint ids
[2] = { 0, };
1620 cmds::GenVertexArraysOESImmediate gen
;
1624 expected
.gen
.Init(arraysize(ids
), &ids
[0]);
1625 expected
.data
[0] = kVertexArraysStartId
;
1626 expected
.data
[1] = kVertexArraysStartId
+ 1;
1627 gl_
->GenVertexArraysOES(arraysize(ids
), &ids
[0]);
1628 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1629 EXPECT_EQ(kVertexArraysStartId
, ids
[0]);
1630 EXPECT_EQ(kVertexArraysStartId
+ 1, ids
[1]);
1633 TEST_F(GLES2ImplementationTest
, DeleteVertexArraysOES
) {
1634 GLuint ids
[2] = { kVertexArraysStartId
, kVertexArraysStartId
+ 1 };
1636 cmds::DeleteVertexArraysOESImmediate del
;
1640 expected
.del
.Init(arraysize(ids
), &ids
[0]);
1641 expected
.data
[0] = kVertexArraysStartId
;
1642 expected
.data
[1] = kVertexArraysStartId
+ 1;
1643 gl_
->DeleteVertexArraysOES(arraysize(ids
), &ids
[0]);
1644 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1647 TEST_F(GLES2ImplementationTest
, IsVertexArrayOES
) {
1649 cmds::IsVertexArrayOES cmd
;
1652 typedef cmds::IsVertexArrayOES::Result Result
;
1654 ExpectedMemoryInfo result1
=
1655 GetExpectedResultMemory(sizeof(cmds::IsVertexArrayOES::Result
));
1656 expected
.cmd
.Init(1, result1
.id
, result1
.offset
);
1658 EXPECT_CALL(*command_buffer(), OnFlush())
1659 .WillOnce(SetMemory(result1
.ptr
, uint32(1)))
1660 .RetiresOnSaturation();
1662 GLboolean result
= gl_
->IsVertexArrayOES(1);
1663 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1664 EXPECT_TRUE(result
);
1666 // TODO: Implement unit test for GenSharedIdsCHROMIUM
1667 // TODO: Implement unit test for DeleteSharedIdsCHROMIUM
1668 // TODO: Implement unit test for RegisterSharedIdsCHROMIUM
1669 // TODO: Implement unit test for EnableFeatureCHROMIUM
1671 TEST_F(GLES2ImplementationTest
, ResizeCHROMIUM
) {
1673 cmds::ResizeCHROMIUM cmd
;
1676 expected
.cmd
.Init(1, 2, 3);
1678 gl_
->ResizeCHROMIUM(1, 2, 3);
1679 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1681 // TODO: Implement unit test for GetRequestableExtensionsCHROMIUM
1683 TEST_F(GLES2ImplementationTest
, DestroyStreamTextureCHROMIUM
) {
1685 cmds::DestroyStreamTextureCHROMIUM cmd
;
1688 expected
.cmd
.Init(1);
1690 gl_
->DestroyStreamTextureCHROMIUM(1);
1691 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1693 // TODO: Implement unit test for GetTranslatedShaderSourceANGLE
1695 TEST_F(GLES2ImplementationTest
, TexImageIOSurface2DCHROMIUM
) {
1697 cmds::TexImageIOSurface2DCHROMIUM cmd
;
1700 expected
.cmd
.Init(GL_TEXTURE_2D
, 2, 3, 4, 5);
1702 gl_
->TexImageIOSurface2DCHROMIUM(GL_TEXTURE_2D
, 2, 3, 4, 5);
1703 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1706 TEST_F(GLES2ImplementationTest
, CopyTextureCHROMIUM
) {
1708 cmds::CopyTextureCHROMIUM cmd
;
1711 expected
.cmd
.Init(1, 2, 3, 4, GL_ALPHA
, GL_UNSIGNED_BYTE
);
1713 gl_
->CopyTextureCHROMIUM(1, 2, 3, 4, GL_ALPHA
, GL_UNSIGNED_BYTE
);
1714 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1717 TEST_F(GLES2ImplementationTest
, DrawArraysInstancedANGLE
) {
1719 cmds::DrawArraysInstancedANGLE cmd
;
1722 expected
.cmd
.Init(GL_POINTS
, 2, 3, 4);
1724 gl_
->DrawArraysInstancedANGLE(GL_POINTS
, 2, 3, 4);
1725 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1728 TEST_F(GLES2ImplementationTest
, VertexAttribDivisorANGLE
) {
1730 cmds::VertexAttribDivisorANGLE cmd
;
1733 expected
.cmd
.Init(1, 2);
1735 gl_
->VertexAttribDivisorANGLE(1, 2);
1736 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1739 TEST_F(GLES2ImplementationTest
, ProduceTextureCHROMIUM
) {
1740 GLbyte data
[64] = {0};
1742 cmds::ProduceTextureCHROMIUMImmediate cmd
;
1746 for (int jj
= 0; jj
< 64; ++jj
) {
1747 data
[jj
] = static_cast<GLbyte
>(jj
);
1750 expected
.cmd
.Init(GL_TEXTURE_2D
, &data
[0]);
1751 gl_
->ProduceTextureCHROMIUM(GL_TEXTURE_2D
, &data
[0]);
1752 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1755 TEST_F(GLES2ImplementationTest
, ConsumeTextureCHROMIUM
) {
1756 GLbyte data
[64] = {0};
1758 cmds::ConsumeTextureCHROMIUMImmediate cmd
;
1762 for (int jj
= 0; jj
< 64; ++jj
) {
1763 data
[jj
] = static_cast<GLbyte
>(jj
);
1766 expected
.cmd
.Init(GL_TEXTURE_2D
, &data
[0]);
1767 gl_
->ConsumeTextureCHROMIUM(GL_TEXTURE_2D
, &data
[0]);
1768 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1770 // TODO: Implement unit test for BindUniformLocationCHROMIUM
1772 TEST_F(GLES2ImplementationTest
, BindTexImage2DCHROMIUM
) {
1774 cmds::BindTexImage2DCHROMIUM cmd
;
1777 expected
.cmd
.Init(GL_TEXTURE_2D
, 2);
1779 gl_
->BindTexImage2DCHROMIUM(GL_TEXTURE_2D
, 2);
1780 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1783 TEST_F(GLES2ImplementationTest
, ReleaseTexImage2DCHROMIUM
) {
1785 cmds::ReleaseTexImage2DCHROMIUM cmd
;
1788 expected
.cmd
.Init(GL_TEXTURE_2D
, 2);
1790 gl_
->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D
, 2);
1791 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1794 TEST_F(GLES2ImplementationTest
, DiscardFramebufferEXT
) {
1795 GLenum data
[2][1] = {{0}};
1797 cmds::DiscardFramebufferEXTImmediate cmd
;
1802 for (int ii
= 0; ii
< 2; ++ii
) {
1803 for (int jj
= 0; jj
< 1; ++jj
) {
1804 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
1807 expected
.cmd
.Init(1, 2, &data
[0][0]);
1808 gl_
->DiscardFramebufferEXT(1, 2, &data
[0][0]);
1809 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1812 TEST_F(GLES2ImplementationTest
, LoseContextCHROMIUM
) {
1814 cmds::LoseContextCHROMIUM cmd
;
1817 expected
.cmd
.Init(1, 2);
1819 gl_
->LoseContextCHROMIUM(1, 2);
1820 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1822 // TODO: Implement unit test for InsertSyncPointCHROMIUM
1824 TEST_F(GLES2ImplementationTest
, WaitSyncPointCHROMIUM
) {
1826 cmds::WaitSyncPointCHROMIUM cmd
;
1829 expected
.cmd
.Init(1);
1831 gl_
->WaitSyncPointCHROMIUM(1);
1832 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1835 TEST_F(GLES2ImplementationTest
, DrawBuffersEXT
) {
1836 GLenum data
[1][1] = {{0}};
1838 cmds::DrawBuffersEXTImmediate cmd
;
1843 for (int ii
= 0; ii
< 1; ++ii
) {
1844 for (int jj
= 0; jj
< 1; ++jj
) {
1845 data
[ii
][jj
] = static_cast<GLenum
>(ii
* 1 + jj
);
1848 expected
.cmd
.Init(1, &data
[0][0]);
1849 gl_
->DrawBuffersEXT(1, &data
[0][0]);
1850 EXPECT_EQ(0, memcmp(&expected
, commands_
, sizeof(expected
)));
1852 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_