Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / gpu / command_buffer / client / gles2_implementation_unittest_autogen.h
blob253b4bf731b3b3b8b37671a8bf8f941983ed8b49
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
9 // DO NOT EDIT!
11 // This file is included by gles2_implementation.h to declare the
12 // GL api functions.
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) {
17 struct Cmds {
18 cmds::AttachShader cmd;
20 Cmds expected;
21 expected.cmd.Init(1, 2);
23 gl_->AttachShader(1, 2);
24 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
26 // TODO(zmo): Implement unit test for BindAttribLocation
28 TEST_F(GLES2ImplementationTest, BindBuffer) {
29 struct Cmds {
30 cmds::BindBuffer cmd;
32 Cmds expected;
33 expected.cmd.Init(GL_ARRAY_BUFFER, 2);
35 gl_->BindBuffer(GL_ARRAY_BUFFER, 2);
36 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
37 ClearCommands();
38 gl_->BindBuffer(GL_ARRAY_BUFFER, 2);
39 EXPECT_TRUE(NoCommandsWritten());
42 TEST_F(GLES2ImplementationTest, BindBufferBase) {
43 struct Cmds {
44 cmds::BindBufferBase cmd;
46 Cmds expected;
47 expected.cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3);
49 gl_->BindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3);
50 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
53 TEST_F(GLES2ImplementationTest, BindBufferRange) {
54 struct Cmds {
55 cmds::BindBufferRange cmd;
57 Cmds expected;
58 expected.cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3, 4, 4);
60 gl_->BindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3, 4, 4);
61 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
64 TEST_F(GLES2ImplementationTest, BindFramebuffer) {
65 struct Cmds {
66 cmds::BindFramebuffer cmd;
68 Cmds expected;
69 expected.cmd.Init(GL_FRAMEBUFFER, 2);
71 gl_->BindFramebuffer(GL_FRAMEBUFFER, 2);
72 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
73 ClearCommands();
74 gl_->BindFramebuffer(GL_FRAMEBUFFER, 2);
75 EXPECT_TRUE(NoCommandsWritten());
78 TEST_F(GLES2ImplementationTest, BindRenderbuffer) {
79 struct Cmds {
80 cmds::BindRenderbuffer cmd;
82 Cmds expected;
83 expected.cmd.Init(GL_RENDERBUFFER, 2);
85 gl_->BindRenderbuffer(GL_RENDERBUFFER, 2);
86 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
87 ClearCommands();
88 gl_->BindRenderbuffer(GL_RENDERBUFFER, 2);
89 EXPECT_TRUE(NoCommandsWritten());
92 TEST_F(GLES2ImplementationTest, BindSampler) {
93 struct Cmds {
94 cmds::BindSampler cmd;
96 Cmds expected;
97 expected.cmd.Init(1, 2);
99 gl_->BindSampler(1, 2);
100 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
103 TEST_F(GLES2ImplementationTest, BindTransformFeedback) {
104 struct Cmds {
105 cmds::BindTransformFeedback cmd;
107 Cmds expected;
108 expected.cmd.Init(GL_TRANSFORM_FEEDBACK, 2);
110 gl_->BindTransformFeedback(GL_TRANSFORM_FEEDBACK, 2);
111 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
114 TEST_F(GLES2ImplementationTest, BlendColor) {
115 struct Cmds {
116 cmds::BlendColor cmd;
118 Cmds expected;
119 expected.cmd.Init(1, 2, 3, 4);
121 gl_->BlendColor(1, 2, 3, 4);
122 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
125 TEST_F(GLES2ImplementationTest, BlendEquation) {
126 struct Cmds {
127 cmds::BlendEquation cmd;
129 Cmds expected;
130 expected.cmd.Init(GL_FUNC_SUBTRACT);
132 gl_->BlendEquation(GL_FUNC_SUBTRACT);
133 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
136 TEST_F(GLES2ImplementationTest, BlendEquationSeparate) {
137 struct Cmds {
138 cmds::BlendEquationSeparate cmd;
140 Cmds expected;
141 expected.cmd.Init(GL_FUNC_SUBTRACT, GL_FUNC_ADD);
143 gl_->BlendEquationSeparate(GL_FUNC_SUBTRACT, GL_FUNC_ADD);
144 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
147 TEST_F(GLES2ImplementationTest, BlendFunc) {
148 struct Cmds {
149 cmds::BlendFunc cmd;
151 Cmds expected;
152 expected.cmd.Init(GL_ZERO, GL_ZERO);
154 gl_->BlendFunc(GL_ZERO, GL_ZERO);
155 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
158 TEST_F(GLES2ImplementationTest, BlendFuncSeparate) {
159 struct Cmds {
160 cmds::BlendFuncSeparate cmd;
162 Cmds expected;
163 expected.cmd.Init(GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO);
165 gl_->BlendFuncSeparate(GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO);
166 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
169 TEST_F(GLES2ImplementationTest, CheckFramebufferStatus) {
170 struct Cmds {
171 cmds::CheckFramebufferStatus cmd;
174 Cmds expected;
175 ExpectedMemoryInfo result1 =
176 GetExpectedResultMemory(sizeof(cmds::CheckFramebufferStatus::Result));
177 expected.cmd.Init(GL_FRAMEBUFFER, result1.id, result1.offset);
179 EXPECT_CALL(*command_buffer(), OnFlush())
180 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
181 .RetiresOnSaturation();
183 GLboolean result = gl_->CheckFramebufferStatus(GL_FRAMEBUFFER);
184 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
185 EXPECT_TRUE(result);
188 TEST_F(GLES2ImplementationTest, Clear) {
189 struct Cmds {
190 cmds::Clear cmd;
192 Cmds expected;
193 expected.cmd.Init(1);
195 gl_->Clear(1);
196 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
199 TEST_F(GLES2ImplementationTest, ClearBufferfi) {
200 struct Cmds {
201 cmds::ClearBufferfi cmd;
203 Cmds expected;
204 expected.cmd.Init(GL_COLOR, 2, 3, 4);
206 gl_->ClearBufferfi(GL_COLOR, 2, 3, 4);
207 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
210 TEST_F(GLES2ImplementationTest, ClearBufferfv) {
211 GLfloat data[4] = {0};
212 struct Cmds {
213 cmds::ClearBufferfvImmediate cmd;
214 GLfloat data[4];
217 for (int jj = 0; jj < 4; ++jj) {
218 data[jj] = static_cast<GLfloat>(jj);
220 Cmds expected;
221 expected.cmd.Init(GL_COLOR, 2, &data[0]);
222 gl_->ClearBufferfv(GL_COLOR, 2, &data[0]);
223 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
226 TEST_F(GLES2ImplementationTest, ClearBufferiv) {
227 GLint data[4] = {0};
228 struct Cmds {
229 cmds::ClearBufferivImmediate cmd;
230 GLint data[4];
233 for (int jj = 0; jj < 4; ++jj) {
234 data[jj] = static_cast<GLint>(jj);
236 Cmds expected;
237 expected.cmd.Init(GL_COLOR, 2, &data[0]);
238 gl_->ClearBufferiv(GL_COLOR, 2, &data[0]);
239 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
242 TEST_F(GLES2ImplementationTest, ClearBufferuiv) {
243 GLuint data[4] = {0};
244 struct Cmds {
245 cmds::ClearBufferuivImmediate cmd;
246 GLuint data[4];
249 for (int jj = 0; jj < 4; ++jj) {
250 data[jj] = static_cast<GLuint>(jj);
252 Cmds expected;
253 expected.cmd.Init(GL_COLOR, 2, &data[0]);
254 gl_->ClearBufferuiv(GL_COLOR, 2, &data[0]);
255 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
258 TEST_F(GLES2ImplementationTest, ClearColor) {
259 struct Cmds {
260 cmds::ClearColor cmd;
262 Cmds expected;
263 expected.cmd.Init(1, 2, 3, 4);
265 gl_->ClearColor(1, 2, 3, 4);
266 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
269 TEST_F(GLES2ImplementationTest, ClearDepthf) {
270 struct Cmds {
271 cmds::ClearDepthf cmd;
273 Cmds expected;
274 expected.cmd.Init(0.5f);
276 gl_->ClearDepthf(0.5f);
277 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
280 TEST_F(GLES2ImplementationTest, ClearStencil) {
281 struct Cmds {
282 cmds::ClearStencil cmd;
284 Cmds expected;
285 expected.cmd.Init(1);
287 gl_->ClearStencil(1);
288 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
290 // TODO(zmo): Implement unit test for ClientWaitSync
292 TEST_F(GLES2ImplementationTest, ColorMask) {
293 struct Cmds {
294 cmds::ColorMask cmd;
296 Cmds expected;
297 expected.cmd.Init(true, true, true, true);
299 gl_->ColorMask(true, true, true, true);
300 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
303 TEST_F(GLES2ImplementationTest, CompileShader) {
304 struct Cmds {
305 cmds::CompileShader cmd;
307 Cmds expected;
308 expected.cmd.Init(1);
310 gl_->CompileShader(1);
311 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
313 // TODO(zmo): Implement unit test for CompressedTexImage2D
314 // TODO(zmo): Implement unit test for CompressedTexSubImage2D
315 // TODO(zmo): Implement unit test for CompressedTexImage3D
316 // TODO(zmo): Implement unit test for CompressedTexSubImage3D
318 TEST_F(GLES2ImplementationTest, CopyBufferSubData) {
319 struct Cmds {
320 cmds::CopyBufferSubData cmd;
322 Cmds expected;
323 expected.cmd.Init(GL_ARRAY_BUFFER, GL_ARRAY_BUFFER, 3, 4, 5);
325 gl_->CopyBufferSubData(GL_ARRAY_BUFFER, GL_ARRAY_BUFFER, 3, 4, 5);
326 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
329 TEST_F(GLES2ImplementationTest, CopyTexImage2D) {
330 struct Cmds {
331 cmds::CopyTexImage2D cmd;
333 Cmds expected;
334 expected.cmd.Init(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7);
336 gl_->CopyTexImage2D(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7, 0);
337 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
340 TEST_F(GLES2ImplementationTest, CopyTexImage2DInvalidConstantArg7) {
341 gl_->CopyTexImage2D(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7, 1);
342 EXPECT_TRUE(NoCommandsWritten());
343 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
346 TEST_F(GLES2ImplementationTest, CopyTexSubImage2D) {
347 struct Cmds {
348 cmds::CopyTexSubImage2D cmd;
350 Cmds expected;
351 expected.cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8);
353 gl_->CopyTexSubImage2D(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8);
354 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
357 TEST_F(GLES2ImplementationTest, CopyTexSubImage3D) {
358 struct Cmds {
359 cmds::CopyTexSubImage3D cmd;
361 Cmds expected;
362 expected.cmd.Init(GL_TEXTURE_3D, 2, 3, 4, 5, 6, 7, 8, 9);
364 gl_->CopyTexSubImage3D(GL_TEXTURE_3D, 2, 3, 4, 5, 6, 7, 8, 9);
365 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
368 TEST_F(GLES2ImplementationTest, CullFace) {
369 struct Cmds {
370 cmds::CullFace cmd;
372 Cmds expected;
373 expected.cmd.Init(GL_FRONT);
375 gl_->CullFace(GL_FRONT);
376 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
379 TEST_F(GLES2ImplementationTest, DeleteBuffers) {
380 GLuint ids[2] = {kBuffersStartId, kBuffersStartId + 1};
381 struct Cmds {
382 cmds::DeleteBuffersImmediate del;
383 GLuint data[2];
385 Cmds expected;
386 expected.del.Init(arraysize(ids), &ids[0]);
387 expected.data[0] = kBuffersStartId;
388 expected.data[1] = kBuffersStartId + 1;
389 gl_->DeleteBuffers(arraysize(ids), &ids[0]);
390 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
393 TEST_F(GLES2ImplementationTest, DeleteFramebuffers) {
394 GLuint ids[2] = {kFramebuffersStartId, kFramebuffersStartId + 1};
395 struct Cmds {
396 cmds::DeleteFramebuffersImmediate del;
397 GLuint data[2];
399 Cmds expected;
400 expected.del.Init(arraysize(ids), &ids[0]);
401 expected.data[0] = kFramebuffersStartId;
402 expected.data[1] = kFramebuffersStartId + 1;
403 gl_->DeleteFramebuffers(arraysize(ids), &ids[0]);
404 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
407 TEST_F(GLES2ImplementationTest, DeleteProgram) {
408 struct Cmds {
409 cmds::DeleteProgram cmd;
411 Cmds expected;
412 expected.cmd.Init(1);
414 gl_->DeleteProgram(1);
415 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
418 TEST_F(GLES2ImplementationTest, DeleteRenderbuffers) {
419 GLuint ids[2] = {kRenderbuffersStartId, kRenderbuffersStartId + 1};
420 struct Cmds {
421 cmds::DeleteRenderbuffersImmediate del;
422 GLuint data[2];
424 Cmds expected;
425 expected.del.Init(arraysize(ids), &ids[0]);
426 expected.data[0] = kRenderbuffersStartId;
427 expected.data[1] = kRenderbuffersStartId + 1;
428 gl_->DeleteRenderbuffers(arraysize(ids), &ids[0]);
429 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
432 TEST_F(GLES2ImplementationTest, DeleteSamplers) {
433 GLuint ids[2] = {kSamplersStartId, kSamplersStartId + 1};
434 struct Cmds {
435 cmds::DeleteSamplersImmediate del;
436 GLuint data[2];
438 Cmds expected;
439 expected.del.Init(arraysize(ids), &ids[0]);
440 expected.data[0] = kSamplersStartId;
441 expected.data[1] = kSamplersStartId + 1;
442 gl_->DeleteSamplers(arraysize(ids), &ids[0]);
443 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
446 TEST_F(GLES2ImplementationTest, DeleteSync) {
447 struct Cmds {
448 cmds::DeleteSync cmd;
450 Cmds expected;
451 expected.cmd.Init(1);
453 gl_->DeleteSync(reinterpret_cast<GLsync>(1));
454 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
457 TEST_F(GLES2ImplementationTest, DeleteShader) {
458 struct Cmds {
459 cmds::DeleteShader cmd;
461 Cmds expected;
462 expected.cmd.Init(1);
464 gl_->DeleteShader(1);
465 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
468 TEST_F(GLES2ImplementationTest, DeleteTextures) {
469 GLuint ids[2] = {kTexturesStartId, kTexturesStartId + 1};
470 struct Cmds {
471 cmds::DeleteTexturesImmediate del;
472 GLuint data[2];
474 Cmds expected;
475 expected.del.Init(arraysize(ids), &ids[0]);
476 expected.data[0] = kTexturesStartId;
477 expected.data[1] = kTexturesStartId + 1;
478 gl_->DeleteTextures(arraysize(ids), &ids[0]);
479 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
482 TEST_F(GLES2ImplementationTest, DeleteTransformFeedbacks) {
483 GLuint ids[2] = {kTransformFeedbacksStartId, kTransformFeedbacksStartId + 1};
484 struct Cmds {
485 cmds::DeleteTransformFeedbacksImmediate del;
486 GLuint data[2];
488 Cmds expected;
489 expected.del.Init(arraysize(ids), &ids[0]);
490 expected.data[0] = kTransformFeedbacksStartId;
491 expected.data[1] = kTransformFeedbacksStartId + 1;
492 gl_->DeleteTransformFeedbacks(arraysize(ids), &ids[0]);
493 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
496 TEST_F(GLES2ImplementationTest, DepthFunc) {
497 struct Cmds {
498 cmds::DepthFunc cmd;
500 Cmds expected;
501 expected.cmd.Init(GL_NEVER);
503 gl_->DepthFunc(GL_NEVER);
504 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
507 TEST_F(GLES2ImplementationTest, DepthMask) {
508 struct Cmds {
509 cmds::DepthMask cmd;
511 Cmds expected;
512 expected.cmd.Init(true);
514 gl_->DepthMask(true);
515 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
518 TEST_F(GLES2ImplementationTest, DepthRangef) {
519 struct Cmds {
520 cmds::DepthRangef cmd;
522 Cmds expected;
523 expected.cmd.Init(1, 2);
525 gl_->DepthRangef(1, 2);
526 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
529 TEST_F(GLES2ImplementationTest, DetachShader) {
530 struct Cmds {
531 cmds::DetachShader cmd;
533 Cmds expected;
534 expected.cmd.Init(1, 2);
536 gl_->DetachShader(1, 2);
537 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
540 TEST_F(GLES2ImplementationTest, DisableVertexAttribArray) {
541 struct Cmds {
542 cmds::DisableVertexAttribArray cmd;
544 Cmds expected;
545 expected.cmd.Init(1);
547 gl_->DisableVertexAttribArray(1);
548 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
551 TEST_F(GLES2ImplementationTest, DrawArrays) {
552 struct Cmds {
553 cmds::DrawArrays cmd;
555 Cmds expected;
556 expected.cmd.Init(GL_POINTS, 2, 3);
558 gl_->DrawArrays(GL_POINTS, 2, 3);
559 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
561 // TODO(zmo): Implement unit test for DrawRangeElements
563 TEST_F(GLES2ImplementationTest, EnableVertexAttribArray) {
564 struct Cmds {
565 cmds::EnableVertexAttribArray cmd;
567 Cmds expected;
568 expected.cmd.Init(1);
570 gl_->EnableVertexAttribArray(1);
571 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
574 TEST_F(GLES2ImplementationTest, Flush) {
575 struct Cmds {
576 cmds::Flush cmd;
578 Cmds expected;
579 expected.cmd.Init();
581 gl_->Flush();
582 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
585 TEST_F(GLES2ImplementationTest, FramebufferRenderbuffer) {
586 struct Cmds {
587 cmds::FramebufferRenderbuffer cmd;
589 Cmds expected;
590 expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 4);
592 gl_->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
593 GL_RENDERBUFFER, 4);
594 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
597 TEST_F(GLES2ImplementationTest, FramebufferTexture2D) {
598 struct Cmds {
599 cmds::FramebufferTexture2D cmd;
601 Cmds expected;
602 expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4);
604 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
605 4, 0);
606 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
609 TEST_F(GLES2ImplementationTest, FramebufferTexture2DInvalidConstantArg4) {
610 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
611 4, 1);
612 EXPECT_TRUE(NoCommandsWritten());
613 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
616 TEST_F(GLES2ImplementationTest, FramebufferTextureLayer) {
617 struct Cmds {
618 cmds::FramebufferTextureLayer cmd;
620 Cmds expected;
621 expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 3, 4, 5);
623 gl_->FramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 3, 4, 5);
624 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
627 TEST_F(GLES2ImplementationTest, FrontFace) {
628 struct Cmds {
629 cmds::FrontFace cmd;
631 Cmds expected;
632 expected.cmd.Init(GL_CW);
634 gl_->FrontFace(GL_CW);
635 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
638 TEST_F(GLES2ImplementationTest, GenBuffers) {
639 GLuint ids[2] = {
642 struct Cmds {
643 cmds::GenBuffersImmediate gen;
644 GLuint data[2];
646 Cmds expected;
647 expected.gen.Init(arraysize(ids), &ids[0]);
648 expected.data[0] = kBuffersStartId;
649 expected.data[1] = kBuffersStartId + 1;
650 gl_->GenBuffers(arraysize(ids), &ids[0]);
651 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
652 EXPECT_EQ(kBuffersStartId, ids[0]);
653 EXPECT_EQ(kBuffersStartId + 1, ids[1]);
656 TEST_F(GLES2ImplementationTest, GenerateMipmap) {
657 struct Cmds {
658 cmds::GenerateMipmap cmd;
660 Cmds expected;
661 expected.cmd.Init(GL_TEXTURE_2D);
663 gl_->GenerateMipmap(GL_TEXTURE_2D);
664 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
667 TEST_F(GLES2ImplementationTest, GenFramebuffers) {
668 GLuint ids[2] = {
671 struct Cmds {
672 cmds::GenFramebuffersImmediate gen;
673 GLuint data[2];
675 Cmds expected;
676 expected.gen.Init(arraysize(ids), &ids[0]);
677 expected.data[0] = kFramebuffersStartId;
678 expected.data[1] = kFramebuffersStartId + 1;
679 gl_->GenFramebuffers(arraysize(ids), &ids[0]);
680 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
681 EXPECT_EQ(kFramebuffersStartId, ids[0]);
682 EXPECT_EQ(kFramebuffersStartId + 1, ids[1]);
685 TEST_F(GLES2ImplementationTest, GenRenderbuffers) {
686 GLuint ids[2] = {
689 struct Cmds {
690 cmds::GenRenderbuffersImmediate gen;
691 GLuint data[2];
693 Cmds expected;
694 expected.gen.Init(arraysize(ids), &ids[0]);
695 expected.data[0] = kRenderbuffersStartId;
696 expected.data[1] = kRenderbuffersStartId + 1;
697 gl_->GenRenderbuffers(arraysize(ids), &ids[0]);
698 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
699 EXPECT_EQ(kRenderbuffersStartId, ids[0]);
700 EXPECT_EQ(kRenderbuffersStartId + 1, ids[1]);
703 TEST_F(GLES2ImplementationTest, GenSamplers) {
704 GLuint ids[2] = {
707 struct Cmds {
708 cmds::GenSamplersImmediate gen;
709 GLuint data[2];
711 Cmds expected;
712 expected.gen.Init(arraysize(ids), &ids[0]);
713 expected.data[0] = kSamplersStartId;
714 expected.data[1] = kSamplersStartId + 1;
715 gl_->GenSamplers(arraysize(ids), &ids[0]);
716 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
717 EXPECT_EQ(kSamplersStartId, ids[0]);
718 EXPECT_EQ(kSamplersStartId + 1, ids[1]);
721 TEST_F(GLES2ImplementationTest, GenTextures) {
722 GLuint ids[2] = {
725 struct Cmds {
726 cmds::GenTexturesImmediate gen;
727 GLuint data[2];
729 Cmds expected;
730 expected.gen.Init(arraysize(ids), &ids[0]);
731 expected.data[0] = kTexturesStartId;
732 expected.data[1] = kTexturesStartId + 1;
733 gl_->GenTextures(arraysize(ids), &ids[0]);
734 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
735 EXPECT_EQ(kTexturesStartId, ids[0]);
736 EXPECT_EQ(kTexturesStartId + 1, ids[1]);
739 TEST_F(GLES2ImplementationTest, GenTransformFeedbacks) {
740 GLuint ids[2] = {
743 struct Cmds {
744 cmds::GenTransformFeedbacksImmediate gen;
745 GLuint data[2];
747 Cmds expected;
748 expected.gen.Init(arraysize(ids), &ids[0]);
749 expected.data[0] = kTransformFeedbacksStartId;
750 expected.data[1] = kTransformFeedbacksStartId + 1;
751 gl_->GenTransformFeedbacks(arraysize(ids), &ids[0]);
752 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
753 EXPECT_EQ(kTransformFeedbacksStartId, ids[0]);
754 EXPECT_EQ(kTransformFeedbacksStartId + 1, ids[1]);
756 // TODO(zmo): Implement unit test for GetActiveAttrib
757 // TODO(zmo): Implement unit test for GetActiveUniform
758 // TODO(zmo): Implement unit test for GetActiveUniformBlockiv
759 // TODO(zmo): Implement unit test for GetActiveUniformBlockName
760 // TODO(zmo): Implement unit test for GetActiveUniformsiv
761 // TODO(zmo): Implement unit test for GetAttachedShaders
762 // TODO(zmo): Implement unit test for GetAttribLocation
764 TEST_F(GLES2ImplementationTest, GetBooleanv) {
765 struct Cmds {
766 cmds::GetBooleanv cmd;
768 typedef cmds::GetBooleanv::Result::Type ResultType;
769 ResultType result = 0;
770 Cmds expected;
771 ExpectedMemoryInfo result1 =
772 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
773 expected.cmd.Init(123, result1.id, result1.offset);
774 EXPECT_CALL(*command_buffer(), OnFlush())
775 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
776 .RetiresOnSaturation();
777 gl_->GetBooleanv(123, &result);
778 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
779 EXPECT_EQ(static_cast<ResultType>(1), result);
782 TEST_F(GLES2ImplementationTest, GetBufferParameteri64v) {
783 struct Cmds {
784 cmds::GetBufferParameteri64v cmd;
786 typedef cmds::GetBufferParameteri64v::Result::Type ResultType;
787 ResultType result = 0;
788 Cmds expected;
789 ExpectedMemoryInfo result1 =
790 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
791 expected.cmd.Init(123, GL_BUFFER_SIZE, result1.id, result1.offset);
792 EXPECT_CALL(*command_buffer(), OnFlush())
793 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
794 .RetiresOnSaturation();
795 gl_->GetBufferParameteri64v(123, GL_BUFFER_SIZE, &result);
796 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
797 EXPECT_EQ(static_cast<ResultType>(1), result);
800 TEST_F(GLES2ImplementationTest, GetBufferParameteriv) {
801 struct Cmds {
802 cmds::GetBufferParameteriv cmd;
804 typedef cmds::GetBufferParameteriv::Result::Type ResultType;
805 ResultType result = 0;
806 Cmds expected;
807 ExpectedMemoryInfo result1 =
808 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
809 expected.cmd.Init(123, GL_BUFFER_SIZE, result1.id, result1.offset);
810 EXPECT_CALL(*command_buffer(), OnFlush())
811 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
812 .RetiresOnSaturation();
813 gl_->GetBufferParameteriv(123, GL_BUFFER_SIZE, &result);
814 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
815 EXPECT_EQ(static_cast<ResultType>(1), result);
818 TEST_F(GLES2ImplementationTest, GetFloatv) {
819 struct Cmds {
820 cmds::GetFloatv cmd;
822 typedef cmds::GetFloatv::Result::Type ResultType;
823 ResultType result = 0;
824 Cmds expected;
825 ExpectedMemoryInfo result1 =
826 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
827 expected.cmd.Init(123, result1.id, result1.offset);
828 EXPECT_CALL(*command_buffer(), OnFlush())
829 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
830 .RetiresOnSaturation();
831 gl_->GetFloatv(123, &result);
832 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
833 EXPECT_EQ(static_cast<ResultType>(1), result);
835 // TODO(zmo): Implement unit test for GetFragDataLocation
837 TEST_F(GLES2ImplementationTest, GetFramebufferAttachmentParameteriv) {
838 struct Cmds {
839 cmds::GetFramebufferAttachmentParameteriv cmd;
841 typedef cmds::GetFramebufferAttachmentParameteriv::Result::Type ResultType;
842 ResultType result = 0;
843 Cmds expected;
844 ExpectedMemoryInfo result1 =
845 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
846 expected.cmd.Init(123, GL_COLOR_ATTACHMENT0,
847 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, result1.id,
848 result1.offset);
849 EXPECT_CALL(*command_buffer(), OnFlush())
850 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
851 .RetiresOnSaturation();
852 gl_->GetFramebufferAttachmentParameteriv(
853 123, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
854 &result);
855 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
856 EXPECT_EQ(static_cast<ResultType>(1), result);
859 TEST_F(GLES2ImplementationTest, GetInteger64v) {
860 struct Cmds {
861 cmds::GetInteger64v cmd;
863 typedef cmds::GetInteger64v::Result::Type ResultType;
864 ResultType result = 0;
865 Cmds expected;
866 ExpectedMemoryInfo result1 =
867 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
868 expected.cmd.Init(123, result1.id, result1.offset);
869 EXPECT_CALL(*command_buffer(), OnFlush())
870 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
871 .RetiresOnSaturation();
872 gl_->GetInteger64v(123, &result);
873 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
874 EXPECT_EQ(static_cast<ResultType>(1), result);
877 TEST_F(GLES2ImplementationTest, GetIntegeri_v) {
878 struct Cmds {
879 cmds::GetIntegeri_v cmd;
881 typedef cmds::GetIntegeri_v::Result::Type ResultType;
882 ResultType result = 0;
883 Cmds expected;
884 ExpectedMemoryInfo result1 =
885 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
886 expected.cmd.Init(123, 2, result1.id, result1.offset);
887 EXPECT_CALL(*command_buffer(), OnFlush())
888 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
889 .RetiresOnSaturation();
890 gl_->GetIntegeri_v(123, 2, &result);
891 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
892 EXPECT_EQ(static_cast<ResultType>(1), result);
895 TEST_F(GLES2ImplementationTest, GetInteger64i_v) {
896 struct Cmds {
897 cmds::GetInteger64i_v cmd;
899 typedef cmds::GetInteger64i_v::Result::Type ResultType;
900 ResultType result = 0;
901 Cmds expected;
902 ExpectedMemoryInfo result1 =
903 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
904 expected.cmd.Init(123, 2, result1.id, result1.offset);
905 EXPECT_CALL(*command_buffer(), OnFlush())
906 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
907 .RetiresOnSaturation();
908 gl_->GetInteger64i_v(123, 2, &result);
909 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
910 EXPECT_EQ(static_cast<ResultType>(1), result);
913 TEST_F(GLES2ImplementationTest, GetIntegerv) {
914 struct Cmds {
915 cmds::GetIntegerv cmd;
917 typedef cmds::GetIntegerv::Result::Type ResultType;
918 ResultType result = 0;
919 Cmds expected;
920 ExpectedMemoryInfo result1 =
921 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
922 expected.cmd.Init(123, result1.id, result1.offset);
923 EXPECT_CALL(*command_buffer(), OnFlush())
924 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
925 .RetiresOnSaturation();
926 gl_->GetIntegerv(123, &result);
927 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
928 EXPECT_EQ(static_cast<ResultType>(1), result);
930 // TODO(zmo): Implement unit test for GetInternalformativ
932 TEST_F(GLES2ImplementationTest, GetProgramiv) {
933 struct Cmds {
934 cmds::GetProgramiv cmd;
936 typedef cmds::GetProgramiv::Result::Type ResultType;
937 ResultType result = 0;
938 Cmds expected;
939 ExpectedMemoryInfo result1 =
940 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
941 expected.cmd.Init(123, GL_DELETE_STATUS, result1.id, result1.offset);
942 EXPECT_CALL(*command_buffer(), OnFlush())
943 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
944 .RetiresOnSaturation();
945 gl_->GetProgramiv(123, GL_DELETE_STATUS, &result);
946 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
947 EXPECT_EQ(static_cast<ResultType>(1), result);
949 // TODO(zmo): Implement unit test for GetProgramInfoLog
951 TEST_F(GLES2ImplementationTest, GetRenderbufferParameteriv) {
952 struct Cmds {
953 cmds::GetRenderbufferParameteriv cmd;
955 typedef cmds::GetRenderbufferParameteriv::Result::Type ResultType;
956 ResultType result = 0;
957 Cmds expected;
958 ExpectedMemoryInfo result1 =
959 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
960 expected.cmd.Init(123, GL_RENDERBUFFER_RED_SIZE, result1.id, result1.offset);
961 EXPECT_CALL(*command_buffer(), OnFlush())
962 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
963 .RetiresOnSaturation();
964 gl_->GetRenderbufferParameteriv(123, GL_RENDERBUFFER_RED_SIZE, &result);
965 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
966 EXPECT_EQ(static_cast<ResultType>(1), result);
969 TEST_F(GLES2ImplementationTest, GetSamplerParameterfv) {
970 struct Cmds {
971 cmds::GetSamplerParameterfv cmd;
973 typedef cmds::GetSamplerParameterfv::Result::Type ResultType;
974 ResultType result = 0;
975 Cmds expected;
976 ExpectedMemoryInfo result1 =
977 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
978 expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
979 EXPECT_CALL(*command_buffer(), OnFlush())
980 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
981 .RetiresOnSaturation();
982 gl_->GetSamplerParameterfv(123, GL_TEXTURE_MAG_FILTER, &result);
983 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
984 EXPECT_EQ(static_cast<ResultType>(1), result);
987 TEST_F(GLES2ImplementationTest, GetSamplerParameteriv) {
988 struct Cmds {
989 cmds::GetSamplerParameteriv cmd;
991 typedef cmds::GetSamplerParameteriv::Result::Type ResultType;
992 ResultType result = 0;
993 Cmds expected;
994 ExpectedMemoryInfo result1 =
995 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
996 expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
997 EXPECT_CALL(*command_buffer(), OnFlush())
998 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
999 .RetiresOnSaturation();
1000 gl_->GetSamplerParameteriv(123, GL_TEXTURE_MAG_FILTER, &result);
1001 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1002 EXPECT_EQ(static_cast<ResultType>(1), result);
1005 TEST_F(GLES2ImplementationTest, GetShaderiv) {
1006 struct Cmds {
1007 cmds::GetShaderiv cmd;
1009 typedef cmds::GetShaderiv::Result::Type ResultType;
1010 ResultType result = 0;
1011 Cmds expected;
1012 ExpectedMemoryInfo result1 =
1013 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1014 expected.cmd.Init(123, GL_SHADER_TYPE, result1.id, result1.offset);
1015 EXPECT_CALL(*command_buffer(), OnFlush())
1016 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1017 .RetiresOnSaturation();
1018 gl_->GetShaderiv(123, GL_SHADER_TYPE, &result);
1019 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1020 EXPECT_EQ(static_cast<ResultType>(1), result);
1022 // TODO(zmo): Implement unit test for GetShaderInfoLog
1023 // TODO(zmo): Implement unit test for GetShaderPrecisionFormat
1025 TEST_F(GLES2ImplementationTest, GetSynciv) {
1026 struct Cmds {
1027 cmds::GetSynciv cmd;
1029 typedef cmds::GetSynciv::Result::Type ResultType;
1030 ResultType result = 0;
1031 Cmds expected;
1032 ExpectedMemoryInfo result1 =
1033 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1034 expected.cmd.Init(123, GL_SYNC_STATUS, result1.id, result1.offset);
1035 EXPECT_CALL(*command_buffer(), OnFlush())
1036 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1037 .RetiresOnSaturation();
1038 gl_->GetSynciv(reinterpret_cast<GLsync>(123), GL_SYNC_STATUS, 3, nullptr,
1039 &result);
1040 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1041 EXPECT_EQ(static_cast<ResultType>(1), result);
1044 TEST_F(GLES2ImplementationTest, GetTexParameterfv) {
1045 struct Cmds {
1046 cmds::GetTexParameterfv cmd;
1048 typedef cmds::GetTexParameterfv::Result::Type ResultType;
1049 ResultType result = 0;
1050 Cmds expected;
1051 ExpectedMemoryInfo result1 =
1052 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1053 expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
1054 EXPECT_CALL(*command_buffer(), OnFlush())
1055 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1056 .RetiresOnSaturation();
1057 gl_->GetTexParameterfv(123, GL_TEXTURE_MAG_FILTER, &result);
1058 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1059 EXPECT_EQ(static_cast<ResultType>(1), result);
1062 TEST_F(GLES2ImplementationTest, GetTexParameteriv) {
1063 struct Cmds {
1064 cmds::GetTexParameteriv cmd;
1066 typedef cmds::GetTexParameteriv::Result::Type ResultType;
1067 ResultType result = 0;
1068 Cmds expected;
1069 ExpectedMemoryInfo result1 =
1070 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1071 expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
1072 EXPECT_CALL(*command_buffer(), OnFlush())
1073 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1074 .RetiresOnSaturation();
1075 gl_->GetTexParameteriv(123, GL_TEXTURE_MAG_FILTER, &result);
1076 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1077 EXPECT_EQ(static_cast<ResultType>(1), result);
1079 // TODO(zmo): Implement unit test for GetTransformFeedbackVarying
1080 // TODO(zmo): Implement unit test for GetUniformBlockIndex
1081 // TODO(zmo): Implement unit test for GetUniformfv
1082 // TODO(zmo): Implement unit test for GetUniformiv
1083 // TODO(zmo): Implement unit test for GetUniformuiv
1084 // TODO(zmo): Implement unit test for GetUniformIndices
1085 // TODO(zmo): Implement unit test for GetUniformLocation
1087 TEST_F(GLES2ImplementationTest, GetVertexAttribfv) {
1088 struct Cmds {
1089 cmds::GetVertexAttribfv cmd;
1091 typedef cmds::GetVertexAttribfv::Result::Type ResultType;
1092 ResultType result = 0;
1093 Cmds expected;
1094 ExpectedMemoryInfo result1 =
1095 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1096 expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1097 result1.offset);
1098 EXPECT_CALL(*command_buffer(), OnFlush())
1099 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1100 .RetiresOnSaturation();
1101 gl_->GetVertexAttribfv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1102 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1103 EXPECT_EQ(static_cast<ResultType>(1), result);
1106 TEST_F(GLES2ImplementationTest, GetVertexAttribiv) {
1107 struct Cmds {
1108 cmds::GetVertexAttribiv cmd;
1110 typedef cmds::GetVertexAttribiv::Result::Type ResultType;
1111 ResultType result = 0;
1112 Cmds expected;
1113 ExpectedMemoryInfo result1 =
1114 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1115 expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1116 result1.offset);
1117 EXPECT_CALL(*command_buffer(), OnFlush())
1118 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1119 .RetiresOnSaturation();
1120 gl_->GetVertexAttribiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1121 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1122 EXPECT_EQ(static_cast<ResultType>(1), result);
1125 TEST_F(GLES2ImplementationTest, GetVertexAttribIiv) {
1126 struct Cmds {
1127 cmds::GetVertexAttribIiv cmd;
1129 typedef cmds::GetVertexAttribIiv::Result::Type ResultType;
1130 ResultType result = 0;
1131 Cmds expected;
1132 ExpectedMemoryInfo result1 =
1133 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1134 expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1135 result1.offset);
1136 EXPECT_CALL(*command_buffer(), OnFlush())
1137 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1138 .RetiresOnSaturation();
1139 gl_->GetVertexAttribIiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1140 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1141 EXPECT_EQ(static_cast<ResultType>(1), result);
1144 TEST_F(GLES2ImplementationTest, GetVertexAttribIuiv) {
1145 struct Cmds {
1146 cmds::GetVertexAttribIuiv cmd;
1148 typedef cmds::GetVertexAttribIuiv::Result::Type ResultType;
1149 ResultType result = 0;
1150 Cmds expected;
1151 ExpectedMemoryInfo result1 =
1152 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1153 expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1154 result1.offset);
1155 EXPECT_CALL(*command_buffer(), OnFlush())
1156 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1157 .RetiresOnSaturation();
1158 gl_->GetVertexAttribIuiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1159 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1160 EXPECT_EQ(static_cast<ResultType>(1), result);
1163 TEST_F(GLES2ImplementationTest, Hint) {
1164 struct Cmds {
1165 cmds::Hint cmd;
1167 Cmds expected;
1168 expected.cmd.Init(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
1170 gl_->Hint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
1171 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1174 TEST_F(GLES2ImplementationTest, InvalidateFramebuffer) {
1175 GLenum data[2][1] = {{0}};
1176 struct Cmds {
1177 cmds::InvalidateFramebufferImmediate cmd;
1178 GLenum data[2][1];
1181 Cmds expected;
1182 for (int ii = 0; ii < 2; ++ii) {
1183 for (int jj = 0; jj < 1; ++jj) {
1184 data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
1187 expected.cmd.Init(GL_FRAMEBUFFER, 2, &data[0][0]);
1188 gl_->InvalidateFramebuffer(GL_FRAMEBUFFER, 2, &data[0][0]);
1189 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1192 TEST_F(GLES2ImplementationTest, InvalidateSubFramebuffer) {
1193 GLenum data[2][1] = {{0}};
1194 struct Cmds {
1195 cmds::InvalidateSubFramebufferImmediate cmd;
1196 GLenum data[2][1];
1199 Cmds expected;
1200 for (int ii = 0; ii < 2; ++ii) {
1201 for (int jj = 0; jj < 1; ++jj) {
1202 data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
1205 expected.cmd.Init(GL_FRAMEBUFFER, 2, &data[0][0], 4, 5, 6, 7);
1206 gl_->InvalidateSubFramebuffer(GL_FRAMEBUFFER, 2, &data[0][0], 4, 5, 6, 7);
1207 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1210 TEST_F(GLES2ImplementationTest, IsBuffer) {
1211 struct Cmds {
1212 cmds::IsBuffer cmd;
1215 Cmds expected;
1216 ExpectedMemoryInfo result1 =
1217 GetExpectedResultMemory(sizeof(cmds::IsBuffer::Result));
1218 expected.cmd.Init(1, result1.id, result1.offset);
1220 EXPECT_CALL(*command_buffer(), OnFlush())
1221 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1222 .RetiresOnSaturation();
1224 GLboolean result = gl_->IsBuffer(1);
1225 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1226 EXPECT_TRUE(result);
1229 TEST_F(GLES2ImplementationTest, IsFramebuffer) {
1230 struct Cmds {
1231 cmds::IsFramebuffer cmd;
1234 Cmds expected;
1235 ExpectedMemoryInfo result1 =
1236 GetExpectedResultMemory(sizeof(cmds::IsFramebuffer::Result));
1237 expected.cmd.Init(1, result1.id, result1.offset);
1239 EXPECT_CALL(*command_buffer(), OnFlush())
1240 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1241 .RetiresOnSaturation();
1243 GLboolean result = gl_->IsFramebuffer(1);
1244 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1245 EXPECT_TRUE(result);
1248 TEST_F(GLES2ImplementationTest, IsProgram) {
1249 struct Cmds {
1250 cmds::IsProgram cmd;
1253 Cmds expected;
1254 ExpectedMemoryInfo result1 =
1255 GetExpectedResultMemory(sizeof(cmds::IsProgram::Result));
1256 expected.cmd.Init(1, result1.id, result1.offset);
1258 EXPECT_CALL(*command_buffer(), OnFlush())
1259 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1260 .RetiresOnSaturation();
1262 GLboolean result = gl_->IsProgram(1);
1263 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1264 EXPECT_TRUE(result);
1267 TEST_F(GLES2ImplementationTest, IsRenderbuffer) {
1268 struct Cmds {
1269 cmds::IsRenderbuffer cmd;
1272 Cmds expected;
1273 ExpectedMemoryInfo result1 =
1274 GetExpectedResultMemory(sizeof(cmds::IsRenderbuffer::Result));
1275 expected.cmd.Init(1, result1.id, result1.offset);
1277 EXPECT_CALL(*command_buffer(), OnFlush())
1278 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1279 .RetiresOnSaturation();
1281 GLboolean result = gl_->IsRenderbuffer(1);
1282 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1283 EXPECT_TRUE(result);
1286 TEST_F(GLES2ImplementationTest, IsSampler) {
1287 struct Cmds {
1288 cmds::IsSampler cmd;
1291 Cmds expected;
1292 ExpectedMemoryInfo result1 =
1293 GetExpectedResultMemory(sizeof(cmds::IsSampler::Result));
1294 expected.cmd.Init(1, result1.id, result1.offset);
1296 EXPECT_CALL(*command_buffer(), OnFlush())
1297 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1298 .RetiresOnSaturation();
1300 GLboolean result = gl_->IsSampler(1);
1301 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1302 EXPECT_TRUE(result);
1305 TEST_F(GLES2ImplementationTest, IsShader) {
1306 struct Cmds {
1307 cmds::IsShader cmd;
1310 Cmds expected;
1311 ExpectedMemoryInfo result1 =
1312 GetExpectedResultMemory(sizeof(cmds::IsShader::Result));
1313 expected.cmd.Init(1, result1.id, result1.offset);
1315 EXPECT_CALL(*command_buffer(), OnFlush())
1316 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1317 .RetiresOnSaturation();
1319 GLboolean result = gl_->IsShader(1);
1320 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1321 EXPECT_TRUE(result);
1324 TEST_F(GLES2ImplementationTest, IsSync) {
1325 struct Cmds {
1326 cmds::IsSync cmd;
1329 Cmds expected;
1330 ExpectedMemoryInfo result1 =
1331 GetExpectedResultMemory(sizeof(cmds::IsSync::Result));
1332 expected.cmd.Init(1, result1.id, result1.offset);
1334 EXPECT_CALL(*command_buffer(), OnFlush())
1335 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1336 .RetiresOnSaturation();
1338 GLboolean result = gl_->IsSync(reinterpret_cast<GLsync>(1));
1339 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1340 EXPECT_TRUE(result);
1343 TEST_F(GLES2ImplementationTest, IsTexture) {
1344 struct Cmds {
1345 cmds::IsTexture cmd;
1348 Cmds expected;
1349 ExpectedMemoryInfo result1 =
1350 GetExpectedResultMemory(sizeof(cmds::IsTexture::Result));
1351 expected.cmd.Init(1, result1.id, result1.offset);
1353 EXPECT_CALL(*command_buffer(), OnFlush())
1354 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1355 .RetiresOnSaturation();
1357 GLboolean result = gl_->IsTexture(1);
1358 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1359 EXPECT_TRUE(result);
1362 TEST_F(GLES2ImplementationTest, IsTransformFeedback) {
1363 struct Cmds {
1364 cmds::IsTransformFeedback cmd;
1367 Cmds expected;
1368 ExpectedMemoryInfo result1 =
1369 GetExpectedResultMemory(sizeof(cmds::IsTransformFeedback::Result));
1370 expected.cmd.Init(1, result1.id, result1.offset);
1372 EXPECT_CALL(*command_buffer(), OnFlush())
1373 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1374 .RetiresOnSaturation();
1376 GLboolean result = gl_->IsTransformFeedback(1);
1377 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1378 EXPECT_TRUE(result);
1381 TEST_F(GLES2ImplementationTest, LineWidth) {
1382 struct Cmds {
1383 cmds::LineWidth cmd;
1385 Cmds expected;
1386 expected.cmd.Init(0.5f);
1388 gl_->LineWidth(0.5f);
1389 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1392 TEST_F(GLES2ImplementationTest, LinkProgram) {
1393 struct Cmds {
1394 cmds::LinkProgram cmd;
1396 Cmds expected;
1397 expected.cmd.Init(1);
1399 gl_->LinkProgram(1);
1400 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1403 TEST_F(GLES2ImplementationTest, PauseTransformFeedback) {
1404 struct Cmds {
1405 cmds::PauseTransformFeedback cmd;
1407 Cmds expected;
1408 expected.cmd.Init();
1410 gl_->PauseTransformFeedback();
1411 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1414 TEST_F(GLES2ImplementationTest, PixelStorei) {
1415 struct Cmds {
1416 cmds::PixelStorei cmd;
1418 Cmds expected;
1419 expected.cmd.Init(GL_PACK_ALIGNMENT, 1);
1421 gl_->PixelStorei(GL_PACK_ALIGNMENT, 1);
1422 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1425 TEST_F(GLES2ImplementationTest, PolygonOffset) {
1426 struct Cmds {
1427 cmds::PolygonOffset cmd;
1429 Cmds expected;
1430 expected.cmd.Init(1, 2);
1432 gl_->PolygonOffset(1, 2);
1433 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1436 TEST_F(GLES2ImplementationTest, ReadBuffer) {
1437 struct Cmds {
1438 cmds::ReadBuffer cmd;
1440 Cmds expected;
1441 expected.cmd.Init(GL_NONE);
1443 gl_->ReadBuffer(GL_NONE);
1444 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1447 TEST_F(GLES2ImplementationTest, ReleaseShaderCompiler) {
1448 struct Cmds {
1449 cmds::ReleaseShaderCompiler cmd;
1451 Cmds expected;
1452 expected.cmd.Init();
1454 gl_->ReleaseShaderCompiler();
1455 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1458 TEST_F(GLES2ImplementationTest, RenderbufferStorage) {
1459 struct Cmds {
1460 cmds::RenderbufferStorage cmd;
1462 Cmds expected;
1463 expected.cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
1465 gl_->RenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
1466 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1469 TEST_F(GLES2ImplementationTest, ResumeTransformFeedback) {
1470 struct Cmds {
1471 cmds::ResumeTransformFeedback cmd;
1473 Cmds expected;
1474 expected.cmd.Init();
1476 gl_->ResumeTransformFeedback();
1477 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1480 TEST_F(GLES2ImplementationTest, SampleCoverage) {
1481 struct Cmds {
1482 cmds::SampleCoverage cmd;
1484 Cmds expected;
1485 expected.cmd.Init(1, true);
1487 gl_->SampleCoverage(1, true);
1488 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1491 TEST_F(GLES2ImplementationTest, SamplerParameterf) {
1492 struct Cmds {
1493 cmds::SamplerParameterf cmd;
1495 Cmds expected;
1496 expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1498 gl_->SamplerParameterf(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1499 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1502 TEST_F(GLES2ImplementationTest, SamplerParameterfv) {
1503 GLfloat data[1] = {0};
1504 struct Cmds {
1505 cmds::SamplerParameterfvImmediate cmd;
1506 GLfloat data[1];
1509 for (int jj = 0; jj < 1; ++jj) {
1510 data[jj] = static_cast<GLfloat>(jj);
1512 Cmds expected;
1513 expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1514 gl_->SamplerParameterfv(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1515 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1518 TEST_F(GLES2ImplementationTest, SamplerParameteri) {
1519 struct Cmds {
1520 cmds::SamplerParameteri cmd;
1522 Cmds expected;
1523 expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1525 gl_->SamplerParameteri(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1526 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1529 TEST_F(GLES2ImplementationTest, SamplerParameteriv) {
1530 GLint data[1] = {0};
1531 struct Cmds {
1532 cmds::SamplerParameterivImmediate cmd;
1533 GLint data[1];
1536 for (int jj = 0; jj < 1; ++jj) {
1537 data[jj] = static_cast<GLint>(jj);
1539 Cmds expected;
1540 expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1541 gl_->SamplerParameteriv(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1542 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1545 TEST_F(GLES2ImplementationTest, Scissor) {
1546 struct Cmds {
1547 cmds::Scissor cmd;
1549 Cmds expected;
1550 expected.cmd.Init(1, 2, 3, 4);
1552 gl_->Scissor(1, 2, 3, 4);
1553 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1556 TEST_F(GLES2ImplementationTest, ShaderSource) {
1557 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
1558 const char* kString1 = "happy";
1559 const char* kString2 = "ending";
1560 const size_t kString1Size = ::strlen(kString1) + 1;
1561 const size_t kString2Size = ::strlen(kString2) + 1;
1562 const size_t kHeaderSize = sizeof(GLint) * 3;
1563 const size_t kSourceSize = kHeaderSize + kString1Size + kString2Size;
1564 const size_t kPaddedHeaderSize =
1565 transfer_buffer_->RoundToAlignment(kHeaderSize);
1566 const size_t kPaddedString1Size =
1567 transfer_buffer_->RoundToAlignment(kString1Size);
1568 const size_t kPaddedString2Size =
1569 transfer_buffer_->RoundToAlignment(kString2Size);
1570 struct Cmds {
1571 cmd::SetBucketSize set_bucket_size;
1572 cmd::SetBucketData set_bucket_header;
1573 cmd::SetToken set_token1;
1574 cmd::SetBucketData set_bucket_data1;
1575 cmd::SetToken set_token2;
1576 cmd::SetBucketData set_bucket_data2;
1577 cmd::SetToken set_token3;
1578 cmds::ShaderSourceBucket cmd_bucket;
1579 cmd::SetBucketSize clear_bucket_size;
1582 ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1583 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedString1Size);
1584 ExpectedMemoryInfo mem2 = GetExpectedMemory(kPaddedString2Size);
1586 Cmds expected;
1587 expected.set_bucket_size.Init(kBucketId, kSourceSize);
1588 expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1589 mem0.offset);
1590 expected.set_token1.Init(GetNextToken());
1591 expected.set_bucket_data1.Init(kBucketId, kHeaderSize, kString1Size, mem1.id,
1592 mem1.offset);
1593 expected.set_token2.Init(GetNextToken());
1594 expected.set_bucket_data2.Init(kBucketId, kHeaderSize + kString1Size,
1595 kString2Size, mem2.id, mem2.offset);
1596 expected.set_token3.Init(GetNextToken());
1597 expected.cmd_bucket.Init(1, kBucketId);
1598 expected.clear_bucket_size.Init(kBucketId, 0);
1599 const char* kStrings[] = {kString1, kString2};
1600 gl_->ShaderSource(1, 2, kStrings, NULL);
1601 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1604 TEST_F(GLES2ImplementationTest, ShaderSourceWithLength) {
1605 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
1606 const char* kString = "foobar******";
1607 const size_t kStringSize = 6; // We only need "foobar".
1608 const size_t kHeaderSize = sizeof(GLint) * 2;
1609 const size_t kSourceSize = kHeaderSize + kStringSize + 1;
1610 const size_t kPaddedHeaderSize =
1611 transfer_buffer_->RoundToAlignment(kHeaderSize);
1612 const size_t kPaddedStringSize =
1613 transfer_buffer_->RoundToAlignment(kStringSize + 1);
1614 struct Cmds {
1615 cmd::SetBucketSize set_bucket_size;
1616 cmd::SetBucketData set_bucket_header;
1617 cmd::SetToken set_token1;
1618 cmd::SetBucketData set_bucket_data;
1619 cmd::SetToken set_token2;
1620 cmds::ShaderSourceBucket shader_source_bucket;
1621 cmd::SetBucketSize clear_bucket_size;
1624 ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1625 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedStringSize);
1627 Cmds expected;
1628 expected.set_bucket_size.Init(kBucketId, kSourceSize);
1629 expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1630 mem0.offset);
1631 expected.set_token1.Init(GetNextToken());
1632 expected.set_bucket_data.Init(kBucketId, kHeaderSize, kStringSize + 1,
1633 mem1.id, mem1.offset);
1634 expected.set_token2.Init(GetNextToken());
1635 expected.shader_source_bucket.Init(1, kBucketId);
1636 expected.clear_bucket_size.Init(kBucketId, 0);
1637 const char* kStrings[] = {kString};
1638 const GLint kLength[] = {kStringSize};
1639 gl_->ShaderSource(1, 1, kStrings, kLength);
1640 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1643 TEST_F(GLES2ImplementationTest, StencilFunc) {
1644 struct Cmds {
1645 cmds::StencilFunc cmd;
1647 Cmds expected;
1648 expected.cmd.Init(GL_NEVER, 2, 3);
1650 gl_->StencilFunc(GL_NEVER, 2, 3);
1651 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1654 TEST_F(GLES2ImplementationTest, StencilFuncSeparate) {
1655 struct Cmds {
1656 cmds::StencilFuncSeparate cmd;
1658 Cmds expected;
1659 expected.cmd.Init(GL_FRONT, GL_NEVER, 3, 4);
1661 gl_->StencilFuncSeparate(GL_FRONT, GL_NEVER, 3, 4);
1662 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1665 TEST_F(GLES2ImplementationTest, StencilMask) {
1666 struct Cmds {
1667 cmds::StencilMask cmd;
1669 Cmds expected;
1670 expected.cmd.Init(1);
1672 gl_->StencilMask(1);
1673 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1676 TEST_F(GLES2ImplementationTest, StencilMaskSeparate) {
1677 struct Cmds {
1678 cmds::StencilMaskSeparate cmd;
1680 Cmds expected;
1681 expected.cmd.Init(GL_FRONT, 2);
1683 gl_->StencilMaskSeparate(GL_FRONT, 2);
1684 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1687 TEST_F(GLES2ImplementationTest, StencilOp) {
1688 struct Cmds {
1689 cmds::StencilOp cmd;
1691 Cmds expected;
1692 expected.cmd.Init(GL_KEEP, GL_INCR, GL_KEEP);
1694 gl_->StencilOp(GL_KEEP, GL_INCR, GL_KEEP);
1695 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1698 TEST_F(GLES2ImplementationTest, StencilOpSeparate) {
1699 struct Cmds {
1700 cmds::StencilOpSeparate cmd;
1702 Cmds expected;
1703 expected.cmd.Init(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP);
1705 gl_->StencilOpSeparate(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP);
1706 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1709 TEST_F(GLES2ImplementationTest, TexParameterf) {
1710 struct Cmds {
1711 cmds::TexParameterf cmd;
1713 Cmds expected;
1714 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1716 gl_->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1717 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1720 TEST_F(GLES2ImplementationTest, TexParameterfv) {
1721 GLfloat data[1] = {0};
1722 struct Cmds {
1723 cmds::TexParameterfvImmediate cmd;
1724 GLfloat data[1];
1727 for (int jj = 0; jj < 1; ++jj) {
1728 data[jj] = static_cast<GLfloat>(jj);
1730 Cmds expected;
1731 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1732 gl_->TexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1733 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1736 TEST_F(GLES2ImplementationTest, TexParameteri) {
1737 struct Cmds {
1738 cmds::TexParameteri cmd;
1740 Cmds expected;
1741 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1743 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1744 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1747 TEST_F(GLES2ImplementationTest, TexParameteriv) {
1748 GLint data[1] = {0};
1749 struct Cmds {
1750 cmds::TexParameterivImmediate cmd;
1751 GLint data[1];
1754 for (int jj = 0; jj < 1; ++jj) {
1755 data[jj] = static_cast<GLint>(jj);
1757 Cmds expected;
1758 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1759 gl_->TexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1760 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1763 TEST_F(GLES2ImplementationTest, TexStorage3D) {
1764 struct Cmds {
1765 cmds::TexStorage3D cmd;
1767 Cmds expected;
1768 expected.cmd.Init(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6);
1770 gl_->TexStorage3D(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6);
1771 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1774 TEST_F(GLES2ImplementationTest, TransformFeedbackVaryings) {
1775 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
1776 const char* kString1 = "happy";
1777 const char* kString2 = "ending";
1778 const size_t kString1Size = ::strlen(kString1) + 1;
1779 const size_t kString2Size = ::strlen(kString2) + 1;
1780 const size_t kHeaderSize = sizeof(GLint) * 3;
1781 const size_t kSourceSize = kHeaderSize + kString1Size + kString2Size;
1782 const size_t kPaddedHeaderSize =
1783 transfer_buffer_->RoundToAlignment(kHeaderSize);
1784 const size_t kPaddedString1Size =
1785 transfer_buffer_->RoundToAlignment(kString1Size);
1786 const size_t kPaddedString2Size =
1787 transfer_buffer_->RoundToAlignment(kString2Size);
1788 struct Cmds {
1789 cmd::SetBucketSize set_bucket_size;
1790 cmd::SetBucketData set_bucket_header;
1791 cmd::SetToken set_token1;
1792 cmd::SetBucketData set_bucket_data1;
1793 cmd::SetToken set_token2;
1794 cmd::SetBucketData set_bucket_data2;
1795 cmd::SetToken set_token3;
1796 cmds::TransformFeedbackVaryingsBucket cmd_bucket;
1797 cmd::SetBucketSize clear_bucket_size;
1800 ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1801 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedString1Size);
1802 ExpectedMemoryInfo mem2 = GetExpectedMemory(kPaddedString2Size);
1804 Cmds expected;
1805 expected.set_bucket_size.Init(kBucketId, kSourceSize);
1806 expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1807 mem0.offset);
1808 expected.set_token1.Init(GetNextToken());
1809 expected.set_bucket_data1.Init(kBucketId, kHeaderSize, kString1Size, mem1.id,
1810 mem1.offset);
1811 expected.set_token2.Init(GetNextToken());
1812 expected.set_bucket_data2.Init(kBucketId, kHeaderSize + kString1Size,
1813 kString2Size, mem2.id, mem2.offset);
1814 expected.set_token3.Init(GetNextToken());
1815 expected.cmd_bucket.Init(1, kBucketId, GL_INTERLEAVED_ATTRIBS);
1816 expected.clear_bucket_size.Init(kBucketId, 0);
1817 const char* kStrings[] = {kString1, kString2};
1818 gl_->TransformFeedbackVaryings(1, 2, kStrings, GL_INTERLEAVED_ATTRIBS);
1819 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1822 TEST_F(GLES2ImplementationTest, Uniform1f) {
1823 struct Cmds {
1824 cmds::Uniform1f cmd;
1826 Cmds expected;
1827 expected.cmd.Init(1, 2);
1829 gl_->Uniform1f(1, 2);
1830 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1833 TEST_F(GLES2ImplementationTest, Uniform1fv) {
1834 GLfloat data[2][1] = {{0}};
1835 struct Cmds {
1836 cmds::Uniform1fvImmediate cmd;
1837 GLfloat data[2][1];
1840 Cmds expected;
1841 for (int ii = 0; ii < 2; ++ii) {
1842 for (int jj = 0; jj < 1; ++jj) {
1843 data[ii][jj] = static_cast<GLfloat>(ii * 1 + jj);
1846 expected.cmd.Init(1, 2, &data[0][0]);
1847 gl_->Uniform1fv(1, 2, &data[0][0]);
1848 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1851 TEST_F(GLES2ImplementationTest, Uniform1i) {
1852 struct Cmds {
1853 cmds::Uniform1i cmd;
1855 Cmds expected;
1856 expected.cmd.Init(1, 2);
1858 gl_->Uniform1i(1, 2);
1859 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1862 TEST_F(GLES2ImplementationTest, Uniform1iv) {
1863 GLint data[2][1] = {{0}};
1864 struct Cmds {
1865 cmds::Uniform1ivImmediate cmd;
1866 GLint data[2][1];
1869 Cmds expected;
1870 for (int ii = 0; ii < 2; ++ii) {
1871 for (int jj = 0; jj < 1; ++jj) {
1872 data[ii][jj] = static_cast<GLint>(ii * 1 + jj);
1875 expected.cmd.Init(1, 2, &data[0][0]);
1876 gl_->Uniform1iv(1, 2, &data[0][0]);
1877 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1880 TEST_F(GLES2ImplementationTest, Uniform1ui) {
1881 struct Cmds {
1882 cmds::Uniform1ui cmd;
1884 Cmds expected;
1885 expected.cmd.Init(1, 2);
1887 gl_->Uniform1ui(1, 2);
1888 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1891 TEST_F(GLES2ImplementationTest, Uniform1uiv) {
1892 GLuint data[2][1] = {{0}};
1893 struct Cmds {
1894 cmds::Uniform1uivImmediate cmd;
1895 GLuint data[2][1];
1898 Cmds expected;
1899 for (int ii = 0; ii < 2; ++ii) {
1900 for (int jj = 0; jj < 1; ++jj) {
1901 data[ii][jj] = static_cast<GLuint>(ii * 1 + jj);
1904 expected.cmd.Init(1, 2, &data[0][0]);
1905 gl_->Uniform1uiv(1, 2, &data[0][0]);
1906 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1909 TEST_F(GLES2ImplementationTest, Uniform2f) {
1910 struct Cmds {
1911 cmds::Uniform2f cmd;
1913 Cmds expected;
1914 expected.cmd.Init(1, 2, 3);
1916 gl_->Uniform2f(1, 2, 3);
1917 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1920 TEST_F(GLES2ImplementationTest, Uniform2fv) {
1921 GLfloat data[2][2] = {{0}};
1922 struct Cmds {
1923 cmds::Uniform2fvImmediate cmd;
1924 GLfloat data[2][2];
1927 Cmds expected;
1928 for (int ii = 0; ii < 2; ++ii) {
1929 for (int jj = 0; jj < 2; ++jj) {
1930 data[ii][jj] = static_cast<GLfloat>(ii * 2 + jj);
1933 expected.cmd.Init(1, 2, &data[0][0]);
1934 gl_->Uniform2fv(1, 2, &data[0][0]);
1935 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1938 TEST_F(GLES2ImplementationTest, Uniform2i) {
1939 struct Cmds {
1940 cmds::Uniform2i cmd;
1942 Cmds expected;
1943 expected.cmd.Init(1, 2, 3);
1945 gl_->Uniform2i(1, 2, 3);
1946 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1949 TEST_F(GLES2ImplementationTest, Uniform2iv) {
1950 GLint data[2][2] = {{0}};
1951 struct Cmds {
1952 cmds::Uniform2ivImmediate cmd;
1953 GLint data[2][2];
1956 Cmds expected;
1957 for (int ii = 0; ii < 2; ++ii) {
1958 for (int jj = 0; jj < 2; ++jj) {
1959 data[ii][jj] = static_cast<GLint>(ii * 2 + jj);
1962 expected.cmd.Init(1, 2, &data[0][0]);
1963 gl_->Uniform2iv(1, 2, &data[0][0]);
1964 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1967 TEST_F(GLES2ImplementationTest, Uniform2ui) {
1968 struct Cmds {
1969 cmds::Uniform2ui cmd;
1971 Cmds expected;
1972 expected.cmd.Init(1, 2, 3);
1974 gl_->Uniform2ui(1, 2, 3);
1975 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1978 TEST_F(GLES2ImplementationTest, Uniform2uiv) {
1979 GLuint data[2][2] = {{0}};
1980 struct Cmds {
1981 cmds::Uniform2uivImmediate cmd;
1982 GLuint data[2][2];
1985 Cmds expected;
1986 for (int ii = 0; ii < 2; ++ii) {
1987 for (int jj = 0; jj < 2; ++jj) {
1988 data[ii][jj] = static_cast<GLuint>(ii * 2 + jj);
1991 expected.cmd.Init(1, 2, &data[0][0]);
1992 gl_->Uniform2uiv(1, 2, &data[0][0]);
1993 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1996 TEST_F(GLES2ImplementationTest, Uniform3f) {
1997 struct Cmds {
1998 cmds::Uniform3f cmd;
2000 Cmds expected;
2001 expected.cmd.Init(1, 2, 3, 4);
2003 gl_->Uniform3f(1, 2, 3, 4);
2004 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2007 TEST_F(GLES2ImplementationTest, Uniform3fv) {
2008 GLfloat data[2][3] = {{0}};
2009 struct Cmds {
2010 cmds::Uniform3fvImmediate cmd;
2011 GLfloat data[2][3];
2014 Cmds expected;
2015 for (int ii = 0; ii < 2; ++ii) {
2016 for (int jj = 0; jj < 3; ++jj) {
2017 data[ii][jj] = static_cast<GLfloat>(ii * 3 + jj);
2020 expected.cmd.Init(1, 2, &data[0][0]);
2021 gl_->Uniform3fv(1, 2, &data[0][0]);
2022 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2025 TEST_F(GLES2ImplementationTest, Uniform3i) {
2026 struct Cmds {
2027 cmds::Uniform3i cmd;
2029 Cmds expected;
2030 expected.cmd.Init(1, 2, 3, 4);
2032 gl_->Uniform3i(1, 2, 3, 4);
2033 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2036 TEST_F(GLES2ImplementationTest, Uniform3iv) {
2037 GLint data[2][3] = {{0}};
2038 struct Cmds {
2039 cmds::Uniform3ivImmediate cmd;
2040 GLint data[2][3];
2043 Cmds expected;
2044 for (int ii = 0; ii < 2; ++ii) {
2045 for (int jj = 0; jj < 3; ++jj) {
2046 data[ii][jj] = static_cast<GLint>(ii * 3 + jj);
2049 expected.cmd.Init(1, 2, &data[0][0]);
2050 gl_->Uniform3iv(1, 2, &data[0][0]);
2051 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2054 TEST_F(GLES2ImplementationTest, Uniform3ui) {
2055 struct Cmds {
2056 cmds::Uniform3ui cmd;
2058 Cmds expected;
2059 expected.cmd.Init(1, 2, 3, 4);
2061 gl_->Uniform3ui(1, 2, 3, 4);
2062 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2065 TEST_F(GLES2ImplementationTest, Uniform3uiv) {
2066 GLuint data[2][3] = {{0}};
2067 struct Cmds {
2068 cmds::Uniform3uivImmediate cmd;
2069 GLuint data[2][3];
2072 Cmds expected;
2073 for (int ii = 0; ii < 2; ++ii) {
2074 for (int jj = 0; jj < 3; ++jj) {
2075 data[ii][jj] = static_cast<GLuint>(ii * 3 + jj);
2078 expected.cmd.Init(1, 2, &data[0][0]);
2079 gl_->Uniform3uiv(1, 2, &data[0][0]);
2080 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2083 TEST_F(GLES2ImplementationTest, Uniform4f) {
2084 struct Cmds {
2085 cmds::Uniform4f cmd;
2087 Cmds expected;
2088 expected.cmd.Init(1, 2, 3, 4, 5);
2090 gl_->Uniform4f(1, 2, 3, 4, 5);
2091 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2094 TEST_F(GLES2ImplementationTest, Uniform4fv) {
2095 GLfloat data[2][4] = {{0}};
2096 struct Cmds {
2097 cmds::Uniform4fvImmediate cmd;
2098 GLfloat data[2][4];
2101 Cmds expected;
2102 for (int ii = 0; ii < 2; ++ii) {
2103 for (int jj = 0; jj < 4; ++jj) {
2104 data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
2107 expected.cmd.Init(1, 2, &data[0][0]);
2108 gl_->Uniform4fv(1, 2, &data[0][0]);
2109 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2112 TEST_F(GLES2ImplementationTest, Uniform4i) {
2113 struct Cmds {
2114 cmds::Uniform4i cmd;
2116 Cmds expected;
2117 expected.cmd.Init(1, 2, 3, 4, 5);
2119 gl_->Uniform4i(1, 2, 3, 4, 5);
2120 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2123 TEST_F(GLES2ImplementationTest, Uniform4iv) {
2124 GLint data[2][4] = {{0}};
2125 struct Cmds {
2126 cmds::Uniform4ivImmediate cmd;
2127 GLint data[2][4];
2130 Cmds expected;
2131 for (int ii = 0; ii < 2; ++ii) {
2132 for (int jj = 0; jj < 4; ++jj) {
2133 data[ii][jj] = static_cast<GLint>(ii * 4 + jj);
2136 expected.cmd.Init(1, 2, &data[0][0]);
2137 gl_->Uniform4iv(1, 2, &data[0][0]);
2138 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2141 TEST_F(GLES2ImplementationTest, Uniform4ui) {
2142 struct Cmds {
2143 cmds::Uniform4ui cmd;
2145 Cmds expected;
2146 expected.cmd.Init(1, 2, 3, 4, 5);
2148 gl_->Uniform4ui(1, 2, 3, 4, 5);
2149 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2152 TEST_F(GLES2ImplementationTest, Uniform4uiv) {
2153 GLuint data[2][4] = {{0}};
2154 struct Cmds {
2155 cmds::Uniform4uivImmediate cmd;
2156 GLuint data[2][4];
2159 Cmds expected;
2160 for (int ii = 0; ii < 2; ++ii) {
2161 for (int jj = 0; jj < 4; ++jj) {
2162 data[ii][jj] = static_cast<GLuint>(ii * 4 + jj);
2165 expected.cmd.Init(1, 2, &data[0][0]);
2166 gl_->Uniform4uiv(1, 2, &data[0][0]);
2167 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2170 TEST_F(GLES2ImplementationTest, UniformBlockBinding) {
2171 struct Cmds {
2172 cmds::UniformBlockBinding cmd;
2174 Cmds expected;
2175 expected.cmd.Init(1, 2, 3);
2177 gl_->UniformBlockBinding(1, 2, 3);
2178 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2181 TEST_F(GLES2ImplementationTest, UniformMatrix2fv) {
2182 GLfloat data[2][4] = {{0}};
2183 struct Cmds {
2184 cmds::UniformMatrix2fvImmediate cmd;
2185 GLfloat data[2][4];
2188 Cmds expected;
2189 for (int ii = 0; ii < 2; ++ii) {
2190 for (int jj = 0; jj < 4; ++jj) {
2191 data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
2194 expected.cmd.Init(1, 2, &data[0][0]);
2195 gl_->UniformMatrix2fv(1, 2, false, &data[0][0]);
2196 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2199 TEST_F(GLES2ImplementationTest, UniformMatrix2fvInvalidConstantArg2) {
2200 GLfloat data[2][4] = {{0}};
2201 for (int ii = 0; ii < 2; ++ii) {
2202 for (int jj = 0; jj < 4; ++jj) {
2203 data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
2206 gl_->UniformMatrix2fv(1, 2, true, &data[0][0]);
2207 EXPECT_TRUE(NoCommandsWritten());
2208 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2211 TEST_F(GLES2ImplementationTest, UniformMatrix2x3fv) {
2212 GLfloat data[2][6] = {{0}};
2213 struct Cmds {
2214 cmds::UniformMatrix2x3fvImmediate cmd;
2215 GLfloat data[2][6];
2218 Cmds expected;
2219 for (int ii = 0; ii < 2; ++ii) {
2220 for (int jj = 0; jj < 6; ++jj) {
2221 data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2224 expected.cmd.Init(1, 2, &data[0][0]);
2225 gl_->UniformMatrix2x3fv(1, 2, false, &data[0][0]);
2226 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2229 TEST_F(GLES2ImplementationTest, UniformMatrix2x3fvInvalidConstantArg2) {
2230 GLfloat data[2][6] = {{0}};
2231 for (int ii = 0; ii < 2; ++ii) {
2232 for (int jj = 0; jj < 6; ++jj) {
2233 data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2236 gl_->UniformMatrix2x3fv(1, 2, true, &data[0][0]);
2237 EXPECT_TRUE(NoCommandsWritten());
2238 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2241 TEST_F(GLES2ImplementationTest, UniformMatrix2x4fv) {
2242 GLfloat data[2][8] = {{0}};
2243 struct Cmds {
2244 cmds::UniformMatrix2x4fvImmediate cmd;
2245 GLfloat data[2][8];
2248 Cmds expected;
2249 for (int ii = 0; ii < 2; ++ii) {
2250 for (int jj = 0; jj < 8; ++jj) {
2251 data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2254 expected.cmd.Init(1, 2, &data[0][0]);
2255 gl_->UniformMatrix2x4fv(1, 2, false, &data[0][0]);
2256 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2259 TEST_F(GLES2ImplementationTest, UniformMatrix2x4fvInvalidConstantArg2) {
2260 GLfloat data[2][8] = {{0}};
2261 for (int ii = 0; ii < 2; ++ii) {
2262 for (int jj = 0; jj < 8; ++jj) {
2263 data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2266 gl_->UniformMatrix2x4fv(1, 2, true, &data[0][0]);
2267 EXPECT_TRUE(NoCommandsWritten());
2268 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2271 TEST_F(GLES2ImplementationTest, UniformMatrix3fv) {
2272 GLfloat data[2][9] = {{0}};
2273 struct Cmds {
2274 cmds::UniformMatrix3fvImmediate cmd;
2275 GLfloat data[2][9];
2278 Cmds expected;
2279 for (int ii = 0; ii < 2; ++ii) {
2280 for (int jj = 0; jj < 9; ++jj) {
2281 data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj);
2284 expected.cmd.Init(1, 2, &data[0][0]);
2285 gl_->UniformMatrix3fv(1, 2, false, &data[0][0]);
2286 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2289 TEST_F(GLES2ImplementationTest, UniformMatrix3fvInvalidConstantArg2) {
2290 GLfloat data[2][9] = {{0}};
2291 for (int ii = 0; ii < 2; ++ii) {
2292 for (int jj = 0; jj < 9; ++jj) {
2293 data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj);
2296 gl_->UniformMatrix3fv(1, 2, true, &data[0][0]);
2297 EXPECT_TRUE(NoCommandsWritten());
2298 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2301 TEST_F(GLES2ImplementationTest, UniformMatrix3x2fv) {
2302 GLfloat data[2][6] = {{0}};
2303 struct Cmds {
2304 cmds::UniformMatrix3x2fvImmediate cmd;
2305 GLfloat data[2][6];
2308 Cmds expected;
2309 for (int ii = 0; ii < 2; ++ii) {
2310 for (int jj = 0; jj < 6; ++jj) {
2311 data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2314 expected.cmd.Init(1, 2, &data[0][0]);
2315 gl_->UniformMatrix3x2fv(1, 2, false, &data[0][0]);
2316 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2319 TEST_F(GLES2ImplementationTest, UniformMatrix3x2fvInvalidConstantArg2) {
2320 GLfloat data[2][6] = {{0}};
2321 for (int ii = 0; ii < 2; ++ii) {
2322 for (int jj = 0; jj < 6; ++jj) {
2323 data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2326 gl_->UniformMatrix3x2fv(1, 2, true, &data[0][0]);
2327 EXPECT_TRUE(NoCommandsWritten());
2328 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2331 TEST_F(GLES2ImplementationTest, UniformMatrix3x4fv) {
2332 GLfloat data[2][12] = {{0}};
2333 struct Cmds {
2334 cmds::UniformMatrix3x4fvImmediate cmd;
2335 GLfloat data[2][12];
2338 Cmds expected;
2339 for (int ii = 0; ii < 2; ++ii) {
2340 for (int jj = 0; jj < 12; ++jj) {
2341 data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2344 expected.cmd.Init(1, 2, &data[0][0]);
2345 gl_->UniformMatrix3x4fv(1, 2, false, &data[0][0]);
2346 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2349 TEST_F(GLES2ImplementationTest, UniformMatrix3x4fvInvalidConstantArg2) {
2350 GLfloat data[2][12] = {{0}};
2351 for (int ii = 0; ii < 2; ++ii) {
2352 for (int jj = 0; jj < 12; ++jj) {
2353 data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2356 gl_->UniformMatrix3x4fv(1, 2, true, &data[0][0]);
2357 EXPECT_TRUE(NoCommandsWritten());
2358 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2361 TEST_F(GLES2ImplementationTest, UniformMatrix4fv) {
2362 GLfloat data[2][16] = {{0}};
2363 struct Cmds {
2364 cmds::UniformMatrix4fvImmediate cmd;
2365 GLfloat data[2][16];
2368 Cmds expected;
2369 for (int ii = 0; ii < 2; ++ii) {
2370 for (int jj = 0; jj < 16; ++jj) {
2371 data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj);
2374 expected.cmd.Init(1, 2, &data[0][0]);
2375 gl_->UniformMatrix4fv(1, 2, false, &data[0][0]);
2376 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2379 TEST_F(GLES2ImplementationTest, UniformMatrix4fvInvalidConstantArg2) {
2380 GLfloat data[2][16] = {{0}};
2381 for (int ii = 0; ii < 2; ++ii) {
2382 for (int jj = 0; jj < 16; ++jj) {
2383 data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj);
2386 gl_->UniformMatrix4fv(1, 2, true, &data[0][0]);
2387 EXPECT_TRUE(NoCommandsWritten());
2388 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2391 TEST_F(GLES2ImplementationTest, UniformMatrix4x2fv) {
2392 GLfloat data[2][8] = {{0}};
2393 struct Cmds {
2394 cmds::UniformMatrix4x2fvImmediate cmd;
2395 GLfloat data[2][8];
2398 Cmds expected;
2399 for (int ii = 0; ii < 2; ++ii) {
2400 for (int jj = 0; jj < 8; ++jj) {
2401 data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2404 expected.cmd.Init(1, 2, &data[0][0]);
2405 gl_->UniformMatrix4x2fv(1, 2, false, &data[0][0]);
2406 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2409 TEST_F(GLES2ImplementationTest, UniformMatrix4x2fvInvalidConstantArg2) {
2410 GLfloat data[2][8] = {{0}};
2411 for (int ii = 0; ii < 2; ++ii) {
2412 for (int jj = 0; jj < 8; ++jj) {
2413 data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2416 gl_->UniformMatrix4x2fv(1, 2, true, &data[0][0]);
2417 EXPECT_TRUE(NoCommandsWritten());
2418 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2421 TEST_F(GLES2ImplementationTest, UniformMatrix4x3fv) {
2422 GLfloat data[2][12] = {{0}};
2423 struct Cmds {
2424 cmds::UniformMatrix4x3fvImmediate cmd;
2425 GLfloat data[2][12];
2428 Cmds expected;
2429 for (int ii = 0; ii < 2; ++ii) {
2430 for (int jj = 0; jj < 12; ++jj) {
2431 data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2434 expected.cmd.Init(1, 2, &data[0][0]);
2435 gl_->UniformMatrix4x3fv(1, 2, false, &data[0][0]);
2436 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2439 TEST_F(GLES2ImplementationTest, UniformMatrix4x3fvInvalidConstantArg2) {
2440 GLfloat data[2][12] = {{0}};
2441 for (int ii = 0; ii < 2; ++ii) {
2442 for (int jj = 0; jj < 12; ++jj) {
2443 data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2446 gl_->UniformMatrix4x3fv(1, 2, true, &data[0][0]);
2447 EXPECT_TRUE(NoCommandsWritten());
2448 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2451 TEST_F(GLES2ImplementationTest, UseProgram) {
2452 struct Cmds {
2453 cmds::UseProgram cmd;
2455 Cmds expected;
2456 expected.cmd.Init(1);
2458 gl_->UseProgram(1);
2459 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2460 ClearCommands();
2461 gl_->UseProgram(1);
2462 EXPECT_TRUE(NoCommandsWritten());
2465 TEST_F(GLES2ImplementationTest, ValidateProgram) {
2466 struct Cmds {
2467 cmds::ValidateProgram cmd;
2469 Cmds expected;
2470 expected.cmd.Init(1);
2472 gl_->ValidateProgram(1);
2473 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2476 TEST_F(GLES2ImplementationTest, VertexAttrib1f) {
2477 struct Cmds {
2478 cmds::VertexAttrib1f cmd;
2480 Cmds expected;
2481 expected.cmd.Init(1, 2);
2483 gl_->VertexAttrib1f(1, 2);
2484 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2487 TEST_F(GLES2ImplementationTest, VertexAttrib1fv) {
2488 GLfloat data[1] = {0};
2489 struct Cmds {
2490 cmds::VertexAttrib1fvImmediate cmd;
2491 GLfloat data[1];
2494 for (int jj = 0; jj < 1; ++jj) {
2495 data[jj] = static_cast<GLfloat>(jj);
2497 Cmds expected;
2498 expected.cmd.Init(1, &data[0]);
2499 gl_->VertexAttrib1fv(1, &data[0]);
2500 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2503 TEST_F(GLES2ImplementationTest, VertexAttrib2f) {
2504 struct Cmds {
2505 cmds::VertexAttrib2f cmd;
2507 Cmds expected;
2508 expected.cmd.Init(1, 2, 3);
2510 gl_->VertexAttrib2f(1, 2, 3);
2511 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2514 TEST_F(GLES2ImplementationTest, VertexAttrib2fv) {
2515 GLfloat data[2] = {0};
2516 struct Cmds {
2517 cmds::VertexAttrib2fvImmediate cmd;
2518 GLfloat data[2];
2521 for (int jj = 0; jj < 2; ++jj) {
2522 data[jj] = static_cast<GLfloat>(jj);
2524 Cmds expected;
2525 expected.cmd.Init(1, &data[0]);
2526 gl_->VertexAttrib2fv(1, &data[0]);
2527 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2530 TEST_F(GLES2ImplementationTest, VertexAttrib3f) {
2531 struct Cmds {
2532 cmds::VertexAttrib3f cmd;
2534 Cmds expected;
2535 expected.cmd.Init(1, 2, 3, 4);
2537 gl_->VertexAttrib3f(1, 2, 3, 4);
2538 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2541 TEST_F(GLES2ImplementationTest, VertexAttrib3fv) {
2542 GLfloat data[3] = {0};
2543 struct Cmds {
2544 cmds::VertexAttrib3fvImmediate cmd;
2545 GLfloat data[3];
2548 for (int jj = 0; jj < 3; ++jj) {
2549 data[jj] = static_cast<GLfloat>(jj);
2551 Cmds expected;
2552 expected.cmd.Init(1, &data[0]);
2553 gl_->VertexAttrib3fv(1, &data[0]);
2554 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2557 TEST_F(GLES2ImplementationTest, VertexAttrib4f) {
2558 struct Cmds {
2559 cmds::VertexAttrib4f cmd;
2561 Cmds expected;
2562 expected.cmd.Init(1, 2, 3, 4, 5);
2564 gl_->VertexAttrib4f(1, 2, 3, 4, 5);
2565 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2568 TEST_F(GLES2ImplementationTest, VertexAttrib4fv) {
2569 GLfloat data[4] = {0};
2570 struct Cmds {
2571 cmds::VertexAttrib4fvImmediate cmd;
2572 GLfloat data[4];
2575 for (int jj = 0; jj < 4; ++jj) {
2576 data[jj] = static_cast<GLfloat>(jj);
2578 Cmds expected;
2579 expected.cmd.Init(1, &data[0]);
2580 gl_->VertexAttrib4fv(1, &data[0]);
2581 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2584 TEST_F(GLES2ImplementationTest, VertexAttribI4i) {
2585 struct Cmds {
2586 cmds::VertexAttribI4i cmd;
2588 Cmds expected;
2589 expected.cmd.Init(1, 2, 3, 4, 5);
2591 gl_->VertexAttribI4i(1, 2, 3, 4, 5);
2592 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2595 TEST_F(GLES2ImplementationTest, VertexAttribI4iv) {
2596 GLint data[4] = {0};
2597 struct Cmds {
2598 cmds::VertexAttribI4ivImmediate cmd;
2599 GLint data[4];
2602 for (int jj = 0; jj < 4; ++jj) {
2603 data[jj] = static_cast<GLint>(jj);
2605 Cmds expected;
2606 expected.cmd.Init(1, &data[0]);
2607 gl_->VertexAttribI4iv(1, &data[0]);
2608 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2611 TEST_F(GLES2ImplementationTest, VertexAttribI4ui) {
2612 struct Cmds {
2613 cmds::VertexAttribI4ui cmd;
2615 Cmds expected;
2616 expected.cmd.Init(1, 2, 3, 4, 5);
2618 gl_->VertexAttribI4ui(1, 2, 3, 4, 5);
2619 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2622 TEST_F(GLES2ImplementationTest, VertexAttribI4uiv) {
2623 GLuint data[4] = {0};
2624 struct Cmds {
2625 cmds::VertexAttribI4uivImmediate cmd;
2626 GLuint data[4];
2629 for (int jj = 0; jj < 4; ++jj) {
2630 data[jj] = static_cast<GLuint>(jj);
2632 Cmds expected;
2633 expected.cmd.Init(1, &data[0]);
2634 gl_->VertexAttribI4uiv(1, &data[0]);
2635 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2638 TEST_F(GLES2ImplementationTest, Viewport) {
2639 struct Cmds {
2640 cmds::Viewport cmd;
2642 Cmds expected;
2643 expected.cmd.Init(1, 2, 3, 4);
2645 gl_->Viewport(1, 2, 3, 4);
2646 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2649 TEST_F(GLES2ImplementationTest, BlitFramebufferCHROMIUM) {
2650 struct Cmds {
2651 cmds::BlitFramebufferCHROMIUM cmd;
2653 Cmds expected;
2654 expected.cmd.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
2656 gl_->BlitFramebufferCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
2657 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2660 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleCHROMIUM) {
2661 struct Cmds {
2662 cmds::RenderbufferStorageMultisampleCHROMIUM cmd;
2664 Cmds expected;
2665 expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2667 gl_->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, 2, GL_RGBA4, 4,
2669 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2672 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleEXT) {
2673 struct Cmds {
2674 cmds::RenderbufferStorageMultisampleEXT cmd;
2676 Cmds expected;
2677 expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2679 gl_->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2680 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2683 TEST_F(GLES2ImplementationTest, FramebufferTexture2DMultisampleEXT) {
2684 struct Cmds {
2685 cmds::FramebufferTexture2DMultisampleEXT cmd;
2687 Cmds expected;
2688 expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4, 6);
2690 gl_->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2691 GL_TEXTURE_2D, 4, 0, 6);
2692 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2695 TEST_F(GLES2ImplementationTest,
2696 FramebufferTexture2DMultisampleEXTInvalidConstantArg4) {
2697 gl_->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2698 GL_TEXTURE_2D, 4, 1, 6);
2699 EXPECT_TRUE(NoCommandsWritten());
2700 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2703 TEST_F(GLES2ImplementationTest, TexStorage2DEXT) {
2704 struct Cmds {
2705 cmds::TexStorage2DEXT cmd;
2707 Cmds expected;
2708 expected.cmd.Init(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
2710 gl_->TexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
2711 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2714 TEST_F(GLES2ImplementationTest, GenQueriesEXT) {
2715 GLuint ids[2] = {
2718 struct Cmds {
2719 cmds::GenQueriesEXTImmediate gen;
2720 GLuint data[2];
2722 Cmds expected;
2723 expected.gen.Init(arraysize(ids), &ids[0]);
2724 expected.data[0] = kQueriesStartId;
2725 expected.data[1] = kQueriesStartId + 1;
2726 gl_->GenQueriesEXT(arraysize(ids), &ids[0]);
2727 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2728 EXPECT_EQ(kQueriesStartId, ids[0]);
2729 EXPECT_EQ(kQueriesStartId + 1, ids[1]);
2732 TEST_F(GLES2ImplementationTest, DeleteQueriesEXT) {
2733 GLuint ids[2] = {kQueriesStartId, kQueriesStartId + 1};
2734 struct Cmds {
2735 cmds::DeleteQueriesEXTImmediate del;
2736 GLuint data[2];
2738 Cmds expected;
2739 expected.del.Init(arraysize(ids), &ids[0]);
2740 expected.data[0] = kQueriesStartId;
2741 expected.data[1] = kQueriesStartId + 1;
2742 gl_->DeleteQueriesEXT(arraysize(ids), &ids[0]);
2743 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2745 // TODO(zmo): Implement unit test for QueryCounterEXT
2746 // TODO(zmo): Implement unit test for BeginQueryEXT
2748 TEST_F(GLES2ImplementationTest, BeginTransformFeedback) {
2749 struct Cmds {
2750 cmds::BeginTransformFeedback cmd;
2752 Cmds expected;
2753 expected.cmd.Init(GL_POINTS);
2755 gl_->BeginTransformFeedback(GL_POINTS);
2756 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2759 TEST_F(GLES2ImplementationTest, EndTransformFeedback) {
2760 struct Cmds {
2761 cmds::EndTransformFeedback cmd;
2763 Cmds expected;
2764 expected.cmd.Init();
2766 gl_->EndTransformFeedback();
2767 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2769 // TODO(zmo): Implement unit test for InsertEventMarkerEXT
2770 // TODO(zmo): Implement unit test for PushGroupMarkerEXT
2772 TEST_F(GLES2ImplementationTest, PopGroupMarkerEXT) {
2773 struct Cmds {
2774 cmds::PopGroupMarkerEXT cmd;
2776 Cmds expected;
2777 expected.cmd.Init();
2779 gl_->PopGroupMarkerEXT();
2780 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2783 TEST_F(GLES2ImplementationTest, GenVertexArraysOES) {
2784 GLuint ids[2] = {
2787 struct Cmds {
2788 cmds::GenVertexArraysOESImmediate gen;
2789 GLuint data[2];
2791 Cmds expected;
2792 expected.gen.Init(arraysize(ids), &ids[0]);
2793 expected.data[0] = kVertexArraysStartId;
2794 expected.data[1] = kVertexArraysStartId + 1;
2795 gl_->GenVertexArraysOES(arraysize(ids), &ids[0]);
2796 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2797 EXPECT_EQ(kVertexArraysStartId, ids[0]);
2798 EXPECT_EQ(kVertexArraysStartId + 1, ids[1]);
2801 TEST_F(GLES2ImplementationTest, DeleteVertexArraysOES) {
2802 GLuint ids[2] = {kVertexArraysStartId, kVertexArraysStartId + 1};
2803 struct Cmds {
2804 cmds::DeleteVertexArraysOESImmediate del;
2805 GLuint data[2];
2807 Cmds expected;
2808 expected.del.Init(arraysize(ids), &ids[0]);
2809 expected.data[0] = kVertexArraysStartId;
2810 expected.data[1] = kVertexArraysStartId + 1;
2811 gl_->DeleteVertexArraysOES(arraysize(ids), &ids[0]);
2812 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2815 TEST_F(GLES2ImplementationTest, IsVertexArrayOES) {
2816 struct Cmds {
2817 cmds::IsVertexArrayOES cmd;
2820 Cmds expected;
2821 ExpectedMemoryInfo result1 =
2822 GetExpectedResultMemory(sizeof(cmds::IsVertexArrayOES::Result));
2823 expected.cmd.Init(1, result1.id, result1.offset);
2825 EXPECT_CALL(*command_buffer(), OnFlush())
2826 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
2827 .RetiresOnSaturation();
2829 GLboolean result = gl_->IsVertexArrayOES(1);
2830 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2831 EXPECT_TRUE(result);
2833 // TODO(zmo): Implement unit test for EnableFeatureCHROMIUM
2834 // TODO(zmo): Implement unit test for MapBufferRange
2835 // TODO(zmo): Implement unit test for UnmapBuffer
2837 TEST_F(GLES2ImplementationTest, ResizeCHROMIUM) {
2838 struct Cmds {
2839 cmds::ResizeCHROMIUM cmd;
2841 Cmds expected;
2842 expected.cmd.Init(1, 2, 3);
2844 gl_->ResizeCHROMIUM(1, 2, 3);
2845 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2847 // TODO(zmo): Implement unit test for GetRequestableExtensionsCHROMIUM
2848 // TODO(zmo): Implement unit test for CreateStreamTextureCHROMIUM
2849 // TODO(zmo): Implement unit test for GetTranslatedShaderSourceANGLE
2851 TEST_F(GLES2ImplementationTest, TexImageIOSurface2DCHROMIUM) {
2852 struct Cmds {
2853 cmds::TexImageIOSurface2DCHROMIUM cmd;
2855 Cmds expected;
2856 expected.cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5);
2858 gl_->TexImageIOSurface2DCHROMIUM(GL_TEXTURE_2D, 2, 3, 4, 5);
2859 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2862 TEST_F(GLES2ImplementationTest, CopyTextureCHROMIUM) {
2863 struct Cmds {
2864 cmds::CopyTextureCHROMIUM cmd;
2866 Cmds expected;
2867 expected.cmd.Init(1, 2, 3, GL_ALPHA, GL_UNSIGNED_BYTE, true, true, true);
2869 gl_->CopyTextureCHROMIUM(1, 2, 3, GL_ALPHA, GL_UNSIGNED_BYTE, true, true,
2870 true);
2871 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2874 TEST_F(GLES2ImplementationTest, CopySubTextureCHROMIUM) {
2875 struct Cmds {
2876 cmds::CopySubTextureCHROMIUM cmd;
2878 Cmds expected;
2879 expected.cmd.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, true, true, true);
2881 gl_->CopySubTextureCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, true, true, true);
2882 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2885 TEST_F(GLES2ImplementationTest, CompressedCopyTextureCHROMIUM) {
2886 struct Cmds {
2887 cmds::CompressedCopyTextureCHROMIUM cmd;
2889 Cmds expected;
2890 expected.cmd.Init(1, 2, 3);
2892 gl_->CompressedCopyTextureCHROMIUM(1, 2, 3);
2893 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2896 TEST_F(GLES2ImplementationTest, DrawArraysInstancedANGLE) {
2897 struct Cmds {
2898 cmds::DrawArraysInstancedANGLE cmd;
2900 Cmds expected;
2901 expected.cmd.Init(GL_POINTS, 2, 3, 4);
2903 gl_->DrawArraysInstancedANGLE(GL_POINTS, 2, 3, 4);
2904 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2907 TEST_F(GLES2ImplementationTest, VertexAttribDivisorANGLE) {
2908 struct Cmds {
2909 cmds::VertexAttribDivisorANGLE cmd;
2911 Cmds expected;
2912 expected.cmd.Init(1, 2);
2914 gl_->VertexAttribDivisorANGLE(1, 2);
2915 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2917 // TODO(zmo): Implement unit test for GenMailboxCHROMIUM
2918 // TODO(zmo): Implement unit test for BindUniformLocationCHROMIUM
2920 TEST_F(GLES2ImplementationTest, GenValuebuffersCHROMIUM) {
2921 GLuint ids[2] = {
2924 struct Cmds {
2925 cmds::GenValuebuffersCHROMIUMImmediate gen;
2926 GLuint data[2];
2928 Cmds expected;
2929 expected.gen.Init(arraysize(ids), &ids[0]);
2930 expected.data[0] = kValuebuffersStartId;
2931 expected.data[1] = kValuebuffersStartId + 1;
2932 gl_->GenValuebuffersCHROMIUM(arraysize(ids), &ids[0]);
2933 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2934 EXPECT_EQ(kValuebuffersStartId, ids[0]);
2935 EXPECT_EQ(kValuebuffersStartId + 1, ids[1]);
2938 TEST_F(GLES2ImplementationTest, DeleteValuebuffersCHROMIUM) {
2939 GLuint ids[2] = {kValuebuffersStartId, kValuebuffersStartId + 1};
2940 struct Cmds {
2941 cmds::DeleteValuebuffersCHROMIUMImmediate del;
2942 GLuint data[2];
2944 Cmds expected;
2945 expected.del.Init(arraysize(ids), &ids[0]);
2946 expected.data[0] = kValuebuffersStartId;
2947 expected.data[1] = kValuebuffersStartId + 1;
2948 gl_->DeleteValuebuffersCHROMIUM(arraysize(ids), &ids[0]);
2949 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2952 TEST_F(GLES2ImplementationTest, IsValuebufferCHROMIUM) {
2953 struct Cmds {
2954 cmds::IsValuebufferCHROMIUM cmd;
2957 Cmds expected;
2958 ExpectedMemoryInfo result1 =
2959 GetExpectedResultMemory(sizeof(cmds::IsValuebufferCHROMIUM::Result));
2960 expected.cmd.Init(1, result1.id, result1.offset);
2962 EXPECT_CALL(*command_buffer(), OnFlush())
2963 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
2964 .RetiresOnSaturation();
2966 GLboolean result = gl_->IsValuebufferCHROMIUM(1);
2967 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2968 EXPECT_TRUE(result);
2971 TEST_F(GLES2ImplementationTest, BindValuebufferCHROMIUM) {
2972 struct Cmds {
2973 cmds::BindValuebufferCHROMIUM cmd;
2975 Cmds expected;
2976 expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
2978 gl_->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
2979 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2980 ClearCommands();
2981 gl_->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
2982 EXPECT_TRUE(NoCommandsWritten());
2985 TEST_F(GLES2ImplementationTest, SubscribeValueCHROMIUM) {
2986 struct Cmds {
2987 cmds::SubscribeValueCHROMIUM cmd;
2989 Cmds expected;
2990 expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
2991 GL_MOUSE_POSITION_CHROMIUM);
2993 gl_->SubscribeValueCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
2994 GL_MOUSE_POSITION_CHROMIUM);
2995 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2998 TEST_F(GLES2ImplementationTest, PopulateSubscribedValuesCHROMIUM) {
2999 struct Cmds {
3000 cmds::PopulateSubscribedValuesCHROMIUM cmd;
3002 Cmds expected;
3003 expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM);
3005 gl_->PopulateSubscribedValuesCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM);
3006 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3009 TEST_F(GLES2ImplementationTest, UniformValuebufferCHROMIUM) {
3010 struct Cmds {
3011 cmds::UniformValuebufferCHROMIUM cmd;
3013 Cmds expected;
3014 expected.cmd.Init(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
3015 GL_MOUSE_POSITION_CHROMIUM);
3017 gl_->UniformValuebufferCHROMIUM(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
3018 GL_MOUSE_POSITION_CHROMIUM);
3019 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3022 TEST_F(GLES2ImplementationTest, BindTexImage2DCHROMIUM) {
3023 struct Cmds {
3024 cmds::BindTexImage2DCHROMIUM cmd;
3026 Cmds expected;
3027 expected.cmd.Init(GL_TEXTURE_2D, 2);
3029 gl_->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
3030 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3033 TEST_F(GLES2ImplementationTest, ReleaseTexImage2DCHROMIUM) {
3034 struct Cmds {
3035 cmds::ReleaseTexImage2DCHROMIUM cmd;
3037 Cmds expected;
3038 expected.cmd.Init(GL_TEXTURE_2D, 2);
3040 gl_->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
3041 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3044 TEST_F(GLES2ImplementationTest, DiscardFramebufferEXT) {
3045 GLenum data[2][1] = {{0}};
3046 struct Cmds {
3047 cmds::DiscardFramebufferEXTImmediate cmd;
3048 GLenum data[2][1];
3051 Cmds expected;
3052 for (int ii = 0; ii < 2; ++ii) {
3053 for (int jj = 0; jj < 1; ++jj) {
3054 data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
3057 expected.cmd.Init(1, 2, &data[0][0]);
3058 gl_->DiscardFramebufferEXT(1, 2, &data[0][0]);
3059 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3062 TEST_F(GLES2ImplementationTest, LoseContextCHROMIUM) {
3063 struct Cmds {
3064 cmds::LoseContextCHROMIUM cmd;
3066 Cmds expected;
3067 expected.cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_GUILTY_CONTEXT_RESET_ARB);
3069 gl_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
3070 GL_GUILTY_CONTEXT_RESET_ARB);
3071 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3073 // TODO(zmo): Implement unit test for InsertSyncPointCHROMIUM
3075 TEST_F(GLES2ImplementationTest, WaitSyncPointCHROMIUM) {
3076 struct Cmds {
3077 cmds::WaitSyncPointCHROMIUM cmd;
3079 Cmds expected;
3080 expected.cmd.Init(1);
3082 gl_->WaitSyncPointCHROMIUM(1);
3083 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3086 TEST_F(GLES2ImplementationTest, DrawBuffersEXT) {
3087 GLenum data[1][1] = {{0}};
3088 struct Cmds {
3089 cmds::DrawBuffersEXTImmediate cmd;
3090 GLenum data[1][1];
3093 Cmds expected;
3094 for (int ii = 0; ii < 1; ++ii) {
3095 for (int jj = 0; jj < 1; ++jj) {
3096 data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
3099 expected.cmd.Init(1, &data[0][0]);
3100 gl_->DrawBuffersEXT(1, &data[0][0]);
3101 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3104 TEST_F(GLES2ImplementationTest, DiscardBackbufferCHROMIUM) {
3105 struct Cmds {
3106 cmds::DiscardBackbufferCHROMIUM cmd;
3108 Cmds expected;
3109 expected.cmd.Init();
3111 gl_->DiscardBackbufferCHROMIUM();
3112 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3115 TEST_F(GLES2ImplementationTest, FlushDriverCachesCHROMIUM) {
3116 struct Cmds {
3117 cmds::FlushDriverCachesCHROMIUM cmd;
3119 Cmds expected;
3120 expected.cmd.Init();
3122 gl_->FlushDriverCachesCHROMIUM();
3123 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3126 TEST_F(GLES2ImplementationTest, MatrixLoadfCHROMIUM) {
3127 GLfloat data[16] = {0};
3128 struct Cmds {
3129 cmds::MatrixLoadfCHROMIUMImmediate cmd;
3130 GLfloat data[16];
3133 for (int jj = 0; jj < 16; ++jj) {
3134 data[jj] = static_cast<GLfloat>(jj);
3136 Cmds expected;
3137 expected.cmd.Init(GL_PATH_PROJECTION_CHROMIUM, &data[0]);
3138 gl_->MatrixLoadfCHROMIUM(GL_PATH_PROJECTION_CHROMIUM, &data[0]);
3139 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3142 TEST_F(GLES2ImplementationTest, MatrixLoadIdentityCHROMIUM) {
3143 struct Cmds {
3144 cmds::MatrixLoadIdentityCHROMIUM cmd;
3146 Cmds expected;
3147 expected.cmd.Init(GL_PATH_PROJECTION_CHROMIUM);
3149 gl_->MatrixLoadIdentityCHROMIUM(GL_PATH_PROJECTION_CHROMIUM);
3150 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3152 // TODO(zmo): Implement unit test for GenPathsCHROMIUM
3154 TEST_F(GLES2ImplementationTest, DeletePathsCHROMIUM) {
3155 struct Cmds {
3156 cmds::DeletePathsCHROMIUM cmd;
3158 Cmds expected;
3159 expected.cmd.Init(1, 2);
3161 gl_->DeletePathsCHROMIUM(1, 2);
3162 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3165 TEST_F(GLES2ImplementationTest, IsPathCHROMIUM) {
3166 struct Cmds {
3167 cmds::IsPathCHROMIUM cmd;
3170 Cmds expected;
3171 ExpectedMemoryInfo result1 =
3172 GetExpectedResultMemory(sizeof(cmds::IsPathCHROMIUM::Result));
3173 expected.cmd.Init(1, result1.id, result1.offset);
3175 EXPECT_CALL(*command_buffer(), OnFlush())
3176 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
3177 .RetiresOnSaturation();
3179 GLboolean result = gl_->IsPathCHROMIUM(1);
3180 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3181 EXPECT_TRUE(result);
3183 // TODO(zmo): Implement unit test for PathCommandsCHROMIUM
3185 TEST_F(GLES2ImplementationTest, PathParameterfCHROMIUM) {
3186 struct Cmds {
3187 cmds::PathParameterfCHROMIUM cmd;
3189 Cmds expected;
3190 expected.cmd.Init(1, GL_PATH_STROKE_WIDTH_CHROMIUM, 3);
3192 gl_->PathParameterfCHROMIUM(1, GL_PATH_STROKE_WIDTH_CHROMIUM, 3);
3193 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3196 TEST_F(GLES2ImplementationTest, PathParameteriCHROMIUM) {
3197 struct Cmds {
3198 cmds::PathParameteriCHROMIUM cmd;
3200 Cmds expected;
3201 expected.cmd.Init(1, GL_PATH_STROKE_WIDTH_CHROMIUM, 3);
3203 gl_->PathParameteriCHROMIUM(1, GL_PATH_STROKE_WIDTH_CHROMIUM, 3);
3204 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3207 TEST_F(GLES2ImplementationTest, PathStencilFuncCHROMIUM) {
3208 struct Cmds {
3209 cmds::PathStencilFuncCHROMIUM cmd;
3211 Cmds expected;
3212 expected.cmd.Init(GL_NEVER, 2, 3);
3214 gl_->PathStencilFuncCHROMIUM(GL_NEVER, 2, 3);
3215 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3218 TEST_F(GLES2ImplementationTest, StencilFillPathCHROMIUM) {
3219 struct Cmds {
3220 cmds::StencilFillPathCHROMIUM cmd;
3222 Cmds expected;
3223 expected.cmd.Init(1, GL_INVERT, 3);
3225 gl_->StencilFillPathCHROMIUM(1, GL_INVERT, 3);
3226 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3229 TEST_F(GLES2ImplementationTest, StencilStrokePathCHROMIUM) {
3230 struct Cmds {
3231 cmds::StencilStrokePathCHROMIUM cmd;
3233 Cmds expected;
3234 expected.cmd.Init(1, 2, 3);
3236 gl_->StencilStrokePathCHROMIUM(1, 2, 3);
3237 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3240 TEST_F(GLES2ImplementationTest, CoverFillPathCHROMIUM) {
3241 struct Cmds {
3242 cmds::CoverFillPathCHROMIUM cmd;
3244 Cmds expected;
3245 expected.cmd.Init(1, GL_CONVEX_HULL_CHROMIUM);
3247 gl_->CoverFillPathCHROMIUM(1, GL_CONVEX_HULL_CHROMIUM);
3248 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3251 TEST_F(GLES2ImplementationTest, CoverStrokePathCHROMIUM) {
3252 struct Cmds {
3253 cmds::CoverStrokePathCHROMIUM cmd;
3255 Cmds expected;
3256 expected.cmd.Init(1, GL_CONVEX_HULL_CHROMIUM);
3258 gl_->CoverStrokePathCHROMIUM(1, GL_CONVEX_HULL_CHROMIUM);
3259 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3262 TEST_F(GLES2ImplementationTest, StencilThenCoverFillPathCHROMIUM) {
3263 struct Cmds {
3264 cmds::StencilThenCoverFillPathCHROMIUM cmd;
3266 Cmds expected;
3267 expected.cmd.Init(1, GL_INVERT, 3, GL_CONVEX_HULL_CHROMIUM);
3269 gl_->StencilThenCoverFillPathCHROMIUM(1, GL_INVERT, 3,
3270 GL_CONVEX_HULL_CHROMIUM);
3271 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3274 TEST_F(GLES2ImplementationTest, StencilThenCoverStrokePathCHROMIUM) {
3275 struct Cmds {
3276 cmds::StencilThenCoverStrokePathCHROMIUM cmd;
3278 Cmds expected;
3279 expected.cmd.Init(1, 2, 3, GL_CONVEX_HULL_CHROMIUM);
3281 gl_->StencilThenCoverStrokePathCHROMIUM(1, 2, 3, GL_CONVEX_HULL_CHROMIUM);
3282 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3284 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_