Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / gpu / command_buffer / client / gles2_implementation_unittest_autogen.h
blob97a467a5d007870d18708bb853c765a818b4b0d1
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, GetBufferParameteriv) {
783 struct Cmds {
784 cmds::GetBufferParameteriv cmd;
786 typedef cmds::GetBufferParameteriv::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_->GetBufferParameteriv(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, GetFloatv) {
801 struct Cmds {
802 cmds::GetFloatv cmd;
804 typedef cmds::GetFloatv::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, result1.id, result1.offset);
810 EXPECT_CALL(*command_buffer(), OnFlush())
811 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
812 .RetiresOnSaturation();
813 gl_->GetFloatv(123, &result);
814 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
815 EXPECT_EQ(static_cast<ResultType>(1), result);
817 // TODO(zmo): Implement unit test for GetFragDataLocation
819 TEST_F(GLES2ImplementationTest, GetFramebufferAttachmentParameteriv) {
820 struct Cmds {
821 cmds::GetFramebufferAttachmentParameteriv cmd;
823 typedef cmds::GetFramebufferAttachmentParameteriv::Result::Type ResultType;
824 ResultType result = 0;
825 Cmds expected;
826 ExpectedMemoryInfo result1 =
827 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
828 expected.cmd.Init(123, GL_COLOR_ATTACHMENT0,
829 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, result1.id,
830 result1.offset);
831 EXPECT_CALL(*command_buffer(), OnFlush())
832 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
833 .RetiresOnSaturation();
834 gl_->GetFramebufferAttachmentParameteriv(
835 123, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
836 &result);
837 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
838 EXPECT_EQ(static_cast<ResultType>(1), result);
841 TEST_F(GLES2ImplementationTest, GetInteger64v) {
842 struct Cmds {
843 cmds::GetInteger64v cmd;
845 typedef cmds::GetInteger64v::Result::Type ResultType;
846 ResultType result = 0;
847 Cmds expected;
848 ExpectedMemoryInfo result1 =
849 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
850 expected.cmd.Init(123, result1.id, result1.offset);
851 EXPECT_CALL(*command_buffer(), OnFlush())
852 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
853 .RetiresOnSaturation();
854 gl_->GetInteger64v(123, &result);
855 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
856 EXPECT_EQ(static_cast<ResultType>(1), result);
859 TEST_F(GLES2ImplementationTest, GetIntegeri_v) {
860 struct Cmds {
861 cmds::GetIntegeri_v cmd;
863 typedef cmds::GetIntegeri_v::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, 2, result1.id, result1.offset);
869 EXPECT_CALL(*command_buffer(), OnFlush())
870 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
871 .RetiresOnSaturation();
872 gl_->GetIntegeri_v(123, 2, &result);
873 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
874 EXPECT_EQ(static_cast<ResultType>(1), result);
877 TEST_F(GLES2ImplementationTest, GetInteger64i_v) {
878 struct Cmds {
879 cmds::GetInteger64i_v cmd;
881 typedef cmds::GetInteger64i_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_->GetInteger64i_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, GetIntegerv) {
896 struct Cmds {
897 cmds::GetIntegerv cmd;
899 typedef cmds::GetIntegerv::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, result1.id, result1.offset);
905 EXPECT_CALL(*command_buffer(), OnFlush())
906 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
907 .RetiresOnSaturation();
908 gl_->GetIntegerv(123, &result);
909 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
910 EXPECT_EQ(static_cast<ResultType>(1), result);
912 // TODO(zmo): Implement unit test for GetInternalformativ
914 TEST_F(GLES2ImplementationTest, GetProgramiv) {
915 struct Cmds {
916 cmds::GetProgramiv cmd;
918 typedef cmds::GetProgramiv::Result::Type ResultType;
919 ResultType result = 0;
920 Cmds expected;
921 ExpectedMemoryInfo result1 =
922 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
923 expected.cmd.Init(123, GL_DELETE_STATUS, result1.id, result1.offset);
924 EXPECT_CALL(*command_buffer(), OnFlush())
925 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
926 .RetiresOnSaturation();
927 gl_->GetProgramiv(123, GL_DELETE_STATUS, &result);
928 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
929 EXPECT_EQ(static_cast<ResultType>(1), result);
931 // TODO(zmo): Implement unit test for GetProgramInfoLog
933 TEST_F(GLES2ImplementationTest, GetRenderbufferParameteriv) {
934 struct Cmds {
935 cmds::GetRenderbufferParameteriv cmd;
937 typedef cmds::GetRenderbufferParameteriv::Result::Type ResultType;
938 ResultType result = 0;
939 Cmds expected;
940 ExpectedMemoryInfo result1 =
941 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
942 expected.cmd.Init(123, GL_RENDERBUFFER_RED_SIZE, result1.id, result1.offset);
943 EXPECT_CALL(*command_buffer(), OnFlush())
944 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
945 .RetiresOnSaturation();
946 gl_->GetRenderbufferParameteriv(123, GL_RENDERBUFFER_RED_SIZE, &result);
947 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
948 EXPECT_EQ(static_cast<ResultType>(1), result);
951 TEST_F(GLES2ImplementationTest, GetSamplerParameterfv) {
952 struct Cmds {
953 cmds::GetSamplerParameterfv cmd;
955 typedef cmds::GetSamplerParameterfv::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_TEXTURE_MAG_FILTER, result1.id, result1.offset);
961 EXPECT_CALL(*command_buffer(), OnFlush())
962 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
963 .RetiresOnSaturation();
964 gl_->GetSamplerParameterfv(123, GL_TEXTURE_MAG_FILTER, &result);
965 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
966 EXPECT_EQ(static_cast<ResultType>(1), result);
969 TEST_F(GLES2ImplementationTest, GetSamplerParameteriv) {
970 struct Cmds {
971 cmds::GetSamplerParameteriv cmd;
973 typedef cmds::GetSamplerParameteriv::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_->GetSamplerParameteriv(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, GetShaderiv) {
988 struct Cmds {
989 cmds::GetShaderiv cmd;
991 typedef cmds::GetShaderiv::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_SHADER_TYPE, result1.id, result1.offset);
997 EXPECT_CALL(*command_buffer(), OnFlush())
998 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
999 .RetiresOnSaturation();
1000 gl_->GetShaderiv(123, GL_SHADER_TYPE, &result);
1001 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1002 EXPECT_EQ(static_cast<ResultType>(1), result);
1004 // TODO(zmo): Implement unit test for GetShaderInfoLog
1005 // TODO(zmo): Implement unit test for GetShaderPrecisionFormat
1007 TEST_F(GLES2ImplementationTest, GetSynciv) {
1008 struct Cmds {
1009 cmds::GetSynciv cmd;
1011 typedef cmds::GetSynciv::Result::Type ResultType;
1012 ResultType result = 0;
1013 Cmds expected;
1014 ExpectedMemoryInfo result1 =
1015 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1016 expected.cmd.Init(123, GL_SYNC_STATUS, result1.id, result1.offset);
1017 EXPECT_CALL(*command_buffer(), OnFlush())
1018 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1019 .RetiresOnSaturation();
1020 gl_->GetSynciv(reinterpret_cast<GLsync>(123), GL_SYNC_STATUS, 3, nullptr,
1021 &result);
1022 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1023 EXPECT_EQ(static_cast<ResultType>(1), result);
1026 TEST_F(GLES2ImplementationTest, GetTexParameterfv) {
1027 struct Cmds {
1028 cmds::GetTexParameterfv cmd;
1030 typedef cmds::GetTexParameterfv::Result::Type ResultType;
1031 ResultType result = 0;
1032 Cmds expected;
1033 ExpectedMemoryInfo result1 =
1034 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1035 expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
1036 EXPECT_CALL(*command_buffer(), OnFlush())
1037 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1038 .RetiresOnSaturation();
1039 gl_->GetTexParameterfv(123, GL_TEXTURE_MAG_FILTER, &result);
1040 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1041 EXPECT_EQ(static_cast<ResultType>(1), result);
1044 TEST_F(GLES2ImplementationTest, GetTexParameteriv) {
1045 struct Cmds {
1046 cmds::GetTexParameteriv cmd;
1048 typedef cmds::GetTexParameteriv::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_->GetTexParameteriv(123, GL_TEXTURE_MAG_FILTER, &result);
1058 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1059 EXPECT_EQ(static_cast<ResultType>(1), result);
1061 // TODO(zmo): Implement unit test for GetTransformFeedbackVarying
1062 // TODO(zmo): Implement unit test for GetUniformBlockIndex
1063 // TODO(zmo): Implement unit test for GetUniformfv
1064 // TODO(zmo): Implement unit test for GetUniformiv
1065 // TODO(zmo): Implement unit test for GetUniformuiv
1066 // TODO(zmo): Implement unit test for GetUniformIndices
1067 // TODO(zmo): Implement unit test for GetUniformLocation
1069 TEST_F(GLES2ImplementationTest, GetVertexAttribfv) {
1070 struct Cmds {
1071 cmds::GetVertexAttribfv cmd;
1073 typedef cmds::GetVertexAttribfv::Result::Type ResultType;
1074 ResultType result = 0;
1075 Cmds expected;
1076 ExpectedMemoryInfo result1 =
1077 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1078 expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1079 result1.offset);
1080 EXPECT_CALL(*command_buffer(), OnFlush())
1081 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1082 .RetiresOnSaturation();
1083 gl_->GetVertexAttribfv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1084 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1085 EXPECT_EQ(static_cast<ResultType>(1), result);
1088 TEST_F(GLES2ImplementationTest, GetVertexAttribiv) {
1089 struct Cmds {
1090 cmds::GetVertexAttribiv cmd;
1092 typedef cmds::GetVertexAttribiv::Result::Type ResultType;
1093 ResultType result = 0;
1094 Cmds expected;
1095 ExpectedMemoryInfo result1 =
1096 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1097 expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1098 result1.offset);
1099 EXPECT_CALL(*command_buffer(), OnFlush())
1100 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1101 .RetiresOnSaturation();
1102 gl_->GetVertexAttribiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1103 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1104 EXPECT_EQ(static_cast<ResultType>(1), result);
1107 TEST_F(GLES2ImplementationTest, GetVertexAttribIiv) {
1108 struct Cmds {
1109 cmds::GetVertexAttribIiv cmd;
1111 typedef cmds::GetVertexAttribIiv::Result::Type ResultType;
1112 ResultType result = 0;
1113 Cmds expected;
1114 ExpectedMemoryInfo result1 =
1115 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1116 expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1117 result1.offset);
1118 EXPECT_CALL(*command_buffer(), OnFlush())
1119 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1120 .RetiresOnSaturation();
1121 gl_->GetVertexAttribIiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1122 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1123 EXPECT_EQ(static_cast<ResultType>(1), result);
1126 TEST_F(GLES2ImplementationTest, GetVertexAttribIuiv) {
1127 struct Cmds {
1128 cmds::GetVertexAttribIuiv cmd;
1130 typedef cmds::GetVertexAttribIuiv::Result::Type ResultType;
1131 ResultType result = 0;
1132 Cmds expected;
1133 ExpectedMemoryInfo result1 =
1134 GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1135 expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1136 result1.offset);
1137 EXPECT_CALL(*command_buffer(), OnFlush())
1138 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1139 .RetiresOnSaturation();
1140 gl_->GetVertexAttribIuiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1141 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1142 EXPECT_EQ(static_cast<ResultType>(1), result);
1145 TEST_F(GLES2ImplementationTest, Hint) {
1146 struct Cmds {
1147 cmds::Hint cmd;
1149 Cmds expected;
1150 expected.cmd.Init(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
1152 gl_->Hint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
1153 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1156 TEST_F(GLES2ImplementationTest, InvalidateFramebuffer) {
1157 GLenum data[2][1] = {{0}};
1158 struct Cmds {
1159 cmds::InvalidateFramebufferImmediate cmd;
1160 GLenum data[2][1];
1163 Cmds expected;
1164 for (int ii = 0; ii < 2; ++ii) {
1165 for (int jj = 0; jj < 1; ++jj) {
1166 data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
1169 expected.cmd.Init(GL_FRAMEBUFFER, 2, &data[0][0]);
1170 gl_->InvalidateFramebuffer(GL_FRAMEBUFFER, 2, &data[0][0]);
1171 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1174 TEST_F(GLES2ImplementationTest, InvalidateSubFramebuffer) {
1175 GLenum data[2][1] = {{0}};
1176 struct Cmds {
1177 cmds::InvalidateSubFramebufferImmediate 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], 4, 5, 6, 7);
1188 gl_->InvalidateSubFramebuffer(GL_FRAMEBUFFER, 2, &data[0][0], 4, 5, 6, 7);
1189 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1192 TEST_F(GLES2ImplementationTest, IsBuffer) {
1193 struct Cmds {
1194 cmds::IsBuffer cmd;
1197 Cmds expected;
1198 ExpectedMemoryInfo result1 =
1199 GetExpectedResultMemory(sizeof(cmds::IsBuffer::Result));
1200 expected.cmd.Init(1, result1.id, result1.offset);
1202 EXPECT_CALL(*command_buffer(), OnFlush())
1203 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1204 .RetiresOnSaturation();
1206 GLboolean result = gl_->IsBuffer(1);
1207 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1208 EXPECT_TRUE(result);
1211 TEST_F(GLES2ImplementationTest, IsFramebuffer) {
1212 struct Cmds {
1213 cmds::IsFramebuffer cmd;
1216 Cmds expected;
1217 ExpectedMemoryInfo result1 =
1218 GetExpectedResultMemory(sizeof(cmds::IsFramebuffer::Result));
1219 expected.cmd.Init(1, result1.id, result1.offset);
1221 EXPECT_CALL(*command_buffer(), OnFlush())
1222 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1223 .RetiresOnSaturation();
1225 GLboolean result = gl_->IsFramebuffer(1);
1226 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1227 EXPECT_TRUE(result);
1230 TEST_F(GLES2ImplementationTest, IsProgram) {
1231 struct Cmds {
1232 cmds::IsProgram cmd;
1235 Cmds expected;
1236 ExpectedMemoryInfo result1 =
1237 GetExpectedResultMemory(sizeof(cmds::IsProgram::Result));
1238 expected.cmd.Init(1, result1.id, result1.offset);
1240 EXPECT_CALL(*command_buffer(), OnFlush())
1241 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1242 .RetiresOnSaturation();
1244 GLboolean result = gl_->IsProgram(1);
1245 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1246 EXPECT_TRUE(result);
1249 TEST_F(GLES2ImplementationTest, IsRenderbuffer) {
1250 struct Cmds {
1251 cmds::IsRenderbuffer cmd;
1254 Cmds expected;
1255 ExpectedMemoryInfo result1 =
1256 GetExpectedResultMemory(sizeof(cmds::IsRenderbuffer::Result));
1257 expected.cmd.Init(1, result1.id, result1.offset);
1259 EXPECT_CALL(*command_buffer(), OnFlush())
1260 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1261 .RetiresOnSaturation();
1263 GLboolean result = gl_->IsRenderbuffer(1);
1264 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1265 EXPECT_TRUE(result);
1268 TEST_F(GLES2ImplementationTest, IsSampler) {
1269 struct Cmds {
1270 cmds::IsSampler cmd;
1273 Cmds expected;
1274 ExpectedMemoryInfo result1 =
1275 GetExpectedResultMemory(sizeof(cmds::IsSampler::Result));
1276 expected.cmd.Init(1, result1.id, result1.offset);
1278 EXPECT_CALL(*command_buffer(), OnFlush())
1279 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1280 .RetiresOnSaturation();
1282 GLboolean result = gl_->IsSampler(1);
1283 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1284 EXPECT_TRUE(result);
1287 TEST_F(GLES2ImplementationTest, IsShader) {
1288 struct Cmds {
1289 cmds::IsShader cmd;
1292 Cmds expected;
1293 ExpectedMemoryInfo result1 =
1294 GetExpectedResultMemory(sizeof(cmds::IsShader::Result));
1295 expected.cmd.Init(1, result1.id, result1.offset);
1297 EXPECT_CALL(*command_buffer(), OnFlush())
1298 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1299 .RetiresOnSaturation();
1301 GLboolean result = gl_->IsShader(1);
1302 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1303 EXPECT_TRUE(result);
1306 TEST_F(GLES2ImplementationTest, IsSync) {
1307 struct Cmds {
1308 cmds::IsSync cmd;
1311 Cmds expected;
1312 ExpectedMemoryInfo result1 =
1313 GetExpectedResultMemory(sizeof(cmds::IsSync::Result));
1314 expected.cmd.Init(1, result1.id, result1.offset);
1316 EXPECT_CALL(*command_buffer(), OnFlush())
1317 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1318 .RetiresOnSaturation();
1320 GLboolean result = gl_->IsSync(reinterpret_cast<GLsync>(1));
1321 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1322 EXPECT_TRUE(result);
1325 TEST_F(GLES2ImplementationTest, IsTexture) {
1326 struct Cmds {
1327 cmds::IsTexture cmd;
1330 Cmds expected;
1331 ExpectedMemoryInfo result1 =
1332 GetExpectedResultMemory(sizeof(cmds::IsTexture::Result));
1333 expected.cmd.Init(1, result1.id, result1.offset);
1335 EXPECT_CALL(*command_buffer(), OnFlush())
1336 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1337 .RetiresOnSaturation();
1339 GLboolean result = gl_->IsTexture(1);
1340 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1341 EXPECT_TRUE(result);
1344 TEST_F(GLES2ImplementationTest, IsTransformFeedback) {
1345 struct Cmds {
1346 cmds::IsTransformFeedback cmd;
1349 Cmds expected;
1350 ExpectedMemoryInfo result1 =
1351 GetExpectedResultMemory(sizeof(cmds::IsTransformFeedback::Result));
1352 expected.cmd.Init(1, result1.id, result1.offset);
1354 EXPECT_CALL(*command_buffer(), OnFlush())
1355 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1356 .RetiresOnSaturation();
1358 GLboolean result = gl_->IsTransformFeedback(1);
1359 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1360 EXPECT_TRUE(result);
1363 TEST_F(GLES2ImplementationTest, LineWidth) {
1364 struct Cmds {
1365 cmds::LineWidth cmd;
1367 Cmds expected;
1368 expected.cmd.Init(0.5f);
1370 gl_->LineWidth(0.5f);
1371 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1374 TEST_F(GLES2ImplementationTest, LinkProgram) {
1375 struct Cmds {
1376 cmds::LinkProgram cmd;
1378 Cmds expected;
1379 expected.cmd.Init(1);
1381 gl_->LinkProgram(1);
1382 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1385 TEST_F(GLES2ImplementationTest, PauseTransformFeedback) {
1386 struct Cmds {
1387 cmds::PauseTransformFeedback cmd;
1389 Cmds expected;
1390 expected.cmd.Init();
1392 gl_->PauseTransformFeedback();
1393 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1396 TEST_F(GLES2ImplementationTest, PixelStorei) {
1397 struct Cmds {
1398 cmds::PixelStorei cmd;
1400 Cmds expected;
1401 expected.cmd.Init(GL_PACK_ALIGNMENT, 1);
1403 gl_->PixelStorei(GL_PACK_ALIGNMENT, 1);
1404 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1407 TEST_F(GLES2ImplementationTest, PolygonOffset) {
1408 struct Cmds {
1409 cmds::PolygonOffset cmd;
1411 Cmds expected;
1412 expected.cmd.Init(1, 2);
1414 gl_->PolygonOffset(1, 2);
1415 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1418 TEST_F(GLES2ImplementationTest, ReadBuffer) {
1419 struct Cmds {
1420 cmds::ReadBuffer cmd;
1422 Cmds expected;
1423 expected.cmd.Init(1);
1425 gl_->ReadBuffer(1);
1426 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1429 TEST_F(GLES2ImplementationTest, ReleaseShaderCompiler) {
1430 struct Cmds {
1431 cmds::ReleaseShaderCompiler cmd;
1433 Cmds expected;
1434 expected.cmd.Init();
1436 gl_->ReleaseShaderCompiler();
1437 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1440 TEST_F(GLES2ImplementationTest, RenderbufferStorage) {
1441 struct Cmds {
1442 cmds::RenderbufferStorage cmd;
1444 Cmds expected;
1445 expected.cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
1447 gl_->RenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
1448 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1451 TEST_F(GLES2ImplementationTest, ResumeTransformFeedback) {
1452 struct Cmds {
1453 cmds::ResumeTransformFeedback cmd;
1455 Cmds expected;
1456 expected.cmd.Init();
1458 gl_->ResumeTransformFeedback();
1459 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1462 TEST_F(GLES2ImplementationTest, SampleCoverage) {
1463 struct Cmds {
1464 cmds::SampleCoverage cmd;
1466 Cmds expected;
1467 expected.cmd.Init(1, true);
1469 gl_->SampleCoverage(1, true);
1470 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1473 TEST_F(GLES2ImplementationTest, SamplerParameterf) {
1474 struct Cmds {
1475 cmds::SamplerParameterf cmd;
1477 Cmds expected;
1478 expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1480 gl_->SamplerParameterf(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1481 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1484 TEST_F(GLES2ImplementationTest, SamplerParameterfv) {
1485 GLfloat data[1] = {0};
1486 struct Cmds {
1487 cmds::SamplerParameterfvImmediate cmd;
1488 GLfloat data[1];
1491 for (int jj = 0; jj < 1; ++jj) {
1492 data[jj] = static_cast<GLfloat>(jj);
1494 Cmds expected;
1495 expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1496 gl_->SamplerParameterfv(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1497 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1500 TEST_F(GLES2ImplementationTest, SamplerParameteri) {
1501 struct Cmds {
1502 cmds::SamplerParameteri cmd;
1504 Cmds expected;
1505 expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1507 gl_->SamplerParameteri(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1508 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1511 TEST_F(GLES2ImplementationTest, SamplerParameteriv) {
1512 GLint data[1] = {0};
1513 struct Cmds {
1514 cmds::SamplerParameterivImmediate cmd;
1515 GLint data[1];
1518 for (int jj = 0; jj < 1; ++jj) {
1519 data[jj] = static_cast<GLint>(jj);
1521 Cmds expected;
1522 expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1523 gl_->SamplerParameteriv(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1524 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1527 TEST_F(GLES2ImplementationTest, Scissor) {
1528 struct Cmds {
1529 cmds::Scissor cmd;
1531 Cmds expected;
1532 expected.cmd.Init(1, 2, 3, 4);
1534 gl_->Scissor(1, 2, 3, 4);
1535 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1538 TEST_F(GLES2ImplementationTest, ShaderSource) {
1539 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
1540 const char* kString1 = "happy";
1541 const char* kString2 = "ending";
1542 const size_t kString1Size = ::strlen(kString1) + 1;
1543 const size_t kString2Size = ::strlen(kString2) + 1;
1544 const size_t kHeaderSize = sizeof(GLint) * 3;
1545 const size_t kSourceSize = kHeaderSize + kString1Size + kString2Size;
1546 const size_t kPaddedHeaderSize =
1547 transfer_buffer_->RoundToAlignment(kHeaderSize);
1548 const size_t kPaddedString1Size =
1549 transfer_buffer_->RoundToAlignment(kString1Size);
1550 const size_t kPaddedString2Size =
1551 transfer_buffer_->RoundToAlignment(kString2Size);
1552 struct Cmds {
1553 cmd::SetBucketSize set_bucket_size;
1554 cmd::SetBucketData set_bucket_header;
1555 cmd::SetToken set_token1;
1556 cmd::SetBucketData set_bucket_data1;
1557 cmd::SetToken set_token2;
1558 cmd::SetBucketData set_bucket_data2;
1559 cmd::SetToken set_token3;
1560 cmds::ShaderSourceBucket cmd_bucket;
1561 cmd::SetBucketSize clear_bucket_size;
1564 ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1565 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedString1Size);
1566 ExpectedMemoryInfo mem2 = GetExpectedMemory(kPaddedString2Size);
1568 Cmds expected;
1569 expected.set_bucket_size.Init(kBucketId, kSourceSize);
1570 expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1571 mem0.offset);
1572 expected.set_token1.Init(GetNextToken());
1573 expected.set_bucket_data1.Init(kBucketId, kHeaderSize, kString1Size, mem1.id,
1574 mem1.offset);
1575 expected.set_token2.Init(GetNextToken());
1576 expected.set_bucket_data2.Init(kBucketId, kHeaderSize + kString1Size,
1577 kString2Size, mem2.id, mem2.offset);
1578 expected.set_token3.Init(GetNextToken());
1579 expected.cmd_bucket.Init(1, kBucketId);
1580 expected.clear_bucket_size.Init(kBucketId, 0);
1581 const char* kStrings[] = {kString1, kString2};
1582 gl_->ShaderSource(1, 2, kStrings, NULL);
1583 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1586 TEST_F(GLES2ImplementationTest, ShaderSourceWithLength) {
1587 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
1588 const char* kString = "foobar******";
1589 const size_t kStringSize = 6; // We only need "foobar".
1590 const size_t kHeaderSize = sizeof(GLint) * 2;
1591 const size_t kSourceSize = kHeaderSize + kStringSize + 1;
1592 const size_t kPaddedHeaderSize =
1593 transfer_buffer_->RoundToAlignment(kHeaderSize);
1594 const size_t kPaddedStringSize =
1595 transfer_buffer_->RoundToAlignment(kStringSize + 1);
1596 struct Cmds {
1597 cmd::SetBucketSize set_bucket_size;
1598 cmd::SetBucketData set_bucket_header;
1599 cmd::SetToken set_token1;
1600 cmd::SetBucketData set_bucket_data;
1601 cmd::SetToken set_token2;
1602 cmds::ShaderSourceBucket shader_source_bucket;
1603 cmd::SetBucketSize clear_bucket_size;
1606 ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1607 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedStringSize);
1609 Cmds expected;
1610 expected.set_bucket_size.Init(kBucketId, kSourceSize);
1611 expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1612 mem0.offset);
1613 expected.set_token1.Init(GetNextToken());
1614 expected.set_bucket_data.Init(kBucketId, kHeaderSize, kStringSize + 1,
1615 mem1.id, mem1.offset);
1616 expected.set_token2.Init(GetNextToken());
1617 expected.shader_source_bucket.Init(1, kBucketId);
1618 expected.clear_bucket_size.Init(kBucketId, 0);
1619 const char* kStrings[] = {kString};
1620 const GLint kLength[] = {kStringSize};
1621 gl_->ShaderSource(1, 1, kStrings, kLength);
1622 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1625 TEST_F(GLES2ImplementationTest, StencilFunc) {
1626 struct Cmds {
1627 cmds::StencilFunc cmd;
1629 Cmds expected;
1630 expected.cmd.Init(GL_NEVER, 2, 3);
1632 gl_->StencilFunc(GL_NEVER, 2, 3);
1633 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1636 TEST_F(GLES2ImplementationTest, StencilFuncSeparate) {
1637 struct Cmds {
1638 cmds::StencilFuncSeparate cmd;
1640 Cmds expected;
1641 expected.cmd.Init(GL_FRONT, GL_NEVER, 3, 4);
1643 gl_->StencilFuncSeparate(GL_FRONT, GL_NEVER, 3, 4);
1644 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1647 TEST_F(GLES2ImplementationTest, StencilMask) {
1648 struct Cmds {
1649 cmds::StencilMask cmd;
1651 Cmds expected;
1652 expected.cmd.Init(1);
1654 gl_->StencilMask(1);
1655 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1658 TEST_F(GLES2ImplementationTest, StencilMaskSeparate) {
1659 struct Cmds {
1660 cmds::StencilMaskSeparate cmd;
1662 Cmds expected;
1663 expected.cmd.Init(GL_FRONT, 2);
1665 gl_->StencilMaskSeparate(GL_FRONT, 2);
1666 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1669 TEST_F(GLES2ImplementationTest, StencilOp) {
1670 struct Cmds {
1671 cmds::StencilOp cmd;
1673 Cmds expected;
1674 expected.cmd.Init(GL_KEEP, GL_INCR, GL_KEEP);
1676 gl_->StencilOp(GL_KEEP, GL_INCR, GL_KEEP);
1677 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1680 TEST_F(GLES2ImplementationTest, StencilOpSeparate) {
1681 struct Cmds {
1682 cmds::StencilOpSeparate cmd;
1684 Cmds expected;
1685 expected.cmd.Init(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP);
1687 gl_->StencilOpSeparate(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP);
1688 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1691 TEST_F(GLES2ImplementationTest, TexParameterf) {
1692 struct Cmds {
1693 cmds::TexParameterf cmd;
1695 Cmds expected;
1696 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1698 gl_->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1699 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1702 TEST_F(GLES2ImplementationTest, TexParameterfv) {
1703 GLfloat data[1] = {0};
1704 struct Cmds {
1705 cmds::TexParameterfvImmediate cmd;
1706 GLfloat data[1];
1709 for (int jj = 0; jj < 1; ++jj) {
1710 data[jj] = static_cast<GLfloat>(jj);
1712 Cmds expected;
1713 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1714 gl_->TexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1715 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1718 TEST_F(GLES2ImplementationTest, TexParameteri) {
1719 struct Cmds {
1720 cmds::TexParameteri cmd;
1722 Cmds expected;
1723 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1725 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1726 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1729 TEST_F(GLES2ImplementationTest, TexParameteriv) {
1730 GLint data[1] = {0};
1731 struct Cmds {
1732 cmds::TexParameterivImmediate cmd;
1733 GLint data[1];
1736 for (int jj = 0; jj < 1; ++jj) {
1737 data[jj] = static_cast<GLint>(jj);
1739 Cmds expected;
1740 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1741 gl_->TexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1742 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1745 TEST_F(GLES2ImplementationTest, TexStorage3D) {
1746 struct Cmds {
1747 cmds::TexStorage3D cmd;
1749 Cmds expected;
1750 expected.cmd.Init(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6);
1752 gl_->TexStorage3D(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6);
1753 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1756 TEST_F(GLES2ImplementationTest, TransformFeedbackVaryings) {
1757 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
1758 const char* kString1 = "happy";
1759 const char* kString2 = "ending";
1760 const size_t kString1Size = ::strlen(kString1) + 1;
1761 const size_t kString2Size = ::strlen(kString2) + 1;
1762 const size_t kHeaderSize = sizeof(GLint) * 3;
1763 const size_t kSourceSize = kHeaderSize + kString1Size + kString2Size;
1764 const size_t kPaddedHeaderSize =
1765 transfer_buffer_->RoundToAlignment(kHeaderSize);
1766 const size_t kPaddedString1Size =
1767 transfer_buffer_->RoundToAlignment(kString1Size);
1768 const size_t kPaddedString2Size =
1769 transfer_buffer_->RoundToAlignment(kString2Size);
1770 struct Cmds {
1771 cmd::SetBucketSize set_bucket_size;
1772 cmd::SetBucketData set_bucket_header;
1773 cmd::SetToken set_token1;
1774 cmd::SetBucketData set_bucket_data1;
1775 cmd::SetToken set_token2;
1776 cmd::SetBucketData set_bucket_data2;
1777 cmd::SetToken set_token3;
1778 cmds::TransformFeedbackVaryingsBucket cmd_bucket;
1779 cmd::SetBucketSize clear_bucket_size;
1782 ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1783 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedString1Size);
1784 ExpectedMemoryInfo mem2 = GetExpectedMemory(kPaddedString2Size);
1786 Cmds expected;
1787 expected.set_bucket_size.Init(kBucketId, kSourceSize);
1788 expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1789 mem0.offset);
1790 expected.set_token1.Init(GetNextToken());
1791 expected.set_bucket_data1.Init(kBucketId, kHeaderSize, kString1Size, mem1.id,
1792 mem1.offset);
1793 expected.set_token2.Init(GetNextToken());
1794 expected.set_bucket_data2.Init(kBucketId, kHeaderSize + kString1Size,
1795 kString2Size, mem2.id, mem2.offset);
1796 expected.set_token3.Init(GetNextToken());
1797 expected.cmd_bucket.Init(1, kBucketId, GL_INTERLEAVED_ATTRIBS);
1798 expected.clear_bucket_size.Init(kBucketId, 0);
1799 const char* kStrings[] = {kString1, kString2};
1800 gl_->TransformFeedbackVaryings(1, 2, kStrings, GL_INTERLEAVED_ATTRIBS);
1801 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1804 TEST_F(GLES2ImplementationTest, Uniform1f) {
1805 struct Cmds {
1806 cmds::Uniform1f cmd;
1808 Cmds expected;
1809 expected.cmd.Init(1, 2);
1811 gl_->Uniform1f(1, 2);
1812 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1815 TEST_F(GLES2ImplementationTest, Uniform1fv) {
1816 GLfloat data[2][1] = {{0}};
1817 struct Cmds {
1818 cmds::Uniform1fvImmediate cmd;
1819 GLfloat data[2][1];
1822 Cmds expected;
1823 for (int ii = 0; ii < 2; ++ii) {
1824 for (int jj = 0; jj < 1; ++jj) {
1825 data[ii][jj] = static_cast<GLfloat>(ii * 1 + jj);
1828 expected.cmd.Init(1, 2, &data[0][0]);
1829 gl_->Uniform1fv(1, 2, &data[0][0]);
1830 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1833 TEST_F(GLES2ImplementationTest, Uniform1i) {
1834 struct Cmds {
1835 cmds::Uniform1i cmd;
1837 Cmds expected;
1838 expected.cmd.Init(1, 2);
1840 gl_->Uniform1i(1, 2);
1841 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1844 TEST_F(GLES2ImplementationTest, Uniform1iv) {
1845 GLint data[2][1] = {{0}};
1846 struct Cmds {
1847 cmds::Uniform1ivImmediate cmd;
1848 GLint data[2][1];
1851 Cmds expected;
1852 for (int ii = 0; ii < 2; ++ii) {
1853 for (int jj = 0; jj < 1; ++jj) {
1854 data[ii][jj] = static_cast<GLint>(ii * 1 + jj);
1857 expected.cmd.Init(1, 2, &data[0][0]);
1858 gl_->Uniform1iv(1, 2, &data[0][0]);
1859 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1862 TEST_F(GLES2ImplementationTest, Uniform1ui) {
1863 struct Cmds {
1864 cmds::Uniform1ui cmd;
1866 Cmds expected;
1867 expected.cmd.Init(1, 2);
1869 gl_->Uniform1ui(1, 2);
1870 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1873 TEST_F(GLES2ImplementationTest, Uniform1uiv) {
1874 GLuint data[2][1] = {{0}};
1875 struct Cmds {
1876 cmds::Uniform1uivImmediate cmd;
1877 GLuint data[2][1];
1880 Cmds expected;
1881 for (int ii = 0; ii < 2; ++ii) {
1882 for (int jj = 0; jj < 1; ++jj) {
1883 data[ii][jj] = static_cast<GLuint>(ii * 1 + jj);
1886 expected.cmd.Init(1, 2, &data[0][0]);
1887 gl_->Uniform1uiv(1, 2, &data[0][0]);
1888 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1891 TEST_F(GLES2ImplementationTest, Uniform2f) {
1892 struct Cmds {
1893 cmds::Uniform2f cmd;
1895 Cmds expected;
1896 expected.cmd.Init(1, 2, 3);
1898 gl_->Uniform2f(1, 2, 3);
1899 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1902 TEST_F(GLES2ImplementationTest, Uniform2fv) {
1903 GLfloat data[2][2] = {{0}};
1904 struct Cmds {
1905 cmds::Uniform2fvImmediate cmd;
1906 GLfloat data[2][2];
1909 Cmds expected;
1910 for (int ii = 0; ii < 2; ++ii) {
1911 for (int jj = 0; jj < 2; ++jj) {
1912 data[ii][jj] = static_cast<GLfloat>(ii * 2 + jj);
1915 expected.cmd.Init(1, 2, &data[0][0]);
1916 gl_->Uniform2fv(1, 2, &data[0][0]);
1917 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1920 TEST_F(GLES2ImplementationTest, Uniform2i) {
1921 struct Cmds {
1922 cmds::Uniform2i cmd;
1924 Cmds expected;
1925 expected.cmd.Init(1, 2, 3);
1927 gl_->Uniform2i(1, 2, 3);
1928 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1931 TEST_F(GLES2ImplementationTest, Uniform2iv) {
1932 GLint data[2][2] = {{0}};
1933 struct Cmds {
1934 cmds::Uniform2ivImmediate cmd;
1935 GLint data[2][2];
1938 Cmds expected;
1939 for (int ii = 0; ii < 2; ++ii) {
1940 for (int jj = 0; jj < 2; ++jj) {
1941 data[ii][jj] = static_cast<GLint>(ii * 2 + jj);
1944 expected.cmd.Init(1, 2, &data[0][0]);
1945 gl_->Uniform2iv(1, 2, &data[0][0]);
1946 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1949 TEST_F(GLES2ImplementationTest, Uniform2ui) {
1950 struct Cmds {
1951 cmds::Uniform2ui cmd;
1953 Cmds expected;
1954 expected.cmd.Init(1, 2, 3);
1956 gl_->Uniform2ui(1, 2, 3);
1957 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1960 TEST_F(GLES2ImplementationTest, Uniform2uiv) {
1961 GLuint data[2][2] = {{0}};
1962 struct Cmds {
1963 cmds::Uniform2uivImmediate cmd;
1964 GLuint data[2][2];
1967 Cmds expected;
1968 for (int ii = 0; ii < 2; ++ii) {
1969 for (int jj = 0; jj < 2; ++jj) {
1970 data[ii][jj] = static_cast<GLuint>(ii * 2 + jj);
1973 expected.cmd.Init(1, 2, &data[0][0]);
1974 gl_->Uniform2uiv(1, 2, &data[0][0]);
1975 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1978 TEST_F(GLES2ImplementationTest, Uniform3f) {
1979 struct Cmds {
1980 cmds::Uniform3f cmd;
1982 Cmds expected;
1983 expected.cmd.Init(1, 2, 3, 4);
1985 gl_->Uniform3f(1, 2, 3, 4);
1986 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1989 TEST_F(GLES2ImplementationTest, Uniform3fv) {
1990 GLfloat data[2][3] = {{0}};
1991 struct Cmds {
1992 cmds::Uniform3fvImmediate cmd;
1993 GLfloat data[2][3];
1996 Cmds expected;
1997 for (int ii = 0; ii < 2; ++ii) {
1998 for (int jj = 0; jj < 3; ++jj) {
1999 data[ii][jj] = static_cast<GLfloat>(ii * 3 + jj);
2002 expected.cmd.Init(1, 2, &data[0][0]);
2003 gl_->Uniform3fv(1, 2, &data[0][0]);
2004 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2007 TEST_F(GLES2ImplementationTest, Uniform3i) {
2008 struct Cmds {
2009 cmds::Uniform3i cmd;
2011 Cmds expected;
2012 expected.cmd.Init(1, 2, 3, 4);
2014 gl_->Uniform3i(1, 2, 3, 4);
2015 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2018 TEST_F(GLES2ImplementationTest, Uniform3iv) {
2019 GLint data[2][3] = {{0}};
2020 struct Cmds {
2021 cmds::Uniform3ivImmediate cmd;
2022 GLint data[2][3];
2025 Cmds expected;
2026 for (int ii = 0; ii < 2; ++ii) {
2027 for (int jj = 0; jj < 3; ++jj) {
2028 data[ii][jj] = static_cast<GLint>(ii * 3 + jj);
2031 expected.cmd.Init(1, 2, &data[0][0]);
2032 gl_->Uniform3iv(1, 2, &data[0][0]);
2033 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2036 TEST_F(GLES2ImplementationTest, Uniform3ui) {
2037 struct Cmds {
2038 cmds::Uniform3ui cmd;
2040 Cmds expected;
2041 expected.cmd.Init(1, 2, 3, 4);
2043 gl_->Uniform3ui(1, 2, 3, 4);
2044 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2047 TEST_F(GLES2ImplementationTest, Uniform3uiv) {
2048 GLuint data[2][3] = {{0}};
2049 struct Cmds {
2050 cmds::Uniform3uivImmediate cmd;
2051 GLuint data[2][3];
2054 Cmds expected;
2055 for (int ii = 0; ii < 2; ++ii) {
2056 for (int jj = 0; jj < 3; ++jj) {
2057 data[ii][jj] = static_cast<GLuint>(ii * 3 + jj);
2060 expected.cmd.Init(1, 2, &data[0][0]);
2061 gl_->Uniform3uiv(1, 2, &data[0][0]);
2062 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2065 TEST_F(GLES2ImplementationTest, Uniform4f) {
2066 struct Cmds {
2067 cmds::Uniform4f cmd;
2069 Cmds expected;
2070 expected.cmd.Init(1, 2, 3, 4, 5);
2072 gl_->Uniform4f(1, 2, 3, 4, 5);
2073 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2076 TEST_F(GLES2ImplementationTest, Uniform4fv) {
2077 GLfloat data[2][4] = {{0}};
2078 struct Cmds {
2079 cmds::Uniform4fvImmediate cmd;
2080 GLfloat data[2][4];
2083 Cmds expected;
2084 for (int ii = 0; ii < 2; ++ii) {
2085 for (int jj = 0; jj < 4; ++jj) {
2086 data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
2089 expected.cmd.Init(1, 2, &data[0][0]);
2090 gl_->Uniform4fv(1, 2, &data[0][0]);
2091 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2094 TEST_F(GLES2ImplementationTest, Uniform4i) {
2095 struct Cmds {
2096 cmds::Uniform4i cmd;
2098 Cmds expected;
2099 expected.cmd.Init(1, 2, 3, 4, 5);
2101 gl_->Uniform4i(1, 2, 3, 4, 5);
2102 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2105 TEST_F(GLES2ImplementationTest, Uniform4iv) {
2106 GLint data[2][4] = {{0}};
2107 struct Cmds {
2108 cmds::Uniform4ivImmediate cmd;
2109 GLint data[2][4];
2112 Cmds expected;
2113 for (int ii = 0; ii < 2; ++ii) {
2114 for (int jj = 0; jj < 4; ++jj) {
2115 data[ii][jj] = static_cast<GLint>(ii * 4 + jj);
2118 expected.cmd.Init(1, 2, &data[0][0]);
2119 gl_->Uniform4iv(1, 2, &data[0][0]);
2120 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2123 TEST_F(GLES2ImplementationTest, Uniform4ui) {
2124 struct Cmds {
2125 cmds::Uniform4ui cmd;
2127 Cmds expected;
2128 expected.cmd.Init(1, 2, 3, 4, 5);
2130 gl_->Uniform4ui(1, 2, 3, 4, 5);
2131 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2134 TEST_F(GLES2ImplementationTest, Uniform4uiv) {
2135 GLuint data[2][4] = {{0}};
2136 struct Cmds {
2137 cmds::Uniform4uivImmediate cmd;
2138 GLuint data[2][4];
2141 Cmds expected;
2142 for (int ii = 0; ii < 2; ++ii) {
2143 for (int jj = 0; jj < 4; ++jj) {
2144 data[ii][jj] = static_cast<GLuint>(ii * 4 + jj);
2147 expected.cmd.Init(1, 2, &data[0][0]);
2148 gl_->Uniform4uiv(1, 2, &data[0][0]);
2149 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2152 TEST_F(GLES2ImplementationTest, UniformBlockBinding) {
2153 struct Cmds {
2154 cmds::UniformBlockBinding cmd;
2156 Cmds expected;
2157 expected.cmd.Init(1, 2, 3);
2159 gl_->UniformBlockBinding(1, 2, 3);
2160 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2163 TEST_F(GLES2ImplementationTest, UniformMatrix2fv) {
2164 GLfloat data[2][4] = {{0}};
2165 struct Cmds {
2166 cmds::UniformMatrix2fvImmediate cmd;
2167 GLfloat data[2][4];
2170 Cmds expected;
2171 for (int ii = 0; ii < 2; ++ii) {
2172 for (int jj = 0; jj < 4; ++jj) {
2173 data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
2176 expected.cmd.Init(1, 2, &data[0][0]);
2177 gl_->UniformMatrix2fv(1, 2, false, &data[0][0]);
2178 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2181 TEST_F(GLES2ImplementationTest, UniformMatrix2fvInvalidConstantArg2) {
2182 GLfloat data[2][4] = {{0}};
2183 for (int ii = 0; ii < 2; ++ii) {
2184 for (int jj = 0; jj < 4; ++jj) {
2185 data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
2188 gl_->UniformMatrix2fv(1, 2, true, &data[0][0]);
2189 EXPECT_TRUE(NoCommandsWritten());
2190 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2193 TEST_F(GLES2ImplementationTest, UniformMatrix2x3fv) {
2194 GLfloat data[2][6] = {{0}};
2195 struct Cmds {
2196 cmds::UniformMatrix2x3fvImmediate cmd;
2197 GLfloat data[2][6];
2200 Cmds expected;
2201 for (int ii = 0; ii < 2; ++ii) {
2202 for (int jj = 0; jj < 6; ++jj) {
2203 data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2206 expected.cmd.Init(1, 2, &data[0][0]);
2207 gl_->UniformMatrix2x3fv(1, 2, false, &data[0][0]);
2208 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2211 TEST_F(GLES2ImplementationTest, UniformMatrix2x3fvInvalidConstantArg2) {
2212 GLfloat data[2][6] = {{0}};
2213 for (int ii = 0; ii < 2; ++ii) {
2214 for (int jj = 0; jj < 6; ++jj) {
2215 data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2218 gl_->UniformMatrix2x3fv(1, 2, true, &data[0][0]);
2219 EXPECT_TRUE(NoCommandsWritten());
2220 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2223 TEST_F(GLES2ImplementationTest, UniformMatrix2x4fv) {
2224 GLfloat data[2][8] = {{0}};
2225 struct Cmds {
2226 cmds::UniformMatrix2x4fvImmediate cmd;
2227 GLfloat data[2][8];
2230 Cmds expected;
2231 for (int ii = 0; ii < 2; ++ii) {
2232 for (int jj = 0; jj < 8; ++jj) {
2233 data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2236 expected.cmd.Init(1, 2, &data[0][0]);
2237 gl_->UniformMatrix2x4fv(1, 2, false, &data[0][0]);
2238 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2241 TEST_F(GLES2ImplementationTest, UniformMatrix2x4fvInvalidConstantArg2) {
2242 GLfloat data[2][8] = {{0}};
2243 for (int ii = 0; ii < 2; ++ii) {
2244 for (int jj = 0; jj < 8; ++jj) {
2245 data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2248 gl_->UniformMatrix2x4fv(1, 2, true, &data[0][0]);
2249 EXPECT_TRUE(NoCommandsWritten());
2250 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2253 TEST_F(GLES2ImplementationTest, UniformMatrix3fv) {
2254 GLfloat data[2][9] = {{0}};
2255 struct Cmds {
2256 cmds::UniformMatrix3fvImmediate cmd;
2257 GLfloat data[2][9];
2260 Cmds expected;
2261 for (int ii = 0; ii < 2; ++ii) {
2262 for (int jj = 0; jj < 9; ++jj) {
2263 data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj);
2266 expected.cmd.Init(1, 2, &data[0][0]);
2267 gl_->UniformMatrix3fv(1, 2, false, &data[0][0]);
2268 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2271 TEST_F(GLES2ImplementationTest, UniformMatrix3fvInvalidConstantArg2) {
2272 GLfloat data[2][9] = {{0}};
2273 for (int ii = 0; ii < 2; ++ii) {
2274 for (int jj = 0; jj < 9; ++jj) {
2275 data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj);
2278 gl_->UniformMatrix3fv(1, 2, true, &data[0][0]);
2279 EXPECT_TRUE(NoCommandsWritten());
2280 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2283 TEST_F(GLES2ImplementationTest, UniformMatrix3x2fv) {
2284 GLfloat data[2][6] = {{0}};
2285 struct Cmds {
2286 cmds::UniformMatrix3x2fvImmediate cmd;
2287 GLfloat data[2][6];
2290 Cmds expected;
2291 for (int ii = 0; ii < 2; ++ii) {
2292 for (int jj = 0; jj < 6; ++jj) {
2293 data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2296 expected.cmd.Init(1, 2, &data[0][0]);
2297 gl_->UniformMatrix3x2fv(1, 2, false, &data[0][0]);
2298 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2301 TEST_F(GLES2ImplementationTest, UniformMatrix3x2fvInvalidConstantArg2) {
2302 GLfloat data[2][6] = {{0}};
2303 for (int ii = 0; ii < 2; ++ii) {
2304 for (int jj = 0; jj < 6; ++jj) {
2305 data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2308 gl_->UniformMatrix3x2fv(1, 2, true, &data[0][0]);
2309 EXPECT_TRUE(NoCommandsWritten());
2310 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2313 TEST_F(GLES2ImplementationTest, UniformMatrix3x4fv) {
2314 GLfloat data[2][12] = {{0}};
2315 struct Cmds {
2316 cmds::UniformMatrix3x4fvImmediate cmd;
2317 GLfloat data[2][12];
2320 Cmds expected;
2321 for (int ii = 0; ii < 2; ++ii) {
2322 for (int jj = 0; jj < 12; ++jj) {
2323 data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2326 expected.cmd.Init(1, 2, &data[0][0]);
2327 gl_->UniformMatrix3x4fv(1, 2, false, &data[0][0]);
2328 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2331 TEST_F(GLES2ImplementationTest, UniformMatrix3x4fvInvalidConstantArg2) {
2332 GLfloat data[2][12] = {{0}};
2333 for (int ii = 0; ii < 2; ++ii) {
2334 for (int jj = 0; jj < 12; ++jj) {
2335 data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2338 gl_->UniformMatrix3x4fv(1, 2, true, &data[0][0]);
2339 EXPECT_TRUE(NoCommandsWritten());
2340 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2343 TEST_F(GLES2ImplementationTest, UniformMatrix4fv) {
2344 GLfloat data[2][16] = {{0}};
2345 struct Cmds {
2346 cmds::UniformMatrix4fvImmediate cmd;
2347 GLfloat data[2][16];
2350 Cmds expected;
2351 for (int ii = 0; ii < 2; ++ii) {
2352 for (int jj = 0; jj < 16; ++jj) {
2353 data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj);
2356 expected.cmd.Init(1, 2, &data[0][0]);
2357 gl_->UniformMatrix4fv(1, 2, false, &data[0][0]);
2358 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2361 TEST_F(GLES2ImplementationTest, UniformMatrix4fvInvalidConstantArg2) {
2362 GLfloat data[2][16] = {{0}};
2363 for (int ii = 0; ii < 2; ++ii) {
2364 for (int jj = 0; jj < 16; ++jj) {
2365 data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj);
2368 gl_->UniformMatrix4fv(1, 2, true, &data[0][0]);
2369 EXPECT_TRUE(NoCommandsWritten());
2370 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2373 TEST_F(GLES2ImplementationTest, UniformMatrix4x2fv) {
2374 GLfloat data[2][8] = {{0}};
2375 struct Cmds {
2376 cmds::UniformMatrix4x2fvImmediate cmd;
2377 GLfloat data[2][8];
2380 Cmds expected;
2381 for (int ii = 0; ii < 2; ++ii) {
2382 for (int jj = 0; jj < 8; ++jj) {
2383 data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2386 expected.cmd.Init(1, 2, &data[0][0]);
2387 gl_->UniformMatrix4x2fv(1, 2, false, &data[0][0]);
2388 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2391 TEST_F(GLES2ImplementationTest, UniformMatrix4x2fvInvalidConstantArg2) {
2392 GLfloat data[2][8] = {{0}};
2393 for (int ii = 0; ii < 2; ++ii) {
2394 for (int jj = 0; jj < 8; ++jj) {
2395 data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2398 gl_->UniformMatrix4x2fv(1, 2, true, &data[0][0]);
2399 EXPECT_TRUE(NoCommandsWritten());
2400 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2403 TEST_F(GLES2ImplementationTest, UniformMatrix4x3fv) {
2404 GLfloat data[2][12] = {{0}};
2405 struct Cmds {
2406 cmds::UniformMatrix4x3fvImmediate cmd;
2407 GLfloat data[2][12];
2410 Cmds expected;
2411 for (int ii = 0; ii < 2; ++ii) {
2412 for (int jj = 0; jj < 12; ++jj) {
2413 data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2416 expected.cmd.Init(1, 2, &data[0][0]);
2417 gl_->UniformMatrix4x3fv(1, 2, false, &data[0][0]);
2418 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2421 TEST_F(GLES2ImplementationTest, UniformMatrix4x3fvInvalidConstantArg2) {
2422 GLfloat data[2][12] = {{0}};
2423 for (int ii = 0; ii < 2; ++ii) {
2424 for (int jj = 0; jj < 12; ++jj) {
2425 data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2428 gl_->UniformMatrix4x3fv(1, 2, true, &data[0][0]);
2429 EXPECT_TRUE(NoCommandsWritten());
2430 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2433 TEST_F(GLES2ImplementationTest, UseProgram) {
2434 struct Cmds {
2435 cmds::UseProgram cmd;
2437 Cmds expected;
2438 expected.cmd.Init(1);
2440 gl_->UseProgram(1);
2441 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2442 ClearCommands();
2443 gl_->UseProgram(1);
2444 EXPECT_TRUE(NoCommandsWritten());
2447 TEST_F(GLES2ImplementationTest, ValidateProgram) {
2448 struct Cmds {
2449 cmds::ValidateProgram cmd;
2451 Cmds expected;
2452 expected.cmd.Init(1);
2454 gl_->ValidateProgram(1);
2455 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2458 TEST_F(GLES2ImplementationTest, VertexAttrib1f) {
2459 struct Cmds {
2460 cmds::VertexAttrib1f cmd;
2462 Cmds expected;
2463 expected.cmd.Init(1, 2);
2465 gl_->VertexAttrib1f(1, 2);
2466 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2469 TEST_F(GLES2ImplementationTest, VertexAttrib1fv) {
2470 GLfloat data[1] = {0};
2471 struct Cmds {
2472 cmds::VertexAttrib1fvImmediate cmd;
2473 GLfloat data[1];
2476 for (int jj = 0; jj < 1; ++jj) {
2477 data[jj] = static_cast<GLfloat>(jj);
2479 Cmds expected;
2480 expected.cmd.Init(1, &data[0]);
2481 gl_->VertexAttrib1fv(1, &data[0]);
2482 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2485 TEST_F(GLES2ImplementationTest, VertexAttrib2f) {
2486 struct Cmds {
2487 cmds::VertexAttrib2f cmd;
2489 Cmds expected;
2490 expected.cmd.Init(1, 2, 3);
2492 gl_->VertexAttrib2f(1, 2, 3);
2493 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2496 TEST_F(GLES2ImplementationTest, VertexAttrib2fv) {
2497 GLfloat data[2] = {0};
2498 struct Cmds {
2499 cmds::VertexAttrib2fvImmediate cmd;
2500 GLfloat data[2];
2503 for (int jj = 0; jj < 2; ++jj) {
2504 data[jj] = static_cast<GLfloat>(jj);
2506 Cmds expected;
2507 expected.cmd.Init(1, &data[0]);
2508 gl_->VertexAttrib2fv(1, &data[0]);
2509 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2512 TEST_F(GLES2ImplementationTest, VertexAttrib3f) {
2513 struct Cmds {
2514 cmds::VertexAttrib3f cmd;
2516 Cmds expected;
2517 expected.cmd.Init(1, 2, 3, 4);
2519 gl_->VertexAttrib3f(1, 2, 3, 4);
2520 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2523 TEST_F(GLES2ImplementationTest, VertexAttrib3fv) {
2524 GLfloat data[3] = {0};
2525 struct Cmds {
2526 cmds::VertexAttrib3fvImmediate cmd;
2527 GLfloat data[3];
2530 for (int jj = 0; jj < 3; ++jj) {
2531 data[jj] = static_cast<GLfloat>(jj);
2533 Cmds expected;
2534 expected.cmd.Init(1, &data[0]);
2535 gl_->VertexAttrib3fv(1, &data[0]);
2536 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2539 TEST_F(GLES2ImplementationTest, VertexAttrib4f) {
2540 struct Cmds {
2541 cmds::VertexAttrib4f cmd;
2543 Cmds expected;
2544 expected.cmd.Init(1, 2, 3, 4, 5);
2546 gl_->VertexAttrib4f(1, 2, 3, 4, 5);
2547 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2550 TEST_F(GLES2ImplementationTest, VertexAttrib4fv) {
2551 GLfloat data[4] = {0};
2552 struct Cmds {
2553 cmds::VertexAttrib4fvImmediate cmd;
2554 GLfloat data[4];
2557 for (int jj = 0; jj < 4; ++jj) {
2558 data[jj] = static_cast<GLfloat>(jj);
2560 Cmds expected;
2561 expected.cmd.Init(1, &data[0]);
2562 gl_->VertexAttrib4fv(1, &data[0]);
2563 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2566 TEST_F(GLES2ImplementationTest, VertexAttribI4i) {
2567 struct Cmds {
2568 cmds::VertexAttribI4i cmd;
2570 Cmds expected;
2571 expected.cmd.Init(1, 2, 3, 4, 5);
2573 gl_->VertexAttribI4i(1, 2, 3, 4, 5);
2574 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2577 TEST_F(GLES2ImplementationTest, VertexAttribI4iv) {
2578 GLint data[4] = {0};
2579 struct Cmds {
2580 cmds::VertexAttribI4ivImmediate cmd;
2581 GLint data[4];
2584 for (int jj = 0; jj < 4; ++jj) {
2585 data[jj] = static_cast<GLint>(jj);
2587 Cmds expected;
2588 expected.cmd.Init(1, &data[0]);
2589 gl_->VertexAttribI4iv(1, &data[0]);
2590 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2593 TEST_F(GLES2ImplementationTest, VertexAttribI4ui) {
2594 struct Cmds {
2595 cmds::VertexAttribI4ui cmd;
2597 Cmds expected;
2598 expected.cmd.Init(1, 2, 3, 4, 5);
2600 gl_->VertexAttribI4ui(1, 2, 3, 4, 5);
2601 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2604 TEST_F(GLES2ImplementationTest, VertexAttribI4uiv) {
2605 GLuint data[4] = {0};
2606 struct Cmds {
2607 cmds::VertexAttribI4uivImmediate cmd;
2608 GLuint data[4];
2611 for (int jj = 0; jj < 4; ++jj) {
2612 data[jj] = static_cast<GLuint>(jj);
2614 Cmds expected;
2615 expected.cmd.Init(1, &data[0]);
2616 gl_->VertexAttribI4uiv(1, &data[0]);
2617 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2620 TEST_F(GLES2ImplementationTest, Viewport) {
2621 struct Cmds {
2622 cmds::Viewport cmd;
2624 Cmds expected;
2625 expected.cmd.Init(1, 2, 3, 4);
2627 gl_->Viewport(1, 2, 3, 4);
2628 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2631 TEST_F(GLES2ImplementationTest, BlitFramebufferCHROMIUM) {
2632 struct Cmds {
2633 cmds::BlitFramebufferCHROMIUM cmd;
2635 Cmds expected;
2636 expected.cmd.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
2638 gl_->BlitFramebufferCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
2639 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2642 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleCHROMIUM) {
2643 struct Cmds {
2644 cmds::RenderbufferStorageMultisampleCHROMIUM cmd;
2646 Cmds expected;
2647 expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2649 gl_->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, 2, GL_RGBA4, 4,
2651 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2654 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleEXT) {
2655 struct Cmds {
2656 cmds::RenderbufferStorageMultisampleEXT cmd;
2658 Cmds expected;
2659 expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2661 gl_->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2662 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2665 TEST_F(GLES2ImplementationTest, FramebufferTexture2DMultisampleEXT) {
2666 struct Cmds {
2667 cmds::FramebufferTexture2DMultisampleEXT cmd;
2669 Cmds expected;
2670 expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4, 6);
2672 gl_->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2673 GL_TEXTURE_2D, 4, 0, 6);
2674 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2677 TEST_F(GLES2ImplementationTest,
2678 FramebufferTexture2DMultisampleEXTInvalidConstantArg4) {
2679 gl_->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2680 GL_TEXTURE_2D, 4, 1, 6);
2681 EXPECT_TRUE(NoCommandsWritten());
2682 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2685 TEST_F(GLES2ImplementationTest, TexStorage2DEXT) {
2686 struct Cmds {
2687 cmds::TexStorage2DEXT cmd;
2689 Cmds expected;
2690 expected.cmd.Init(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
2692 gl_->TexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
2693 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2696 TEST_F(GLES2ImplementationTest, GenQueriesEXT) {
2697 GLuint ids[2] = {
2700 struct Cmds {
2701 cmds::GenQueriesEXTImmediate gen;
2702 GLuint data[2];
2704 Cmds expected;
2705 expected.gen.Init(arraysize(ids), &ids[0]);
2706 expected.data[0] = kQueriesStartId;
2707 expected.data[1] = kQueriesStartId + 1;
2708 gl_->GenQueriesEXT(arraysize(ids), &ids[0]);
2709 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2710 EXPECT_EQ(kQueriesStartId, ids[0]);
2711 EXPECT_EQ(kQueriesStartId + 1, ids[1]);
2714 TEST_F(GLES2ImplementationTest, DeleteQueriesEXT) {
2715 GLuint ids[2] = {kQueriesStartId, kQueriesStartId + 1};
2716 struct Cmds {
2717 cmds::DeleteQueriesEXTImmediate del;
2718 GLuint data[2];
2720 Cmds expected;
2721 expected.del.Init(arraysize(ids), &ids[0]);
2722 expected.data[0] = kQueriesStartId;
2723 expected.data[1] = kQueriesStartId + 1;
2724 gl_->DeleteQueriesEXT(arraysize(ids), &ids[0]);
2725 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2727 // TODO(zmo): Implement unit test for QueryCounterEXT
2728 // TODO(zmo): Implement unit test for BeginQueryEXT
2730 TEST_F(GLES2ImplementationTest, BeginTransformFeedback) {
2731 struct Cmds {
2732 cmds::BeginTransformFeedback cmd;
2734 Cmds expected;
2735 expected.cmd.Init(GL_POINTS);
2737 gl_->BeginTransformFeedback(GL_POINTS);
2738 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2741 TEST_F(GLES2ImplementationTest, EndTransformFeedback) {
2742 struct Cmds {
2743 cmds::EndTransformFeedback cmd;
2745 Cmds expected;
2746 expected.cmd.Init();
2748 gl_->EndTransformFeedback();
2749 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2751 // TODO(zmo): Implement unit test for InsertEventMarkerEXT
2752 // TODO(zmo): Implement unit test for PushGroupMarkerEXT
2754 TEST_F(GLES2ImplementationTest, PopGroupMarkerEXT) {
2755 struct Cmds {
2756 cmds::PopGroupMarkerEXT cmd;
2758 Cmds expected;
2759 expected.cmd.Init();
2761 gl_->PopGroupMarkerEXT();
2762 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2765 TEST_F(GLES2ImplementationTest, GenVertexArraysOES) {
2766 GLuint ids[2] = {
2769 struct Cmds {
2770 cmds::GenVertexArraysOESImmediate gen;
2771 GLuint data[2];
2773 Cmds expected;
2774 expected.gen.Init(arraysize(ids), &ids[0]);
2775 expected.data[0] = kVertexArraysStartId;
2776 expected.data[1] = kVertexArraysStartId + 1;
2777 gl_->GenVertexArraysOES(arraysize(ids), &ids[0]);
2778 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2779 EXPECT_EQ(kVertexArraysStartId, ids[0]);
2780 EXPECT_EQ(kVertexArraysStartId + 1, ids[1]);
2783 TEST_F(GLES2ImplementationTest, DeleteVertexArraysOES) {
2784 GLuint ids[2] = {kVertexArraysStartId, kVertexArraysStartId + 1};
2785 struct Cmds {
2786 cmds::DeleteVertexArraysOESImmediate del;
2787 GLuint data[2];
2789 Cmds expected;
2790 expected.del.Init(arraysize(ids), &ids[0]);
2791 expected.data[0] = kVertexArraysStartId;
2792 expected.data[1] = kVertexArraysStartId + 1;
2793 gl_->DeleteVertexArraysOES(arraysize(ids), &ids[0]);
2794 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2797 TEST_F(GLES2ImplementationTest, IsVertexArrayOES) {
2798 struct Cmds {
2799 cmds::IsVertexArrayOES cmd;
2802 Cmds expected;
2803 ExpectedMemoryInfo result1 =
2804 GetExpectedResultMemory(sizeof(cmds::IsVertexArrayOES::Result));
2805 expected.cmd.Init(1, result1.id, result1.offset);
2807 EXPECT_CALL(*command_buffer(), OnFlush())
2808 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
2809 .RetiresOnSaturation();
2811 GLboolean result = gl_->IsVertexArrayOES(1);
2812 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2813 EXPECT_TRUE(result);
2815 // TODO(zmo): Implement unit test for EnableFeatureCHROMIUM
2816 // TODO(zmo): Implement unit test for MapBufferRange
2817 // TODO(zmo): Implement unit test for UnmapBuffer
2819 TEST_F(GLES2ImplementationTest, ResizeCHROMIUM) {
2820 struct Cmds {
2821 cmds::ResizeCHROMIUM cmd;
2823 Cmds expected;
2824 expected.cmd.Init(1, 2, 3);
2826 gl_->ResizeCHROMIUM(1, 2, 3);
2827 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2829 // TODO(zmo): Implement unit test for GetRequestableExtensionsCHROMIUM
2830 // TODO(zmo): Implement unit test for CreateStreamTextureCHROMIUM
2831 // TODO(zmo): Implement unit test for GetTranslatedShaderSourceANGLE
2833 TEST_F(GLES2ImplementationTest, TexImageIOSurface2DCHROMIUM) {
2834 struct Cmds {
2835 cmds::TexImageIOSurface2DCHROMIUM cmd;
2837 Cmds expected;
2838 expected.cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5);
2840 gl_->TexImageIOSurface2DCHROMIUM(GL_TEXTURE_2D, 2, 3, 4, 5);
2841 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2844 TEST_F(GLES2ImplementationTest, CopyTextureCHROMIUM) {
2845 struct Cmds {
2846 cmds::CopyTextureCHROMIUM cmd;
2848 Cmds expected;
2849 expected.cmd.Init(1, 2, 3, GL_ALPHA, GL_UNSIGNED_BYTE, true, true, true);
2851 gl_->CopyTextureCHROMIUM(1, 2, 3, GL_ALPHA, GL_UNSIGNED_BYTE, true, true,
2852 true);
2853 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2856 TEST_F(GLES2ImplementationTest, CopySubTextureCHROMIUM) {
2857 struct Cmds {
2858 cmds::CopySubTextureCHROMIUM cmd;
2860 Cmds expected;
2861 expected.cmd.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, true, true, true);
2863 gl_->CopySubTextureCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, true, true, true);
2864 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2867 TEST_F(GLES2ImplementationTest, CompressedCopyTextureCHROMIUM) {
2868 struct Cmds {
2869 cmds::CompressedCopyTextureCHROMIUM cmd;
2871 Cmds expected;
2872 expected.cmd.Init(1, 2, 3);
2874 gl_->CompressedCopyTextureCHROMIUM(1, 2, 3);
2875 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2878 TEST_F(GLES2ImplementationTest, DrawArraysInstancedANGLE) {
2879 struct Cmds {
2880 cmds::DrawArraysInstancedANGLE cmd;
2882 Cmds expected;
2883 expected.cmd.Init(GL_POINTS, 2, 3, 4);
2885 gl_->DrawArraysInstancedANGLE(GL_POINTS, 2, 3, 4);
2886 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2889 TEST_F(GLES2ImplementationTest, VertexAttribDivisorANGLE) {
2890 struct Cmds {
2891 cmds::VertexAttribDivisorANGLE cmd;
2893 Cmds expected;
2894 expected.cmd.Init(1, 2);
2896 gl_->VertexAttribDivisorANGLE(1, 2);
2897 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2899 // TODO(zmo): Implement unit test for GenMailboxCHROMIUM
2900 // TODO(zmo): Implement unit test for BindUniformLocationCHROMIUM
2902 TEST_F(GLES2ImplementationTest, GenValuebuffersCHROMIUM) {
2903 GLuint ids[2] = {
2906 struct Cmds {
2907 cmds::GenValuebuffersCHROMIUMImmediate gen;
2908 GLuint data[2];
2910 Cmds expected;
2911 expected.gen.Init(arraysize(ids), &ids[0]);
2912 expected.data[0] = kValuebuffersStartId;
2913 expected.data[1] = kValuebuffersStartId + 1;
2914 gl_->GenValuebuffersCHROMIUM(arraysize(ids), &ids[0]);
2915 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2916 EXPECT_EQ(kValuebuffersStartId, ids[0]);
2917 EXPECT_EQ(kValuebuffersStartId + 1, ids[1]);
2920 TEST_F(GLES2ImplementationTest, DeleteValuebuffersCHROMIUM) {
2921 GLuint ids[2] = {kValuebuffersStartId, kValuebuffersStartId + 1};
2922 struct Cmds {
2923 cmds::DeleteValuebuffersCHROMIUMImmediate del;
2924 GLuint data[2];
2926 Cmds expected;
2927 expected.del.Init(arraysize(ids), &ids[0]);
2928 expected.data[0] = kValuebuffersStartId;
2929 expected.data[1] = kValuebuffersStartId + 1;
2930 gl_->DeleteValuebuffersCHROMIUM(arraysize(ids), &ids[0]);
2931 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2934 TEST_F(GLES2ImplementationTest, IsValuebufferCHROMIUM) {
2935 struct Cmds {
2936 cmds::IsValuebufferCHROMIUM cmd;
2939 Cmds expected;
2940 ExpectedMemoryInfo result1 =
2941 GetExpectedResultMemory(sizeof(cmds::IsValuebufferCHROMIUM::Result));
2942 expected.cmd.Init(1, result1.id, result1.offset);
2944 EXPECT_CALL(*command_buffer(), OnFlush())
2945 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
2946 .RetiresOnSaturation();
2948 GLboolean result = gl_->IsValuebufferCHROMIUM(1);
2949 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2950 EXPECT_TRUE(result);
2953 TEST_F(GLES2ImplementationTest, BindValuebufferCHROMIUM) {
2954 struct Cmds {
2955 cmds::BindValuebufferCHROMIUM cmd;
2957 Cmds expected;
2958 expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
2960 gl_->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
2961 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2962 ClearCommands();
2963 gl_->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
2964 EXPECT_TRUE(NoCommandsWritten());
2967 TEST_F(GLES2ImplementationTest, SubscribeValueCHROMIUM) {
2968 struct Cmds {
2969 cmds::SubscribeValueCHROMIUM cmd;
2971 Cmds expected;
2972 expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
2973 GL_MOUSE_POSITION_CHROMIUM);
2975 gl_->SubscribeValueCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
2976 GL_MOUSE_POSITION_CHROMIUM);
2977 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2980 TEST_F(GLES2ImplementationTest, PopulateSubscribedValuesCHROMIUM) {
2981 struct Cmds {
2982 cmds::PopulateSubscribedValuesCHROMIUM cmd;
2984 Cmds expected;
2985 expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM);
2987 gl_->PopulateSubscribedValuesCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM);
2988 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2991 TEST_F(GLES2ImplementationTest, UniformValuebufferCHROMIUM) {
2992 struct Cmds {
2993 cmds::UniformValuebufferCHROMIUM cmd;
2995 Cmds expected;
2996 expected.cmd.Init(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
2997 GL_MOUSE_POSITION_CHROMIUM);
2999 gl_->UniformValuebufferCHROMIUM(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
3000 GL_MOUSE_POSITION_CHROMIUM);
3001 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3004 TEST_F(GLES2ImplementationTest, BindTexImage2DCHROMIUM) {
3005 struct Cmds {
3006 cmds::BindTexImage2DCHROMIUM cmd;
3008 Cmds expected;
3009 expected.cmd.Init(GL_TEXTURE_2D, 2);
3011 gl_->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
3012 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3015 TEST_F(GLES2ImplementationTest, ReleaseTexImage2DCHROMIUM) {
3016 struct Cmds {
3017 cmds::ReleaseTexImage2DCHROMIUM cmd;
3019 Cmds expected;
3020 expected.cmd.Init(GL_TEXTURE_2D, 2);
3022 gl_->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
3023 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3026 TEST_F(GLES2ImplementationTest, DiscardFramebufferEXT) {
3027 GLenum data[2][1] = {{0}};
3028 struct Cmds {
3029 cmds::DiscardFramebufferEXTImmediate cmd;
3030 GLenum data[2][1];
3033 Cmds expected;
3034 for (int ii = 0; ii < 2; ++ii) {
3035 for (int jj = 0; jj < 1; ++jj) {
3036 data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
3039 expected.cmd.Init(1, 2, &data[0][0]);
3040 gl_->DiscardFramebufferEXT(1, 2, &data[0][0]);
3041 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3044 TEST_F(GLES2ImplementationTest, LoseContextCHROMIUM) {
3045 struct Cmds {
3046 cmds::LoseContextCHROMIUM cmd;
3048 Cmds expected;
3049 expected.cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_GUILTY_CONTEXT_RESET_ARB);
3051 gl_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
3052 GL_GUILTY_CONTEXT_RESET_ARB);
3053 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3055 // TODO(zmo): Implement unit test for InsertSyncPointCHROMIUM
3057 TEST_F(GLES2ImplementationTest, WaitSyncPointCHROMIUM) {
3058 struct Cmds {
3059 cmds::WaitSyncPointCHROMIUM cmd;
3061 Cmds expected;
3062 expected.cmd.Init(1);
3064 gl_->WaitSyncPointCHROMIUM(1);
3065 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3068 TEST_F(GLES2ImplementationTest, DrawBuffersEXT) {
3069 GLenum data[1][1] = {{0}};
3070 struct Cmds {
3071 cmds::DrawBuffersEXTImmediate cmd;
3072 GLenum data[1][1];
3075 Cmds expected;
3076 for (int ii = 0; ii < 1; ++ii) {
3077 for (int jj = 0; jj < 1; ++jj) {
3078 data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
3081 expected.cmd.Init(1, &data[0][0]);
3082 gl_->DrawBuffersEXT(1, &data[0][0]);
3083 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3086 TEST_F(GLES2ImplementationTest, DiscardBackbufferCHROMIUM) {
3087 struct Cmds {
3088 cmds::DiscardBackbufferCHROMIUM cmd;
3090 Cmds expected;
3091 expected.cmd.Init();
3093 gl_->DiscardBackbufferCHROMIUM();
3094 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3097 TEST_F(GLES2ImplementationTest, FlushDriverCachesCHROMIUM) {
3098 struct Cmds {
3099 cmds::FlushDriverCachesCHROMIUM cmd;
3101 Cmds expected;
3102 expected.cmd.Init();
3104 gl_->FlushDriverCachesCHROMIUM();
3105 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3108 TEST_F(GLES2ImplementationTest, MatrixLoadfCHROMIUM) {
3109 GLfloat data[16] = {0};
3110 struct Cmds {
3111 cmds::MatrixLoadfCHROMIUMImmediate cmd;
3112 GLfloat data[16];
3115 for (int jj = 0; jj < 16; ++jj) {
3116 data[jj] = static_cast<GLfloat>(jj);
3118 Cmds expected;
3119 expected.cmd.Init(GL_PATH_PROJECTION_CHROMIUM, &data[0]);
3120 gl_->MatrixLoadfCHROMIUM(GL_PATH_PROJECTION_CHROMIUM, &data[0]);
3121 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3124 TEST_F(GLES2ImplementationTest, MatrixLoadIdentityCHROMIUM) {
3125 struct Cmds {
3126 cmds::MatrixLoadIdentityCHROMIUM cmd;
3128 Cmds expected;
3129 expected.cmd.Init(GL_PATH_PROJECTION_CHROMIUM);
3131 gl_->MatrixLoadIdentityCHROMIUM(GL_PATH_PROJECTION_CHROMIUM);
3132 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3134 // TODO(zmo): Implement unit test for GenPathsCHROMIUM
3136 TEST_F(GLES2ImplementationTest, DeletePathsCHROMIUM) {
3137 struct Cmds {
3138 cmds::DeletePathsCHROMIUM cmd;
3140 Cmds expected;
3141 expected.cmd.Init(1, 2);
3143 gl_->DeletePathsCHROMIUM(1, 2);
3144 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3147 TEST_F(GLES2ImplementationTest, IsPathCHROMIUM) {
3148 struct Cmds {
3149 cmds::IsPathCHROMIUM cmd;
3152 Cmds expected;
3153 ExpectedMemoryInfo result1 =
3154 GetExpectedResultMemory(sizeof(cmds::IsPathCHROMIUM::Result));
3155 expected.cmd.Init(1, result1.id, result1.offset);
3157 EXPECT_CALL(*command_buffer(), OnFlush())
3158 .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
3159 .RetiresOnSaturation();
3161 GLboolean result = gl_->IsPathCHROMIUM(1);
3162 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3163 EXPECT_TRUE(result);
3165 // TODO(zmo): Implement unit test for PathCommandsCHROMIUM
3167 TEST_F(GLES2ImplementationTest, PathParameterfCHROMIUM) {
3168 struct Cmds {
3169 cmds::PathParameterfCHROMIUM cmd;
3171 Cmds expected;
3172 expected.cmd.Init(1, GL_PATH_STROKE_WIDTH_CHROMIUM, 3);
3174 gl_->PathParameterfCHROMIUM(1, GL_PATH_STROKE_WIDTH_CHROMIUM, 3);
3175 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3178 TEST_F(GLES2ImplementationTest, PathParameteriCHROMIUM) {
3179 struct Cmds {
3180 cmds::PathParameteriCHROMIUM cmd;
3182 Cmds expected;
3183 expected.cmd.Init(1, GL_PATH_STROKE_WIDTH_CHROMIUM, 3);
3185 gl_->PathParameteriCHROMIUM(1, GL_PATH_STROKE_WIDTH_CHROMIUM, 3);
3186 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3189 TEST_F(GLES2ImplementationTest, PathStencilFuncCHROMIUM) {
3190 struct Cmds {
3191 cmds::PathStencilFuncCHROMIUM cmd;
3193 Cmds expected;
3194 expected.cmd.Init(GL_NEVER, 2, 3);
3196 gl_->PathStencilFuncCHROMIUM(GL_NEVER, 2, 3);
3197 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3200 TEST_F(GLES2ImplementationTest, StencilFillPathCHROMIUM) {
3201 struct Cmds {
3202 cmds::StencilFillPathCHROMIUM cmd;
3204 Cmds expected;
3205 expected.cmd.Init(1, GL_INVERT, 3);
3207 gl_->StencilFillPathCHROMIUM(1, GL_INVERT, 3);
3208 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3211 TEST_F(GLES2ImplementationTest, StencilStrokePathCHROMIUM) {
3212 struct Cmds {
3213 cmds::StencilStrokePathCHROMIUM cmd;
3215 Cmds expected;
3216 expected.cmd.Init(1, 2, 3);
3218 gl_->StencilStrokePathCHROMIUM(1, 2, 3);
3219 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3222 TEST_F(GLES2ImplementationTest, CoverFillPathCHROMIUM) {
3223 struct Cmds {
3224 cmds::CoverFillPathCHROMIUM cmd;
3226 Cmds expected;
3227 expected.cmd.Init(1, GL_CONVEX_HULL_CHROMIUM);
3229 gl_->CoverFillPathCHROMIUM(1, GL_CONVEX_HULL_CHROMIUM);
3230 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3233 TEST_F(GLES2ImplementationTest, CoverStrokePathCHROMIUM) {
3234 struct Cmds {
3235 cmds::CoverStrokePathCHROMIUM cmd;
3237 Cmds expected;
3238 expected.cmd.Init(1, GL_CONVEX_HULL_CHROMIUM);
3240 gl_->CoverStrokePathCHROMIUM(1, GL_CONVEX_HULL_CHROMIUM);
3241 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3244 TEST_F(GLES2ImplementationTest, StencilThenCoverFillPathCHROMIUM) {
3245 struct Cmds {
3246 cmds::StencilThenCoverFillPathCHROMIUM cmd;
3248 Cmds expected;
3249 expected.cmd.Init(1, GL_INVERT, 3, GL_CONVEX_HULL_CHROMIUM);
3251 gl_->StencilThenCoverFillPathCHROMIUM(1, GL_INVERT, 3,
3252 GL_CONVEX_HULL_CHROMIUM);
3253 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3256 TEST_F(GLES2ImplementationTest, StencilThenCoverStrokePathCHROMIUM) {
3257 struct Cmds {
3258 cmds::StencilThenCoverStrokePathCHROMIUM cmd;
3260 Cmds expected;
3261 expected.cmd.Init(1, 2, 3, GL_CONVEX_HULL_CHROMIUM);
3263 gl_->StencilThenCoverStrokePathCHROMIUM(1, 2, 3, GL_CONVEX_HULL_CHROMIUM);
3264 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3266 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_