Rewrite AndroidSyncSettings to be significantly simpler.
[chromium-blink-merge.git] / gpu / command_buffer / client / gles2_implementation_unittest_autogen.h
blob9b43afebdaa800eeb4006ab41df1bf3c42a9c4ba
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
316 TEST_F(GLES2ImplementationTest, CopyBufferSubData) {
317 struct Cmds {
318 cmds::CopyBufferSubData cmd;
320 Cmds expected;
321 expected.cmd.Init(GL_ARRAY_BUFFER, GL_ARRAY_BUFFER, 3, 4, 5);
323 gl_->CopyBufferSubData(GL_ARRAY_BUFFER, GL_ARRAY_BUFFER, 3, 4, 5);
324 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
327 TEST_F(GLES2ImplementationTest, CopyTexImage2D) {
328 struct Cmds {
329 cmds::CopyTexImage2D cmd;
331 Cmds expected;
332 expected.cmd.Init(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7);
334 gl_->CopyTexImage2D(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7, 0);
335 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
338 TEST_F(GLES2ImplementationTest, CopyTexImage2DInvalidConstantArg7) {
339 gl_->CopyTexImage2D(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7, 1);
340 EXPECT_TRUE(NoCommandsWritten());
341 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
344 TEST_F(GLES2ImplementationTest, CopyTexSubImage2D) {
345 struct Cmds {
346 cmds::CopyTexSubImage2D cmd;
348 Cmds expected;
349 expected.cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8);
351 gl_->CopyTexSubImage2D(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8);
352 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
355 TEST_F(GLES2ImplementationTest, CopyTexSubImage3D) {
356 struct Cmds {
357 cmds::CopyTexSubImage3D cmd;
359 Cmds expected;
360 expected.cmd.Init(GL_TEXTURE_3D, 2, 3, 4, 5, 6, 7, 8, 9);
362 gl_->CopyTexSubImage3D(GL_TEXTURE_3D, 2, 3, 4, 5, 6, 7, 8, 9);
363 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
366 TEST_F(GLES2ImplementationTest, CullFace) {
367 struct Cmds {
368 cmds::CullFace cmd;
370 Cmds expected;
371 expected.cmd.Init(GL_FRONT);
373 gl_->CullFace(GL_FRONT);
374 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
377 TEST_F(GLES2ImplementationTest, DeleteBuffers) {
378 GLuint ids[2] = {kBuffersStartId, kBuffersStartId + 1};
379 struct Cmds {
380 cmds::DeleteBuffersImmediate del;
381 GLuint data[2];
383 Cmds expected;
384 expected.del.Init(arraysize(ids), &ids[0]);
385 expected.data[0] = kBuffersStartId;
386 expected.data[1] = kBuffersStartId + 1;
387 gl_->DeleteBuffers(arraysize(ids), &ids[0]);
388 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
391 TEST_F(GLES2ImplementationTest, DeleteFramebuffers) {
392 GLuint ids[2] = {kFramebuffersStartId, kFramebuffersStartId + 1};
393 struct Cmds {
394 cmds::DeleteFramebuffersImmediate del;
395 GLuint data[2];
397 Cmds expected;
398 expected.del.Init(arraysize(ids), &ids[0]);
399 expected.data[0] = kFramebuffersStartId;
400 expected.data[1] = kFramebuffersStartId + 1;
401 gl_->DeleteFramebuffers(arraysize(ids), &ids[0]);
402 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
405 TEST_F(GLES2ImplementationTest, DeleteProgram) {
406 struct Cmds {
407 cmds::DeleteProgram cmd;
409 Cmds expected;
410 expected.cmd.Init(1);
412 gl_->DeleteProgram(1);
413 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
416 TEST_F(GLES2ImplementationTest, DeleteRenderbuffers) {
417 GLuint ids[2] = {kRenderbuffersStartId, kRenderbuffersStartId + 1};
418 struct Cmds {
419 cmds::DeleteRenderbuffersImmediate del;
420 GLuint data[2];
422 Cmds expected;
423 expected.del.Init(arraysize(ids), &ids[0]);
424 expected.data[0] = kRenderbuffersStartId;
425 expected.data[1] = kRenderbuffersStartId + 1;
426 gl_->DeleteRenderbuffers(arraysize(ids), &ids[0]);
427 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
430 TEST_F(GLES2ImplementationTest, DeleteSamplers) {
431 GLuint ids[2] = {kSamplersStartId, kSamplersStartId + 1};
432 struct Cmds {
433 cmds::DeleteSamplersImmediate del;
434 GLuint data[2];
436 Cmds expected;
437 expected.del.Init(arraysize(ids), &ids[0]);
438 expected.data[0] = kSamplersStartId;
439 expected.data[1] = kSamplersStartId + 1;
440 gl_->DeleteSamplers(arraysize(ids), &ids[0]);
441 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
444 TEST_F(GLES2ImplementationTest, DeleteSync) {
445 struct Cmds {
446 cmds::DeleteSync cmd;
448 Cmds expected;
449 expected.cmd.Init(1);
451 gl_->DeleteSync(reinterpret_cast<GLsync>(1));
452 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
455 TEST_F(GLES2ImplementationTest, DeleteShader) {
456 struct Cmds {
457 cmds::DeleteShader cmd;
459 Cmds expected;
460 expected.cmd.Init(1);
462 gl_->DeleteShader(1);
463 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
466 TEST_F(GLES2ImplementationTest, DeleteTextures) {
467 GLuint ids[2] = {kTexturesStartId, kTexturesStartId + 1};
468 struct Cmds {
469 cmds::DeleteTexturesImmediate del;
470 GLuint data[2];
472 Cmds expected;
473 expected.del.Init(arraysize(ids), &ids[0]);
474 expected.data[0] = kTexturesStartId;
475 expected.data[1] = kTexturesStartId + 1;
476 gl_->DeleteTextures(arraysize(ids), &ids[0]);
477 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
480 TEST_F(GLES2ImplementationTest, DeleteTransformFeedbacks) {
481 GLuint ids[2] = {kTransformFeedbacksStartId, kTransformFeedbacksStartId + 1};
482 struct Cmds {
483 cmds::DeleteTransformFeedbacksImmediate del;
484 GLuint data[2];
486 Cmds expected;
487 expected.del.Init(arraysize(ids), &ids[0]);
488 expected.data[0] = kTransformFeedbacksStartId;
489 expected.data[1] = kTransformFeedbacksStartId + 1;
490 gl_->DeleteTransformFeedbacks(arraysize(ids), &ids[0]);
491 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
494 TEST_F(GLES2ImplementationTest, DepthFunc) {
495 struct Cmds {
496 cmds::DepthFunc cmd;
498 Cmds expected;
499 expected.cmd.Init(GL_NEVER);
501 gl_->DepthFunc(GL_NEVER);
502 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
505 TEST_F(GLES2ImplementationTest, DepthMask) {
506 struct Cmds {
507 cmds::DepthMask cmd;
509 Cmds expected;
510 expected.cmd.Init(true);
512 gl_->DepthMask(true);
513 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
516 TEST_F(GLES2ImplementationTest, DepthRangef) {
517 struct Cmds {
518 cmds::DepthRangef cmd;
520 Cmds expected;
521 expected.cmd.Init(1, 2);
523 gl_->DepthRangef(1, 2);
524 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
527 TEST_F(GLES2ImplementationTest, DetachShader) {
528 struct Cmds {
529 cmds::DetachShader cmd;
531 Cmds expected;
532 expected.cmd.Init(1, 2);
534 gl_->DetachShader(1, 2);
535 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
538 TEST_F(GLES2ImplementationTest, DisableVertexAttribArray) {
539 struct Cmds {
540 cmds::DisableVertexAttribArray cmd;
542 Cmds expected;
543 expected.cmd.Init(1);
545 gl_->DisableVertexAttribArray(1);
546 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
549 TEST_F(GLES2ImplementationTest, DrawArrays) {
550 struct Cmds {
551 cmds::DrawArrays cmd;
553 Cmds expected;
554 expected.cmd.Init(GL_POINTS, 2, 3);
556 gl_->DrawArrays(GL_POINTS, 2, 3);
557 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
560 TEST_F(GLES2ImplementationTest, EnableVertexAttribArray) {
561 struct Cmds {
562 cmds::EnableVertexAttribArray cmd;
564 Cmds expected;
565 expected.cmd.Init(1);
567 gl_->EnableVertexAttribArray(1);
568 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
571 TEST_F(GLES2ImplementationTest, Flush) {
572 struct Cmds {
573 cmds::Flush cmd;
575 Cmds expected;
576 expected.cmd.Init();
578 gl_->Flush();
579 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
582 TEST_F(GLES2ImplementationTest, FramebufferRenderbuffer) {
583 struct Cmds {
584 cmds::FramebufferRenderbuffer cmd;
586 Cmds expected;
587 expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 4);
589 gl_->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
590 GL_RENDERBUFFER, 4);
591 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
594 TEST_F(GLES2ImplementationTest, FramebufferTexture2D) {
595 struct Cmds {
596 cmds::FramebufferTexture2D cmd;
598 Cmds expected;
599 expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4);
601 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
602 4, 0);
603 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
606 TEST_F(GLES2ImplementationTest, FramebufferTexture2DInvalidConstantArg4) {
607 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
608 4, 1);
609 EXPECT_TRUE(NoCommandsWritten());
610 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
613 TEST_F(GLES2ImplementationTest, FramebufferTextureLayer) {
614 struct Cmds {
615 cmds::FramebufferTextureLayer cmd;
617 Cmds expected;
618 expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 3, 4, 5);
620 gl_->FramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 3, 4, 5);
621 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
624 TEST_F(GLES2ImplementationTest, FrontFace) {
625 struct Cmds {
626 cmds::FrontFace cmd;
628 Cmds expected;
629 expected.cmd.Init(GL_CW);
631 gl_->FrontFace(GL_CW);
632 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
635 TEST_F(GLES2ImplementationTest, GenBuffers) {
636 GLuint ids[2] = {
639 struct Cmds {
640 cmds::GenBuffersImmediate gen;
641 GLuint data[2];
643 Cmds expected;
644 expected.gen.Init(arraysize(ids), &ids[0]);
645 expected.data[0] = kBuffersStartId;
646 expected.data[1] = kBuffersStartId + 1;
647 gl_->GenBuffers(arraysize(ids), &ids[0]);
648 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
649 EXPECT_EQ(kBuffersStartId, ids[0]);
650 EXPECT_EQ(kBuffersStartId + 1, ids[1]);
653 TEST_F(GLES2ImplementationTest, GenerateMipmap) {
654 struct Cmds {
655 cmds::GenerateMipmap cmd;
657 Cmds expected;
658 expected.cmd.Init(GL_TEXTURE_2D);
660 gl_->GenerateMipmap(GL_TEXTURE_2D);
661 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
664 TEST_F(GLES2ImplementationTest, GenFramebuffers) {
665 GLuint ids[2] = {
668 struct Cmds {
669 cmds::GenFramebuffersImmediate gen;
670 GLuint data[2];
672 Cmds expected;
673 expected.gen.Init(arraysize(ids), &ids[0]);
674 expected.data[0] = kFramebuffersStartId;
675 expected.data[1] = kFramebuffersStartId + 1;
676 gl_->GenFramebuffers(arraysize(ids), &ids[0]);
677 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
678 EXPECT_EQ(kFramebuffersStartId, ids[0]);
679 EXPECT_EQ(kFramebuffersStartId + 1, ids[1]);
682 TEST_F(GLES2ImplementationTest, GenRenderbuffers) {
683 GLuint ids[2] = {
686 struct Cmds {
687 cmds::GenRenderbuffersImmediate gen;
688 GLuint data[2];
690 Cmds expected;
691 expected.gen.Init(arraysize(ids), &ids[0]);
692 expected.data[0] = kRenderbuffersStartId;
693 expected.data[1] = kRenderbuffersStartId + 1;
694 gl_->GenRenderbuffers(arraysize(ids), &ids[0]);
695 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
696 EXPECT_EQ(kRenderbuffersStartId, ids[0]);
697 EXPECT_EQ(kRenderbuffersStartId + 1, ids[1]);
700 TEST_F(GLES2ImplementationTest, GenSamplers) {
701 GLuint ids[2] = {
704 struct Cmds {
705 cmds::GenSamplersImmediate gen;
706 GLuint data[2];
708 Cmds expected;
709 expected.gen.Init(arraysize(ids), &ids[0]);
710 expected.data[0] = kSamplersStartId;
711 expected.data[1] = kSamplersStartId + 1;
712 gl_->GenSamplers(arraysize(ids), &ids[0]);
713 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
714 EXPECT_EQ(kSamplersStartId, ids[0]);
715 EXPECT_EQ(kSamplersStartId + 1, ids[1]);
718 TEST_F(GLES2ImplementationTest, GenTextures) {
719 GLuint ids[2] = {
722 struct Cmds {
723 cmds::GenTexturesImmediate gen;
724 GLuint data[2];
726 Cmds expected;
727 expected.gen.Init(arraysize(ids), &ids[0]);
728 expected.data[0] = kTexturesStartId;
729 expected.data[1] = kTexturesStartId + 1;
730 gl_->GenTextures(arraysize(ids), &ids[0]);
731 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
732 EXPECT_EQ(kTexturesStartId, ids[0]);
733 EXPECT_EQ(kTexturesStartId + 1, ids[1]);
736 TEST_F(GLES2ImplementationTest, GenTransformFeedbacks) {
737 GLuint ids[2] = {
740 struct Cmds {
741 cmds::GenTransformFeedbacksImmediate gen;
742 GLuint data[2];
744 Cmds expected;
745 expected.gen.Init(arraysize(ids), &ids[0]);
746 expected.data[0] = kTransformFeedbacksStartId;
747 expected.data[1] = kTransformFeedbacksStartId + 1;
748 gl_->GenTransformFeedbacks(arraysize(ids), &ids[0]);
749 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
750 EXPECT_EQ(kTransformFeedbacksStartId, ids[0]);
751 EXPECT_EQ(kTransformFeedbacksStartId + 1, ids[1]);
753 // TODO(zmo): Implement unit test for GetActiveAttrib
754 // TODO(zmo): Implement unit test for GetActiveUniform
755 // TODO(zmo): Implement unit test for GetActiveUniformBlockiv
756 // TODO(zmo): Implement unit test for GetActiveUniformBlockName
757 // TODO(zmo): Implement unit test for GetActiveUniformsiv
758 // TODO(zmo): Implement unit test for GetAttachedShaders
759 // TODO(zmo): Implement unit test for GetAttribLocation
761 TEST_F(GLES2ImplementationTest, GetBooleanv) {
762 struct Cmds {
763 cmds::GetBooleanv cmd;
765 typedef cmds::GetBooleanv::Result Result;
766 Result::Type result = 0;
767 Cmds expected;
768 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
769 expected.cmd.Init(123, result1.id, result1.offset);
770 EXPECT_CALL(*command_buffer(), OnFlush())
771 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
772 .RetiresOnSaturation();
773 gl_->GetBooleanv(123, &result);
774 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
775 EXPECT_EQ(static_cast<Result::Type>(1), result);
778 TEST_F(GLES2ImplementationTest, GetBufferParameteriv) {
779 struct Cmds {
780 cmds::GetBufferParameteriv cmd;
782 typedef cmds::GetBufferParameteriv::Result Result;
783 Result::Type result = 0;
784 Cmds expected;
785 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
786 expected.cmd.Init(123, GL_BUFFER_SIZE, result1.id, result1.offset);
787 EXPECT_CALL(*command_buffer(), OnFlush())
788 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
789 .RetiresOnSaturation();
790 gl_->GetBufferParameteriv(123, GL_BUFFER_SIZE, &result);
791 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
792 EXPECT_EQ(static_cast<Result::Type>(1), result);
795 TEST_F(GLES2ImplementationTest, GetFloatv) {
796 struct Cmds {
797 cmds::GetFloatv cmd;
799 typedef cmds::GetFloatv::Result Result;
800 Result::Type result = 0;
801 Cmds expected;
802 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
803 expected.cmd.Init(123, result1.id, result1.offset);
804 EXPECT_CALL(*command_buffer(), OnFlush())
805 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
806 .RetiresOnSaturation();
807 gl_->GetFloatv(123, &result);
808 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
809 EXPECT_EQ(static_cast<Result::Type>(1), result);
811 // TODO(zmo): Implement unit test for GetFragDataLocation
813 TEST_F(GLES2ImplementationTest, GetFramebufferAttachmentParameteriv) {
814 struct Cmds {
815 cmds::GetFramebufferAttachmentParameteriv cmd;
817 typedef cmds::GetFramebufferAttachmentParameteriv::Result Result;
818 Result::Type result = 0;
819 Cmds expected;
820 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
821 expected.cmd.Init(123, GL_COLOR_ATTACHMENT0,
822 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, result1.id,
823 result1.offset);
824 EXPECT_CALL(*command_buffer(), OnFlush())
825 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
826 .RetiresOnSaturation();
827 gl_->GetFramebufferAttachmentParameteriv(
828 123, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
829 &result);
830 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
831 EXPECT_EQ(static_cast<Result::Type>(1), result);
834 TEST_F(GLES2ImplementationTest, GetIntegerv) {
835 struct Cmds {
836 cmds::GetIntegerv cmd;
838 typedef cmds::GetIntegerv::Result Result;
839 Result::Type result = 0;
840 Cmds expected;
841 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
842 expected.cmd.Init(123, result1.id, result1.offset);
843 EXPECT_CALL(*command_buffer(), OnFlush())
844 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
845 .RetiresOnSaturation();
846 gl_->GetIntegerv(123, &result);
847 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
848 EXPECT_EQ(static_cast<Result::Type>(1), result);
851 TEST_F(GLES2ImplementationTest, GetInternalformativ) {
852 struct Cmds {
853 cmds::GetInternalformativ cmd;
855 typedef cmds::GetInternalformativ::Result Result;
856 Result::Type result = 0;
857 Cmds expected;
858 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
859 expected.cmd.Init(123, GL_RGBA4, GL_RENDERBUFFER_RED_SIZE, 4, result1.id,
860 result1.offset);
861 EXPECT_CALL(*command_buffer(), OnFlush())
862 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
863 .RetiresOnSaturation();
864 gl_->GetInternalformativ(123, GL_RGBA4, GL_RENDERBUFFER_RED_SIZE, 4, &result);
865 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
866 EXPECT_EQ(static_cast<Result::Type>(1), result);
869 TEST_F(GLES2ImplementationTest, GetProgramiv) {
870 struct Cmds {
871 cmds::GetProgramiv cmd;
873 typedef cmds::GetProgramiv::Result Result;
874 Result::Type result = 0;
875 Cmds expected;
876 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
877 expected.cmd.Init(123, GL_DELETE_STATUS, result1.id, result1.offset);
878 EXPECT_CALL(*command_buffer(), OnFlush())
879 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
880 .RetiresOnSaturation();
881 gl_->GetProgramiv(123, GL_DELETE_STATUS, &result);
882 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
883 EXPECT_EQ(static_cast<Result::Type>(1), result);
885 // TODO(zmo): Implement unit test for GetProgramInfoLog
887 TEST_F(GLES2ImplementationTest, GetRenderbufferParameteriv) {
888 struct Cmds {
889 cmds::GetRenderbufferParameteriv cmd;
891 typedef cmds::GetRenderbufferParameteriv::Result Result;
892 Result::Type result = 0;
893 Cmds expected;
894 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
895 expected.cmd.Init(123, GL_RENDERBUFFER_RED_SIZE, result1.id, result1.offset);
896 EXPECT_CALL(*command_buffer(), OnFlush())
897 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
898 .RetiresOnSaturation();
899 gl_->GetRenderbufferParameteriv(123, GL_RENDERBUFFER_RED_SIZE, &result);
900 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
901 EXPECT_EQ(static_cast<Result::Type>(1), result);
904 TEST_F(GLES2ImplementationTest, GetSamplerParameterfv) {
905 struct Cmds {
906 cmds::GetSamplerParameterfv cmd;
908 typedef cmds::GetSamplerParameterfv::Result Result;
909 Result::Type result = 0;
910 Cmds expected;
911 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
912 expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
913 EXPECT_CALL(*command_buffer(), OnFlush())
914 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
915 .RetiresOnSaturation();
916 gl_->GetSamplerParameterfv(123, GL_TEXTURE_MAG_FILTER, &result);
917 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
918 EXPECT_EQ(static_cast<Result::Type>(1), result);
921 TEST_F(GLES2ImplementationTest, GetSamplerParameteriv) {
922 struct Cmds {
923 cmds::GetSamplerParameteriv cmd;
925 typedef cmds::GetSamplerParameteriv::Result Result;
926 Result::Type result = 0;
927 Cmds expected;
928 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
929 expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
930 EXPECT_CALL(*command_buffer(), OnFlush())
931 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
932 .RetiresOnSaturation();
933 gl_->GetSamplerParameteriv(123, GL_TEXTURE_MAG_FILTER, &result);
934 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
935 EXPECT_EQ(static_cast<Result::Type>(1), result);
938 TEST_F(GLES2ImplementationTest, GetShaderiv) {
939 struct Cmds {
940 cmds::GetShaderiv cmd;
942 typedef cmds::GetShaderiv::Result Result;
943 Result::Type result = 0;
944 Cmds expected;
945 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
946 expected.cmd.Init(123, GL_SHADER_TYPE, result1.id, result1.offset);
947 EXPECT_CALL(*command_buffer(), OnFlush())
948 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
949 .RetiresOnSaturation();
950 gl_->GetShaderiv(123, GL_SHADER_TYPE, &result);
951 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
952 EXPECT_EQ(static_cast<Result::Type>(1), result);
954 // TODO(zmo): Implement unit test for GetShaderInfoLog
955 // TODO(zmo): Implement unit test for GetShaderPrecisionFormat
957 TEST_F(GLES2ImplementationTest, GetSynciv) {
958 struct Cmds {
959 cmds::GetSynciv cmd;
961 typedef cmds::GetSynciv::Result Result;
962 Result::Type result = 0;
963 Cmds expected;
964 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
965 expected.cmd.Init(123, GL_SYNC_STATUS, result1.id, result1.offset);
966 EXPECT_CALL(*command_buffer(), OnFlush())
967 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
968 .RetiresOnSaturation();
969 gl_->GetSynciv(reinterpret_cast<GLsync>(123), GL_SYNC_STATUS, 3, nullptr,
970 &result);
971 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
972 EXPECT_EQ(static_cast<Result::Type>(1), result);
975 TEST_F(GLES2ImplementationTest, GetTexParameterfv) {
976 struct Cmds {
977 cmds::GetTexParameterfv cmd;
979 typedef cmds::GetTexParameterfv::Result Result;
980 Result::Type result = 0;
981 Cmds expected;
982 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
983 expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
984 EXPECT_CALL(*command_buffer(), OnFlush())
985 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
986 .RetiresOnSaturation();
987 gl_->GetTexParameterfv(123, GL_TEXTURE_MAG_FILTER, &result);
988 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
989 EXPECT_EQ(static_cast<Result::Type>(1), result);
992 TEST_F(GLES2ImplementationTest, GetTexParameteriv) {
993 struct Cmds {
994 cmds::GetTexParameteriv cmd;
996 typedef cmds::GetTexParameteriv::Result Result;
997 Result::Type result = 0;
998 Cmds expected;
999 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
1000 expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
1001 EXPECT_CALL(*command_buffer(), OnFlush())
1002 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
1003 .RetiresOnSaturation();
1004 gl_->GetTexParameteriv(123, GL_TEXTURE_MAG_FILTER, &result);
1005 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1006 EXPECT_EQ(static_cast<Result::Type>(1), result);
1008 // TODO(zmo): Implement unit test for GetTransformFeedbackVarying
1009 // TODO(zmo): Implement unit test for GetUniformBlockIndex
1010 // TODO(zmo): Implement unit test for GetUniformfv
1011 // TODO(zmo): Implement unit test for GetUniformiv
1012 // TODO(zmo): Implement unit test for GetUniformIndices
1013 // TODO(zmo): Implement unit test for GetUniformLocation
1015 TEST_F(GLES2ImplementationTest, GetVertexAttribfv) {
1016 struct Cmds {
1017 cmds::GetVertexAttribfv cmd;
1019 typedef cmds::GetVertexAttribfv::Result Result;
1020 Result::Type result = 0;
1021 Cmds expected;
1022 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
1023 expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1024 result1.offset);
1025 EXPECT_CALL(*command_buffer(), OnFlush())
1026 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
1027 .RetiresOnSaturation();
1028 gl_->GetVertexAttribfv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1029 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1030 EXPECT_EQ(static_cast<Result::Type>(1), result);
1033 TEST_F(GLES2ImplementationTest, GetVertexAttribiv) {
1034 struct Cmds {
1035 cmds::GetVertexAttribiv cmd;
1037 typedef cmds::GetVertexAttribiv::Result Result;
1038 Result::Type result = 0;
1039 Cmds expected;
1040 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
1041 expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1042 result1.offset);
1043 EXPECT_CALL(*command_buffer(), OnFlush())
1044 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
1045 .RetiresOnSaturation();
1046 gl_->GetVertexAttribiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1047 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1048 EXPECT_EQ(static_cast<Result::Type>(1), result);
1051 TEST_F(GLES2ImplementationTest, Hint) {
1052 struct Cmds {
1053 cmds::Hint cmd;
1055 Cmds expected;
1056 expected.cmd.Init(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
1058 gl_->Hint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
1059 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1062 TEST_F(GLES2ImplementationTest, InvalidateFramebuffer) {
1063 GLenum data[2][1] = {{0}};
1064 struct Cmds {
1065 cmds::InvalidateFramebufferImmediate cmd;
1066 GLenum data[2][1];
1069 Cmds expected;
1070 for (int ii = 0; ii < 2; ++ii) {
1071 for (int jj = 0; jj < 1; ++jj) {
1072 data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
1075 expected.cmd.Init(GL_FRAMEBUFFER, 2, &data[0][0]);
1076 gl_->InvalidateFramebuffer(GL_FRAMEBUFFER, 2, &data[0][0]);
1077 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1080 TEST_F(GLES2ImplementationTest, InvalidateSubFramebuffer) {
1081 GLenum data[2][1] = {{0}};
1082 struct Cmds {
1083 cmds::InvalidateSubFramebufferImmediate cmd;
1084 GLenum data[2][1];
1087 Cmds expected;
1088 for (int ii = 0; ii < 2; ++ii) {
1089 for (int jj = 0; jj < 1; ++jj) {
1090 data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
1093 expected.cmd.Init(GL_FRAMEBUFFER, 2, &data[0][0], 4, 5, 6, 7);
1094 gl_->InvalidateSubFramebuffer(GL_FRAMEBUFFER, 2, &data[0][0], 4, 5, 6, 7);
1095 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1098 TEST_F(GLES2ImplementationTest, IsBuffer) {
1099 struct Cmds {
1100 cmds::IsBuffer cmd;
1103 Cmds expected;
1104 ExpectedMemoryInfo result1 =
1105 GetExpectedResultMemory(sizeof(cmds::IsBuffer::Result));
1106 expected.cmd.Init(1, result1.id, result1.offset);
1108 EXPECT_CALL(*command_buffer(), OnFlush())
1109 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1110 .RetiresOnSaturation();
1112 GLboolean result = gl_->IsBuffer(1);
1113 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1114 EXPECT_TRUE(result);
1117 TEST_F(GLES2ImplementationTest, IsFramebuffer) {
1118 struct Cmds {
1119 cmds::IsFramebuffer cmd;
1122 Cmds expected;
1123 ExpectedMemoryInfo result1 =
1124 GetExpectedResultMemory(sizeof(cmds::IsFramebuffer::Result));
1125 expected.cmd.Init(1, result1.id, result1.offset);
1127 EXPECT_CALL(*command_buffer(), OnFlush())
1128 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1129 .RetiresOnSaturation();
1131 GLboolean result = gl_->IsFramebuffer(1);
1132 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1133 EXPECT_TRUE(result);
1136 TEST_F(GLES2ImplementationTest, IsProgram) {
1137 struct Cmds {
1138 cmds::IsProgram cmd;
1141 Cmds expected;
1142 ExpectedMemoryInfo result1 =
1143 GetExpectedResultMemory(sizeof(cmds::IsProgram::Result));
1144 expected.cmd.Init(1, result1.id, result1.offset);
1146 EXPECT_CALL(*command_buffer(), OnFlush())
1147 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1148 .RetiresOnSaturation();
1150 GLboolean result = gl_->IsProgram(1);
1151 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1152 EXPECT_TRUE(result);
1155 TEST_F(GLES2ImplementationTest, IsRenderbuffer) {
1156 struct Cmds {
1157 cmds::IsRenderbuffer cmd;
1160 Cmds expected;
1161 ExpectedMemoryInfo result1 =
1162 GetExpectedResultMemory(sizeof(cmds::IsRenderbuffer::Result));
1163 expected.cmd.Init(1, result1.id, result1.offset);
1165 EXPECT_CALL(*command_buffer(), OnFlush())
1166 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1167 .RetiresOnSaturation();
1169 GLboolean result = gl_->IsRenderbuffer(1);
1170 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1171 EXPECT_TRUE(result);
1174 TEST_F(GLES2ImplementationTest, IsSampler) {
1175 struct Cmds {
1176 cmds::IsSampler cmd;
1179 Cmds expected;
1180 ExpectedMemoryInfo result1 =
1181 GetExpectedResultMemory(sizeof(cmds::IsSampler::Result));
1182 expected.cmd.Init(1, result1.id, result1.offset);
1184 EXPECT_CALL(*command_buffer(), OnFlush())
1185 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1186 .RetiresOnSaturation();
1188 GLboolean result = gl_->IsSampler(1);
1189 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1190 EXPECT_TRUE(result);
1193 TEST_F(GLES2ImplementationTest, IsShader) {
1194 struct Cmds {
1195 cmds::IsShader cmd;
1198 Cmds expected;
1199 ExpectedMemoryInfo result1 =
1200 GetExpectedResultMemory(sizeof(cmds::IsShader::Result));
1201 expected.cmd.Init(1, result1.id, result1.offset);
1203 EXPECT_CALL(*command_buffer(), OnFlush())
1204 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1205 .RetiresOnSaturation();
1207 GLboolean result = gl_->IsShader(1);
1208 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1209 EXPECT_TRUE(result);
1212 TEST_F(GLES2ImplementationTest, IsSync) {
1213 struct Cmds {
1214 cmds::IsSync cmd;
1217 Cmds expected;
1218 ExpectedMemoryInfo result1 =
1219 GetExpectedResultMemory(sizeof(cmds::IsSync::Result));
1220 expected.cmd.Init(1, result1.id, result1.offset);
1222 EXPECT_CALL(*command_buffer(), OnFlush())
1223 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1224 .RetiresOnSaturation();
1226 GLboolean result = gl_->IsSync(reinterpret_cast<GLsync>(1));
1227 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1228 EXPECT_TRUE(result);
1231 TEST_F(GLES2ImplementationTest, IsTexture) {
1232 struct Cmds {
1233 cmds::IsTexture cmd;
1236 Cmds expected;
1237 ExpectedMemoryInfo result1 =
1238 GetExpectedResultMemory(sizeof(cmds::IsTexture::Result));
1239 expected.cmd.Init(1, result1.id, result1.offset);
1241 EXPECT_CALL(*command_buffer(), OnFlush())
1242 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1243 .RetiresOnSaturation();
1245 GLboolean result = gl_->IsTexture(1);
1246 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1247 EXPECT_TRUE(result);
1250 TEST_F(GLES2ImplementationTest, IsTransformFeedback) {
1251 struct Cmds {
1252 cmds::IsTransformFeedback cmd;
1255 Cmds expected;
1256 ExpectedMemoryInfo result1 =
1257 GetExpectedResultMemory(sizeof(cmds::IsTransformFeedback::Result));
1258 expected.cmd.Init(1, result1.id, result1.offset);
1260 EXPECT_CALL(*command_buffer(), OnFlush())
1261 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1262 .RetiresOnSaturation();
1264 GLboolean result = gl_->IsTransformFeedback(1);
1265 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1266 EXPECT_TRUE(result);
1269 TEST_F(GLES2ImplementationTest, LineWidth) {
1270 struct Cmds {
1271 cmds::LineWidth cmd;
1273 Cmds expected;
1274 expected.cmd.Init(0.5f);
1276 gl_->LineWidth(0.5f);
1277 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1280 TEST_F(GLES2ImplementationTest, LinkProgram) {
1281 struct Cmds {
1282 cmds::LinkProgram cmd;
1284 Cmds expected;
1285 expected.cmd.Init(1);
1287 gl_->LinkProgram(1);
1288 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1291 TEST_F(GLES2ImplementationTest, PauseTransformFeedback) {
1292 struct Cmds {
1293 cmds::PauseTransformFeedback cmd;
1295 Cmds expected;
1296 expected.cmd.Init();
1298 gl_->PauseTransformFeedback();
1299 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1302 TEST_F(GLES2ImplementationTest, PixelStorei) {
1303 struct Cmds {
1304 cmds::PixelStorei cmd;
1306 Cmds expected;
1307 expected.cmd.Init(GL_PACK_ALIGNMENT, 1);
1309 gl_->PixelStorei(GL_PACK_ALIGNMENT, 1);
1310 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1313 TEST_F(GLES2ImplementationTest, PolygonOffset) {
1314 struct Cmds {
1315 cmds::PolygonOffset cmd;
1317 Cmds expected;
1318 expected.cmd.Init(1, 2);
1320 gl_->PolygonOffset(1, 2);
1321 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1324 TEST_F(GLES2ImplementationTest, ReadBuffer) {
1325 struct Cmds {
1326 cmds::ReadBuffer cmd;
1328 Cmds expected;
1329 expected.cmd.Init(1);
1331 gl_->ReadBuffer(1);
1332 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1335 TEST_F(GLES2ImplementationTest, ReleaseShaderCompiler) {
1336 struct Cmds {
1337 cmds::ReleaseShaderCompiler cmd;
1339 Cmds expected;
1340 expected.cmd.Init();
1342 gl_->ReleaseShaderCompiler();
1343 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1346 TEST_F(GLES2ImplementationTest, RenderbufferStorage) {
1347 struct Cmds {
1348 cmds::RenderbufferStorage cmd;
1350 Cmds expected;
1351 expected.cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
1353 gl_->RenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
1354 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1357 TEST_F(GLES2ImplementationTest, ResumeTransformFeedback) {
1358 struct Cmds {
1359 cmds::ResumeTransformFeedback cmd;
1361 Cmds expected;
1362 expected.cmd.Init();
1364 gl_->ResumeTransformFeedback();
1365 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1368 TEST_F(GLES2ImplementationTest, SampleCoverage) {
1369 struct Cmds {
1370 cmds::SampleCoverage cmd;
1372 Cmds expected;
1373 expected.cmd.Init(1, true);
1375 gl_->SampleCoverage(1, true);
1376 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1379 TEST_F(GLES2ImplementationTest, SamplerParameterf) {
1380 struct Cmds {
1381 cmds::SamplerParameterf cmd;
1383 Cmds expected;
1384 expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1386 gl_->SamplerParameterf(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1387 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1390 TEST_F(GLES2ImplementationTest, SamplerParameterfv) {
1391 GLfloat data[1] = {0};
1392 struct Cmds {
1393 cmds::SamplerParameterfvImmediate cmd;
1394 GLfloat data[1];
1397 for (int jj = 0; jj < 1; ++jj) {
1398 data[jj] = static_cast<GLfloat>(jj);
1400 Cmds expected;
1401 expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1402 gl_->SamplerParameterfv(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1403 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1406 TEST_F(GLES2ImplementationTest, SamplerParameteri) {
1407 struct Cmds {
1408 cmds::SamplerParameteri cmd;
1410 Cmds expected;
1411 expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1413 gl_->SamplerParameteri(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1414 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1417 TEST_F(GLES2ImplementationTest, SamplerParameteriv) {
1418 GLint data[1] = {0};
1419 struct Cmds {
1420 cmds::SamplerParameterivImmediate cmd;
1421 GLint data[1];
1424 for (int jj = 0; jj < 1; ++jj) {
1425 data[jj] = static_cast<GLint>(jj);
1427 Cmds expected;
1428 expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1429 gl_->SamplerParameteriv(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1430 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1433 TEST_F(GLES2ImplementationTest, Scissor) {
1434 struct Cmds {
1435 cmds::Scissor cmd;
1437 Cmds expected;
1438 expected.cmd.Init(1, 2, 3, 4);
1440 gl_->Scissor(1, 2, 3, 4);
1441 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1444 TEST_F(GLES2ImplementationTest, ShaderSource) {
1445 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
1446 const char* kString1 = "happy";
1447 const char* kString2 = "ending";
1448 const size_t kString1Size = ::strlen(kString1) + 1;
1449 const size_t kString2Size = ::strlen(kString2) + 1;
1450 const size_t kHeaderSize = sizeof(GLint) * 3;
1451 const size_t kSourceSize = kHeaderSize + kString1Size + kString2Size;
1452 const size_t kPaddedHeaderSize =
1453 transfer_buffer_->RoundToAlignment(kHeaderSize);
1454 const size_t kPaddedString1Size =
1455 transfer_buffer_->RoundToAlignment(kString1Size);
1456 const size_t kPaddedString2Size =
1457 transfer_buffer_->RoundToAlignment(kString2Size);
1458 struct Cmds {
1459 cmd::SetBucketSize set_bucket_size;
1460 cmd::SetBucketData set_bucket_header;
1461 cmd::SetToken set_token1;
1462 cmd::SetBucketData set_bucket_data1;
1463 cmd::SetToken set_token2;
1464 cmd::SetBucketData set_bucket_data2;
1465 cmd::SetToken set_token3;
1466 cmds::ShaderSourceBucket cmd_bucket;
1467 cmd::SetBucketSize clear_bucket_size;
1470 ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1471 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedString1Size);
1472 ExpectedMemoryInfo mem2 = GetExpectedMemory(kPaddedString2Size);
1474 Cmds expected;
1475 expected.set_bucket_size.Init(kBucketId, kSourceSize);
1476 expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1477 mem0.offset);
1478 expected.set_token1.Init(GetNextToken());
1479 expected.set_bucket_data1.Init(kBucketId, kHeaderSize, kString1Size, mem1.id,
1480 mem1.offset);
1481 expected.set_token2.Init(GetNextToken());
1482 expected.set_bucket_data2.Init(kBucketId, kHeaderSize + kString1Size,
1483 kString2Size, mem2.id, mem2.offset);
1484 expected.set_token3.Init(GetNextToken());
1485 expected.cmd_bucket.Init(1, kBucketId);
1486 expected.clear_bucket_size.Init(kBucketId, 0);
1487 const char* kStrings[] = {kString1, kString2};
1488 gl_->ShaderSource(1, 2, kStrings, NULL);
1489 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1492 TEST_F(GLES2ImplementationTest, ShaderSourceWithLength) {
1493 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
1494 const char* kString = "foobar******";
1495 const size_t kStringSize = 6; // We only need "foobar".
1496 const size_t kHeaderSize = sizeof(GLint) * 2;
1497 const size_t kSourceSize = kHeaderSize + kStringSize + 1;
1498 const size_t kPaddedHeaderSize =
1499 transfer_buffer_->RoundToAlignment(kHeaderSize);
1500 const size_t kPaddedStringSize =
1501 transfer_buffer_->RoundToAlignment(kStringSize + 1);
1502 struct Cmds {
1503 cmd::SetBucketSize set_bucket_size;
1504 cmd::SetBucketData set_bucket_header;
1505 cmd::SetToken set_token1;
1506 cmd::SetBucketData set_bucket_data;
1507 cmd::SetToken set_token2;
1508 cmds::ShaderSourceBucket shader_source_bucket;
1509 cmd::SetBucketSize clear_bucket_size;
1512 ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1513 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedStringSize);
1515 Cmds expected;
1516 expected.set_bucket_size.Init(kBucketId, kSourceSize);
1517 expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1518 mem0.offset);
1519 expected.set_token1.Init(GetNextToken());
1520 expected.set_bucket_data.Init(kBucketId, kHeaderSize, kStringSize + 1,
1521 mem1.id, mem1.offset);
1522 expected.set_token2.Init(GetNextToken());
1523 expected.shader_source_bucket.Init(1, kBucketId);
1524 expected.clear_bucket_size.Init(kBucketId, 0);
1525 const char* kStrings[] = {kString};
1526 const GLint kLength[] = {kStringSize};
1527 gl_->ShaderSource(1, 1, kStrings, kLength);
1528 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1531 TEST_F(GLES2ImplementationTest, StencilFunc) {
1532 struct Cmds {
1533 cmds::StencilFunc cmd;
1535 Cmds expected;
1536 expected.cmd.Init(GL_NEVER, 2, 3);
1538 gl_->StencilFunc(GL_NEVER, 2, 3);
1539 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1542 TEST_F(GLES2ImplementationTest, StencilFuncSeparate) {
1543 struct Cmds {
1544 cmds::StencilFuncSeparate cmd;
1546 Cmds expected;
1547 expected.cmd.Init(GL_FRONT, GL_NEVER, 3, 4);
1549 gl_->StencilFuncSeparate(GL_FRONT, GL_NEVER, 3, 4);
1550 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1553 TEST_F(GLES2ImplementationTest, StencilMask) {
1554 struct Cmds {
1555 cmds::StencilMask cmd;
1557 Cmds expected;
1558 expected.cmd.Init(1);
1560 gl_->StencilMask(1);
1561 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1564 TEST_F(GLES2ImplementationTest, StencilMaskSeparate) {
1565 struct Cmds {
1566 cmds::StencilMaskSeparate cmd;
1568 Cmds expected;
1569 expected.cmd.Init(GL_FRONT, 2);
1571 gl_->StencilMaskSeparate(GL_FRONT, 2);
1572 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1575 TEST_F(GLES2ImplementationTest, StencilOp) {
1576 struct Cmds {
1577 cmds::StencilOp cmd;
1579 Cmds expected;
1580 expected.cmd.Init(GL_KEEP, GL_INCR, GL_KEEP);
1582 gl_->StencilOp(GL_KEEP, GL_INCR, GL_KEEP);
1583 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1586 TEST_F(GLES2ImplementationTest, StencilOpSeparate) {
1587 struct Cmds {
1588 cmds::StencilOpSeparate cmd;
1590 Cmds expected;
1591 expected.cmd.Init(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP);
1593 gl_->StencilOpSeparate(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP);
1594 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1597 TEST_F(GLES2ImplementationTest, TexParameterf) {
1598 struct Cmds {
1599 cmds::TexParameterf cmd;
1601 Cmds expected;
1602 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1604 gl_->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1605 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1608 TEST_F(GLES2ImplementationTest, TexParameterfv) {
1609 GLfloat data[1] = {0};
1610 struct Cmds {
1611 cmds::TexParameterfvImmediate cmd;
1612 GLfloat data[1];
1615 for (int jj = 0; jj < 1; ++jj) {
1616 data[jj] = static_cast<GLfloat>(jj);
1618 Cmds expected;
1619 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1620 gl_->TexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1621 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1624 TEST_F(GLES2ImplementationTest, TexParameteri) {
1625 struct Cmds {
1626 cmds::TexParameteri cmd;
1628 Cmds expected;
1629 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1631 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1632 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1635 TEST_F(GLES2ImplementationTest, TexParameteriv) {
1636 GLint data[1] = {0};
1637 struct Cmds {
1638 cmds::TexParameterivImmediate cmd;
1639 GLint data[1];
1642 for (int jj = 0; jj < 1; ++jj) {
1643 data[jj] = static_cast<GLint>(jj);
1645 Cmds expected;
1646 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1647 gl_->TexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1648 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1651 TEST_F(GLES2ImplementationTest, TexStorage3D) {
1652 struct Cmds {
1653 cmds::TexStorage3D cmd;
1655 Cmds expected;
1656 expected.cmd.Init(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6);
1658 gl_->TexStorage3D(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6);
1659 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1662 TEST_F(GLES2ImplementationTest, TransformFeedbackVaryings) {
1663 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
1664 const char* kString1 = "happy";
1665 const char* kString2 = "ending";
1666 const size_t kString1Size = ::strlen(kString1) + 1;
1667 const size_t kString2Size = ::strlen(kString2) + 1;
1668 const size_t kHeaderSize = sizeof(GLint) * 3;
1669 const size_t kSourceSize = kHeaderSize + kString1Size + kString2Size;
1670 const size_t kPaddedHeaderSize =
1671 transfer_buffer_->RoundToAlignment(kHeaderSize);
1672 const size_t kPaddedString1Size =
1673 transfer_buffer_->RoundToAlignment(kString1Size);
1674 const size_t kPaddedString2Size =
1675 transfer_buffer_->RoundToAlignment(kString2Size);
1676 struct Cmds {
1677 cmd::SetBucketSize set_bucket_size;
1678 cmd::SetBucketData set_bucket_header;
1679 cmd::SetToken set_token1;
1680 cmd::SetBucketData set_bucket_data1;
1681 cmd::SetToken set_token2;
1682 cmd::SetBucketData set_bucket_data2;
1683 cmd::SetToken set_token3;
1684 cmds::TransformFeedbackVaryingsBucket cmd_bucket;
1685 cmd::SetBucketSize clear_bucket_size;
1688 ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1689 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedString1Size);
1690 ExpectedMemoryInfo mem2 = GetExpectedMemory(kPaddedString2Size);
1692 Cmds expected;
1693 expected.set_bucket_size.Init(kBucketId, kSourceSize);
1694 expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1695 mem0.offset);
1696 expected.set_token1.Init(GetNextToken());
1697 expected.set_bucket_data1.Init(kBucketId, kHeaderSize, kString1Size, mem1.id,
1698 mem1.offset);
1699 expected.set_token2.Init(GetNextToken());
1700 expected.set_bucket_data2.Init(kBucketId, kHeaderSize + kString1Size,
1701 kString2Size, mem2.id, mem2.offset);
1702 expected.set_token3.Init(GetNextToken());
1703 expected.cmd_bucket.Init(1, kBucketId, GL_INTERLEAVED_ATTRIBS);
1704 expected.clear_bucket_size.Init(kBucketId, 0);
1705 const char* kStrings[] = {kString1, kString2};
1706 gl_->TransformFeedbackVaryings(1, 2, kStrings, GL_INTERLEAVED_ATTRIBS);
1707 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1710 TEST_F(GLES2ImplementationTest, Uniform1f) {
1711 struct Cmds {
1712 cmds::Uniform1f cmd;
1714 Cmds expected;
1715 expected.cmd.Init(1, 2);
1717 gl_->Uniform1f(1, 2);
1718 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1721 TEST_F(GLES2ImplementationTest, Uniform1fv) {
1722 GLfloat data[2][1] = {{0}};
1723 struct Cmds {
1724 cmds::Uniform1fvImmediate cmd;
1725 GLfloat data[2][1];
1728 Cmds expected;
1729 for (int ii = 0; ii < 2; ++ii) {
1730 for (int jj = 0; jj < 1; ++jj) {
1731 data[ii][jj] = static_cast<GLfloat>(ii * 1 + jj);
1734 expected.cmd.Init(1, 2, &data[0][0]);
1735 gl_->Uniform1fv(1, 2, &data[0][0]);
1736 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1739 TEST_F(GLES2ImplementationTest, Uniform1i) {
1740 struct Cmds {
1741 cmds::Uniform1i cmd;
1743 Cmds expected;
1744 expected.cmd.Init(1, 2);
1746 gl_->Uniform1i(1, 2);
1747 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1750 TEST_F(GLES2ImplementationTest, Uniform1iv) {
1751 GLint data[2][1] = {{0}};
1752 struct Cmds {
1753 cmds::Uniform1ivImmediate cmd;
1754 GLint data[2][1];
1757 Cmds expected;
1758 for (int ii = 0; ii < 2; ++ii) {
1759 for (int jj = 0; jj < 1; ++jj) {
1760 data[ii][jj] = static_cast<GLint>(ii * 1 + jj);
1763 expected.cmd.Init(1, 2, &data[0][0]);
1764 gl_->Uniform1iv(1, 2, &data[0][0]);
1765 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1768 TEST_F(GLES2ImplementationTest, Uniform1ui) {
1769 struct Cmds {
1770 cmds::Uniform1ui cmd;
1772 Cmds expected;
1773 expected.cmd.Init(1, 2);
1775 gl_->Uniform1ui(1, 2);
1776 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1779 TEST_F(GLES2ImplementationTest, Uniform1uiv) {
1780 GLuint data[2][1] = {{0}};
1781 struct Cmds {
1782 cmds::Uniform1uivImmediate cmd;
1783 GLuint data[2][1];
1786 Cmds expected;
1787 for (int ii = 0; ii < 2; ++ii) {
1788 for (int jj = 0; jj < 1; ++jj) {
1789 data[ii][jj] = static_cast<GLuint>(ii * 1 + jj);
1792 expected.cmd.Init(1, 2, &data[0][0]);
1793 gl_->Uniform1uiv(1, 2, &data[0][0]);
1794 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1797 TEST_F(GLES2ImplementationTest, Uniform2f) {
1798 struct Cmds {
1799 cmds::Uniform2f cmd;
1801 Cmds expected;
1802 expected.cmd.Init(1, 2, 3);
1804 gl_->Uniform2f(1, 2, 3);
1805 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1808 TEST_F(GLES2ImplementationTest, Uniform2fv) {
1809 GLfloat data[2][2] = {{0}};
1810 struct Cmds {
1811 cmds::Uniform2fvImmediate cmd;
1812 GLfloat data[2][2];
1815 Cmds expected;
1816 for (int ii = 0; ii < 2; ++ii) {
1817 for (int jj = 0; jj < 2; ++jj) {
1818 data[ii][jj] = static_cast<GLfloat>(ii * 2 + jj);
1821 expected.cmd.Init(1, 2, &data[0][0]);
1822 gl_->Uniform2fv(1, 2, &data[0][0]);
1823 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1826 TEST_F(GLES2ImplementationTest, Uniform2i) {
1827 struct Cmds {
1828 cmds::Uniform2i cmd;
1830 Cmds expected;
1831 expected.cmd.Init(1, 2, 3);
1833 gl_->Uniform2i(1, 2, 3);
1834 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1837 TEST_F(GLES2ImplementationTest, Uniform2iv) {
1838 GLint data[2][2] = {{0}};
1839 struct Cmds {
1840 cmds::Uniform2ivImmediate cmd;
1841 GLint data[2][2];
1844 Cmds expected;
1845 for (int ii = 0; ii < 2; ++ii) {
1846 for (int jj = 0; jj < 2; ++jj) {
1847 data[ii][jj] = static_cast<GLint>(ii * 2 + jj);
1850 expected.cmd.Init(1, 2, &data[0][0]);
1851 gl_->Uniform2iv(1, 2, &data[0][0]);
1852 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1855 TEST_F(GLES2ImplementationTest, Uniform2ui) {
1856 struct Cmds {
1857 cmds::Uniform2ui cmd;
1859 Cmds expected;
1860 expected.cmd.Init(1, 2, 3);
1862 gl_->Uniform2ui(1, 2, 3);
1863 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1866 TEST_F(GLES2ImplementationTest, Uniform2uiv) {
1867 GLuint data[2][2] = {{0}};
1868 struct Cmds {
1869 cmds::Uniform2uivImmediate cmd;
1870 GLuint data[2][2];
1873 Cmds expected;
1874 for (int ii = 0; ii < 2; ++ii) {
1875 for (int jj = 0; jj < 2; ++jj) {
1876 data[ii][jj] = static_cast<GLuint>(ii * 2 + jj);
1879 expected.cmd.Init(1, 2, &data[0][0]);
1880 gl_->Uniform2uiv(1, 2, &data[0][0]);
1881 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1884 TEST_F(GLES2ImplementationTest, Uniform3f) {
1885 struct Cmds {
1886 cmds::Uniform3f cmd;
1888 Cmds expected;
1889 expected.cmd.Init(1, 2, 3, 4);
1891 gl_->Uniform3f(1, 2, 3, 4);
1892 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1895 TEST_F(GLES2ImplementationTest, Uniform3fv) {
1896 GLfloat data[2][3] = {{0}};
1897 struct Cmds {
1898 cmds::Uniform3fvImmediate cmd;
1899 GLfloat data[2][3];
1902 Cmds expected;
1903 for (int ii = 0; ii < 2; ++ii) {
1904 for (int jj = 0; jj < 3; ++jj) {
1905 data[ii][jj] = static_cast<GLfloat>(ii * 3 + jj);
1908 expected.cmd.Init(1, 2, &data[0][0]);
1909 gl_->Uniform3fv(1, 2, &data[0][0]);
1910 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1913 TEST_F(GLES2ImplementationTest, Uniform3i) {
1914 struct Cmds {
1915 cmds::Uniform3i cmd;
1917 Cmds expected;
1918 expected.cmd.Init(1, 2, 3, 4);
1920 gl_->Uniform3i(1, 2, 3, 4);
1921 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1924 TEST_F(GLES2ImplementationTest, Uniform3iv) {
1925 GLint data[2][3] = {{0}};
1926 struct Cmds {
1927 cmds::Uniform3ivImmediate cmd;
1928 GLint data[2][3];
1931 Cmds expected;
1932 for (int ii = 0; ii < 2; ++ii) {
1933 for (int jj = 0; jj < 3; ++jj) {
1934 data[ii][jj] = static_cast<GLint>(ii * 3 + jj);
1937 expected.cmd.Init(1, 2, &data[0][0]);
1938 gl_->Uniform3iv(1, 2, &data[0][0]);
1939 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1942 TEST_F(GLES2ImplementationTest, Uniform3ui) {
1943 struct Cmds {
1944 cmds::Uniform3ui cmd;
1946 Cmds expected;
1947 expected.cmd.Init(1, 2, 3, 4);
1949 gl_->Uniform3ui(1, 2, 3, 4);
1950 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1953 TEST_F(GLES2ImplementationTest, Uniform3uiv) {
1954 GLuint data[2][3] = {{0}};
1955 struct Cmds {
1956 cmds::Uniform3uivImmediate cmd;
1957 GLuint data[2][3];
1960 Cmds expected;
1961 for (int ii = 0; ii < 2; ++ii) {
1962 for (int jj = 0; jj < 3; ++jj) {
1963 data[ii][jj] = static_cast<GLuint>(ii * 3 + jj);
1966 expected.cmd.Init(1, 2, &data[0][0]);
1967 gl_->Uniform3uiv(1, 2, &data[0][0]);
1968 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1971 TEST_F(GLES2ImplementationTest, Uniform4f) {
1972 struct Cmds {
1973 cmds::Uniform4f cmd;
1975 Cmds expected;
1976 expected.cmd.Init(1, 2, 3, 4, 5);
1978 gl_->Uniform4f(1, 2, 3, 4, 5);
1979 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1982 TEST_F(GLES2ImplementationTest, Uniform4fv) {
1983 GLfloat data[2][4] = {{0}};
1984 struct Cmds {
1985 cmds::Uniform4fvImmediate cmd;
1986 GLfloat data[2][4];
1989 Cmds expected;
1990 for (int ii = 0; ii < 2; ++ii) {
1991 for (int jj = 0; jj < 4; ++jj) {
1992 data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
1995 expected.cmd.Init(1, 2, &data[0][0]);
1996 gl_->Uniform4fv(1, 2, &data[0][0]);
1997 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2000 TEST_F(GLES2ImplementationTest, Uniform4i) {
2001 struct Cmds {
2002 cmds::Uniform4i cmd;
2004 Cmds expected;
2005 expected.cmd.Init(1, 2, 3, 4, 5);
2007 gl_->Uniform4i(1, 2, 3, 4, 5);
2008 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2011 TEST_F(GLES2ImplementationTest, Uniform4iv) {
2012 GLint data[2][4] = {{0}};
2013 struct Cmds {
2014 cmds::Uniform4ivImmediate cmd;
2015 GLint data[2][4];
2018 Cmds expected;
2019 for (int ii = 0; ii < 2; ++ii) {
2020 for (int jj = 0; jj < 4; ++jj) {
2021 data[ii][jj] = static_cast<GLint>(ii * 4 + jj);
2024 expected.cmd.Init(1, 2, &data[0][0]);
2025 gl_->Uniform4iv(1, 2, &data[0][0]);
2026 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2029 TEST_F(GLES2ImplementationTest, Uniform4ui) {
2030 struct Cmds {
2031 cmds::Uniform4ui cmd;
2033 Cmds expected;
2034 expected.cmd.Init(1, 2, 3, 4, 5);
2036 gl_->Uniform4ui(1, 2, 3, 4, 5);
2037 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2040 TEST_F(GLES2ImplementationTest, Uniform4uiv) {
2041 GLuint data[2][4] = {{0}};
2042 struct Cmds {
2043 cmds::Uniform4uivImmediate cmd;
2044 GLuint data[2][4];
2047 Cmds expected;
2048 for (int ii = 0; ii < 2; ++ii) {
2049 for (int jj = 0; jj < 4; ++jj) {
2050 data[ii][jj] = static_cast<GLuint>(ii * 4 + jj);
2053 expected.cmd.Init(1, 2, &data[0][0]);
2054 gl_->Uniform4uiv(1, 2, &data[0][0]);
2055 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2058 TEST_F(GLES2ImplementationTest, UniformBlockBinding) {
2059 struct Cmds {
2060 cmds::UniformBlockBinding cmd;
2062 Cmds expected;
2063 expected.cmd.Init(1, 2, 3);
2065 gl_->UniformBlockBinding(1, 2, 3);
2066 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2069 TEST_F(GLES2ImplementationTest, UniformMatrix2fv) {
2070 GLfloat data[2][4] = {{0}};
2071 struct Cmds {
2072 cmds::UniformMatrix2fvImmediate cmd;
2073 GLfloat data[2][4];
2076 Cmds expected;
2077 for (int ii = 0; ii < 2; ++ii) {
2078 for (int jj = 0; jj < 4; ++jj) {
2079 data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
2082 expected.cmd.Init(1, 2, &data[0][0]);
2083 gl_->UniformMatrix2fv(1, 2, false, &data[0][0]);
2084 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2087 TEST_F(GLES2ImplementationTest, UniformMatrix2fvInvalidConstantArg2) {
2088 GLfloat data[2][4] = {{0}};
2089 for (int ii = 0; ii < 2; ++ii) {
2090 for (int jj = 0; jj < 4; ++jj) {
2091 data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
2094 gl_->UniformMatrix2fv(1, 2, true, &data[0][0]);
2095 EXPECT_TRUE(NoCommandsWritten());
2096 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2099 TEST_F(GLES2ImplementationTest, UniformMatrix2x3fv) {
2100 GLfloat data[2][6] = {{0}};
2101 struct Cmds {
2102 cmds::UniformMatrix2x3fvImmediate cmd;
2103 GLfloat data[2][6];
2106 Cmds expected;
2107 for (int ii = 0; ii < 2; ++ii) {
2108 for (int jj = 0; jj < 6; ++jj) {
2109 data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2112 expected.cmd.Init(1, 2, &data[0][0]);
2113 gl_->UniformMatrix2x3fv(1, 2, false, &data[0][0]);
2114 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2117 TEST_F(GLES2ImplementationTest, UniformMatrix2x3fvInvalidConstantArg2) {
2118 GLfloat data[2][6] = {{0}};
2119 for (int ii = 0; ii < 2; ++ii) {
2120 for (int jj = 0; jj < 6; ++jj) {
2121 data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2124 gl_->UniformMatrix2x3fv(1, 2, true, &data[0][0]);
2125 EXPECT_TRUE(NoCommandsWritten());
2126 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2129 TEST_F(GLES2ImplementationTest, UniformMatrix2x4fv) {
2130 GLfloat data[2][8] = {{0}};
2131 struct Cmds {
2132 cmds::UniformMatrix2x4fvImmediate cmd;
2133 GLfloat data[2][8];
2136 Cmds expected;
2137 for (int ii = 0; ii < 2; ++ii) {
2138 for (int jj = 0; jj < 8; ++jj) {
2139 data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2142 expected.cmd.Init(1, 2, &data[0][0]);
2143 gl_->UniformMatrix2x4fv(1, 2, false, &data[0][0]);
2144 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2147 TEST_F(GLES2ImplementationTest, UniformMatrix2x4fvInvalidConstantArg2) {
2148 GLfloat data[2][8] = {{0}};
2149 for (int ii = 0; ii < 2; ++ii) {
2150 for (int jj = 0; jj < 8; ++jj) {
2151 data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2154 gl_->UniformMatrix2x4fv(1, 2, true, &data[0][0]);
2155 EXPECT_TRUE(NoCommandsWritten());
2156 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2159 TEST_F(GLES2ImplementationTest, UniformMatrix3fv) {
2160 GLfloat data[2][9] = {{0}};
2161 struct Cmds {
2162 cmds::UniformMatrix3fvImmediate cmd;
2163 GLfloat data[2][9];
2166 Cmds expected;
2167 for (int ii = 0; ii < 2; ++ii) {
2168 for (int jj = 0; jj < 9; ++jj) {
2169 data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj);
2172 expected.cmd.Init(1, 2, &data[0][0]);
2173 gl_->UniformMatrix3fv(1, 2, false, &data[0][0]);
2174 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2177 TEST_F(GLES2ImplementationTest, UniformMatrix3fvInvalidConstantArg2) {
2178 GLfloat data[2][9] = {{0}};
2179 for (int ii = 0; ii < 2; ++ii) {
2180 for (int jj = 0; jj < 9; ++jj) {
2181 data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj);
2184 gl_->UniformMatrix3fv(1, 2, true, &data[0][0]);
2185 EXPECT_TRUE(NoCommandsWritten());
2186 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2189 TEST_F(GLES2ImplementationTest, UniformMatrix3x2fv) {
2190 GLfloat data[2][6] = {{0}};
2191 struct Cmds {
2192 cmds::UniformMatrix3x2fvImmediate cmd;
2193 GLfloat data[2][6];
2196 Cmds expected;
2197 for (int ii = 0; ii < 2; ++ii) {
2198 for (int jj = 0; jj < 6; ++jj) {
2199 data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2202 expected.cmd.Init(1, 2, &data[0][0]);
2203 gl_->UniformMatrix3x2fv(1, 2, false, &data[0][0]);
2204 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2207 TEST_F(GLES2ImplementationTest, UniformMatrix3x2fvInvalidConstantArg2) {
2208 GLfloat data[2][6] = {{0}};
2209 for (int ii = 0; ii < 2; ++ii) {
2210 for (int jj = 0; jj < 6; ++jj) {
2211 data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2214 gl_->UniformMatrix3x2fv(1, 2, true, &data[0][0]);
2215 EXPECT_TRUE(NoCommandsWritten());
2216 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2219 TEST_F(GLES2ImplementationTest, UniformMatrix3x4fv) {
2220 GLfloat data[2][12] = {{0}};
2221 struct Cmds {
2222 cmds::UniformMatrix3x4fvImmediate cmd;
2223 GLfloat data[2][12];
2226 Cmds expected;
2227 for (int ii = 0; ii < 2; ++ii) {
2228 for (int jj = 0; jj < 12; ++jj) {
2229 data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2232 expected.cmd.Init(1, 2, &data[0][0]);
2233 gl_->UniformMatrix3x4fv(1, 2, false, &data[0][0]);
2234 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2237 TEST_F(GLES2ImplementationTest, UniformMatrix3x4fvInvalidConstantArg2) {
2238 GLfloat data[2][12] = {{0}};
2239 for (int ii = 0; ii < 2; ++ii) {
2240 for (int jj = 0; jj < 12; ++jj) {
2241 data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2244 gl_->UniformMatrix3x4fv(1, 2, true, &data[0][0]);
2245 EXPECT_TRUE(NoCommandsWritten());
2246 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2249 TEST_F(GLES2ImplementationTest, UniformMatrix4fv) {
2250 GLfloat data[2][16] = {{0}};
2251 struct Cmds {
2252 cmds::UniformMatrix4fvImmediate cmd;
2253 GLfloat data[2][16];
2256 Cmds expected;
2257 for (int ii = 0; ii < 2; ++ii) {
2258 for (int jj = 0; jj < 16; ++jj) {
2259 data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj);
2262 expected.cmd.Init(1, 2, &data[0][0]);
2263 gl_->UniformMatrix4fv(1, 2, false, &data[0][0]);
2264 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2267 TEST_F(GLES2ImplementationTest, UniformMatrix4fvInvalidConstantArg2) {
2268 GLfloat data[2][16] = {{0}};
2269 for (int ii = 0; ii < 2; ++ii) {
2270 for (int jj = 0; jj < 16; ++jj) {
2271 data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj);
2274 gl_->UniformMatrix4fv(1, 2, true, &data[0][0]);
2275 EXPECT_TRUE(NoCommandsWritten());
2276 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2279 TEST_F(GLES2ImplementationTest, UniformMatrix4x2fv) {
2280 GLfloat data[2][8] = {{0}};
2281 struct Cmds {
2282 cmds::UniformMatrix4x2fvImmediate cmd;
2283 GLfloat data[2][8];
2286 Cmds expected;
2287 for (int ii = 0; ii < 2; ++ii) {
2288 for (int jj = 0; jj < 8; ++jj) {
2289 data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2292 expected.cmd.Init(1, 2, &data[0][0]);
2293 gl_->UniformMatrix4x2fv(1, 2, false, &data[0][0]);
2294 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2297 TEST_F(GLES2ImplementationTest, UniformMatrix4x2fvInvalidConstantArg2) {
2298 GLfloat data[2][8] = {{0}};
2299 for (int ii = 0; ii < 2; ++ii) {
2300 for (int jj = 0; jj < 8; ++jj) {
2301 data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2304 gl_->UniformMatrix4x2fv(1, 2, true, &data[0][0]);
2305 EXPECT_TRUE(NoCommandsWritten());
2306 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2309 TEST_F(GLES2ImplementationTest, UniformMatrix4x3fv) {
2310 GLfloat data[2][12] = {{0}};
2311 struct Cmds {
2312 cmds::UniformMatrix4x3fvImmediate cmd;
2313 GLfloat data[2][12];
2316 Cmds expected;
2317 for (int ii = 0; ii < 2; ++ii) {
2318 for (int jj = 0; jj < 12; ++jj) {
2319 data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2322 expected.cmd.Init(1, 2, &data[0][0]);
2323 gl_->UniformMatrix4x3fv(1, 2, false, &data[0][0]);
2324 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2327 TEST_F(GLES2ImplementationTest, UniformMatrix4x3fvInvalidConstantArg2) {
2328 GLfloat data[2][12] = {{0}};
2329 for (int ii = 0; ii < 2; ++ii) {
2330 for (int jj = 0; jj < 12; ++jj) {
2331 data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2334 gl_->UniformMatrix4x3fv(1, 2, true, &data[0][0]);
2335 EXPECT_TRUE(NoCommandsWritten());
2336 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2339 TEST_F(GLES2ImplementationTest, UseProgram) {
2340 struct Cmds {
2341 cmds::UseProgram cmd;
2343 Cmds expected;
2344 expected.cmd.Init(1);
2346 gl_->UseProgram(1);
2347 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2348 ClearCommands();
2349 gl_->UseProgram(1);
2350 EXPECT_TRUE(NoCommandsWritten());
2353 TEST_F(GLES2ImplementationTest, ValidateProgram) {
2354 struct Cmds {
2355 cmds::ValidateProgram cmd;
2357 Cmds expected;
2358 expected.cmd.Init(1);
2360 gl_->ValidateProgram(1);
2361 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2364 TEST_F(GLES2ImplementationTest, VertexAttrib1f) {
2365 struct Cmds {
2366 cmds::VertexAttrib1f cmd;
2368 Cmds expected;
2369 expected.cmd.Init(1, 2);
2371 gl_->VertexAttrib1f(1, 2);
2372 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2375 TEST_F(GLES2ImplementationTest, VertexAttrib1fv) {
2376 GLfloat data[1] = {0};
2377 struct Cmds {
2378 cmds::VertexAttrib1fvImmediate cmd;
2379 GLfloat data[1];
2382 for (int jj = 0; jj < 1; ++jj) {
2383 data[jj] = static_cast<GLfloat>(jj);
2385 Cmds expected;
2386 expected.cmd.Init(1, &data[0]);
2387 gl_->VertexAttrib1fv(1, &data[0]);
2388 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2391 TEST_F(GLES2ImplementationTest, VertexAttrib2f) {
2392 struct Cmds {
2393 cmds::VertexAttrib2f cmd;
2395 Cmds expected;
2396 expected.cmd.Init(1, 2, 3);
2398 gl_->VertexAttrib2f(1, 2, 3);
2399 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2402 TEST_F(GLES2ImplementationTest, VertexAttrib2fv) {
2403 GLfloat data[2] = {0};
2404 struct Cmds {
2405 cmds::VertexAttrib2fvImmediate cmd;
2406 GLfloat data[2];
2409 for (int jj = 0; jj < 2; ++jj) {
2410 data[jj] = static_cast<GLfloat>(jj);
2412 Cmds expected;
2413 expected.cmd.Init(1, &data[0]);
2414 gl_->VertexAttrib2fv(1, &data[0]);
2415 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2418 TEST_F(GLES2ImplementationTest, VertexAttrib3f) {
2419 struct Cmds {
2420 cmds::VertexAttrib3f cmd;
2422 Cmds expected;
2423 expected.cmd.Init(1, 2, 3, 4);
2425 gl_->VertexAttrib3f(1, 2, 3, 4);
2426 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2429 TEST_F(GLES2ImplementationTest, VertexAttrib3fv) {
2430 GLfloat data[3] = {0};
2431 struct Cmds {
2432 cmds::VertexAttrib3fvImmediate cmd;
2433 GLfloat data[3];
2436 for (int jj = 0; jj < 3; ++jj) {
2437 data[jj] = static_cast<GLfloat>(jj);
2439 Cmds expected;
2440 expected.cmd.Init(1, &data[0]);
2441 gl_->VertexAttrib3fv(1, &data[0]);
2442 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2445 TEST_F(GLES2ImplementationTest, VertexAttrib4f) {
2446 struct Cmds {
2447 cmds::VertexAttrib4f cmd;
2449 Cmds expected;
2450 expected.cmd.Init(1, 2, 3, 4, 5);
2452 gl_->VertexAttrib4f(1, 2, 3, 4, 5);
2453 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2456 TEST_F(GLES2ImplementationTest, VertexAttrib4fv) {
2457 GLfloat data[4] = {0};
2458 struct Cmds {
2459 cmds::VertexAttrib4fvImmediate cmd;
2460 GLfloat data[4];
2463 for (int jj = 0; jj < 4; ++jj) {
2464 data[jj] = static_cast<GLfloat>(jj);
2466 Cmds expected;
2467 expected.cmd.Init(1, &data[0]);
2468 gl_->VertexAttrib4fv(1, &data[0]);
2469 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2472 TEST_F(GLES2ImplementationTest, VertexAttribI4i) {
2473 struct Cmds {
2474 cmds::VertexAttribI4i cmd;
2476 Cmds expected;
2477 expected.cmd.Init(1, 2, 3, 4, 5);
2479 gl_->VertexAttribI4i(1, 2, 3, 4, 5);
2480 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2483 TEST_F(GLES2ImplementationTest, VertexAttribI4iv) {
2484 GLint data[4] = {0};
2485 struct Cmds {
2486 cmds::VertexAttribI4ivImmediate cmd;
2487 GLint data[4];
2490 for (int jj = 0; jj < 4; ++jj) {
2491 data[jj] = static_cast<GLint>(jj);
2493 Cmds expected;
2494 expected.cmd.Init(1, &data[0]);
2495 gl_->VertexAttribI4iv(1, &data[0]);
2496 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2499 TEST_F(GLES2ImplementationTest, VertexAttribI4ui) {
2500 struct Cmds {
2501 cmds::VertexAttribI4ui cmd;
2503 Cmds expected;
2504 expected.cmd.Init(1, 2, 3, 4, 5);
2506 gl_->VertexAttribI4ui(1, 2, 3, 4, 5);
2507 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2510 TEST_F(GLES2ImplementationTest, VertexAttribI4uiv) {
2511 GLuint data[4] = {0};
2512 struct Cmds {
2513 cmds::VertexAttribI4uivImmediate cmd;
2514 GLuint data[4];
2517 for (int jj = 0; jj < 4; ++jj) {
2518 data[jj] = static_cast<GLuint>(jj);
2520 Cmds expected;
2521 expected.cmd.Init(1, &data[0]);
2522 gl_->VertexAttribI4uiv(1, &data[0]);
2523 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2526 TEST_F(GLES2ImplementationTest, Viewport) {
2527 struct Cmds {
2528 cmds::Viewport cmd;
2530 Cmds expected;
2531 expected.cmd.Init(1, 2, 3, 4);
2533 gl_->Viewport(1, 2, 3, 4);
2534 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2537 TEST_F(GLES2ImplementationTest, BlitFramebufferCHROMIUM) {
2538 struct Cmds {
2539 cmds::BlitFramebufferCHROMIUM cmd;
2541 Cmds expected;
2542 expected.cmd.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
2544 gl_->BlitFramebufferCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
2545 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2548 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleCHROMIUM) {
2549 struct Cmds {
2550 cmds::RenderbufferStorageMultisampleCHROMIUM cmd;
2552 Cmds expected;
2553 expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2555 gl_->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, 2, GL_RGBA4, 4,
2557 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2560 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleEXT) {
2561 struct Cmds {
2562 cmds::RenderbufferStorageMultisampleEXT cmd;
2564 Cmds expected;
2565 expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2567 gl_->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2568 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2571 TEST_F(GLES2ImplementationTest, FramebufferTexture2DMultisampleEXT) {
2572 struct Cmds {
2573 cmds::FramebufferTexture2DMultisampleEXT cmd;
2575 Cmds expected;
2576 expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4, 6);
2578 gl_->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2579 GL_TEXTURE_2D, 4, 0, 6);
2580 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2583 TEST_F(GLES2ImplementationTest,
2584 FramebufferTexture2DMultisampleEXTInvalidConstantArg4) {
2585 gl_->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2586 GL_TEXTURE_2D, 4, 1, 6);
2587 EXPECT_TRUE(NoCommandsWritten());
2588 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2591 TEST_F(GLES2ImplementationTest, TexStorage2DEXT) {
2592 struct Cmds {
2593 cmds::TexStorage2DEXT cmd;
2595 Cmds expected;
2596 expected.cmd.Init(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
2598 gl_->TexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
2599 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2602 TEST_F(GLES2ImplementationTest, GenQueriesEXT) {
2603 GLuint ids[2] = {
2606 struct Cmds {
2607 cmds::GenQueriesEXTImmediate gen;
2608 GLuint data[2];
2610 Cmds expected;
2611 expected.gen.Init(arraysize(ids), &ids[0]);
2612 expected.data[0] = kQueriesStartId;
2613 expected.data[1] = kQueriesStartId + 1;
2614 gl_->GenQueriesEXT(arraysize(ids), &ids[0]);
2615 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2616 EXPECT_EQ(kQueriesStartId, ids[0]);
2617 EXPECT_EQ(kQueriesStartId + 1, ids[1]);
2620 TEST_F(GLES2ImplementationTest, DeleteQueriesEXT) {
2621 GLuint ids[2] = {kQueriesStartId, kQueriesStartId + 1};
2622 struct Cmds {
2623 cmds::DeleteQueriesEXTImmediate del;
2624 GLuint data[2];
2626 Cmds expected;
2627 expected.del.Init(arraysize(ids), &ids[0]);
2628 expected.data[0] = kQueriesStartId;
2629 expected.data[1] = kQueriesStartId + 1;
2630 gl_->DeleteQueriesEXT(arraysize(ids), &ids[0]);
2631 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2633 // TODO(zmo): Implement unit test for BeginQueryEXT
2635 TEST_F(GLES2ImplementationTest, BeginTransformFeedback) {
2636 struct Cmds {
2637 cmds::BeginTransformFeedback cmd;
2639 Cmds expected;
2640 expected.cmd.Init(GL_POINTS);
2642 gl_->BeginTransformFeedback(GL_POINTS);
2643 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2646 TEST_F(GLES2ImplementationTest, EndTransformFeedback) {
2647 struct Cmds {
2648 cmds::EndTransformFeedback cmd;
2650 Cmds expected;
2651 expected.cmd.Init();
2653 gl_->EndTransformFeedback();
2654 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2656 // TODO(zmo): Implement unit test for InsertEventMarkerEXT
2657 // TODO(zmo): Implement unit test for PushGroupMarkerEXT
2659 TEST_F(GLES2ImplementationTest, PopGroupMarkerEXT) {
2660 struct Cmds {
2661 cmds::PopGroupMarkerEXT cmd;
2663 Cmds expected;
2664 expected.cmd.Init();
2666 gl_->PopGroupMarkerEXT();
2667 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2670 TEST_F(GLES2ImplementationTest, GenVertexArraysOES) {
2671 GLuint ids[2] = {
2674 struct Cmds {
2675 cmds::GenVertexArraysOESImmediate gen;
2676 GLuint data[2];
2678 Cmds expected;
2679 expected.gen.Init(arraysize(ids), &ids[0]);
2680 expected.data[0] = kVertexArraysStartId;
2681 expected.data[1] = kVertexArraysStartId + 1;
2682 gl_->GenVertexArraysOES(arraysize(ids), &ids[0]);
2683 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2684 EXPECT_EQ(kVertexArraysStartId, ids[0]);
2685 EXPECT_EQ(kVertexArraysStartId + 1, ids[1]);
2688 TEST_F(GLES2ImplementationTest, DeleteVertexArraysOES) {
2689 GLuint ids[2] = {kVertexArraysStartId, kVertexArraysStartId + 1};
2690 struct Cmds {
2691 cmds::DeleteVertexArraysOESImmediate del;
2692 GLuint data[2];
2694 Cmds expected;
2695 expected.del.Init(arraysize(ids), &ids[0]);
2696 expected.data[0] = kVertexArraysStartId;
2697 expected.data[1] = kVertexArraysStartId + 1;
2698 gl_->DeleteVertexArraysOES(arraysize(ids), &ids[0]);
2699 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2702 TEST_F(GLES2ImplementationTest, IsVertexArrayOES) {
2703 struct Cmds {
2704 cmds::IsVertexArrayOES cmd;
2707 Cmds expected;
2708 ExpectedMemoryInfo result1 =
2709 GetExpectedResultMemory(sizeof(cmds::IsVertexArrayOES::Result));
2710 expected.cmd.Init(1, result1.id, result1.offset);
2712 EXPECT_CALL(*command_buffer(), OnFlush())
2713 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
2714 .RetiresOnSaturation();
2716 GLboolean result = gl_->IsVertexArrayOES(1);
2717 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2718 EXPECT_TRUE(result);
2720 // TODO(zmo): Implement unit test for EnableFeatureCHROMIUM
2722 TEST_F(GLES2ImplementationTest, ResizeCHROMIUM) {
2723 struct Cmds {
2724 cmds::ResizeCHROMIUM cmd;
2726 Cmds expected;
2727 expected.cmd.Init(1, 2, 3);
2729 gl_->ResizeCHROMIUM(1, 2, 3);
2730 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2732 // TODO(zmo): Implement unit test for GetRequestableExtensionsCHROMIUM
2733 // TODO(zmo): Implement unit test for CreateStreamTextureCHROMIUM
2734 // TODO(zmo): Implement unit test for GetTranslatedShaderSourceANGLE
2736 TEST_F(GLES2ImplementationTest, TexImageIOSurface2DCHROMIUM) {
2737 struct Cmds {
2738 cmds::TexImageIOSurface2DCHROMIUM cmd;
2740 Cmds expected;
2741 expected.cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5);
2743 gl_->TexImageIOSurface2DCHROMIUM(GL_TEXTURE_2D, 2, 3, 4, 5);
2744 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2747 TEST_F(GLES2ImplementationTest, CopyTextureCHROMIUM) {
2748 struct Cmds {
2749 cmds::CopyTextureCHROMIUM cmd;
2751 Cmds expected;
2752 expected.cmd.Init(1, 2, 3, 4, GL_ALPHA, GL_UNSIGNED_BYTE);
2754 gl_->CopyTextureCHROMIUM(1, 2, 3, 4, GL_ALPHA, GL_UNSIGNED_BYTE);
2755 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2758 TEST_F(GLES2ImplementationTest, DrawArraysInstancedANGLE) {
2759 struct Cmds {
2760 cmds::DrawArraysInstancedANGLE cmd;
2762 Cmds expected;
2763 expected.cmd.Init(GL_POINTS, 2, 3, 4);
2765 gl_->DrawArraysInstancedANGLE(GL_POINTS, 2, 3, 4);
2766 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2769 TEST_F(GLES2ImplementationTest, VertexAttribDivisorANGLE) {
2770 struct Cmds {
2771 cmds::VertexAttribDivisorANGLE cmd;
2773 Cmds expected;
2774 expected.cmd.Init(1, 2);
2776 gl_->VertexAttribDivisorANGLE(1, 2);
2777 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2779 // TODO(zmo): Implement unit test for GenMailboxCHROMIUM
2780 // TODO(zmo): Implement unit test for BindUniformLocationCHROMIUM
2782 TEST_F(GLES2ImplementationTest, GenValuebuffersCHROMIUM) {
2783 GLuint ids[2] = {
2786 struct Cmds {
2787 cmds::GenValuebuffersCHROMIUMImmediate gen;
2788 GLuint data[2];
2790 Cmds expected;
2791 expected.gen.Init(arraysize(ids), &ids[0]);
2792 expected.data[0] = kValuebuffersStartId;
2793 expected.data[1] = kValuebuffersStartId + 1;
2794 gl_->GenValuebuffersCHROMIUM(arraysize(ids), &ids[0]);
2795 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2796 EXPECT_EQ(kValuebuffersStartId, ids[0]);
2797 EXPECT_EQ(kValuebuffersStartId + 1, ids[1]);
2800 TEST_F(GLES2ImplementationTest, DeleteValuebuffersCHROMIUM) {
2801 GLuint ids[2] = {kValuebuffersStartId, kValuebuffersStartId + 1};
2802 struct Cmds {
2803 cmds::DeleteValuebuffersCHROMIUMImmediate del;
2804 GLuint data[2];
2806 Cmds expected;
2807 expected.del.Init(arraysize(ids), &ids[0]);
2808 expected.data[0] = kValuebuffersStartId;
2809 expected.data[1] = kValuebuffersStartId + 1;
2810 gl_->DeleteValuebuffersCHROMIUM(arraysize(ids), &ids[0]);
2811 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2814 TEST_F(GLES2ImplementationTest, IsValuebufferCHROMIUM) {
2815 struct Cmds {
2816 cmds::IsValuebufferCHROMIUM cmd;
2819 Cmds expected;
2820 ExpectedMemoryInfo result1 =
2821 GetExpectedResultMemory(sizeof(cmds::IsValuebufferCHROMIUM::Result));
2822 expected.cmd.Init(1, result1.id, result1.offset);
2824 EXPECT_CALL(*command_buffer(), OnFlush())
2825 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
2826 .RetiresOnSaturation();
2828 GLboolean result = gl_->IsValuebufferCHROMIUM(1);
2829 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2830 EXPECT_TRUE(result);
2833 TEST_F(GLES2ImplementationTest, BindValuebufferCHROMIUM) {
2834 struct Cmds {
2835 cmds::BindValuebufferCHROMIUM cmd;
2837 Cmds expected;
2838 expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
2840 gl_->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
2841 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2842 ClearCommands();
2843 gl_->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
2844 EXPECT_TRUE(NoCommandsWritten());
2847 TEST_F(GLES2ImplementationTest, SubscribeValueCHROMIUM) {
2848 struct Cmds {
2849 cmds::SubscribeValueCHROMIUM cmd;
2851 Cmds expected;
2852 expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
2853 GL_MOUSE_POSITION_CHROMIUM);
2855 gl_->SubscribeValueCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
2856 GL_MOUSE_POSITION_CHROMIUM);
2857 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2860 TEST_F(GLES2ImplementationTest, PopulateSubscribedValuesCHROMIUM) {
2861 struct Cmds {
2862 cmds::PopulateSubscribedValuesCHROMIUM cmd;
2864 Cmds expected;
2865 expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM);
2867 gl_->PopulateSubscribedValuesCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM);
2868 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2871 TEST_F(GLES2ImplementationTest, UniformValuebufferCHROMIUM) {
2872 struct Cmds {
2873 cmds::UniformValuebufferCHROMIUM cmd;
2875 Cmds expected;
2876 expected.cmd.Init(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
2877 GL_MOUSE_POSITION_CHROMIUM);
2879 gl_->UniformValuebufferCHROMIUM(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
2880 GL_MOUSE_POSITION_CHROMIUM);
2881 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2884 TEST_F(GLES2ImplementationTest, BindTexImage2DCHROMIUM) {
2885 struct Cmds {
2886 cmds::BindTexImage2DCHROMIUM cmd;
2888 Cmds expected;
2889 expected.cmd.Init(GL_TEXTURE_2D, 2);
2891 gl_->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
2892 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2895 TEST_F(GLES2ImplementationTest, ReleaseTexImage2DCHROMIUM) {
2896 struct Cmds {
2897 cmds::ReleaseTexImage2DCHROMIUM cmd;
2899 Cmds expected;
2900 expected.cmd.Init(GL_TEXTURE_2D, 2);
2902 gl_->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
2903 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2906 TEST_F(GLES2ImplementationTest, DiscardFramebufferEXT) {
2907 GLenum data[2][1] = {{0}};
2908 struct Cmds {
2909 cmds::DiscardFramebufferEXTImmediate cmd;
2910 GLenum data[2][1];
2913 Cmds expected;
2914 for (int ii = 0; ii < 2; ++ii) {
2915 for (int jj = 0; jj < 1; ++jj) {
2916 data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
2919 expected.cmd.Init(1, 2, &data[0][0]);
2920 gl_->DiscardFramebufferEXT(1, 2, &data[0][0]);
2921 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2924 TEST_F(GLES2ImplementationTest, LoseContextCHROMIUM) {
2925 struct Cmds {
2926 cmds::LoseContextCHROMIUM cmd;
2928 Cmds expected;
2929 expected.cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_GUILTY_CONTEXT_RESET_ARB);
2931 gl_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
2932 GL_GUILTY_CONTEXT_RESET_ARB);
2933 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2935 // TODO(zmo): Implement unit test for InsertSyncPointCHROMIUM
2937 TEST_F(GLES2ImplementationTest, WaitSyncPointCHROMIUM) {
2938 struct Cmds {
2939 cmds::WaitSyncPointCHROMIUM cmd;
2941 Cmds expected;
2942 expected.cmd.Init(1);
2944 gl_->WaitSyncPointCHROMIUM(1);
2945 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2948 TEST_F(GLES2ImplementationTest, DrawBuffersEXT) {
2949 GLenum data[1][1] = {{0}};
2950 struct Cmds {
2951 cmds::DrawBuffersEXTImmediate cmd;
2952 GLenum data[1][1];
2955 Cmds expected;
2956 for (int ii = 0; ii < 1; ++ii) {
2957 for (int jj = 0; jj < 1; ++jj) {
2958 data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
2961 expected.cmd.Init(1, &data[0][0]);
2962 gl_->DrawBuffersEXT(1, &data[0][0]);
2963 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2966 TEST_F(GLES2ImplementationTest, DiscardBackbufferCHROMIUM) {
2967 struct Cmds {
2968 cmds::DiscardBackbufferCHROMIUM cmd;
2970 Cmds expected;
2971 expected.cmd.Init();
2973 gl_->DiscardBackbufferCHROMIUM();
2974 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2977 TEST_F(GLES2ImplementationTest, MatrixLoadfCHROMIUM) {
2978 GLfloat data[16] = {0};
2979 struct Cmds {
2980 cmds::MatrixLoadfCHROMIUMImmediate cmd;
2981 GLfloat data[16];
2984 for (int jj = 0; jj < 16; ++jj) {
2985 data[jj] = static_cast<GLfloat>(jj);
2987 Cmds expected;
2988 expected.cmd.Init(GL_PATH_PROJECTION_CHROMIUM, &data[0]);
2989 gl_->MatrixLoadfCHROMIUM(GL_PATH_PROJECTION_CHROMIUM, &data[0]);
2990 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2993 TEST_F(GLES2ImplementationTest, MatrixLoadIdentityCHROMIUM) {
2994 struct Cmds {
2995 cmds::MatrixLoadIdentityCHROMIUM cmd;
2997 Cmds expected;
2998 expected.cmd.Init(GL_PATH_PROJECTION_CHROMIUM);
3000 gl_->MatrixLoadIdentityCHROMIUM(GL_PATH_PROJECTION_CHROMIUM);
3001 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3003 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_