Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / gpu / command_buffer / client / gles2_implementation_unittest_autogen.h
blob74a438c0f6b57e08220c442caf6b06af947c8e9d
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: 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, BindFramebuffer) {
43 struct Cmds {
44 cmds::BindFramebuffer cmd;
46 Cmds expected;
47 expected.cmd.Init(GL_FRAMEBUFFER, 2);
49 gl_->BindFramebuffer(GL_FRAMEBUFFER, 2);
50 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
51 ClearCommands();
52 gl_->BindFramebuffer(GL_FRAMEBUFFER, 2);
53 EXPECT_TRUE(NoCommandsWritten());
56 TEST_F(GLES2ImplementationTest, BindRenderbuffer) {
57 struct Cmds {
58 cmds::BindRenderbuffer cmd;
60 Cmds expected;
61 expected.cmd.Init(GL_RENDERBUFFER, 2);
63 gl_->BindRenderbuffer(GL_RENDERBUFFER, 2);
64 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
65 ClearCommands();
66 gl_->BindRenderbuffer(GL_RENDERBUFFER, 2);
67 EXPECT_TRUE(NoCommandsWritten());
70 TEST_F(GLES2ImplementationTest, BlendColor) {
71 struct Cmds {
72 cmds::BlendColor cmd;
74 Cmds expected;
75 expected.cmd.Init(1, 2, 3, 4);
77 gl_->BlendColor(1, 2, 3, 4);
78 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
81 TEST_F(GLES2ImplementationTest, BlendEquation) {
82 struct Cmds {
83 cmds::BlendEquation cmd;
85 Cmds expected;
86 expected.cmd.Init(GL_FUNC_SUBTRACT);
88 gl_->BlendEquation(GL_FUNC_SUBTRACT);
89 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
92 TEST_F(GLES2ImplementationTest, BlendEquationSeparate) {
93 struct Cmds {
94 cmds::BlendEquationSeparate cmd;
96 Cmds expected;
97 expected.cmd.Init(GL_FUNC_SUBTRACT, GL_FUNC_ADD);
99 gl_->BlendEquationSeparate(GL_FUNC_SUBTRACT, GL_FUNC_ADD);
100 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
103 TEST_F(GLES2ImplementationTest, BlendFunc) {
104 struct Cmds {
105 cmds::BlendFunc cmd;
107 Cmds expected;
108 expected.cmd.Init(GL_ZERO, GL_ZERO);
110 gl_->BlendFunc(GL_ZERO, GL_ZERO);
111 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
114 TEST_F(GLES2ImplementationTest, BlendFuncSeparate) {
115 struct Cmds {
116 cmds::BlendFuncSeparate cmd;
118 Cmds expected;
119 expected.cmd.Init(GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO);
121 gl_->BlendFuncSeparate(GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO);
122 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
125 TEST_F(GLES2ImplementationTest, CheckFramebufferStatus) {
126 struct Cmds {
127 cmds::CheckFramebufferStatus cmd;
130 Cmds expected;
131 ExpectedMemoryInfo result1 =
132 GetExpectedResultMemory(sizeof(cmds::CheckFramebufferStatus::Result));
133 expected.cmd.Init(1, result1.id, result1.offset);
135 EXPECT_CALL(*command_buffer(), OnFlush())
136 .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
137 .RetiresOnSaturation();
139 GLboolean result = gl_->CheckFramebufferStatus(1);
140 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
141 EXPECT_TRUE(result);
144 TEST_F(GLES2ImplementationTest, Clear) {
145 struct Cmds {
146 cmds::Clear cmd;
148 Cmds expected;
149 expected.cmd.Init(1);
151 gl_->Clear(1);
152 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
155 TEST_F(GLES2ImplementationTest, ClearColor) {
156 struct Cmds {
157 cmds::ClearColor cmd;
159 Cmds expected;
160 expected.cmd.Init(1, 2, 3, 4);
162 gl_->ClearColor(1, 2, 3, 4);
163 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
166 TEST_F(GLES2ImplementationTest, ClearDepthf) {
167 struct Cmds {
168 cmds::ClearDepthf cmd;
170 Cmds expected;
171 expected.cmd.Init(0.5f);
173 gl_->ClearDepthf(0.5f);
174 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
177 TEST_F(GLES2ImplementationTest, ClearStencil) {
178 struct Cmds {
179 cmds::ClearStencil cmd;
181 Cmds expected;
182 expected.cmd.Init(1);
184 gl_->ClearStencil(1);
185 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
188 TEST_F(GLES2ImplementationTest, ColorMask) {
189 struct Cmds {
190 cmds::ColorMask cmd;
192 Cmds expected;
193 expected.cmd.Init(true, true, true, true);
195 gl_->ColorMask(true, true, true, true);
196 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
199 TEST_F(GLES2ImplementationTest, CompileShader) {
200 struct Cmds {
201 cmds::CompileShader cmd;
203 Cmds expected;
204 expected.cmd.Init(1);
206 gl_->CompileShader(1);
207 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
209 // TODO: Implement unit test for CompressedTexImage2D
210 // TODO: Implement unit test for CompressedTexSubImage2D
212 TEST_F(GLES2ImplementationTest, CopyTexImage2D) {
213 struct Cmds {
214 cmds::CopyTexImage2D cmd;
216 Cmds expected;
217 expected.cmd.Init(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7);
219 gl_->CopyTexImage2D(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7, 0);
220 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
223 TEST_F(GLES2ImplementationTest, CopyTexImage2DInvalidConstantArg7) {
224 gl_->CopyTexImage2D(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7, 1);
225 EXPECT_TRUE(NoCommandsWritten());
226 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
229 TEST_F(GLES2ImplementationTest, CopyTexSubImage2D) {
230 struct Cmds {
231 cmds::CopyTexSubImage2D cmd;
233 Cmds expected;
234 expected.cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8);
236 gl_->CopyTexSubImage2D(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8);
237 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
240 TEST_F(GLES2ImplementationTest, CullFace) {
241 struct Cmds {
242 cmds::CullFace cmd;
244 Cmds expected;
245 expected.cmd.Init(GL_FRONT);
247 gl_->CullFace(GL_FRONT);
248 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
251 TEST_F(GLES2ImplementationTest, DeleteBuffers) {
252 GLuint ids[2] = {kBuffersStartId, kBuffersStartId + 1};
253 struct Cmds {
254 cmds::DeleteBuffersImmediate del;
255 GLuint data[2];
257 Cmds expected;
258 expected.del.Init(arraysize(ids), &ids[0]);
259 expected.data[0] = kBuffersStartId;
260 expected.data[1] = kBuffersStartId + 1;
261 gl_->DeleteBuffers(arraysize(ids), &ids[0]);
262 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
265 TEST_F(GLES2ImplementationTest, DeleteFramebuffers) {
266 GLuint ids[2] = {kFramebuffersStartId, kFramebuffersStartId + 1};
267 struct Cmds {
268 cmds::DeleteFramebuffersImmediate del;
269 GLuint data[2];
271 Cmds expected;
272 expected.del.Init(arraysize(ids), &ids[0]);
273 expected.data[0] = kFramebuffersStartId;
274 expected.data[1] = kFramebuffersStartId + 1;
275 gl_->DeleteFramebuffers(arraysize(ids), &ids[0]);
276 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
279 TEST_F(GLES2ImplementationTest, DeleteProgram) {
280 struct Cmds {
281 cmds::DeleteProgram cmd;
283 Cmds expected;
284 expected.cmd.Init(1);
286 gl_->DeleteProgram(1);
287 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
290 TEST_F(GLES2ImplementationTest, DeleteRenderbuffers) {
291 GLuint ids[2] = {kRenderbuffersStartId, kRenderbuffersStartId + 1};
292 struct Cmds {
293 cmds::DeleteRenderbuffersImmediate del;
294 GLuint data[2];
296 Cmds expected;
297 expected.del.Init(arraysize(ids), &ids[0]);
298 expected.data[0] = kRenderbuffersStartId;
299 expected.data[1] = kRenderbuffersStartId + 1;
300 gl_->DeleteRenderbuffers(arraysize(ids), &ids[0]);
301 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
304 TEST_F(GLES2ImplementationTest, DeleteShader) {
305 struct Cmds {
306 cmds::DeleteShader cmd;
308 Cmds expected;
309 expected.cmd.Init(1);
311 gl_->DeleteShader(1);
312 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
315 TEST_F(GLES2ImplementationTest, DeleteTextures) {
316 GLuint ids[2] = {kTexturesStartId, kTexturesStartId + 1};
317 struct Cmds {
318 cmds::DeleteTexturesImmediate del;
319 GLuint data[2];
321 Cmds expected;
322 expected.del.Init(arraysize(ids), &ids[0]);
323 expected.data[0] = kTexturesStartId;
324 expected.data[1] = kTexturesStartId + 1;
325 gl_->DeleteTextures(arraysize(ids), &ids[0]);
326 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
329 TEST_F(GLES2ImplementationTest, DepthFunc) {
330 struct Cmds {
331 cmds::DepthFunc cmd;
333 Cmds expected;
334 expected.cmd.Init(GL_NEVER);
336 gl_->DepthFunc(GL_NEVER);
337 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
340 TEST_F(GLES2ImplementationTest, DepthMask) {
341 struct Cmds {
342 cmds::DepthMask cmd;
344 Cmds expected;
345 expected.cmd.Init(true);
347 gl_->DepthMask(true);
348 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
351 TEST_F(GLES2ImplementationTest, DepthRangef) {
352 struct Cmds {
353 cmds::DepthRangef cmd;
355 Cmds expected;
356 expected.cmd.Init(1, 2);
358 gl_->DepthRangef(1, 2);
359 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
362 TEST_F(GLES2ImplementationTest, DetachShader) {
363 struct Cmds {
364 cmds::DetachShader cmd;
366 Cmds expected;
367 expected.cmd.Init(1, 2);
369 gl_->DetachShader(1, 2);
370 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
373 TEST_F(GLES2ImplementationTest, DisableVertexAttribArray) {
374 struct Cmds {
375 cmds::DisableVertexAttribArray cmd;
377 Cmds expected;
378 expected.cmd.Init(1);
380 gl_->DisableVertexAttribArray(1);
381 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
384 TEST_F(GLES2ImplementationTest, DrawArrays) {
385 struct Cmds {
386 cmds::DrawArrays cmd;
388 Cmds expected;
389 expected.cmd.Init(GL_POINTS, 2, 3);
391 gl_->DrawArrays(GL_POINTS, 2, 3);
392 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
395 TEST_F(GLES2ImplementationTest, EnableVertexAttribArray) {
396 struct Cmds {
397 cmds::EnableVertexAttribArray cmd;
399 Cmds expected;
400 expected.cmd.Init(1);
402 gl_->EnableVertexAttribArray(1);
403 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
406 TEST_F(GLES2ImplementationTest, Flush) {
407 struct Cmds {
408 cmds::Flush cmd;
410 Cmds expected;
411 expected.cmd.Init();
413 gl_->Flush();
414 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
417 TEST_F(GLES2ImplementationTest, FramebufferRenderbuffer) {
418 struct Cmds {
419 cmds::FramebufferRenderbuffer cmd;
421 Cmds expected;
422 expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 4);
424 gl_->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
425 GL_RENDERBUFFER, 4);
426 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
429 TEST_F(GLES2ImplementationTest, FramebufferTexture2D) {
430 struct Cmds {
431 cmds::FramebufferTexture2D cmd;
433 Cmds expected;
434 expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4);
436 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
437 4, 0);
438 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
441 TEST_F(GLES2ImplementationTest, FramebufferTexture2DInvalidConstantArg4) {
442 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
443 4, 1);
444 EXPECT_TRUE(NoCommandsWritten());
445 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
448 TEST_F(GLES2ImplementationTest, FrontFace) {
449 struct Cmds {
450 cmds::FrontFace cmd;
452 Cmds expected;
453 expected.cmd.Init(GL_CW);
455 gl_->FrontFace(GL_CW);
456 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
459 TEST_F(GLES2ImplementationTest, GenBuffers) {
460 GLuint ids[2] = {
463 struct Cmds {
464 cmds::GenBuffersImmediate gen;
465 GLuint data[2];
467 Cmds expected;
468 expected.gen.Init(arraysize(ids), &ids[0]);
469 expected.data[0] = kBuffersStartId;
470 expected.data[1] = kBuffersStartId + 1;
471 gl_->GenBuffers(arraysize(ids), &ids[0]);
472 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
473 EXPECT_EQ(kBuffersStartId, ids[0]);
474 EXPECT_EQ(kBuffersStartId + 1, ids[1]);
477 TEST_F(GLES2ImplementationTest, GenerateMipmap) {
478 struct Cmds {
479 cmds::GenerateMipmap cmd;
481 Cmds expected;
482 expected.cmd.Init(GL_TEXTURE_2D);
484 gl_->GenerateMipmap(GL_TEXTURE_2D);
485 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
488 TEST_F(GLES2ImplementationTest, GenFramebuffers) {
489 GLuint ids[2] = {
492 struct Cmds {
493 cmds::GenFramebuffersImmediate gen;
494 GLuint data[2];
496 Cmds expected;
497 expected.gen.Init(arraysize(ids), &ids[0]);
498 expected.data[0] = kFramebuffersStartId;
499 expected.data[1] = kFramebuffersStartId + 1;
500 gl_->GenFramebuffers(arraysize(ids), &ids[0]);
501 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
502 EXPECT_EQ(kFramebuffersStartId, ids[0]);
503 EXPECT_EQ(kFramebuffersStartId + 1, ids[1]);
506 TEST_F(GLES2ImplementationTest, GenRenderbuffers) {
507 GLuint ids[2] = {
510 struct Cmds {
511 cmds::GenRenderbuffersImmediate gen;
512 GLuint data[2];
514 Cmds expected;
515 expected.gen.Init(arraysize(ids), &ids[0]);
516 expected.data[0] = kRenderbuffersStartId;
517 expected.data[1] = kRenderbuffersStartId + 1;
518 gl_->GenRenderbuffers(arraysize(ids), &ids[0]);
519 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
520 EXPECT_EQ(kRenderbuffersStartId, ids[0]);
521 EXPECT_EQ(kRenderbuffersStartId + 1, ids[1]);
524 TEST_F(GLES2ImplementationTest, GenTextures) {
525 GLuint ids[2] = {
528 struct Cmds {
529 cmds::GenTexturesImmediate gen;
530 GLuint data[2];
532 Cmds expected;
533 expected.gen.Init(arraysize(ids), &ids[0]);
534 expected.data[0] = kTexturesStartId;
535 expected.data[1] = kTexturesStartId + 1;
536 gl_->GenTextures(arraysize(ids), &ids[0]);
537 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
538 EXPECT_EQ(kTexturesStartId, ids[0]);
539 EXPECT_EQ(kTexturesStartId + 1, ids[1]);
541 // TODO: Implement unit test for GetActiveAttrib
542 // TODO: Implement unit test for GetActiveUniform
543 // TODO: Implement unit test for GetAttachedShaders
544 // TODO: Implement unit test for GetAttribLocation
546 TEST_F(GLES2ImplementationTest, GetBooleanv) {
547 struct Cmds {
548 cmds::GetBooleanv cmd;
550 typedef cmds::GetBooleanv::Result Result;
551 Result::Type result = 0;
552 Cmds expected;
553 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
554 expected.cmd.Init(123, result1.id, result1.offset);
555 EXPECT_CALL(*command_buffer(), OnFlush())
556 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
557 .RetiresOnSaturation();
558 gl_->GetBooleanv(123, &result);
559 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
560 EXPECT_EQ(static_cast<Result::Type>(1), result);
563 TEST_F(GLES2ImplementationTest, GetBufferParameteriv) {
564 struct Cmds {
565 cmds::GetBufferParameteriv cmd;
567 typedef cmds::GetBufferParameteriv::Result Result;
568 Result::Type result = 0;
569 Cmds expected;
570 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
571 expected.cmd.Init(123, GL_BUFFER_SIZE, result1.id, result1.offset);
572 EXPECT_CALL(*command_buffer(), OnFlush())
573 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
574 .RetiresOnSaturation();
575 gl_->GetBufferParameteriv(123, GL_BUFFER_SIZE, &result);
576 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
577 EXPECT_EQ(static_cast<Result::Type>(1), result);
580 TEST_F(GLES2ImplementationTest, GetFloatv) {
581 struct Cmds {
582 cmds::GetFloatv cmd;
584 typedef cmds::GetFloatv::Result Result;
585 Result::Type result = 0;
586 Cmds expected;
587 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
588 expected.cmd.Init(123, result1.id, result1.offset);
589 EXPECT_CALL(*command_buffer(), OnFlush())
590 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
591 .RetiresOnSaturation();
592 gl_->GetFloatv(123, &result);
593 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
594 EXPECT_EQ(static_cast<Result::Type>(1), result);
597 TEST_F(GLES2ImplementationTest, GetFramebufferAttachmentParameteriv) {
598 struct Cmds {
599 cmds::GetFramebufferAttachmentParameteriv cmd;
601 typedef cmds::GetFramebufferAttachmentParameteriv::Result Result;
602 Result::Type result = 0;
603 Cmds expected;
604 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
605 expected.cmd.Init(123, GL_COLOR_ATTACHMENT0,
606 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, result1.id,
607 result1.offset);
608 EXPECT_CALL(*command_buffer(), OnFlush())
609 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
610 .RetiresOnSaturation();
611 gl_->GetFramebufferAttachmentParameteriv(
612 123, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
613 &result);
614 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
615 EXPECT_EQ(static_cast<Result::Type>(1), result);
618 TEST_F(GLES2ImplementationTest, GetIntegerv) {
619 struct Cmds {
620 cmds::GetIntegerv cmd;
622 typedef cmds::GetIntegerv::Result Result;
623 Result::Type result = 0;
624 Cmds expected;
625 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
626 expected.cmd.Init(123, result1.id, result1.offset);
627 EXPECT_CALL(*command_buffer(), OnFlush())
628 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
629 .RetiresOnSaturation();
630 gl_->GetIntegerv(123, &result);
631 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
632 EXPECT_EQ(static_cast<Result::Type>(1), result);
635 TEST_F(GLES2ImplementationTest, GetProgramiv) {
636 struct Cmds {
637 cmds::GetProgramiv cmd;
639 typedef cmds::GetProgramiv::Result Result;
640 Result::Type result = 0;
641 Cmds expected;
642 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
643 expected.cmd.Init(123, GL_DELETE_STATUS, result1.id, result1.offset);
644 EXPECT_CALL(*command_buffer(), OnFlush())
645 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
646 .RetiresOnSaturation();
647 gl_->GetProgramiv(123, GL_DELETE_STATUS, &result);
648 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
649 EXPECT_EQ(static_cast<Result::Type>(1), result);
651 // TODO: Implement unit test for GetProgramInfoLog
653 TEST_F(GLES2ImplementationTest, GetRenderbufferParameteriv) {
654 struct Cmds {
655 cmds::GetRenderbufferParameteriv cmd;
657 typedef cmds::GetRenderbufferParameteriv::Result Result;
658 Result::Type result = 0;
659 Cmds expected;
660 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
661 expected.cmd.Init(123, GL_RENDERBUFFER_RED_SIZE, result1.id, result1.offset);
662 EXPECT_CALL(*command_buffer(), OnFlush())
663 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
664 .RetiresOnSaturation();
665 gl_->GetRenderbufferParameteriv(123, GL_RENDERBUFFER_RED_SIZE, &result);
666 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
667 EXPECT_EQ(static_cast<Result::Type>(1), result);
670 TEST_F(GLES2ImplementationTest, GetShaderiv) {
671 struct Cmds {
672 cmds::GetShaderiv cmd;
674 typedef cmds::GetShaderiv::Result Result;
675 Result::Type result = 0;
676 Cmds expected;
677 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
678 expected.cmd.Init(123, GL_SHADER_TYPE, result1.id, result1.offset);
679 EXPECT_CALL(*command_buffer(), OnFlush())
680 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
681 .RetiresOnSaturation();
682 gl_->GetShaderiv(123, GL_SHADER_TYPE, &result);
683 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
684 EXPECT_EQ(static_cast<Result::Type>(1), result);
686 // TODO: Implement unit test for GetShaderInfoLog
687 // TODO: Implement unit test for GetShaderPrecisionFormat
689 TEST_F(GLES2ImplementationTest, GetTexParameterfv) {
690 struct Cmds {
691 cmds::GetTexParameterfv cmd;
693 typedef cmds::GetTexParameterfv::Result Result;
694 Result::Type result = 0;
695 Cmds expected;
696 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
697 expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
698 EXPECT_CALL(*command_buffer(), OnFlush())
699 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
700 .RetiresOnSaturation();
701 gl_->GetTexParameterfv(123, GL_TEXTURE_MAG_FILTER, &result);
702 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
703 EXPECT_EQ(static_cast<Result::Type>(1), result);
706 TEST_F(GLES2ImplementationTest, GetTexParameteriv) {
707 struct Cmds {
708 cmds::GetTexParameteriv cmd;
710 typedef cmds::GetTexParameteriv::Result Result;
711 Result::Type result = 0;
712 Cmds expected;
713 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
714 expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
715 EXPECT_CALL(*command_buffer(), OnFlush())
716 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
717 .RetiresOnSaturation();
718 gl_->GetTexParameteriv(123, GL_TEXTURE_MAG_FILTER, &result);
719 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
720 EXPECT_EQ(static_cast<Result::Type>(1), result);
722 // TODO: Implement unit test for GetUniformfv
723 // TODO: Implement unit test for GetUniformiv
724 // TODO: Implement unit test for GetUniformLocation
726 TEST_F(GLES2ImplementationTest, GetVertexAttribfv) {
727 struct Cmds {
728 cmds::GetVertexAttribfv cmd;
730 typedef cmds::GetVertexAttribfv::Result Result;
731 Result::Type result = 0;
732 Cmds expected;
733 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
734 expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
735 result1.offset);
736 EXPECT_CALL(*command_buffer(), OnFlush())
737 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
738 .RetiresOnSaturation();
739 gl_->GetVertexAttribfv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
740 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
741 EXPECT_EQ(static_cast<Result::Type>(1), result);
744 TEST_F(GLES2ImplementationTest, GetVertexAttribiv) {
745 struct Cmds {
746 cmds::GetVertexAttribiv cmd;
748 typedef cmds::GetVertexAttribiv::Result Result;
749 Result::Type result = 0;
750 Cmds expected;
751 ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
752 expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
753 result1.offset);
754 EXPECT_CALL(*command_buffer(), OnFlush())
755 .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
756 .RetiresOnSaturation();
757 gl_->GetVertexAttribiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
758 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
759 EXPECT_EQ(static_cast<Result::Type>(1), result);
762 TEST_F(GLES2ImplementationTest, Hint) {
763 struct Cmds {
764 cmds::Hint cmd;
766 Cmds expected;
767 expected.cmd.Init(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
769 gl_->Hint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
770 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
773 TEST_F(GLES2ImplementationTest, IsBuffer) {
774 struct Cmds {
775 cmds::IsBuffer cmd;
778 Cmds expected;
779 ExpectedMemoryInfo result1 =
780 GetExpectedResultMemory(sizeof(cmds::IsBuffer::Result));
781 expected.cmd.Init(1, result1.id, result1.offset);
783 EXPECT_CALL(*command_buffer(), OnFlush())
784 .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
785 .RetiresOnSaturation();
787 GLboolean result = gl_->IsBuffer(1);
788 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
789 EXPECT_TRUE(result);
792 TEST_F(GLES2ImplementationTest, IsEnabled) {
793 struct Cmds {
794 cmds::IsEnabled cmd;
797 Cmds expected;
798 ExpectedMemoryInfo result1 =
799 GetExpectedResultMemory(sizeof(cmds::IsEnabled::Result));
800 expected.cmd.Init(1, result1.id, result1.offset);
802 EXPECT_CALL(*command_buffer(), OnFlush())
803 .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
804 .RetiresOnSaturation();
806 GLboolean result = gl_->IsEnabled(1);
807 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
808 EXPECT_TRUE(result);
811 TEST_F(GLES2ImplementationTest, IsFramebuffer) {
812 struct Cmds {
813 cmds::IsFramebuffer cmd;
816 Cmds expected;
817 ExpectedMemoryInfo result1 =
818 GetExpectedResultMemory(sizeof(cmds::IsFramebuffer::Result));
819 expected.cmd.Init(1, result1.id, result1.offset);
821 EXPECT_CALL(*command_buffer(), OnFlush())
822 .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
823 .RetiresOnSaturation();
825 GLboolean result = gl_->IsFramebuffer(1);
826 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
827 EXPECT_TRUE(result);
830 TEST_F(GLES2ImplementationTest, IsProgram) {
831 struct Cmds {
832 cmds::IsProgram cmd;
835 Cmds expected;
836 ExpectedMemoryInfo result1 =
837 GetExpectedResultMemory(sizeof(cmds::IsProgram::Result));
838 expected.cmd.Init(1, result1.id, result1.offset);
840 EXPECT_CALL(*command_buffer(), OnFlush())
841 .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
842 .RetiresOnSaturation();
844 GLboolean result = gl_->IsProgram(1);
845 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
846 EXPECT_TRUE(result);
849 TEST_F(GLES2ImplementationTest, IsRenderbuffer) {
850 struct Cmds {
851 cmds::IsRenderbuffer cmd;
854 Cmds expected;
855 ExpectedMemoryInfo result1 =
856 GetExpectedResultMemory(sizeof(cmds::IsRenderbuffer::Result));
857 expected.cmd.Init(1, result1.id, result1.offset);
859 EXPECT_CALL(*command_buffer(), OnFlush())
860 .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
861 .RetiresOnSaturation();
863 GLboolean result = gl_->IsRenderbuffer(1);
864 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
865 EXPECT_TRUE(result);
868 TEST_F(GLES2ImplementationTest, IsShader) {
869 struct Cmds {
870 cmds::IsShader cmd;
873 Cmds expected;
874 ExpectedMemoryInfo result1 =
875 GetExpectedResultMemory(sizeof(cmds::IsShader::Result));
876 expected.cmd.Init(1, result1.id, result1.offset);
878 EXPECT_CALL(*command_buffer(), OnFlush())
879 .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
880 .RetiresOnSaturation();
882 GLboolean result = gl_->IsShader(1);
883 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
884 EXPECT_TRUE(result);
887 TEST_F(GLES2ImplementationTest, IsTexture) {
888 struct Cmds {
889 cmds::IsTexture cmd;
892 Cmds expected;
893 ExpectedMemoryInfo result1 =
894 GetExpectedResultMemory(sizeof(cmds::IsTexture::Result));
895 expected.cmd.Init(1, result1.id, result1.offset);
897 EXPECT_CALL(*command_buffer(), OnFlush())
898 .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
899 .RetiresOnSaturation();
901 GLboolean result = gl_->IsTexture(1);
902 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
903 EXPECT_TRUE(result);
906 TEST_F(GLES2ImplementationTest, LineWidth) {
907 struct Cmds {
908 cmds::LineWidth cmd;
910 Cmds expected;
911 expected.cmd.Init(0.5f);
913 gl_->LineWidth(0.5f);
914 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
917 TEST_F(GLES2ImplementationTest, LinkProgram) {
918 struct Cmds {
919 cmds::LinkProgram cmd;
921 Cmds expected;
922 expected.cmd.Init(1);
924 gl_->LinkProgram(1);
925 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
928 TEST_F(GLES2ImplementationTest, PixelStorei) {
929 struct Cmds {
930 cmds::PixelStorei cmd;
932 Cmds expected;
933 expected.cmd.Init(GL_PACK_ALIGNMENT, 1);
935 gl_->PixelStorei(GL_PACK_ALIGNMENT, 1);
936 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
939 TEST_F(GLES2ImplementationTest, PolygonOffset) {
940 struct Cmds {
941 cmds::PolygonOffset cmd;
943 Cmds expected;
944 expected.cmd.Init(1, 2);
946 gl_->PolygonOffset(1, 2);
947 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
950 TEST_F(GLES2ImplementationTest, ReleaseShaderCompiler) {
951 struct Cmds {
952 cmds::ReleaseShaderCompiler cmd;
954 Cmds expected;
955 expected.cmd.Init();
957 gl_->ReleaseShaderCompiler();
958 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
961 TEST_F(GLES2ImplementationTest, RenderbufferStorage) {
962 struct Cmds {
963 cmds::RenderbufferStorage cmd;
965 Cmds expected;
966 expected.cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
968 gl_->RenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
969 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
972 TEST_F(GLES2ImplementationTest, SampleCoverage) {
973 struct Cmds {
974 cmds::SampleCoverage cmd;
976 Cmds expected;
977 expected.cmd.Init(1, true);
979 gl_->SampleCoverage(1, true);
980 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
983 TEST_F(GLES2ImplementationTest, Scissor) {
984 struct Cmds {
985 cmds::Scissor cmd;
987 Cmds expected;
988 expected.cmd.Init(1, 2, 3, 4);
990 gl_->Scissor(1, 2, 3, 4);
991 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
994 TEST_F(GLES2ImplementationTest, StencilFunc) {
995 struct Cmds {
996 cmds::StencilFunc cmd;
998 Cmds expected;
999 expected.cmd.Init(GL_NEVER, 2, 3);
1001 gl_->StencilFunc(GL_NEVER, 2, 3);
1002 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1005 TEST_F(GLES2ImplementationTest, StencilFuncSeparate) {
1006 struct Cmds {
1007 cmds::StencilFuncSeparate cmd;
1009 Cmds expected;
1010 expected.cmd.Init(GL_FRONT, GL_NEVER, 3, 4);
1012 gl_->StencilFuncSeparate(GL_FRONT, GL_NEVER, 3, 4);
1013 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1016 TEST_F(GLES2ImplementationTest, StencilMask) {
1017 struct Cmds {
1018 cmds::StencilMask cmd;
1020 Cmds expected;
1021 expected.cmd.Init(1);
1023 gl_->StencilMask(1);
1024 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1027 TEST_F(GLES2ImplementationTest, StencilMaskSeparate) {
1028 struct Cmds {
1029 cmds::StencilMaskSeparate cmd;
1031 Cmds expected;
1032 expected.cmd.Init(GL_FRONT, 2);
1034 gl_->StencilMaskSeparate(GL_FRONT, 2);
1035 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1038 TEST_F(GLES2ImplementationTest, StencilOp) {
1039 struct Cmds {
1040 cmds::StencilOp cmd;
1042 Cmds expected;
1043 expected.cmd.Init(GL_KEEP, GL_INCR, GL_KEEP);
1045 gl_->StencilOp(GL_KEEP, GL_INCR, GL_KEEP);
1046 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1049 TEST_F(GLES2ImplementationTest, StencilOpSeparate) {
1050 struct Cmds {
1051 cmds::StencilOpSeparate cmd;
1053 Cmds expected;
1054 expected.cmd.Init(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP);
1056 gl_->StencilOpSeparate(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP);
1057 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1060 TEST_F(GLES2ImplementationTest, TexParameterf) {
1061 struct Cmds {
1062 cmds::TexParameterf cmd;
1064 Cmds expected;
1065 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1067 gl_->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1068 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1071 TEST_F(GLES2ImplementationTest, TexParameterfv) {
1072 GLfloat data[1] = {0};
1073 struct Cmds {
1074 cmds::TexParameterfvImmediate cmd;
1075 GLfloat data[1];
1078 for (int jj = 0; jj < 1; ++jj) {
1079 data[jj] = static_cast<GLfloat>(jj);
1081 Cmds expected;
1082 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1083 gl_->TexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1084 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1087 TEST_F(GLES2ImplementationTest, TexParameteri) {
1088 struct Cmds {
1089 cmds::TexParameteri cmd;
1091 Cmds expected;
1092 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1094 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1095 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1098 TEST_F(GLES2ImplementationTest, TexParameteriv) {
1099 GLint data[1] = {0};
1100 struct Cmds {
1101 cmds::TexParameterivImmediate cmd;
1102 GLint data[1];
1105 for (int jj = 0; jj < 1; ++jj) {
1106 data[jj] = static_cast<GLint>(jj);
1108 Cmds expected;
1109 expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1110 gl_->TexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1111 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1114 TEST_F(GLES2ImplementationTest, Uniform1f) {
1115 struct Cmds {
1116 cmds::Uniform1f cmd;
1118 Cmds expected;
1119 expected.cmd.Init(1, 2);
1121 gl_->Uniform1f(1, 2);
1122 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1125 TEST_F(GLES2ImplementationTest, Uniform1fv) {
1126 GLfloat data[2][1] = {{0}};
1127 struct Cmds {
1128 cmds::Uniform1fvImmediate cmd;
1129 GLfloat data[2][1];
1132 Cmds expected;
1133 for (int ii = 0; ii < 2; ++ii) {
1134 for (int jj = 0; jj < 1; ++jj) {
1135 data[ii][jj] = static_cast<GLfloat>(ii * 1 + jj);
1138 expected.cmd.Init(1, 2, &data[0][0]);
1139 gl_->Uniform1fv(1, 2, &data[0][0]);
1140 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1143 TEST_F(GLES2ImplementationTest, Uniform1i) {
1144 struct Cmds {
1145 cmds::Uniform1i cmd;
1147 Cmds expected;
1148 expected.cmd.Init(1, 2);
1150 gl_->Uniform1i(1, 2);
1151 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1154 TEST_F(GLES2ImplementationTest, Uniform1iv) {
1155 GLint data[2][1] = {{0}};
1156 struct Cmds {
1157 cmds::Uniform1ivImmediate cmd;
1158 GLint data[2][1];
1161 Cmds expected;
1162 for (int ii = 0; ii < 2; ++ii) {
1163 for (int jj = 0; jj < 1; ++jj) {
1164 data[ii][jj] = static_cast<GLint>(ii * 1 + jj);
1167 expected.cmd.Init(1, 2, &data[0][0]);
1168 gl_->Uniform1iv(1, 2, &data[0][0]);
1169 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1172 TEST_F(GLES2ImplementationTest, Uniform2f) {
1173 struct Cmds {
1174 cmds::Uniform2f cmd;
1176 Cmds expected;
1177 expected.cmd.Init(1, 2, 3);
1179 gl_->Uniform2f(1, 2, 3);
1180 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1183 TEST_F(GLES2ImplementationTest, Uniform2fv) {
1184 GLfloat data[2][2] = {{0}};
1185 struct Cmds {
1186 cmds::Uniform2fvImmediate cmd;
1187 GLfloat data[2][2];
1190 Cmds expected;
1191 for (int ii = 0; ii < 2; ++ii) {
1192 for (int jj = 0; jj < 2; ++jj) {
1193 data[ii][jj] = static_cast<GLfloat>(ii * 2 + jj);
1196 expected.cmd.Init(1, 2, &data[0][0]);
1197 gl_->Uniform2fv(1, 2, &data[0][0]);
1198 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1201 TEST_F(GLES2ImplementationTest, Uniform2i) {
1202 struct Cmds {
1203 cmds::Uniform2i cmd;
1205 Cmds expected;
1206 expected.cmd.Init(1, 2, 3);
1208 gl_->Uniform2i(1, 2, 3);
1209 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1212 TEST_F(GLES2ImplementationTest, Uniform2iv) {
1213 GLint data[2][2] = {{0}};
1214 struct Cmds {
1215 cmds::Uniform2ivImmediate cmd;
1216 GLint data[2][2];
1219 Cmds expected;
1220 for (int ii = 0; ii < 2; ++ii) {
1221 for (int jj = 0; jj < 2; ++jj) {
1222 data[ii][jj] = static_cast<GLint>(ii * 2 + jj);
1225 expected.cmd.Init(1, 2, &data[0][0]);
1226 gl_->Uniform2iv(1, 2, &data[0][0]);
1227 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1230 TEST_F(GLES2ImplementationTest, Uniform3f) {
1231 struct Cmds {
1232 cmds::Uniform3f cmd;
1234 Cmds expected;
1235 expected.cmd.Init(1, 2, 3, 4);
1237 gl_->Uniform3f(1, 2, 3, 4);
1238 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1241 TEST_F(GLES2ImplementationTest, Uniform3fv) {
1242 GLfloat data[2][3] = {{0}};
1243 struct Cmds {
1244 cmds::Uniform3fvImmediate cmd;
1245 GLfloat data[2][3];
1248 Cmds expected;
1249 for (int ii = 0; ii < 2; ++ii) {
1250 for (int jj = 0; jj < 3; ++jj) {
1251 data[ii][jj] = static_cast<GLfloat>(ii * 3 + jj);
1254 expected.cmd.Init(1, 2, &data[0][0]);
1255 gl_->Uniform3fv(1, 2, &data[0][0]);
1256 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1259 TEST_F(GLES2ImplementationTest, Uniform3i) {
1260 struct Cmds {
1261 cmds::Uniform3i cmd;
1263 Cmds expected;
1264 expected.cmd.Init(1, 2, 3, 4);
1266 gl_->Uniform3i(1, 2, 3, 4);
1267 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1270 TEST_F(GLES2ImplementationTest, Uniform3iv) {
1271 GLint data[2][3] = {{0}};
1272 struct Cmds {
1273 cmds::Uniform3ivImmediate cmd;
1274 GLint data[2][3];
1277 Cmds expected;
1278 for (int ii = 0; ii < 2; ++ii) {
1279 for (int jj = 0; jj < 3; ++jj) {
1280 data[ii][jj] = static_cast<GLint>(ii * 3 + jj);
1283 expected.cmd.Init(1, 2, &data[0][0]);
1284 gl_->Uniform3iv(1, 2, &data[0][0]);
1285 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1288 TEST_F(GLES2ImplementationTest, Uniform4f) {
1289 struct Cmds {
1290 cmds::Uniform4f cmd;
1292 Cmds expected;
1293 expected.cmd.Init(1, 2, 3, 4, 5);
1295 gl_->Uniform4f(1, 2, 3, 4, 5);
1296 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1299 TEST_F(GLES2ImplementationTest, Uniform4fv) {
1300 GLfloat data[2][4] = {{0}};
1301 struct Cmds {
1302 cmds::Uniform4fvImmediate cmd;
1303 GLfloat data[2][4];
1306 Cmds expected;
1307 for (int ii = 0; ii < 2; ++ii) {
1308 for (int jj = 0; jj < 4; ++jj) {
1309 data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
1312 expected.cmd.Init(1, 2, &data[0][0]);
1313 gl_->Uniform4fv(1, 2, &data[0][0]);
1314 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1317 TEST_F(GLES2ImplementationTest, Uniform4i) {
1318 struct Cmds {
1319 cmds::Uniform4i cmd;
1321 Cmds expected;
1322 expected.cmd.Init(1, 2, 3, 4, 5);
1324 gl_->Uniform4i(1, 2, 3, 4, 5);
1325 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1328 TEST_F(GLES2ImplementationTest, Uniform4iv) {
1329 GLint data[2][4] = {{0}};
1330 struct Cmds {
1331 cmds::Uniform4ivImmediate cmd;
1332 GLint data[2][4];
1335 Cmds expected;
1336 for (int ii = 0; ii < 2; ++ii) {
1337 for (int jj = 0; jj < 4; ++jj) {
1338 data[ii][jj] = static_cast<GLint>(ii * 4 + jj);
1341 expected.cmd.Init(1, 2, &data[0][0]);
1342 gl_->Uniform4iv(1, 2, &data[0][0]);
1343 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1346 TEST_F(GLES2ImplementationTest, UniformMatrix2fv) {
1347 GLfloat data[2][4] = {{0}};
1348 struct Cmds {
1349 cmds::UniformMatrix2fvImmediate cmd;
1350 GLfloat data[2][4];
1353 Cmds expected;
1354 for (int ii = 0; ii < 2; ++ii) {
1355 for (int jj = 0; jj < 4; ++jj) {
1356 data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
1359 expected.cmd.Init(1, 2, &data[0][0]);
1360 gl_->UniformMatrix2fv(1, 2, false, &data[0][0]);
1361 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1364 TEST_F(GLES2ImplementationTest, UniformMatrix2fvInvalidConstantArg2) {
1365 GLfloat data[2][4] = {{0}};
1366 for (int ii = 0; ii < 2; ++ii) {
1367 for (int jj = 0; jj < 4; ++jj) {
1368 data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
1371 gl_->UniformMatrix2fv(1, 2, true, &data[0][0]);
1372 EXPECT_TRUE(NoCommandsWritten());
1373 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
1376 TEST_F(GLES2ImplementationTest, UniformMatrix3fv) {
1377 GLfloat data[2][9] = {{0}};
1378 struct Cmds {
1379 cmds::UniformMatrix3fvImmediate cmd;
1380 GLfloat data[2][9];
1383 Cmds expected;
1384 for (int ii = 0; ii < 2; ++ii) {
1385 for (int jj = 0; jj < 9; ++jj) {
1386 data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj);
1389 expected.cmd.Init(1, 2, &data[0][0]);
1390 gl_->UniformMatrix3fv(1, 2, false, &data[0][0]);
1391 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1394 TEST_F(GLES2ImplementationTest, UniformMatrix3fvInvalidConstantArg2) {
1395 GLfloat data[2][9] = {{0}};
1396 for (int ii = 0; ii < 2; ++ii) {
1397 for (int jj = 0; jj < 9; ++jj) {
1398 data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj);
1401 gl_->UniformMatrix3fv(1, 2, true, &data[0][0]);
1402 EXPECT_TRUE(NoCommandsWritten());
1403 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
1406 TEST_F(GLES2ImplementationTest, UniformMatrix4fv) {
1407 GLfloat data[2][16] = {{0}};
1408 struct Cmds {
1409 cmds::UniformMatrix4fvImmediate cmd;
1410 GLfloat data[2][16];
1413 Cmds expected;
1414 for (int ii = 0; ii < 2; ++ii) {
1415 for (int jj = 0; jj < 16; ++jj) {
1416 data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj);
1419 expected.cmd.Init(1, 2, &data[0][0]);
1420 gl_->UniformMatrix4fv(1, 2, false, &data[0][0]);
1421 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1424 TEST_F(GLES2ImplementationTest, UniformMatrix4fvInvalidConstantArg2) {
1425 GLfloat data[2][16] = {{0}};
1426 for (int ii = 0; ii < 2; ++ii) {
1427 for (int jj = 0; jj < 16; ++jj) {
1428 data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj);
1431 gl_->UniformMatrix4fv(1, 2, true, &data[0][0]);
1432 EXPECT_TRUE(NoCommandsWritten());
1433 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
1436 TEST_F(GLES2ImplementationTest, UseProgram) {
1437 struct Cmds {
1438 cmds::UseProgram cmd;
1440 Cmds expected;
1441 expected.cmd.Init(1);
1443 gl_->UseProgram(1);
1444 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1445 ClearCommands();
1446 gl_->UseProgram(1);
1447 EXPECT_TRUE(NoCommandsWritten());
1450 TEST_F(GLES2ImplementationTest, ValidateProgram) {
1451 struct Cmds {
1452 cmds::ValidateProgram cmd;
1454 Cmds expected;
1455 expected.cmd.Init(1);
1457 gl_->ValidateProgram(1);
1458 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1461 TEST_F(GLES2ImplementationTest, VertexAttrib1f) {
1462 struct Cmds {
1463 cmds::VertexAttrib1f cmd;
1465 Cmds expected;
1466 expected.cmd.Init(1, 2);
1468 gl_->VertexAttrib1f(1, 2);
1469 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1472 TEST_F(GLES2ImplementationTest, VertexAttrib1fv) {
1473 GLfloat data[1] = {0};
1474 struct Cmds {
1475 cmds::VertexAttrib1fvImmediate cmd;
1476 GLfloat data[1];
1479 for (int jj = 0; jj < 1; ++jj) {
1480 data[jj] = static_cast<GLfloat>(jj);
1482 Cmds expected;
1483 expected.cmd.Init(1, &data[0]);
1484 gl_->VertexAttrib1fv(1, &data[0]);
1485 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1488 TEST_F(GLES2ImplementationTest, VertexAttrib2f) {
1489 struct Cmds {
1490 cmds::VertexAttrib2f cmd;
1492 Cmds expected;
1493 expected.cmd.Init(1, 2, 3);
1495 gl_->VertexAttrib2f(1, 2, 3);
1496 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1499 TEST_F(GLES2ImplementationTest, VertexAttrib2fv) {
1500 GLfloat data[2] = {0};
1501 struct Cmds {
1502 cmds::VertexAttrib2fvImmediate cmd;
1503 GLfloat data[2];
1506 for (int jj = 0; jj < 2; ++jj) {
1507 data[jj] = static_cast<GLfloat>(jj);
1509 Cmds expected;
1510 expected.cmd.Init(1, &data[0]);
1511 gl_->VertexAttrib2fv(1, &data[0]);
1512 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1515 TEST_F(GLES2ImplementationTest, VertexAttrib3f) {
1516 struct Cmds {
1517 cmds::VertexAttrib3f cmd;
1519 Cmds expected;
1520 expected.cmd.Init(1, 2, 3, 4);
1522 gl_->VertexAttrib3f(1, 2, 3, 4);
1523 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1526 TEST_F(GLES2ImplementationTest, VertexAttrib3fv) {
1527 GLfloat data[3] = {0};
1528 struct Cmds {
1529 cmds::VertexAttrib3fvImmediate cmd;
1530 GLfloat data[3];
1533 for (int jj = 0; jj < 3; ++jj) {
1534 data[jj] = static_cast<GLfloat>(jj);
1536 Cmds expected;
1537 expected.cmd.Init(1, &data[0]);
1538 gl_->VertexAttrib3fv(1, &data[0]);
1539 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1542 TEST_F(GLES2ImplementationTest, VertexAttrib4f) {
1543 struct Cmds {
1544 cmds::VertexAttrib4f cmd;
1546 Cmds expected;
1547 expected.cmd.Init(1, 2, 3, 4, 5);
1549 gl_->VertexAttrib4f(1, 2, 3, 4, 5);
1550 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1553 TEST_F(GLES2ImplementationTest, VertexAttrib4fv) {
1554 GLfloat data[4] = {0};
1555 struct Cmds {
1556 cmds::VertexAttrib4fvImmediate cmd;
1557 GLfloat data[4];
1560 for (int jj = 0; jj < 4; ++jj) {
1561 data[jj] = static_cast<GLfloat>(jj);
1563 Cmds expected;
1564 expected.cmd.Init(1, &data[0]);
1565 gl_->VertexAttrib4fv(1, &data[0]);
1566 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1569 TEST_F(GLES2ImplementationTest, Viewport) {
1570 struct Cmds {
1571 cmds::Viewport cmd;
1573 Cmds expected;
1574 expected.cmd.Init(1, 2, 3, 4);
1576 gl_->Viewport(1, 2, 3, 4);
1577 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1580 TEST_F(GLES2ImplementationTest, BlitFramebufferCHROMIUM) {
1581 struct Cmds {
1582 cmds::BlitFramebufferCHROMIUM cmd;
1584 Cmds expected;
1585 expected.cmd.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
1587 gl_->BlitFramebufferCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
1588 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1591 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleCHROMIUM) {
1592 struct Cmds {
1593 cmds::RenderbufferStorageMultisampleCHROMIUM cmd;
1595 Cmds expected;
1596 expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
1598 gl_->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, 2, GL_RGBA4, 4,
1600 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1603 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleEXT) {
1604 struct Cmds {
1605 cmds::RenderbufferStorageMultisampleEXT cmd;
1607 Cmds expected;
1608 expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
1610 gl_->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
1611 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1614 TEST_F(GLES2ImplementationTest, FramebufferTexture2DMultisampleEXT) {
1615 struct Cmds {
1616 cmds::FramebufferTexture2DMultisampleEXT cmd;
1618 Cmds expected;
1619 expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4, 6);
1621 gl_->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
1622 GL_TEXTURE_2D, 4, 0, 6);
1623 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1626 TEST_F(GLES2ImplementationTest,
1627 FramebufferTexture2DMultisampleEXTInvalidConstantArg4) {
1628 gl_->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
1629 GL_TEXTURE_2D, 4, 1, 6);
1630 EXPECT_TRUE(NoCommandsWritten());
1631 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
1634 TEST_F(GLES2ImplementationTest, TexStorage2DEXT) {
1635 struct Cmds {
1636 cmds::TexStorage2DEXT cmd;
1638 Cmds expected;
1639 expected.cmd.Init(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
1641 gl_->TexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
1642 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1645 TEST_F(GLES2ImplementationTest, GenQueriesEXT) {
1646 GLuint ids[2] = {
1649 struct Cmds {
1650 cmds::GenQueriesEXTImmediate gen;
1651 GLuint data[2];
1653 Cmds expected;
1654 expected.gen.Init(arraysize(ids), &ids[0]);
1655 expected.data[0] = kQueriesStartId;
1656 expected.data[1] = kQueriesStartId + 1;
1657 gl_->GenQueriesEXT(arraysize(ids), &ids[0]);
1658 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1659 EXPECT_EQ(kQueriesStartId, ids[0]);
1660 EXPECT_EQ(kQueriesStartId + 1, ids[1]);
1663 TEST_F(GLES2ImplementationTest, DeleteQueriesEXT) {
1664 GLuint ids[2] = {kQueriesStartId, kQueriesStartId + 1};
1665 struct Cmds {
1666 cmds::DeleteQueriesEXTImmediate del;
1667 GLuint data[2];
1669 Cmds expected;
1670 expected.del.Init(arraysize(ids), &ids[0]);
1671 expected.data[0] = kQueriesStartId;
1672 expected.data[1] = kQueriesStartId + 1;
1673 gl_->DeleteQueriesEXT(arraysize(ids), &ids[0]);
1674 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1676 // TODO: Implement unit test for BeginQueryEXT
1677 // TODO: Implement unit test for InsertEventMarkerEXT
1678 // TODO: Implement unit test for PushGroupMarkerEXT
1680 TEST_F(GLES2ImplementationTest, PopGroupMarkerEXT) {
1681 struct Cmds {
1682 cmds::PopGroupMarkerEXT cmd;
1684 Cmds expected;
1685 expected.cmd.Init();
1687 gl_->PopGroupMarkerEXT();
1688 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1691 TEST_F(GLES2ImplementationTest, GenVertexArraysOES) {
1692 GLuint ids[2] = {
1695 struct Cmds {
1696 cmds::GenVertexArraysOESImmediate gen;
1697 GLuint data[2];
1699 Cmds expected;
1700 expected.gen.Init(arraysize(ids), &ids[0]);
1701 expected.data[0] = kVertexArraysStartId;
1702 expected.data[1] = kVertexArraysStartId + 1;
1703 gl_->GenVertexArraysOES(arraysize(ids), &ids[0]);
1704 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1705 EXPECT_EQ(kVertexArraysStartId, ids[0]);
1706 EXPECT_EQ(kVertexArraysStartId + 1, ids[1]);
1709 TEST_F(GLES2ImplementationTest, DeleteVertexArraysOES) {
1710 GLuint ids[2] = {kVertexArraysStartId, kVertexArraysStartId + 1};
1711 struct Cmds {
1712 cmds::DeleteVertexArraysOESImmediate del;
1713 GLuint data[2];
1715 Cmds expected;
1716 expected.del.Init(arraysize(ids), &ids[0]);
1717 expected.data[0] = kVertexArraysStartId;
1718 expected.data[1] = kVertexArraysStartId + 1;
1719 gl_->DeleteVertexArraysOES(arraysize(ids), &ids[0]);
1720 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1723 TEST_F(GLES2ImplementationTest, IsVertexArrayOES) {
1724 struct Cmds {
1725 cmds::IsVertexArrayOES cmd;
1728 Cmds expected;
1729 ExpectedMemoryInfo result1 =
1730 GetExpectedResultMemory(sizeof(cmds::IsVertexArrayOES::Result));
1731 expected.cmd.Init(1, result1.id, result1.offset);
1733 EXPECT_CALL(*command_buffer(), OnFlush())
1734 .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
1735 .RetiresOnSaturation();
1737 GLboolean result = gl_->IsVertexArrayOES(1);
1738 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1739 EXPECT_TRUE(result);
1741 // TODO: Implement unit test for EnableFeatureCHROMIUM
1743 TEST_F(GLES2ImplementationTest, ResizeCHROMIUM) {
1744 struct Cmds {
1745 cmds::ResizeCHROMIUM cmd;
1747 Cmds expected;
1748 expected.cmd.Init(1, 2, 3);
1750 gl_->ResizeCHROMIUM(1, 2, 3);
1751 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1753 // TODO: Implement unit test for GetRequestableExtensionsCHROMIUM
1754 // TODO: Implement unit test for CreateStreamTextureCHROMIUM
1755 // TODO: Implement unit test for GetTranslatedShaderSourceANGLE
1757 TEST_F(GLES2ImplementationTest, TexImageIOSurface2DCHROMIUM) {
1758 struct Cmds {
1759 cmds::TexImageIOSurface2DCHROMIUM cmd;
1761 Cmds expected;
1762 expected.cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5);
1764 gl_->TexImageIOSurface2DCHROMIUM(GL_TEXTURE_2D, 2, 3, 4, 5);
1765 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1768 TEST_F(GLES2ImplementationTest, CopyTextureCHROMIUM) {
1769 struct Cmds {
1770 cmds::CopyTextureCHROMIUM cmd;
1772 Cmds expected;
1773 expected.cmd.Init(1, 2, 3, 4, GL_ALPHA, GL_UNSIGNED_BYTE);
1775 gl_->CopyTextureCHROMIUM(1, 2, 3, 4, GL_ALPHA, GL_UNSIGNED_BYTE);
1776 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1779 TEST_F(GLES2ImplementationTest, DrawArraysInstancedANGLE) {
1780 struct Cmds {
1781 cmds::DrawArraysInstancedANGLE cmd;
1783 Cmds expected;
1784 expected.cmd.Init(GL_POINTS, 2, 3, 4);
1786 gl_->DrawArraysInstancedANGLE(GL_POINTS, 2, 3, 4);
1787 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1790 TEST_F(GLES2ImplementationTest, VertexAttribDivisorANGLE) {
1791 struct Cmds {
1792 cmds::VertexAttribDivisorANGLE cmd;
1794 Cmds expected;
1795 expected.cmd.Init(1, 2);
1797 gl_->VertexAttribDivisorANGLE(1, 2);
1798 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1800 // TODO: Implement unit test for GenMailboxCHROMIUM
1801 // TODO: Implement unit test for BindUniformLocationCHROMIUM
1803 TEST_F(GLES2ImplementationTest, GenValuebuffersCHROMIUM) {
1804 GLuint ids[2] = {
1807 struct Cmds {
1808 cmds::GenValuebuffersCHROMIUMImmediate gen;
1809 GLuint data[2];
1811 Cmds expected;
1812 expected.gen.Init(arraysize(ids), &ids[0]);
1813 expected.data[0] = kValuebuffersStartId;
1814 expected.data[1] = kValuebuffersStartId + 1;
1815 gl_->GenValuebuffersCHROMIUM(arraysize(ids), &ids[0]);
1816 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1817 EXPECT_EQ(kValuebuffersStartId, ids[0]);
1818 EXPECT_EQ(kValuebuffersStartId + 1, ids[1]);
1821 TEST_F(GLES2ImplementationTest, DeleteValuebuffersCHROMIUM) {
1822 GLuint ids[2] = {kValuebuffersStartId, kValuebuffersStartId + 1};
1823 struct Cmds {
1824 cmds::DeleteValuebuffersCHROMIUMImmediate del;
1825 GLuint data[2];
1827 Cmds expected;
1828 expected.del.Init(arraysize(ids), &ids[0]);
1829 expected.data[0] = kValuebuffersStartId;
1830 expected.data[1] = kValuebuffersStartId + 1;
1831 gl_->DeleteValuebuffersCHROMIUM(arraysize(ids), &ids[0]);
1832 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1835 TEST_F(GLES2ImplementationTest, IsValuebufferCHROMIUM) {
1836 struct Cmds {
1837 cmds::IsValuebufferCHROMIUM cmd;
1840 Cmds expected;
1841 ExpectedMemoryInfo result1 =
1842 GetExpectedResultMemory(sizeof(cmds::IsValuebufferCHROMIUM::Result));
1843 expected.cmd.Init(1, result1.id, result1.offset);
1845 EXPECT_CALL(*command_buffer(), OnFlush())
1846 .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
1847 .RetiresOnSaturation();
1849 GLboolean result = gl_->IsValuebufferCHROMIUM(1);
1850 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1851 EXPECT_TRUE(result);
1854 TEST_F(GLES2ImplementationTest, BindValuebufferCHROMIUM) {
1855 struct Cmds {
1856 cmds::BindValuebufferCHROMIUM cmd;
1858 Cmds expected;
1859 expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
1861 gl_->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
1862 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1863 ClearCommands();
1864 gl_->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
1865 EXPECT_TRUE(NoCommandsWritten());
1868 TEST_F(GLES2ImplementationTest, SubscribeValueCHROMIUM) {
1869 struct Cmds {
1870 cmds::SubscribeValueCHROMIUM cmd;
1872 Cmds expected;
1873 expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
1874 GL_MOUSE_POSITION_CHROMIUM);
1876 gl_->SubscribeValueCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
1877 GL_MOUSE_POSITION_CHROMIUM);
1878 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1881 TEST_F(GLES2ImplementationTest, PopulateSubscribedValuesCHROMIUM) {
1882 struct Cmds {
1883 cmds::PopulateSubscribedValuesCHROMIUM cmd;
1885 Cmds expected;
1886 expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM);
1888 gl_->PopulateSubscribedValuesCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM);
1889 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1892 TEST_F(GLES2ImplementationTest, UniformValuebufferCHROMIUM) {
1893 struct Cmds {
1894 cmds::UniformValuebufferCHROMIUM cmd;
1896 Cmds expected;
1897 expected.cmd.Init(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
1898 GL_MOUSE_POSITION_CHROMIUM);
1900 gl_->UniformValuebufferCHROMIUM(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
1901 GL_MOUSE_POSITION_CHROMIUM);
1902 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1905 TEST_F(GLES2ImplementationTest, BindTexImage2DCHROMIUM) {
1906 struct Cmds {
1907 cmds::BindTexImage2DCHROMIUM cmd;
1909 Cmds expected;
1910 expected.cmd.Init(GL_TEXTURE_2D, 2);
1912 gl_->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
1913 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1916 TEST_F(GLES2ImplementationTest, ReleaseTexImage2DCHROMIUM) {
1917 struct Cmds {
1918 cmds::ReleaseTexImage2DCHROMIUM cmd;
1920 Cmds expected;
1921 expected.cmd.Init(GL_TEXTURE_2D, 2);
1923 gl_->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
1924 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1927 TEST_F(GLES2ImplementationTest, DiscardFramebufferEXT) {
1928 GLenum data[2][1] = {{0}};
1929 struct Cmds {
1930 cmds::DiscardFramebufferEXTImmediate cmd;
1931 GLenum data[2][1];
1934 Cmds expected;
1935 for (int ii = 0; ii < 2; ++ii) {
1936 for (int jj = 0; jj < 1; ++jj) {
1937 data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
1940 expected.cmd.Init(1, 2, &data[0][0]);
1941 gl_->DiscardFramebufferEXT(1, 2, &data[0][0]);
1942 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1945 TEST_F(GLES2ImplementationTest, LoseContextCHROMIUM) {
1946 struct Cmds {
1947 cmds::LoseContextCHROMIUM cmd;
1949 Cmds expected;
1950 expected.cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_GUILTY_CONTEXT_RESET_ARB);
1952 gl_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
1953 GL_GUILTY_CONTEXT_RESET_ARB);
1954 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1956 // TODO: Implement unit test for InsertSyncPointCHROMIUM
1958 TEST_F(GLES2ImplementationTest, WaitSyncPointCHROMIUM) {
1959 struct Cmds {
1960 cmds::WaitSyncPointCHROMIUM cmd;
1962 Cmds expected;
1963 expected.cmd.Init(1);
1965 gl_->WaitSyncPointCHROMIUM(1);
1966 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1969 TEST_F(GLES2ImplementationTest, DrawBuffersEXT) {
1970 GLenum data[1][1] = {{0}};
1971 struct Cmds {
1972 cmds::DrawBuffersEXTImmediate cmd;
1973 GLenum data[1][1];
1976 Cmds expected;
1977 for (int ii = 0; ii < 1; ++ii) {
1978 for (int jj = 0; jj < 1; ++jj) {
1979 data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
1982 expected.cmd.Init(1, &data[0][0]);
1983 gl_->DrawBuffersEXT(1, &data[0][0]);
1984 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1987 TEST_F(GLES2ImplementationTest, DiscardBackbufferCHROMIUM) {
1988 struct Cmds {
1989 cmds::DiscardBackbufferCHROMIUM cmd;
1991 Cmds expected;
1992 expected.cmd.Init();
1994 gl_->DiscardBackbufferCHROMIUM();
1995 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1998 TEST_F(GLES2ImplementationTest, MatrixLoadfCHROMIUM) {
1999 GLfloat data[16] = {0};
2000 struct Cmds {
2001 cmds::MatrixLoadfCHROMIUMImmediate cmd;
2002 GLfloat data[16];
2005 for (int jj = 0; jj < 16; ++jj) {
2006 data[jj] = static_cast<GLfloat>(jj);
2008 Cmds expected;
2009 expected.cmd.Init(GL_PATH_PROJECTION_CHROMIUM, &data[0]);
2010 gl_->MatrixLoadfCHROMIUM(GL_PATH_PROJECTION_CHROMIUM, &data[0]);
2011 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2014 TEST_F(GLES2ImplementationTest, MatrixLoadIdentityCHROMIUM) {
2015 struct Cmds {
2016 cmds::MatrixLoadIdentityCHROMIUM cmd;
2018 Cmds expected;
2019 expected.cmd.Init(GL_PATH_PROJECTION_CHROMIUM);
2021 gl_->MatrixLoadIdentityCHROMIUM(GL_PATH_PROJECTION_CHROMIUM);
2022 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2024 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_