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.
4 
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!
10 
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_
15 
TEST_F(GLES2ImplementationTest,AttachShader)16 TEST_F(GLES2ImplementationTest, AttachShader) {
17   struct Cmds {
18     cmds::AttachShader cmd;
19   };
20   Cmds expected;
21   expected.cmd.Init(1, 2);
22 
23   gl_->AttachShader(1, 2);
24   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
25 }
26 
TEST_F(GLES2ImplementationTest,BindBuffer)27 TEST_F(GLES2ImplementationTest, BindBuffer) {
28   struct Cmds {
29     cmds::BindBuffer cmd;
30   };
31   Cmds expected;
32   expected.cmd.Init(GL_ARRAY_BUFFER, 2);
33 
34   gl_->BindBuffer(GL_ARRAY_BUFFER, 2);
35   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
36   ClearCommands();
37   gl_->BindBuffer(GL_ARRAY_BUFFER, 2);
38   EXPECT_TRUE(NoCommandsWritten());
39 }
40 
TEST_F(GLES2ImplementationTest,BindBufferBase)41 TEST_F(GLES2ImplementationTest, BindBufferBase) {
42   struct Cmds {
43     cmds::BindBufferBase cmd;
44   };
45   Cmds expected;
46   expected.cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3);
47 
48   gl_->BindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3);
49   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
50 }
51 
TEST_F(GLES2ImplementationTest,BindBufferRange)52 TEST_F(GLES2ImplementationTest, BindBufferRange) {
53   struct Cmds {
54     cmds::BindBufferRange cmd;
55   };
56   Cmds expected;
57   expected.cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3, 4, 4);
58 
59   gl_->BindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3, 4, 4);
60   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
61 }
62 
TEST_F(GLES2ImplementationTest,BindFramebuffer)63 TEST_F(GLES2ImplementationTest, BindFramebuffer) {
64   struct Cmds {
65     cmds::BindFramebuffer cmd;
66   };
67   Cmds expected;
68   expected.cmd.Init(GL_FRAMEBUFFER, 2);
69 
70   gl_->BindFramebuffer(GL_FRAMEBUFFER, 2);
71   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
72   ClearCommands();
73   gl_->BindFramebuffer(GL_FRAMEBUFFER, 2);
74   EXPECT_TRUE(NoCommandsWritten());
75 }
76 
TEST_F(GLES2ImplementationTest,BindRenderbuffer)77 TEST_F(GLES2ImplementationTest, BindRenderbuffer) {
78   struct Cmds {
79     cmds::BindRenderbuffer cmd;
80   };
81   Cmds expected;
82   expected.cmd.Init(GL_RENDERBUFFER, 2);
83 
84   gl_->BindRenderbuffer(GL_RENDERBUFFER, 2);
85   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
86   ClearCommands();
87   gl_->BindRenderbuffer(GL_RENDERBUFFER, 2);
88   EXPECT_TRUE(NoCommandsWritten());
89 }
90 
TEST_F(GLES2ImplementationTest,BindSampler)91 TEST_F(GLES2ImplementationTest, BindSampler) {
92   struct Cmds {
93     cmds::BindSampler cmd;
94   };
95   Cmds expected;
96   expected.cmd.Init(1, 2);
97 
98   gl_->BindSampler(1, 2);
99   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
100 }
101 
TEST_F(GLES2ImplementationTest,BindTransformFeedback)102 TEST_F(GLES2ImplementationTest, BindTransformFeedback) {
103   struct Cmds {
104     cmds::BindTransformFeedback cmd;
105   };
106   Cmds expected;
107   expected.cmd.Init(GL_TRANSFORM_FEEDBACK, 2);
108 
109   gl_->BindTransformFeedback(GL_TRANSFORM_FEEDBACK, 2);
110   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
111 }
112 
TEST_F(GLES2ImplementationTest,BlendColor)113 TEST_F(GLES2ImplementationTest, BlendColor) {
114   struct Cmds {
115     cmds::BlendColor cmd;
116   };
117   Cmds expected;
118   expected.cmd.Init(1, 2, 3, 4);
119 
120   gl_->BlendColor(1, 2, 3, 4);
121   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
122 }
123 
TEST_F(GLES2ImplementationTest,BlendEquation)124 TEST_F(GLES2ImplementationTest, BlendEquation) {
125   struct Cmds {
126     cmds::BlendEquation cmd;
127   };
128   Cmds expected;
129   expected.cmd.Init(GL_FUNC_SUBTRACT);
130 
131   gl_->BlendEquation(GL_FUNC_SUBTRACT);
132   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
133 }
134 
TEST_F(GLES2ImplementationTest,BlendEquationSeparate)135 TEST_F(GLES2ImplementationTest, BlendEquationSeparate) {
136   struct Cmds {
137     cmds::BlendEquationSeparate cmd;
138   };
139   Cmds expected;
140   expected.cmd.Init(GL_FUNC_SUBTRACT, GL_FUNC_ADD);
141 
142   gl_->BlendEquationSeparate(GL_FUNC_SUBTRACT, GL_FUNC_ADD);
143   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
144 }
145 
TEST_F(GLES2ImplementationTest,BlendFunc)146 TEST_F(GLES2ImplementationTest, BlendFunc) {
147   struct Cmds {
148     cmds::BlendFunc cmd;
149   };
150   Cmds expected;
151   expected.cmd.Init(GL_ZERO, GL_ZERO);
152 
153   gl_->BlendFunc(GL_ZERO, GL_ZERO);
154   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
155 }
156 
TEST_F(GLES2ImplementationTest,BlendFuncSeparate)157 TEST_F(GLES2ImplementationTest, BlendFuncSeparate) {
158   struct Cmds {
159     cmds::BlendFuncSeparate cmd;
160   };
161   Cmds expected;
162   expected.cmd.Init(GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO);
163 
164   gl_->BlendFuncSeparate(GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO);
165   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
166 }
167 
TEST_F(GLES2ImplementationTest,CheckFramebufferStatus)168 TEST_F(GLES2ImplementationTest, CheckFramebufferStatus) {
169   struct Cmds {
170     cmds::CheckFramebufferStatus cmd;
171   };
172 
173   Cmds expected;
174   ExpectedMemoryInfo result1 =
175       GetExpectedResultMemory(sizeof(cmds::CheckFramebufferStatus::Result));
176   expected.cmd.Init(GL_FRAMEBUFFER, result1.id, result1.offset);
177 
178   EXPECT_CALL(*command_buffer(), OnFlush())
179       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
180       .RetiresOnSaturation();
181 
182   GLboolean result = gl_->CheckFramebufferStatus(GL_FRAMEBUFFER);
183   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
184   EXPECT_TRUE(result);
185 }
186 
TEST_F(GLES2ImplementationTest,Clear)187 TEST_F(GLES2ImplementationTest, Clear) {
188   struct Cmds {
189     cmds::Clear cmd;
190   };
191   Cmds expected;
192   expected.cmd.Init(GL_COLOR_BUFFER_BIT);
193 
194   gl_->Clear(GL_COLOR_BUFFER_BIT);
195   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
196 }
197 
TEST_F(GLES2ImplementationTest,ClearBufferfi)198 TEST_F(GLES2ImplementationTest, ClearBufferfi) {
199   struct Cmds {
200     cmds::ClearBufferfi cmd;
201   };
202   Cmds expected;
203   expected.cmd.Init(GL_DEPTH_STENCIL, 2, 3, 4);
204 
205   gl_->ClearBufferfi(GL_DEPTH_STENCIL, 2, 3, 4);
206   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
207 }
208 
TEST_F(GLES2ImplementationTest,ClearBufferfv)209 TEST_F(GLES2ImplementationTest, ClearBufferfv) {
210   GLfloat data[4] = {0};
211   struct Cmds {
212     cmds::ClearBufferfvImmediate cmd;
213     GLfloat data[4];
214   };
215 
216   for (int jj = 0; jj < 4; ++jj) {
217     data[jj] = static_cast<GLfloat>(jj);
218   }
219   Cmds expected;
220   expected.cmd.Init(GL_COLOR, 2, &data[0]);
221   gl_->ClearBufferfv(GL_COLOR, 2, &data[0]);
222   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
223 }
224 
TEST_F(GLES2ImplementationTest,ClearBufferiv)225 TEST_F(GLES2ImplementationTest, ClearBufferiv) {
226   GLint data[4] = {0};
227   struct Cmds {
228     cmds::ClearBufferivImmediate cmd;
229     GLint data[4];
230   };
231 
232   for (int jj = 0; jj < 4; ++jj) {
233     data[jj] = static_cast<GLint>(jj);
234   }
235   Cmds expected;
236   expected.cmd.Init(GL_COLOR, 2, &data[0]);
237   gl_->ClearBufferiv(GL_COLOR, 2, &data[0]);
238   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
239 }
240 
TEST_F(GLES2ImplementationTest,ClearBufferuiv)241 TEST_F(GLES2ImplementationTest, ClearBufferuiv) {
242   GLuint data[4] = {0};
243   struct Cmds {
244     cmds::ClearBufferuivImmediate cmd;
245     GLuint data[4];
246   };
247 
248   for (int jj = 0; jj < 4; ++jj) {
249     data[jj] = static_cast<GLuint>(jj);
250   }
251   Cmds expected;
252   expected.cmd.Init(GL_COLOR, 2, &data[0]);
253   gl_->ClearBufferuiv(GL_COLOR, 2, &data[0]);
254   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
255 }
256 
TEST_F(GLES2ImplementationTest,ClearColor)257 TEST_F(GLES2ImplementationTest, ClearColor) {
258   struct Cmds {
259     cmds::ClearColor cmd;
260   };
261   Cmds expected;
262   expected.cmd.Init(1, 2, 3, 4);
263 
264   gl_->ClearColor(1, 2, 3, 4);
265   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
266 }
267 
TEST_F(GLES2ImplementationTest,ClearDepthf)268 TEST_F(GLES2ImplementationTest, ClearDepthf) {
269   struct Cmds {
270     cmds::ClearDepthf cmd;
271   };
272   Cmds expected;
273   expected.cmd.Init(0.5f);
274 
275   gl_->ClearDepthf(0.5f);
276   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
277 }
278 
TEST_F(GLES2ImplementationTest,ClearStencil)279 TEST_F(GLES2ImplementationTest, ClearStencil) {
280   struct Cmds {
281     cmds::ClearStencil cmd;
282   };
283   Cmds expected;
284   expected.cmd.Init(1);
285 
286   gl_->ClearStencil(1);
287   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
288 }
289 
TEST_F(GLES2ImplementationTest,ColorMask)290 TEST_F(GLES2ImplementationTest, ColorMask) {
291   struct Cmds {
292     cmds::ColorMask cmd;
293   };
294   Cmds expected;
295   expected.cmd.Init(true, true, true, true);
296 
297   gl_->ColorMask(true, true, true, true);
298   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
299 }
300 
TEST_F(GLES2ImplementationTest,CompileShader)301 TEST_F(GLES2ImplementationTest, CompileShader) {
302   struct Cmds {
303     cmds::CompileShader cmd;
304   };
305   Cmds expected;
306   expected.cmd.Init(1);
307 
308   gl_->CompileShader(1);
309   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
310 }
311 
TEST_F(GLES2ImplementationTest,CopyBufferSubData)312 TEST_F(GLES2ImplementationTest, CopyBufferSubData) {
313   struct Cmds {
314     cmds::CopyBufferSubData cmd;
315   };
316   Cmds expected;
317   expected.cmd.Init(GL_ARRAY_BUFFER, GL_ARRAY_BUFFER, 3, 4, 5);
318 
319   gl_->CopyBufferSubData(GL_ARRAY_BUFFER, GL_ARRAY_BUFFER, 3, 4, 5);
320   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
321 }
322 
TEST_F(GLES2ImplementationTest,CopyTexImage2D)323 TEST_F(GLES2ImplementationTest, CopyTexImage2D) {
324   struct Cmds {
325     cmds::CopyTexImage2D cmd;
326   };
327   Cmds expected;
328   expected.cmd.Init(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7);
329 
330   gl_->CopyTexImage2D(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7, 0);
331   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
332 }
333 
TEST_F(GLES2ImplementationTest,CopyTexImage2DInvalidConstantArg7)334 TEST_F(GLES2ImplementationTest, CopyTexImage2DInvalidConstantArg7) {
335   gl_->CopyTexImage2D(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7, 1);
336   EXPECT_TRUE(NoCommandsWritten());
337   EXPECT_EQ(GL_INVALID_VALUE, CheckError());
338 }
339 
TEST_F(GLES2ImplementationTest,CopyTexSubImage2D)340 TEST_F(GLES2ImplementationTest, CopyTexSubImage2D) {
341   struct Cmds {
342     cmds::CopyTexSubImage2D cmd;
343   };
344   Cmds expected;
345   expected.cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8);
346 
347   gl_->CopyTexSubImage2D(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8);
348   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
349 }
350 
TEST_F(GLES2ImplementationTest,CopyTexSubImage3D)351 TEST_F(GLES2ImplementationTest, CopyTexSubImage3D) {
352   struct Cmds {
353     cmds::CopyTexSubImage3D cmd;
354   };
355   Cmds expected;
356   expected.cmd.Init(GL_TEXTURE_3D, 2, 3, 4, 5, 6, 7, 8, 9);
357 
358   gl_->CopyTexSubImage3D(GL_TEXTURE_3D, 2, 3, 4, 5, 6, 7, 8, 9);
359   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
360 }
361 
TEST_F(GLES2ImplementationTest,CullFace)362 TEST_F(GLES2ImplementationTest, CullFace) {
363   struct Cmds {
364     cmds::CullFace cmd;
365   };
366   Cmds expected;
367   expected.cmd.Init(GL_FRONT);
368 
369   gl_->CullFace(GL_FRONT);
370   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
371 }
372 
TEST_F(GLES2ImplementationTest,DeleteBuffers)373 TEST_F(GLES2ImplementationTest, DeleteBuffers) {
374   GLuint ids[2] = {kBuffersStartId, kBuffersStartId + 1};
375   struct Cmds {
376     cmds::DeleteBuffersImmediate del;
377     GLuint data[2];
378   };
379   Cmds expected;
380   expected.del.Init(base::size(ids), &ids[0]);
381   expected.data[0] = kBuffersStartId;
382   expected.data[1] = kBuffersStartId + 1;
383   gl_->DeleteBuffers(base::size(ids), &ids[0]);
384   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
385 }
386 
TEST_F(GLES2ImplementationTest,DeleteFramebuffers)387 TEST_F(GLES2ImplementationTest, DeleteFramebuffers) {
388   GLuint ids[2] = {kFramebuffersStartId, kFramebuffersStartId + 1};
389   struct Cmds {
390     cmds::DeleteFramebuffersImmediate del;
391     GLuint data[2];
392   };
393   Cmds expected;
394   expected.del.Init(base::size(ids), &ids[0]);
395   expected.data[0] = kFramebuffersStartId;
396   expected.data[1] = kFramebuffersStartId + 1;
397   gl_->DeleteFramebuffers(base::size(ids), &ids[0]);
398   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
399 }
400 
TEST_F(GLES2ImplementationTest,DeleteProgram)401 TEST_F(GLES2ImplementationTest, DeleteProgram) {
402   struct Cmds {
403     cmds::DeleteProgram cmd;
404   };
405   Cmds expected;
406   expected.cmd.Init(1);
407 
408   gl_->DeleteProgram(1);
409   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
410 }
411 
TEST_F(GLES2ImplementationTest,DeleteRenderbuffers)412 TEST_F(GLES2ImplementationTest, DeleteRenderbuffers) {
413   GLuint ids[2] = {kRenderbuffersStartId, kRenderbuffersStartId + 1};
414   struct Cmds {
415     cmds::DeleteRenderbuffersImmediate del;
416     GLuint data[2];
417   };
418   Cmds expected;
419   expected.del.Init(base::size(ids), &ids[0]);
420   expected.data[0] = kRenderbuffersStartId;
421   expected.data[1] = kRenderbuffersStartId + 1;
422   gl_->DeleteRenderbuffers(base::size(ids), &ids[0]);
423   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
424 }
425 
TEST_F(GLES2ImplementationTest,DeleteSamplers)426 TEST_F(GLES2ImplementationTest, DeleteSamplers) {
427   GLuint ids[2] = {kSamplersStartId, kSamplersStartId + 1};
428   struct Cmds {
429     cmds::DeleteSamplersImmediate del;
430     GLuint data[2];
431   };
432   Cmds expected;
433   expected.del.Init(base::size(ids), &ids[0]);
434   expected.data[0] = kSamplersStartId;
435   expected.data[1] = kSamplersStartId + 1;
436   gl_->DeleteSamplers(base::size(ids), &ids[0]);
437   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
438 }
439 
TEST_F(GLES2ImplementationTest,DeleteSync)440 TEST_F(GLES2ImplementationTest, DeleteSync) {
441   struct Cmds {
442     cmds::DeleteSync cmd;
443   };
444   Cmds expected;
445   expected.cmd.Init(1);
446 
447   gl_->DeleteSync(reinterpret_cast<GLsync>(1));
448   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
449 }
450 
TEST_F(GLES2ImplementationTest,DeleteShader)451 TEST_F(GLES2ImplementationTest, DeleteShader) {
452   struct Cmds {
453     cmds::DeleteShader cmd;
454   };
455   Cmds expected;
456   expected.cmd.Init(1);
457 
458   gl_->DeleteShader(1);
459   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
460 }
461 
TEST_F(GLES2ImplementationTest,DeleteTextures)462 TEST_F(GLES2ImplementationTest, DeleteTextures) {
463   GLuint ids[2] = {kTexturesStartId, kTexturesStartId + 1};
464   struct Cmds {
465     cmds::DeleteTexturesImmediate del;
466     GLuint data[2];
467   };
468   Cmds expected;
469   expected.del.Init(base::size(ids), &ids[0]);
470   expected.data[0] = kTexturesStartId;
471   expected.data[1] = kTexturesStartId + 1;
472   gl_->DeleteTextures(base::size(ids), &ids[0]);
473   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
474 }
475 
TEST_F(GLES2ImplementationTest,DeleteTransformFeedbacks)476 TEST_F(GLES2ImplementationTest, DeleteTransformFeedbacks) {
477   GLuint ids[2] = {kTransformFeedbacksStartId, kTransformFeedbacksStartId + 1};
478   struct Cmds {
479     cmds::DeleteTransformFeedbacksImmediate del;
480     GLuint data[2];
481   };
482   Cmds expected;
483   expected.del.Init(base::size(ids), &ids[0]);
484   expected.data[0] = kTransformFeedbacksStartId;
485   expected.data[1] = kTransformFeedbacksStartId + 1;
486   gl_->DeleteTransformFeedbacks(base::size(ids), &ids[0]);
487   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
488 }
489 
TEST_F(GLES2ImplementationTest,DepthFunc)490 TEST_F(GLES2ImplementationTest, DepthFunc) {
491   struct Cmds {
492     cmds::DepthFunc cmd;
493   };
494   Cmds expected;
495   expected.cmd.Init(GL_NEVER);
496 
497   gl_->DepthFunc(GL_NEVER);
498   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
499 }
500 
TEST_F(GLES2ImplementationTest,DepthMask)501 TEST_F(GLES2ImplementationTest, DepthMask) {
502   struct Cmds {
503     cmds::DepthMask cmd;
504   };
505   Cmds expected;
506   expected.cmd.Init(true);
507 
508   gl_->DepthMask(true);
509   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
510 }
511 
TEST_F(GLES2ImplementationTest,DepthRangef)512 TEST_F(GLES2ImplementationTest, DepthRangef) {
513   struct Cmds {
514     cmds::DepthRangef cmd;
515   };
516   Cmds expected;
517   expected.cmd.Init(1, 2);
518 
519   gl_->DepthRangef(1, 2);
520   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
521 }
522 
TEST_F(GLES2ImplementationTest,DetachShader)523 TEST_F(GLES2ImplementationTest, DetachShader) {
524   struct Cmds {
525     cmds::DetachShader cmd;
526   };
527   Cmds expected;
528   expected.cmd.Init(1, 2);
529 
530   gl_->DetachShader(1, 2);
531   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
532 }
533 
TEST_F(GLES2ImplementationTest,DisableVertexAttribArray)534 TEST_F(GLES2ImplementationTest, DisableVertexAttribArray) {
535   struct Cmds {
536     cmds::DisableVertexAttribArray cmd;
537   };
538   Cmds expected;
539   expected.cmd.Init(1);
540 
541   gl_->DisableVertexAttribArray(1);
542   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
543 }
544 
TEST_F(GLES2ImplementationTest,DrawArrays)545 TEST_F(GLES2ImplementationTest, DrawArrays) {
546   struct Cmds {
547     cmds::DrawArrays cmd;
548   };
549   Cmds expected;
550   expected.cmd.Init(GL_POINTS, 2, 3);
551 
552   gl_->DrawArrays(GL_POINTS, 2, 3);
553   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
554 }
555 
TEST_F(GLES2ImplementationTest,EnableVertexAttribArray)556 TEST_F(GLES2ImplementationTest, EnableVertexAttribArray) {
557   struct Cmds {
558     cmds::EnableVertexAttribArray cmd;
559   };
560   Cmds expected;
561   expected.cmd.Init(1);
562 
563   gl_->EnableVertexAttribArray(1);
564   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
565 }
566 
TEST_F(GLES2ImplementationTest,Flush)567 TEST_F(GLES2ImplementationTest, Flush) {
568   struct Cmds {
569     cmds::Flush cmd;
570   };
571   Cmds expected;
572   expected.cmd.Init();
573 
574   gl_->Flush();
575   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
576 }
577 
TEST_F(GLES2ImplementationTest,FramebufferRenderbuffer)578 TEST_F(GLES2ImplementationTest, FramebufferRenderbuffer) {
579   struct Cmds {
580     cmds::FramebufferRenderbuffer cmd;
581   };
582   Cmds expected;
583   expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 4);
584 
585   gl_->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
586                                GL_RENDERBUFFER, 4);
587   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
588 }
589 
TEST_F(GLES2ImplementationTest,FramebufferTexture2D)590 TEST_F(GLES2ImplementationTest, FramebufferTexture2D) {
591   struct Cmds {
592     cmds::FramebufferTexture2D cmd;
593   };
594   Cmds expected;
595   expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4, 5);
596 
597   gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
598                             4, 5);
599   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
600 }
601 
TEST_F(GLES2ImplementationTest,FramebufferTextureLayer)602 TEST_F(GLES2ImplementationTest, FramebufferTextureLayer) {
603   struct Cmds {
604     cmds::FramebufferTextureLayer cmd;
605   };
606   Cmds expected;
607   expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 3, 4, 5);
608 
609   gl_->FramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 3, 4, 5);
610   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
611 }
612 
TEST_F(GLES2ImplementationTest,FrontFace)613 TEST_F(GLES2ImplementationTest, FrontFace) {
614   struct Cmds {
615     cmds::FrontFace cmd;
616   };
617   Cmds expected;
618   expected.cmd.Init(GL_CW);
619 
620   gl_->FrontFace(GL_CW);
621   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
622 }
623 
TEST_F(GLES2ImplementationTest,GenBuffers)624 TEST_F(GLES2ImplementationTest, GenBuffers) {
625   GLuint ids[2] = {
626       0,
627   };
628   struct Cmds {
629     cmds::GenBuffersImmediate gen;
630     GLuint data[2];
631   };
632   Cmds expected;
633   expected.gen.Init(base::size(ids), &ids[0]);
634   expected.data[0] = kBuffersStartId;
635   expected.data[1] = kBuffersStartId + 1;
636   gl_->GenBuffers(base::size(ids), &ids[0]);
637   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
638   EXPECT_EQ(kBuffersStartId, ids[0]);
639   EXPECT_EQ(kBuffersStartId + 1, ids[1]);
640 }
641 
TEST_F(GLES2ImplementationTest,GenerateMipmap)642 TEST_F(GLES2ImplementationTest, GenerateMipmap) {
643   struct Cmds {
644     cmds::GenerateMipmap cmd;
645   };
646   Cmds expected;
647   expected.cmd.Init(GL_TEXTURE_2D);
648 
649   gl_->GenerateMipmap(GL_TEXTURE_2D);
650   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
651 }
652 
TEST_F(GLES2ImplementationTest,GenFramebuffers)653 TEST_F(GLES2ImplementationTest, GenFramebuffers) {
654   GLuint ids[2] = {
655       0,
656   };
657   struct Cmds {
658     cmds::GenFramebuffersImmediate gen;
659     GLuint data[2];
660   };
661   Cmds expected;
662   expected.gen.Init(base::size(ids), &ids[0]);
663   expected.data[0] = kFramebuffersStartId;
664   expected.data[1] = kFramebuffersStartId + 1;
665   gl_->GenFramebuffers(base::size(ids), &ids[0]);
666   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
667   EXPECT_EQ(kFramebuffersStartId, ids[0]);
668   EXPECT_EQ(kFramebuffersStartId + 1, ids[1]);
669 }
670 
TEST_F(GLES2ImplementationTest,GenRenderbuffers)671 TEST_F(GLES2ImplementationTest, GenRenderbuffers) {
672   GLuint ids[2] = {
673       0,
674   };
675   struct Cmds {
676     cmds::GenRenderbuffersImmediate gen;
677     GLuint data[2];
678   };
679   Cmds expected;
680   expected.gen.Init(base::size(ids), &ids[0]);
681   expected.data[0] = kRenderbuffersStartId;
682   expected.data[1] = kRenderbuffersStartId + 1;
683   gl_->GenRenderbuffers(base::size(ids), &ids[0]);
684   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
685   EXPECT_EQ(kRenderbuffersStartId, ids[0]);
686   EXPECT_EQ(kRenderbuffersStartId + 1, ids[1]);
687 }
688 
TEST_F(GLES2ImplementationTest,GenSamplers)689 TEST_F(GLES2ImplementationTest, GenSamplers) {
690   GLuint ids[2] = {
691       0,
692   };
693   struct Cmds {
694     cmds::GenSamplersImmediate gen;
695     GLuint data[2];
696   };
697   Cmds expected;
698   expected.gen.Init(base::size(ids), &ids[0]);
699   expected.data[0] = kSamplersStartId;
700   expected.data[1] = kSamplersStartId + 1;
701   gl_->GenSamplers(base::size(ids), &ids[0]);
702   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
703   EXPECT_EQ(kSamplersStartId, ids[0]);
704   EXPECT_EQ(kSamplersStartId + 1, ids[1]);
705 }
706 
TEST_F(GLES2ImplementationTest,GenTextures)707 TEST_F(GLES2ImplementationTest, GenTextures) {
708   GLuint ids[2] = {
709       0,
710   };
711   struct Cmds {
712     cmds::GenTexturesImmediate gen;
713     GLuint data[2];
714   };
715   Cmds expected;
716   expected.gen.Init(base::size(ids), &ids[0]);
717   expected.data[0] = kTexturesStartId;
718   expected.data[1] = kTexturesStartId + 1;
719   gl_->GenTextures(base::size(ids), &ids[0]);
720   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
721   EXPECT_EQ(kTexturesStartId, ids[0]);
722   EXPECT_EQ(kTexturesStartId + 1, ids[1]);
723 }
724 
TEST_F(GLES2ImplementationTest,GenTransformFeedbacks)725 TEST_F(GLES2ImplementationTest, GenTransformFeedbacks) {
726   GLuint ids[2] = {
727       0,
728   };
729   struct Cmds {
730     cmds::GenTransformFeedbacksImmediate gen;
731     GLuint data[2];
732   };
733   Cmds expected;
734   expected.gen.Init(base::size(ids), &ids[0]);
735   expected.data[0] = kTransformFeedbacksStartId;
736   expected.data[1] = kTransformFeedbacksStartId + 1;
737   gl_->GenTransformFeedbacks(base::size(ids), &ids[0]);
738   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
739   EXPECT_EQ(kTransformFeedbacksStartId, ids[0]);
740   EXPECT_EQ(kTransformFeedbacksStartId + 1, ids[1]);
741 }
742 
TEST_F(GLES2ImplementationTest,GetBooleanv)743 TEST_F(GLES2ImplementationTest, GetBooleanv) {
744   struct Cmds {
745     cmds::GetBooleanv cmd;
746   };
747   typedef cmds::GetBooleanv::Result::Type ResultType;
748   ResultType result = 0;
749   Cmds expected;
750   ExpectedMemoryInfo result1 =
751       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
752   expected.cmd.Init(123, result1.id, result1.offset);
753   EXPECT_CALL(*command_buffer(), OnFlush())
754       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
755       .RetiresOnSaturation();
756   gl_->GetBooleanv(123, &result);
757   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
758   EXPECT_EQ(static_cast<ResultType>(1), result);
759 }
760 
TEST_F(GLES2ImplementationTest,GetBooleani_v)761 TEST_F(GLES2ImplementationTest, GetBooleani_v) {
762   struct Cmds {
763     cmds::GetBooleani_v cmd;
764   };
765   typedef cmds::GetBooleani_v::Result::Type ResultType;
766   ResultType result = 0;
767   Cmds expected;
768   ExpectedMemoryInfo result1 =
769       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
770   expected.cmd.Init(123, 2, result1.id, result1.offset);
771   EXPECT_CALL(*command_buffer(), OnFlush())
772       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
773       .RetiresOnSaturation();
774   gl_->GetBooleani_v(123, 2, &result);
775   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
776   EXPECT_EQ(static_cast<ResultType>(1), result);
777 }
778 
TEST_F(GLES2ImplementationTest,GetBufferParameteri64v)779 TEST_F(GLES2ImplementationTest, GetBufferParameteri64v) {
780   struct Cmds {
781     cmds::GetBufferParameteri64v cmd;
782   };
783   typedef cmds::GetBufferParameteri64v::Result::Type ResultType;
784   ResultType result = 0;
785   Cmds expected;
786   ExpectedMemoryInfo result1 =
787       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
788   expected.cmd.Init(123, GL_BUFFER_SIZE, result1.id, result1.offset);
789   EXPECT_CALL(*command_buffer(), OnFlush())
790       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
791       .RetiresOnSaturation();
792   gl_->GetBufferParameteri64v(123, GL_BUFFER_SIZE, &result);
793   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
794   EXPECT_EQ(static_cast<ResultType>(1), result);
795 }
796 
TEST_F(GLES2ImplementationTest,GetBufferParameteriv)797 TEST_F(GLES2ImplementationTest, GetBufferParameteriv) {
798   struct Cmds {
799     cmds::GetBufferParameteriv cmd;
800   };
801   typedef cmds::GetBufferParameteriv::Result::Type ResultType;
802   ResultType result = 0;
803   Cmds expected;
804   ExpectedMemoryInfo result1 =
805       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
806   expected.cmd.Init(123, GL_BUFFER_SIZE, result1.id, result1.offset);
807   EXPECT_CALL(*command_buffer(), OnFlush())
808       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
809       .RetiresOnSaturation();
810   gl_->GetBufferParameteriv(123, GL_BUFFER_SIZE, &result);
811   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
812   EXPECT_EQ(static_cast<ResultType>(1), result);
813 }
814 
TEST_F(GLES2ImplementationTest,GetFloatv)815 TEST_F(GLES2ImplementationTest, GetFloatv) {
816   struct Cmds {
817     cmds::GetFloatv cmd;
818   };
819   typedef cmds::GetFloatv::Result::Type ResultType;
820   ResultType result = 0;
821   Cmds expected;
822   ExpectedMemoryInfo result1 =
823       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
824   expected.cmd.Init(123, result1.id, result1.offset);
825   EXPECT_CALL(*command_buffer(), OnFlush())
826       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
827       .RetiresOnSaturation();
828   gl_->GetFloatv(123, &result);
829   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
830   EXPECT_EQ(static_cast<ResultType>(1), result);
831 }
832 
TEST_F(GLES2ImplementationTest,GetFramebufferAttachmentParameteriv)833 TEST_F(GLES2ImplementationTest, GetFramebufferAttachmentParameteriv) {
834   struct Cmds {
835     cmds::GetFramebufferAttachmentParameteriv cmd;
836   };
837   typedef cmds::GetFramebufferAttachmentParameteriv::Result::Type ResultType;
838   ResultType result = 0;
839   Cmds expected;
840   ExpectedMemoryInfo result1 =
841       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
842   expected.cmd.Init(123, GL_COLOR_ATTACHMENT0,
843                     GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, result1.id,
844                     result1.offset);
845   EXPECT_CALL(*command_buffer(), OnFlush())
846       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
847       .RetiresOnSaturation();
848   gl_->GetFramebufferAttachmentParameteriv(
849       123, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
850       &result);
851   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
852   EXPECT_EQ(static_cast<ResultType>(1), result);
853 }
854 
TEST_F(GLES2ImplementationTest,GetInteger64v)855 TEST_F(GLES2ImplementationTest, GetInteger64v) {
856   struct Cmds {
857     cmds::GetInteger64v cmd;
858   };
859   typedef cmds::GetInteger64v::Result::Type ResultType;
860   ResultType result = 0;
861   Cmds expected;
862   ExpectedMemoryInfo result1 =
863       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
864   expected.cmd.Init(123, result1.id, result1.offset);
865   EXPECT_CALL(*command_buffer(), OnFlush())
866       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
867       .RetiresOnSaturation();
868   gl_->GetInteger64v(123, &result);
869   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
870   EXPECT_EQ(static_cast<ResultType>(1), result);
871 }
872 
TEST_F(GLES2ImplementationTest,GetIntegeri_v)873 TEST_F(GLES2ImplementationTest, GetIntegeri_v) {
874   struct Cmds {
875     cmds::GetIntegeri_v cmd;
876   };
877   typedef cmds::GetIntegeri_v::Result::Type ResultType;
878   ResultType result = 0;
879   Cmds expected;
880   ExpectedMemoryInfo result1 =
881       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
882   expected.cmd.Init(123, 2, result1.id, result1.offset);
883   EXPECT_CALL(*command_buffer(), OnFlush())
884       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
885       .RetiresOnSaturation();
886   gl_->GetIntegeri_v(123, 2, &result);
887   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
888   EXPECT_EQ(static_cast<ResultType>(1), result);
889 }
890 
TEST_F(GLES2ImplementationTest,GetInteger64i_v)891 TEST_F(GLES2ImplementationTest, GetInteger64i_v) {
892   struct Cmds {
893     cmds::GetInteger64i_v cmd;
894   };
895   typedef cmds::GetInteger64i_v::Result::Type ResultType;
896   ResultType result = 0;
897   Cmds expected;
898   ExpectedMemoryInfo result1 =
899       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
900   expected.cmd.Init(123, 2, result1.id, result1.offset);
901   EXPECT_CALL(*command_buffer(), OnFlush())
902       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
903       .RetiresOnSaturation();
904   gl_->GetInteger64i_v(123, 2, &result);
905   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
906   EXPECT_EQ(static_cast<ResultType>(1), result);
907 }
908 
TEST_F(GLES2ImplementationTest,GetIntegerv)909 TEST_F(GLES2ImplementationTest, GetIntegerv) {
910   struct Cmds {
911     cmds::GetIntegerv cmd;
912   };
913   typedef cmds::GetIntegerv::Result::Type ResultType;
914   ResultType result = 0;
915   Cmds expected;
916   ExpectedMemoryInfo result1 =
917       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
918   expected.cmd.Init(123, result1.id, result1.offset);
919   EXPECT_CALL(*command_buffer(), OnFlush())
920       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
921       .RetiresOnSaturation();
922   gl_->GetIntegerv(123, &result);
923   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
924   EXPECT_EQ(static_cast<ResultType>(1), result);
925 }
926 
TEST_F(GLES2ImplementationTest,GetProgramiv)927 TEST_F(GLES2ImplementationTest, GetProgramiv) {
928   struct Cmds {
929     cmds::GetProgramiv cmd;
930   };
931   typedef cmds::GetProgramiv::Result::Type ResultType;
932   ResultType result = 0;
933   Cmds expected;
934   ExpectedMemoryInfo result1 =
935       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
936   expected.cmd.Init(123, GL_DELETE_STATUS, result1.id, result1.offset);
937   EXPECT_CALL(*command_buffer(), OnFlush())
938       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
939       .RetiresOnSaturation();
940   gl_->GetProgramiv(123, GL_DELETE_STATUS, &result);
941   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
942   EXPECT_EQ(static_cast<ResultType>(1), result);
943 }
944 
TEST_F(GLES2ImplementationTest,GetRenderbufferParameteriv)945 TEST_F(GLES2ImplementationTest, GetRenderbufferParameteriv) {
946   struct Cmds {
947     cmds::GetRenderbufferParameteriv cmd;
948   };
949   typedef cmds::GetRenderbufferParameteriv::Result::Type ResultType;
950   ResultType result = 0;
951   Cmds expected;
952   ExpectedMemoryInfo result1 =
953       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
954   expected.cmd.Init(123, GL_RENDERBUFFER_RED_SIZE, result1.id, result1.offset);
955   EXPECT_CALL(*command_buffer(), OnFlush())
956       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
957       .RetiresOnSaturation();
958   gl_->GetRenderbufferParameteriv(123, GL_RENDERBUFFER_RED_SIZE, &result);
959   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
960   EXPECT_EQ(static_cast<ResultType>(1), result);
961 }
962 
TEST_F(GLES2ImplementationTest,GetSamplerParameterfv)963 TEST_F(GLES2ImplementationTest, GetSamplerParameterfv) {
964   struct Cmds {
965     cmds::GetSamplerParameterfv cmd;
966   };
967   typedef cmds::GetSamplerParameterfv::Result::Type ResultType;
968   ResultType result = 0;
969   Cmds expected;
970   ExpectedMemoryInfo result1 =
971       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
972   expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
973   EXPECT_CALL(*command_buffer(), OnFlush())
974       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
975       .RetiresOnSaturation();
976   gl_->GetSamplerParameterfv(123, GL_TEXTURE_MAG_FILTER, &result);
977   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
978   EXPECT_EQ(static_cast<ResultType>(1), result);
979 }
980 
TEST_F(GLES2ImplementationTest,GetSamplerParameteriv)981 TEST_F(GLES2ImplementationTest, GetSamplerParameteriv) {
982   struct Cmds {
983     cmds::GetSamplerParameteriv cmd;
984   };
985   typedef cmds::GetSamplerParameteriv::Result::Type ResultType;
986   ResultType result = 0;
987   Cmds expected;
988   ExpectedMemoryInfo result1 =
989       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
990   expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
991   EXPECT_CALL(*command_buffer(), OnFlush())
992       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
993       .RetiresOnSaturation();
994   gl_->GetSamplerParameteriv(123, GL_TEXTURE_MAG_FILTER, &result);
995   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
996   EXPECT_EQ(static_cast<ResultType>(1), result);
997 }
998 
TEST_F(GLES2ImplementationTest,GetShaderiv)999 TEST_F(GLES2ImplementationTest, GetShaderiv) {
1000   struct Cmds {
1001     cmds::GetShaderiv cmd;
1002   };
1003   typedef cmds::GetShaderiv::Result::Type ResultType;
1004   ResultType result = 0;
1005   Cmds expected;
1006   ExpectedMemoryInfo result1 =
1007       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1008   expected.cmd.Init(123, GL_SHADER_TYPE, result1.id, result1.offset);
1009   EXPECT_CALL(*command_buffer(), OnFlush())
1010       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1011       .RetiresOnSaturation();
1012   gl_->GetShaderiv(123, GL_SHADER_TYPE, &result);
1013   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1014   EXPECT_EQ(static_cast<ResultType>(1), result);
1015 }
1016 
TEST_F(GLES2ImplementationTest,GetSynciv)1017 TEST_F(GLES2ImplementationTest, GetSynciv) {
1018   struct Cmds {
1019     cmds::GetSynciv cmd;
1020   };
1021   typedef cmds::GetSynciv::Result::Type ResultType;
1022   ResultType result = 0;
1023   Cmds expected;
1024   ExpectedMemoryInfo result1 =
1025       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1026   expected.cmd.Init(123, GL_SYNC_STATUS, result1.id, result1.offset);
1027   EXPECT_CALL(*command_buffer(), OnFlush())
1028       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1029       .RetiresOnSaturation();
1030   gl_->GetSynciv(reinterpret_cast<GLsync>(123), GL_SYNC_STATUS, 3, nullptr,
1031                  &result);
1032   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1033   EXPECT_EQ(static_cast<ResultType>(1), result);
1034 }
1035 
TEST_F(GLES2ImplementationTest,GetTexParameterfv)1036 TEST_F(GLES2ImplementationTest, GetTexParameterfv) {
1037   struct Cmds {
1038     cmds::GetTexParameterfv cmd;
1039   };
1040   typedef cmds::GetTexParameterfv::Result::Type ResultType;
1041   ResultType result = 0;
1042   Cmds expected;
1043   ExpectedMemoryInfo result1 =
1044       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1045   expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
1046   EXPECT_CALL(*command_buffer(), OnFlush())
1047       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1048       .RetiresOnSaturation();
1049   gl_->GetTexParameterfv(123, GL_TEXTURE_MAG_FILTER, &result);
1050   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1051   EXPECT_EQ(static_cast<ResultType>(1), result);
1052 }
1053 
TEST_F(GLES2ImplementationTest,GetTexParameteriv)1054 TEST_F(GLES2ImplementationTest, GetTexParameteriv) {
1055   struct Cmds {
1056     cmds::GetTexParameteriv cmd;
1057   };
1058   typedef cmds::GetTexParameteriv::Result::Type ResultType;
1059   ResultType result = 0;
1060   Cmds expected;
1061   ExpectedMemoryInfo result1 =
1062       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1063   expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
1064   EXPECT_CALL(*command_buffer(), OnFlush())
1065       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1066       .RetiresOnSaturation();
1067   gl_->GetTexParameteriv(123, GL_TEXTURE_MAG_FILTER, &result);
1068   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1069   EXPECT_EQ(static_cast<ResultType>(1), result);
1070 }
1071 
TEST_F(GLES2ImplementationTest,GetVertexAttribfv)1072 TEST_F(GLES2ImplementationTest, GetVertexAttribfv) {
1073   struct Cmds {
1074     cmds::GetVertexAttribfv cmd;
1075   };
1076   typedef cmds::GetVertexAttribfv::Result::Type ResultType;
1077   ResultType result = 0;
1078   Cmds expected;
1079   ExpectedMemoryInfo result1 =
1080       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1081   expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1082                     result1.offset);
1083   EXPECT_CALL(*command_buffer(), OnFlush())
1084       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1085       .RetiresOnSaturation();
1086   gl_->GetVertexAttribfv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1087   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1088   EXPECT_EQ(static_cast<ResultType>(1), result);
1089 }
1090 
TEST_F(GLES2ImplementationTest,GetVertexAttribiv)1091 TEST_F(GLES2ImplementationTest, GetVertexAttribiv) {
1092   struct Cmds {
1093     cmds::GetVertexAttribiv cmd;
1094   };
1095   typedef cmds::GetVertexAttribiv::Result::Type ResultType;
1096   ResultType result = 0;
1097   Cmds expected;
1098   ExpectedMemoryInfo result1 =
1099       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1100   expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1101                     result1.offset);
1102   EXPECT_CALL(*command_buffer(), OnFlush())
1103       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1104       .RetiresOnSaturation();
1105   gl_->GetVertexAttribiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1106   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1107   EXPECT_EQ(static_cast<ResultType>(1), result);
1108 }
1109 
TEST_F(GLES2ImplementationTest,GetVertexAttribIiv)1110 TEST_F(GLES2ImplementationTest, GetVertexAttribIiv) {
1111   struct Cmds {
1112     cmds::GetVertexAttribIiv cmd;
1113   };
1114   typedef cmds::GetVertexAttribIiv::Result::Type ResultType;
1115   ResultType result = 0;
1116   Cmds expected;
1117   ExpectedMemoryInfo result1 =
1118       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1119   expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1120                     result1.offset);
1121   EXPECT_CALL(*command_buffer(), OnFlush())
1122       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1123       .RetiresOnSaturation();
1124   gl_->GetVertexAttribIiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1125   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1126   EXPECT_EQ(static_cast<ResultType>(1), result);
1127 }
1128 
TEST_F(GLES2ImplementationTest,GetVertexAttribIuiv)1129 TEST_F(GLES2ImplementationTest, GetVertexAttribIuiv) {
1130   struct Cmds {
1131     cmds::GetVertexAttribIuiv cmd;
1132   };
1133   typedef cmds::GetVertexAttribIuiv::Result::Type ResultType;
1134   ResultType result = 0;
1135   Cmds expected;
1136   ExpectedMemoryInfo result1 =
1137       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1138   expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1139                     result1.offset);
1140   EXPECT_CALL(*command_buffer(), OnFlush())
1141       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1142       .RetiresOnSaturation();
1143   gl_->GetVertexAttribIuiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1144   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1145   EXPECT_EQ(static_cast<ResultType>(1), result);
1146 }
1147 
TEST_F(GLES2ImplementationTest,Hint)1148 TEST_F(GLES2ImplementationTest, Hint) {
1149   struct Cmds {
1150     cmds::Hint cmd;
1151   };
1152   Cmds expected;
1153   expected.cmd.Init(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
1154 
1155   gl_->Hint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
1156   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1157 }
1158 
TEST_F(GLES2ImplementationTest,InvalidateFramebuffer)1159 TEST_F(GLES2ImplementationTest, InvalidateFramebuffer) {
1160   GLenum data[2][1] = {{0}};
1161   struct Cmds {
1162     cmds::InvalidateFramebufferImmediate cmd;
1163     GLenum data[2][1];
1164   };
1165 
1166   Cmds expected;
1167   for (int ii = 0; ii < 2; ++ii) {
1168     for (int jj = 0; jj < 1; ++jj) {
1169       data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
1170     }
1171   }
1172   expected.cmd.Init(GL_FRAMEBUFFER, 2, &data[0][0]);
1173   gl_->InvalidateFramebuffer(GL_FRAMEBUFFER, 2, &data[0][0]);
1174   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1175 }
1176 
TEST_F(GLES2ImplementationTest,InvalidateSubFramebuffer)1177 TEST_F(GLES2ImplementationTest, InvalidateSubFramebuffer) {
1178   GLenum data[2][1] = {{0}};
1179   struct Cmds {
1180     cmds::InvalidateSubFramebufferImmediate cmd;
1181     GLenum data[2][1];
1182   };
1183 
1184   Cmds expected;
1185   for (int ii = 0; ii < 2; ++ii) {
1186     for (int jj = 0; jj < 1; ++jj) {
1187       data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
1188     }
1189   }
1190   expected.cmd.Init(GL_FRAMEBUFFER, 2, &data[0][0], 4, 5, 6, 7);
1191   gl_->InvalidateSubFramebuffer(GL_FRAMEBUFFER, 2, &data[0][0], 4, 5, 6, 7);
1192   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1193 }
1194 
TEST_F(GLES2ImplementationTest,IsBuffer)1195 TEST_F(GLES2ImplementationTest, IsBuffer) {
1196   struct Cmds {
1197     cmds::IsBuffer cmd;
1198   };
1199 
1200   Cmds expected;
1201   ExpectedMemoryInfo result1 =
1202       GetExpectedResultMemory(sizeof(cmds::IsBuffer::Result));
1203   expected.cmd.Init(1, result1.id, result1.offset);
1204 
1205   EXPECT_CALL(*command_buffer(), OnFlush())
1206       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1207       .RetiresOnSaturation();
1208 
1209   GLboolean result = gl_->IsBuffer(1);
1210   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1211   EXPECT_TRUE(result);
1212 }
1213 
TEST_F(GLES2ImplementationTest,IsFramebuffer)1214 TEST_F(GLES2ImplementationTest, IsFramebuffer) {
1215   struct Cmds {
1216     cmds::IsFramebuffer cmd;
1217   };
1218 
1219   Cmds expected;
1220   ExpectedMemoryInfo result1 =
1221       GetExpectedResultMemory(sizeof(cmds::IsFramebuffer::Result));
1222   expected.cmd.Init(1, result1.id, result1.offset);
1223 
1224   EXPECT_CALL(*command_buffer(), OnFlush())
1225       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1226       .RetiresOnSaturation();
1227 
1228   GLboolean result = gl_->IsFramebuffer(1);
1229   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1230   EXPECT_TRUE(result);
1231 }
1232 
TEST_F(GLES2ImplementationTest,IsProgram)1233 TEST_F(GLES2ImplementationTest, IsProgram) {
1234   struct Cmds {
1235     cmds::IsProgram cmd;
1236   };
1237 
1238   Cmds expected;
1239   ExpectedMemoryInfo result1 =
1240       GetExpectedResultMemory(sizeof(cmds::IsProgram::Result));
1241   expected.cmd.Init(1, result1.id, result1.offset);
1242 
1243   EXPECT_CALL(*command_buffer(), OnFlush())
1244       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1245       .RetiresOnSaturation();
1246 
1247   GLboolean result = gl_->IsProgram(1);
1248   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1249   EXPECT_TRUE(result);
1250 }
1251 
TEST_F(GLES2ImplementationTest,IsRenderbuffer)1252 TEST_F(GLES2ImplementationTest, IsRenderbuffer) {
1253   struct Cmds {
1254     cmds::IsRenderbuffer cmd;
1255   };
1256 
1257   Cmds expected;
1258   ExpectedMemoryInfo result1 =
1259       GetExpectedResultMemory(sizeof(cmds::IsRenderbuffer::Result));
1260   expected.cmd.Init(1, result1.id, result1.offset);
1261 
1262   EXPECT_CALL(*command_buffer(), OnFlush())
1263       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1264       .RetiresOnSaturation();
1265 
1266   GLboolean result = gl_->IsRenderbuffer(1);
1267   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1268   EXPECT_TRUE(result);
1269 }
1270 
TEST_F(GLES2ImplementationTest,IsSampler)1271 TEST_F(GLES2ImplementationTest, IsSampler) {
1272   struct Cmds {
1273     cmds::IsSampler cmd;
1274   };
1275 
1276   Cmds expected;
1277   ExpectedMemoryInfo result1 =
1278       GetExpectedResultMemory(sizeof(cmds::IsSampler::Result));
1279   expected.cmd.Init(1, result1.id, result1.offset);
1280 
1281   EXPECT_CALL(*command_buffer(), OnFlush())
1282       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1283       .RetiresOnSaturation();
1284 
1285   GLboolean result = gl_->IsSampler(1);
1286   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1287   EXPECT_TRUE(result);
1288 }
1289 
TEST_F(GLES2ImplementationTest,IsShader)1290 TEST_F(GLES2ImplementationTest, IsShader) {
1291   struct Cmds {
1292     cmds::IsShader cmd;
1293   };
1294 
1295   Cmds expected;
1296   ExpectedMemoryInfo result1 =
1297       GetExpectedResultMemory(sizeof(cmds::IsShader::Result));
1298   expected.cmd.Init(1, result1.id, result1.offset);
1299 
1300   EXPECT_CALL(*command_buffer(), OnFlush())
1301       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1302       .RetiresOnSaturation();
1303 
1304   GLboolean result = gl_->IsShader(1);
1305   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1306   EXPECT_TRUE(result);
1307 }
1308 
TEST_F(GLES2ImplementationTest,IsSync)1309 TEST_F(GLES2ImplementationTest, IsSync) {
1310   struct Cmds {
1311     cmds::IsSync cmd;
1312   };
1313 
1314   Cmds expected;
1315   ExpectedMemoryInfo result1 =
1316       GetExpectedResultMemory(sizeof(cmds::IsSync::Result));
1317   expected.cmd.Init(1, result1.id, result1.offset);
1318 
1319   EXPECT_CALL(*command_buffer(), OnFlush())
1320       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1321       .RetiresOnSaturation();
1322 
1323   GLboolean result = gl_->IsSync(reinterpret_cast<GLsync>(1));
1324   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1325   EXPECT_TRUE(result);
1326 }
1327 
TEST_F(GLES2ImplementationTest,IsTexture)1328 TEST_F(GLES2ImplementationTest, IsTexture) {
1329   struct Cmds {
1330     cmds::IsTexture cmd;
1331   };
1332 
1333   Cmds expected;
1334   ExpectedMemoryInfo result1 =
1335       GetExpectedResultMemory(sizeof(cmds::IsTexture::Result));
1336   expected.cmd.Init(1, result1.id, result1.offset);
1337 
1338   EXPECT_CALL(*command_buffer(), OnFlush())
1339       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1340       .RetiresOnSaturation();
1341 
1342   GLboolean result = gl_->IsTexture(1);
1343   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1344   EXPECT_TRUE(result);
1345 }
1346 
TEST_F(GLES2ImplementationTest,IsTransformFeedback)1347 TEST_F(GLES2ImplementationTest, IsTransformFeedback) {
1348   struct Cmds {
1349     cmds::IsTransformFeedback cmd;
1350   };
1351 
1352   Cmds expected;
1353   ExpectedMemoryInfo result1 =
1354       GetExpectedResultMemory(sizeof(cmds::IsTransformFeedback::Result));
1355   expected.cmd.Init(1, result1.id, result1.offset);
1356 
1357   EXPECT_CALL(*command_buffer(), OnFlush())
1358       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1359       .RetiresOnSaturation();
1360 
1361   GLboolean result = gl_->IsTransformFeedback(1);
1362   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1363   EXPECT_TRUE(result);
1364 }
1365 
TEST_F(GLES2ImplementationTest,LineWidth)1366 TEST_F(GLES2ImplementationTest, LineWidth) {
1367   struct Cmds {
1368     cmds::LineWidth cmd;
1369   };
1370   Cmds expected;
1371   expected.cmd.Init(2.0f);
1372 
1373   gl_->LineWidth(2.0f);
1374   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1375 }
1376 
TEST_F(GLES2ImplementationTest,LinkProgram)1377 TEST_F(GLES2ImplementationTest, LinkProgram) {
1378   struct Cmds {
1379     cmds::LinkProgram cmd;
1380   };
1381   Cmds expected;
1382   expected.cmd.Init(1);
1383 
1384   gl_->LinkProgram(1);
1385   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1386 }
1387 
TEST_F(GLES2ImplementationTest,PauseTransformFeedback)1388 TEST_F(GLES2ImplementationTest, PauseTransformFeedback) {
1389   struct Cmds {
1390     cmds::PauseTransformFeedback cmd;
1391   };
1392   Cmds expected;
1393   expected.cmd.Init();
1394 
1395   gl_->PauseTransformFeedback();
1396   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1397 }
1398 
TEST_F(GLES2ImplementationTest,PixelStorei)1399 TEST_F(GLES2ImplementationTest, PixelStorei) {
1400   struct Cmds {
1401     cmds::PixelStorei cmd;
1402   };
1403   Cmds expected;
1404   expected.cmd.Init(GL_PACK_ALIGNMENT, 1);
1405 
1406   gl_->PixelStorei(GL_PACK_ALIGNMENT, 1);
1407   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1408 }
1409 
TEST_F(GLES2ImplementationTest,PolygonOffset)1410 TEST_F(GLES2ImplementationTest, PolygonOffset) {
1411   struct Cmds {
1412     cmds::PolygonOffset cmd;
1413   };
1414   Cmds expected;
1415   expected.cmd.Init(1, 2);
1416 
1417   gl_->PolygonOffset(1, 2);
1418   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1419 }
1420 
TEST_F(GLES2ImplementationTest,ReadBuffer)1421 TEST_F(GLES2ImplementationTest, ReadBuffer) {
1422   struct Cmds {
1423     cmds::ReadBuffer cmd;
1424   };
1425   Cmds expected;
1426   expected.cmd.Init(GL_NONE);
1427 
1428   gl_->ReadBuffer(GL_NONE);
1429   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1430 }
1431 
TEST_F(GLES2ImplementationTest,ReleaseShaderCompiler)1432 TEST_F(GLES2ImplementationTest, ReleaseShaderCompiler) {
1433   struct Cmds {
1434     cmds::ReleaseShaderCompiler cmd;
1435   };
1436   Cmds expected;
1437   expected.cmd.Init();
1438 
1439   gl_->ReleaseShaderCompiler();
1440   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1441 }
1442 
TEST_F(GLES2ImplementationTest,RenderbufferStorage)1443 TEST_F(GLES2ImplementationTest, RenderbufferStorage) {
1444   struct Cmds {
1445     cmds::RenderbufferStorage cmd;
1446   };
1447   Cmds expected;
1448   expected.cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
1449 
1450   gl_->RenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
1451   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1452 }
1453 
TEST_F(GLES2ImplementationTest,ResumeTransformFeedback)1454 TEST_F(GLES2ImplementationTest, ResumeTransformFeedback) {
1455   struct Cmds {
1456     cmds::ResumeTransformFeedback cmd;
1457   };
1458   Cmds expected;
1459   expected.cmd.Init();
1460 
1461   gl_->ResumeTransformFeedback();
1462   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1463 }
1464 
TEST_F(GLES2ImplementationTest,SampleCoverage)1465 TEST_F(GLES2ImplementationTest, SampleCoverage) {
1466   struct Cmds {
1467     cmds::SampleCoverage cmd;
1468   };
1469   Cmds expected;
1470   expected.cmd.Init(1, true);
1471 
1472   gl_->SampleCoverage(1, true);
1473   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1474 }
1475 
TEST_F(GLES2ImplementationTest,SamplerParameterf)1476 TEST_F(GLES2ImplementationTest, SamplerParameterf) {
1477   struct Cmds {
1478     cmds::SamplerParameterf cmd;
1479   };
1480   Cmds expected;
1481   expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1482 
1483   gl_->SamplerParameterf(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1484   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1485 }
1486 
TEST_F(GLES2ImplementationTest,SamplerParameterfv)1487 TEST_F(GLES2ImplementationTest, SamplerParameterfv) {
1488   GLfloat data[1] = {0};
1489   struct Cmds {
1490     cmds::SamplerParameterfvImmediate cmd;
1491     GLfloat data[1];
1492   };
1493 
1494   for (int jj = 0; jj < 1; ++jj) {
1495     data[jj] = static_cast<GLfloat>(jj);
1496   }
1497   Cmds expected;
1498   expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1499   gl_->SamplerParameterfv(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1500   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1501 }
1502 
TEST_F(GLES2ImplementationTest,SamplerParameteri)1503 TEST_F(GLES2ImplementationTest, SamplerParameteri) {
1504   struct Cmds {
1505     cmds::SamplerParameteri cmd;
1506   };
1507   Cmds expected;
1508   expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1509 
1510   gl_->SamplerParameteri(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1511   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1512 }
1513 
TEST_F(GLES2ImplementationTest,SamplerParameteriv)1514 TEST_F(GLES2ImplementationTest, SamplerParameteriv) {
1515   GLint data[1] = {0};
1516   struct Cmds {
1517     cmds::SamplerParameterivImmediate cmd;
1518     GLint data[1];
1519   };
1520 
1521   for (int jj = 0; jj < 1; ++jj) {
1522     data[jj] = static_cast<GLint>(jj);
1523   }
1524   Cmds expected;
1525   expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1526   gl_->SamplerParameteriv(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1527   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1528 }
1529 
TEST_F(GLES2ImplementationTest,Scissor)1530 TEST_F(GLES2ImplementationTest, Scissor) {
1531   struct Cmds {
1532     cmds::Scissor cmd;
1533   };
1534   Cmds expected;
1535   expected.cmd.Init(1, 2, 3, 4);
1536 
1537   gl_->Scissor(1, 2, 3, 4);
1538   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1539 }
1540 
TEST_F(GLES2ImplementationTest,ShaderSource)1541 TEST_F(GLES2ImplementationTest, ShaderSource) {
1542   const uint32_t kBucketId = GLES2Implementation::kResultBucketId;
1543   const char* kString1 = "happy";
1544   const char* kString2 = "ending";
1545   const size_t kString1Size = ::strlen(kString1) + 1;
1546   const size_t kString2Size = ::strlen(kString2) + 1;
1547   const size_t kHeaderSize = sizeof(GLint) * 3;
1548   const size_t kSourceSize = kHeaderSize + kString1Size + kString2Size;
1549   const size_t kPaddedHeaderSize =
1550       transfer_buffer_->RoundToAlignment(kHeaderSize);
1551   const size_t kPaddedString1Size =
1552       transfer_buffer_->RoundToAlignment(kString1Size);
1553   const size_t kPaddedString2Size =
1554       transfer_buffer_->RoundToAlignment(kString2Size);
1555   struct Cmds {
1556     cmd::SetBucketSize set_bucket_size;
1557     cmd::SetBucketData set_bucket_header;
1558     cmd::SetToken set_token1;
1559     cmd::SetBucketData set_bucket_data1;
1560     cmd::SetToken set_token2;
1561     cmd::SetBucketData set_bucket_data2;
1562     cmd::SetToken set_token3;
1563     cmds::ShaderSourceBucket cmd_bucket;
1564     cmd::SetBucketSize clear_bucket_size;
1565   };
1566 
1567   ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1568   ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedString1Size);
1569   ExpectedMemoryInfo mem2 = GetExpectedMemory(kPaddedString2Size);
1570 
1571   Cmds expected;
1572   expected.set_bucket_size.Init(kBucketId, kSourceSize);
1573   expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1574                                   mem0.offset);
1575   expected.set_token1.Init(GetNextToken());
1576   expected.set_bucket_data1.Init(kBucketId, kHeaderSize, kString1Size, mem1.id,
1577                                  mem1.offset);
1578   expected.set_token2.Init(GetNextToken());
1579   expected.set_bucket_data2.Init(kBucketId, kHeaderSize + kString1Size,
1580                                  kString2Size, mem2.id, mem2.offset);
1581   expected.set_token3.Init(GetNextToken());
1582   expected.cmd_bucket.Init(1, kBucketId);
1583   expected.clear_bucket_size.Init(kBucketId, 0);
1584   const char* kStrings[] = {kString1, kString2};
1585   gl_->ShaderSource(1, 2, kStrings, nullptr);
1586   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1587 }
1588 
TEST_F(GLES2ImplementationTest,ShaderSourceWithLength)1589 TEST_F(GLES2ImplementationTest, ShaderSourceWithLength) {
1590   const uint32_t kBucketId = GLES2Implementation::kResultBucketId;
1591   const char* kString = "foobar******";
1592   const size_t kStringSize = 6;  // We only need "foobar".
1593   const size_t kHeaderSize = sizeof(GLint) * 2;
1594   const size_t kSourceSize = kHeaderSize + kStringSize + 1;
1595   const size_t kPaddedHeaderSize =
1596       transfer_buffer_->RoundToAlignment(kHeaderSize);
1597   const size_t kPaddedStringSize =
1598       transfer_buffer_->RoundToAlignment(kStringSize + 1);
1599   struct Cmds {
1600     cmd::SetBucketSize set_bucket_size;
1601     cmd::SetBucketData set_bucket_header;
1602     cmd::SetToken set_token1;
1603     cmd::SetBucketData set_bucket_data;
1604     cmd::SetToken set_token2;
1605     cmds::ShaderSourceBucket shader_source_bucket;
1606     cmd::SetBucketSize clear_bucket_size;
1607   };
1608 
1609   ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1610   ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedStringSize);
1611 
1612   Cmds expected;
1613   expected.set_bucket_size.Init(kBucketId, kSourceSize);
1614   expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1615                                   mem0.offset);
1616   expected.set_token1.Init(GetNextToken());
1617   expected.set_bucket_data.Init(kBucketId, kHeaderSize, kStringSize + 1,
1618                                 mem1.id, mem1.offset);
1619   expected.set_token2.Init(GetNextToken());
1620   expected.shader_source_bucket.Init(1, kBucketId);
1621   expected.clear_bucket_size.Init(kBucketId, 0);
1622   const char* kStrings[] = {kString};
1623   const GLint kLength[] = {kStringSize};
1624   gl_->ShaderSource(1, 1, kStrings, kLength);
1625   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1626 }
1627 
TEST_F(GLES2ImplementationTest,StencilFunc)1628 TEST_F(GLES2ImplementationTest, StencilFunc) {
1629   struct Cmds {
1630     cmds::StencilFunc cmd;
1631   };
1632   Cmds expected;
1633   expected.cmd.Init(GL_NEVER, 2, 3);
1634 
1635   gl_->StencilFunc(GL_NEVER, 2, 3);
1636   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1637 }
1638 
TEST_F(GLES2ImplementationTest,StencilFuncSeparate)1639 TEST_F(GLES2ImplementationTest, StencilFuncSeparate) {
1640   struct Cmds {
1641     cmds::StencilFuncSeparate cmd;
1642   };
1643   Cmds expected;
1644   expected.cmd.Init(GL_FRONT, GL_NEVER, 3, 4);
1645 
1646   gl_->StencilFuncSeparate(GL_FRONT, GL_NEVER, 3, 4);
1647   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1648 }
1649 
TEST_F(GLES2ImplementationTest,StencilMask)1650 TEST_F(GLES2ImplementationTest, StencilMask) {
1651   struct Cmds {
1652     cmds::StencilMask cmd;
1653   };
1654   Cmds expected;
1655   expected.cmd.Init(1);
1656 
1657   gl_->StencilMask(1);
1658   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1659 }
1660 
TEST_F(GLES2ImplementationTest,StencilMaskSeparate)1661 TEST_F(GLES2ImplementationTest, StencilMaskSeparate) {
1662   struct Cmds {
1663     cmds::StencilMaskSeparate cmd;
1664   };
1665   Cmds expected;
1666   expected.cmd.Init(GL_FRONT, 2);
1667 
1668   gl_->StencilMaskSeparate(GL_FRONT, 2);
1669   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1670 }
1671 
TEST_F(GLES2ImplementationTest,StencilOp)1672 TEST_F(GLES2ImplementationTest, StencilOp) {
1673   struct Cmds {
1674     cmds::StencilOp cmd;
1675   };
1676   Cmds expected;
1677   expected.cmd.Init(GL_KEEP, GL_INCR, GL_KEEP);
1678 
1679   gl_->StencilOp(GL_KEEP, GL_INCR, GL_KEEP);
1680   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1681 }
1682 
TEST_F(GLES2ImplementationTest,StencilOpSeparate)1683 TEST_F(GLES2ImplementationTest, StencilOpSeparate) {
1684   struct Cmds {
1685     cmds::StencilOpSeparate cmd;
1686   };
1687   Cmds expected;
1688   expected.cmd.Init(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP);
1689 
1690   gl_->StencilOpSeparate(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP);
1691   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1692 }
1693 
TEST_F(GLES2ImplementationTest,TexParameterf)1694 TEST_F(GLES2ImplementationTest, TexParameterf) {
1695   struct Cmds {
1696     cmds::TexParameterf cmd;
1697   };
1698   Cmds expected;
1699   expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1700 
1701   gl_->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1702   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1703 }
1704 
TEST_F(GLES2ImplementationTest,TexParameterfv)1705 TEST_F(GLES2ImplementationTest, TexParameterfv) {
1706   GLfloat data[1] = {0};
1707   struct Cmds {
1708     cmds::TexParameterfvImmediate cmd;
1709     GLfloat data[1];
1710   };
1711 
1712   for (int jj = 0; jj < 1; ++jj) {
1713     data[jj] = static_cast<GLfloat>(jj);
1714   }
1715   Cmds expected;
1716   expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1717   gl_->TexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1718   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1719 }
1720 
TEST_F(GLES2ImplementationTest,TexParameteri)1721 TEST_F(GLES2ImplementationTest, TexParameteri) {
1722   struct Cmds {
1723     cmds::TexParameteri cmd;
1724   };
1725   Cmds expected;
1726   expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1727 
1728   gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1729   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1730 }
1731 
TEST_F(GLES2ImplementationTest,TexParameteriv)1732 TEST_F(GLES2ImplementationTest, TexParameteriv) {
1733   GLint data[1] = {0};
1734   struct Cmds {
1735     cmds::TexParameterivImmediate cmd;
1736     GLint data[1];
1737   };
1738 
1739   for (int jj = 0; jj < 1; ++jj) {
1740     data[jj] = static_cast<GLint>(jj);
1741   }
1742   Cmds expected;
1743   expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1744   gl_->TexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1745   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1746 }
1747 
TEST_F(GLES2ImplementationTest,TexStorage3D)1748 TEST_F(GLES2ImplementationTest, TexStorage3D) {
1749   struct Cmds {
1750     cmds::TexStorage3D cmd;
1751   };
1752   Cmds expected;
1753   expected.cmd.Init(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6);
1754 
1755   gl_->TexStorage3D(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6);
1756   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1757 }
1758 
TEST_F(GLES2ImplementationTest,TransformFeedbackVaryings)1759 TEST_F(GLES2ImplementationTest, TransformFeedbackVaryings) {
1760   const uint32_t kBucketId = GLES2Implementation::kResultBucketId;
1761   const char* kString1 = "happy";
1762   const char* kString2 = "ending";
1763   const size_t kString1Size = ::strlen(kString1) + 1;
1764   const size_t kString2Size = ::strlen(kString2) + 1;
1765   const size_t kHeaderSize = sizeof(GLint) * 3;
1766   const size_t kSourceSize = kHeaderSize + kString1Size + kString2Size;
1767   const size_t kPaddedHeaderSize =
1768       transfer_buffer_->RoundToAlignment(kHeaderSize);
1769   const size_t kPaddedString1Size =
1770       transfer_buffer_->RoundToAlignment(kString1Size);
1771   const size_t kPaddedString2Size =
1772       transfer_buffer_->RoundToAlignment(kString2Size);
1773   struct Cmds {
1774     cmd::SetBucketSize set_bucket_size;
1775     cmd::SetBucketData set_bucket_header;
1776     cmd::SetToken set_token1;
1777     cmd::SetBucketData set_bucket_data1;
1778     cmd::SetToken set_token2;
1779     cmd::SetBucketData set_bucket_data2;
1780     cmd::SetToken set_token3;
1781     cmds::TransformFeedbackVaryingsBucket cmd_bucket;
1782     cmd::SetBucketSize clear_bucket_size;
1783   };
1784 
1785   ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1786   ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedString1Size);
1787   ExpectedMemoryInfo mem2 = GetExpectedMemory(kPaddedString2Size);
1788 
1789   Cmds expected;
1790   expected.set_bucket_size.Init(kBucketId, kSourceSize);
1791   expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1792                                   mem0.offset);
1793   expected.set_token1.Init(GetNextToken());
1794   expected.set_bucket_data1.Init(kBucketId, kHeaderSize, kString1Size, mem1.id,
1795                                  mem1.offset);
1796   expected.set_token2.Init(GetNextToken());
1797   expected.set_bucket_data2.Init(kBucketId, kHeaderSize + kString1Size,
1798                                  kString2Size, mem2.id, mem2.offset);
1799   expected.set_token3.Init(GetNextToken());
1800   expected.cmd_bucket.Init(1, kBucketId, GL_INTERLEAVED_ATTRIBS);
1801   expected.clear_bucket_size.Init(kBucketId, 0);
1802   const char* kStrings[] = {kString1, kString2};
1803   gl_->TransformFeedbackVaryings(1, 2, kStrings, GL_INTERLEAVED_ATTRIBS);
1804   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1805 }
1806 
TEST_F(GLES2ImplementationTest,Uniform1f)1807 TEST_F(GLES2ImplementationTest, Uniform1f) {
1808   struct Cmds {
1809     cmds::Uniform1f cmd;
1810   };
1811   Cmds expected;
1812   expected.cmd.Init(1, 2);
1813 
1814   gl_->Uniform1f(1, 2);
1815   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1816 }
1817 
TEST_F(GLES2ImplementationTest,Uniform1fv)1818 TEST_F(GLES2ImplementationTest, Uniform1fv) {
1819   GLfloat data[2][1] = {{0}};
1820   struct Cmds {
1821     cmds::Uniform1fvImmediate cmd;
1822     GLfloat data[2][1];
1823   };
1824 
1825   Cmds expected;
1826   for (int ii = 0; ii < 2; ++ii) {
1827     for (int jj = 0; jj < 1; ++jj) {
1828       data[ii][jj] = static_cast<GLfloat>(ii * 1 + jj);
1829     }
1830   }
1831   expected.cmd.Init(1, 2, &data[0][0]);
1832   gl_->Uniform1fv(1, 2, &data[0][0]);
1833   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1834 }
1835 
TEST_F(GLES2ImplementationTest,Uniform1i)1836 TEST_F(GLES2ImplementationTest, Uniform1i) {
1837   struct Cmds {
1838     cmds::Uniform1i cmd;
1839   };
1840   Cmds expected;
1841   expected.cmd.Init(1, 2);
1842 
1843   gl_->Uniform1i(1, 2);
1844   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1845 }
1846 
TEST_F(GLES2ImplementationTest,Uniform1iv)1847 TEST_F(GLES2ImplementationTest, Uniform1iv) {
1848   GLint data[2][1] = {{0}};
1849   struct Cmds {
1850     cmds::Uniform1ivImmediate cmd;
1851     GLint data[2][1];
1852   };
1853 
1854   Cmds expected;
1855   for (int ii = 0; ii < 2; ++ii) {
1856     for (int jj = 0; jj < 1; ++jj) {
1857       data[ii][jj] = static_cast<GLint>(ii * 1 + jj);
1858     }
1859   }
1860   expected.cmd.Init(1, 2, &data[0][0]);
1861   gl_->Uniform1iv(1, 2, &data[0][0]);
1862   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1863 }
1864 
TEST_F(GLES2ImplementationTest,Uniform1ui)1865 TEST_F(GLES2ImplementationTest, Uniform1ui) {
1866   struct Cmds {
1867     cmds::Uniform1ui cmd;
1868   };
1869   Cmds expected;
1870   expected.cmd.Init(1, 2);
1871 
1872   gl_->Uniform1ui(1, 2);
1873   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1874 }
1875 
TEST_F(GLES2ImplementationTest,Uniform1uiv)1876 TEST_F(GLES2ImplementationTest, Uniform1uiv) {
1877   GLuint data[2][1] = {{0}};
1878   struct Cmds {
1879     cmds::Uniform1uivImmediate cmd;
1880     GLuint data[2][1];
1881   };
1882 
1883   Cmds expected;
1884   for (int ii = 0; ii < 2; ++ii) {
1885     for (int jj = 0; jj < 1; ++jj) {
1886       data[ii][jj] = static_cast<GLuint>(ii * 1 + jj);
1887     }
1888   }
1889   expected.cmd.Init(1, 2, &data[0][0]);
1890   gl_->Uniform1uiv(1, 2, &data[0][0]);
1891   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1892 }
1893 
TEST_F(GLES2ImplementationTest,Uniform2f)1894 TEST_F(GLES2ImplementationTest, Uniform2f) {
1895   struct Cmds {
1896     cmds::Uniform2f cmd;
1897   };
1898   Cmds expected;
1899   expected.cmd.Init(1, 2, 3);
1900 
1901   gl_->Uniform2f(1, 2, 3);
1902   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1903 }
1904 
TEST_F(GLES2ImplementationTest,Uniform2fv)1905 TEST_F(GLES2ImplementationTest, Uniform2fv) {
1906   GLfloat data[2][2] = {{0}};
1907   struct Cmds {
1908     cmds::Uniform2fvImmediate cmd;
1909     GLfloat data[2][2];
1910   };
1911 
1912   Cmds expected;
1913   for (int ii = 0; ii < 2; ++ii) {
1914     for (int jj = 0; jj < 2; ++jj) {
1915       data[ii][jj] = static_cast<GLfloat>(ii * 2 + jj);
1916     }
1917   }
1918   expected.cmd.Init(1, 2, &data[0][0]);
1919   gl_->Uniform2fv(1, 2, &data[0][0]);
1920   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1921 }
1922 
TEST_F(GLES2ImplementationTest,Uniform2i)1923 TEST_F(GLES2ImplementationTest, Uniform2i) {
1924   struct Cmds {
1925     cmds::Uniform2i cmd;
1926   };
1927   Cmds expected;
1928   expected.cmd.Init(1, 2, 3);
1929 
1930   gl_->Uniform2i(1, 2, 3);
1931   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1932 }
1933 
TEST_F(GLES2ImplementationTest,Uniform2iv)1934 TEST_F(GLES2ImplementationTest, Uniform2iv) {
1935   GLint data[2][2] = {{0}};
1936   struct Cmds {
1937     cmds::Uniform2ivImmediate cmd;
1938     GLint data[2][2];
1939   };
1940 
1941   Cmds expected;
1942   for (int ii = 0; ii < 2; ++ii) {
1943     for (int jj = 0; jj < 2; ++jj) {
1944       data[ii][jj] = static_cast<GLint>(ii * 2 + jj);
1945     }
1946   }
1947   expected.cmd.Init(1, 2, &data[0][0]);
1948   gl_->Uniform2iv(1, 2, &data[0][0]);
1949   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1950 }
1951 
TEST_F(GLES2ImplementationTest,Uniform2ui)1952 TEST_F(GLES2ImplementationTest, Uniform2ui) {
1953   struct Cmds {
1954     cmds::Uniform2ui cmd;
1955   };
1956   Cmds expected;
1957   expected.cmd.Init(1, 2, 3);
1958 
1959   gl_->Uniform2ui(1, 2, 3);
1960   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1961 }
1962 
TEST_F(GLES2ImplementationTest,Uniform2uiv)1963 TEST_F(GLES2ImplementationTest, Uniform2uiv) {
1964   GLuint data[2][2] = {{0}};
1965   struct Cmds {
1966     cmds::Uniform2uivImmediate cmd;
1967     GLuint data[2][2];
1968   };
1969 
1970   Cmds expected;
1971   for (int ii = 0; ii < 2; ++ii) {
1972     for (int jj = 0; jj < 2; ++jj) {
1973       data[ii][jj] = static_cast<GLuint>(ii * 2 + jj);
1974     }
1975   }
1976   expected.cmd.Init(1, 2, &data[0][0]);
1977   gl_->Uniform2uiv(1, 2, &data[0][0]);
1978   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1979 }
1980 
TEST_F(GLES2ImplementationTest,Uniform3f)1981 TEST_F(GLES2ImplementationTest, Uniform3f) {
1982   struct Cmds {
1983     cmds::Uniform3f cmd;
1984   };
1985   Cmds expected;
1986   expected.cmd.Init(1, 2, 3, 4);
1987 
1988   gl_->Uniform3f(1, 2, 3, 4);
1989   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1990 }
1991 
TEST_F(GLES2ImplementationTest,Uniform3fv)1992 TEST_F(GLES2ImplementationTest, Uniform3fv) {
1993   GLfloat data[2][3] = {{0}};
1994   struct Cmds {
1995     cmds::Uniform3fvImmediate cmd;
1996     GLfloat data[2][3];
1997   };
1998 
1999   Cmds expected;
2000   for (int ii = 0; ii < 2; ++ii) {
2001     for (int jj = 0; jj < 3; ++jj) {
2002       data[ii][jj] = static_cast<GLfloat>(ii * 3 + jj);
2003     }
2004   }
2005   expected.cmd.Init(1, 2, &data[0][0]);
2006   gl_->Uniform3fv(1, 2, &data[0][0]);
2007   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2008 }
2009 
TEST_F(GLES2ImplementationTest,Uniform3i)2010 TEST_F(GLES2ImplementationTest, Uniform3i) {
2011   struct Cmds {
2012     cmds::Uniform3i cmd;
2013   };
2014   Cmds expected;
2015   expected.cmd.Init(1, 2, 3, 4);
2016 
2017   gl_->Uniform3i(1, 2, 3, 4);
2018   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2019 }
2020 
TEST_F(GLES2ImplementationTest,Uniform3iv)2021 TEST_F(GLES2ImplementationTest, Uniform3iv) {
2022   GLint data[2][3] = {{0}};
2023   struct Cmds {
2024     cmds::Uniform3ivImmediate cmd;
2025     GLint data[2][3];
2026   };
2027 
2028   Cmds expected;
2029   for (int ii = 0; ii < 2; ++ii) {
2030     for (int jj = 0; jj < 3; ++jj) {
2031       data[ii][jj] = static_cast<GLint>(ii * 3 + jj);
2032     }
2033   }
2034   expected.cmd.Init(1, 2, &data[0][0]);
2035   gl_->Uniform3iv(1, 2, &data[0][0]);
2036   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2037 }
2038 
TEST_F(GLES2ImplementationTest,Uniform3ui)2039 TEST_F(GLES2ImplementationTest, Uniform3ui) {
2040   struct Cmds {
2041     cmds::Uniform3ui cmd;
2042   };
2043   Cmds expected;
2044   expected.cmd.Init(1, 2, 3, 4);
2045 
2046   gl_->Uniform3ui(1, 2, 3, 4);
2047   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2048 }
2049 
TEST_F(GLES2ImplementationTest,Uniform3uiv)2050 TEST_F(GLES2ImplementationTest, Uniform3uiv) {
2051   GLuint data[2][3] = {{0}};
2052   struct Cmds {
2053     cmds::Uniform3uivImmediate cmd;
2054     GLuint data[2][3];
2055   };
2056 
2057   Cmds expected;
2058   for (int ii = 0; ii < 2; ++ii) {
2059     for (int jj = 0; jj < 3; ++jj) {
2060       data[ii][jj] = static_cast<GLuint>(ii * 3 + jj);
2061     }
2062   }
2063   expected.cmd.Init(1, 2, &data[0][0]);
2064   gl_->Uniform3uiv(1, 2, &data[0][0]);
2065   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2066 }
2067 
TEST_F(GLES2ImplementationTest,Uniform4f)2068 TEST_F(GLES2ImplementationTest, Uniform4f) {
2069   struct Cmds {
2070     cmds::Uniform4f cmd;
2071   };
2072   Cmds expected;
2073   expected.cmd.Init(1, 2, 3, 4, 5);
2074 
2075   gl_->Uniform4f(1, 2, 3, 4, 5);
2076   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2077 }
2078 
TEST_F(GLES2ImplementationTest,Uniform4fv)2079 TEST_F(GLES2ImplementationTest, Uniform4fv) {
2080   GLfloat data[2][4] = {{0}};
2081   struct Cmds {
2082     cmds::Uniform4fvImmediate cmd;
2083     GLfloat data[2][4];
2084   };
2085 
2086   Cmds expected;
2087   for (int ii = 0; ii < 2; ++ii) {
2088     for (int jj = 0; jj < 4; ++jj) {
2089       data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
2090     }
2091   }
2092   expected.cmd.Init(1, 2, &data[0][0]);
2093   gl_->Uniform4fv(1, 2, &data[0][0]);
2094   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2095 }
2096 
TEST_F(GLES2ImplementationTest,Uniform4i)2097 TEST_F(GLES2ImplementationTest, Uniform4i) {
2098   struct Cmds {
2099     cmds::Uniform4i cmd;
2100   };
2101   Cmds expected;
2102   expected.cmd.Init(1, 2, 3, 4, 5);
2103 
2104   gl_->Uniform4i(1, 2, 3, 4, 5);
2105   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2106 }
2107 
TEST_F(GLES2ImplementationTest,Uniform4iv)2108 TEST_F(GLES2ImplementationTest, Uniform4iv) {
2109   GLint data[2][4] = {{0}};
2110   struct Cmds {
2111     cmds::Uniform4ivImmediate cmd;
2112     GLint data[2][4];
2113   };
2114 
2115   Cmds expected;
2116   for (int ii = 0; ii < 2; ++ii) {
2117     for (int jj = 0; jj < 4; ++jj) {
2118       data[ii][jj] = static_cast<GLint>(ii * 4 + jj);
2119     }
2120   }
2121   expected.cmd.Init(1, 2, &data[0][0]);
2122   gl_->Uniform4iv(1, 2, &data[0][0]);
2123   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2124 }
2125 
TEST_F(GLES2ImplementationTest,Uniform4ui)2126 TEST_F(GLES2ImplementationTest, Uniform4ui) {
2127   struct Cmds {
2128     cmds::Uniform4ui cmd;
2129   };
2130   Cmds expected;
2131   expected.cmd.Init(1, 2, 3, 4, 5);
2132 
2133   gl_->Uniform4ui(1, 2, 3, 4, 5);
2134   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2135 }
2136 
TEST_F(GLES2ImplementationTest,Uniform4uiv)2137 TEST_F(GLES2ImplementationTest, Uniform4uiv) {
2138   GLuint data[2][4] = {{0}};
2139   struct Cmds {
2140     cmds::Uniform4uivImmediate cmd;
2141     GLuint data[2][4];
2142   };
2143 
2144   Cmds expected;
2145   for (int ii = 0; ii < 2; ++ii) {
2146     for (int jj = 0; jj < 4; ++jj) {
2147       data[ii][jj] = static_cast<GLuint>(ii * 4 + jj);
2148     }
2149   }
2150   expected.cmd.Init(1, 2, &data[0][0]);
2151   gl_->Uniform4uiv(1, 2, &data[0][0]);
2152   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2153 }
2154 
TEST_F(GLES2ImplementationTest,UniformBlockBinding)2155 TEST_F(GLES2ImplementationTest, UniformBlockBinding) {
2156   struct Cmds {
2157     cmds::UniformBlockBinding cmd;
2158   };
2159   Cmds expected;
2160   expected.cmd.Init(1, 2, 3);
2161 
2162   gl_->UniformBlockBinding(1, 2, 3);
2163   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2164 }
2165 
TEST_F(GLES2ImplementationTest,UniformMatrix2fv)2166 TEST_F(GLES2ImplementationTest, UniformMatrix2fv) {
2167   GLfloat data[2][4] = {{0}};
2168   struct Cmds {
2169     cmds::UniformMatrix2fvImmediate cmd;
2170     GLfloat data[2][4];
2171   };
2172 
2173   Cmds expected;
2174   for (int ii = 0; ii < 2; ++ii) {
2175     for (int jj = 0; jj < 4; ++jj) {
2176       data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
2177     }
2178   }
2179   expected.cmd.Init(1, 2, true, &data[0][0]);
2180   gl_->UniformMatrix2fv(1, 2, true, &data[0][0]);
2181   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2182 }
2183 
TEST_F(GLES2ImplementationTest,UniformMatrix2x3fv)2184 TEST_F(GLES2ImplementationTest, UniformMatrix2x3fv) {
2185   GLfloat data[2][6] = {{0}};
2186   struct Cmds {
2187     cmds::UniformMatrix2x3fvImmediate cmd;
2188     GLfloat data[2][6];
2189   };
2190 
2191   Cmds expected;
2192   for (int ii = 0; ii < 2; ++ii) {
2193     for (int jj = 0; jj < 6; ++jj) {
2194       data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2195     }
2196   }
2197   expected.cmd.Init(1, 2, true, &data[0][0]);
2198   gl_->UniformMatrix2x3fv(1, 2, true, &data[0][0]);
2199   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2200 }
2201 
TEST_F(GLES2ImplementationTest,UniformMatrix2x4fv)2202 TEST_F(GLES2ImplementationTest, UniformMatrix2x4fv) {
2203   GLfloat data[2][8] = {{0}};
2204   struct Cmds {
2205     cmds::UniformMatrix2x4fvImmediate cmd;
2206     GLfloat data[2][8];
2207   };
2208 
2209   Cmds expected;
2210   for (int ii = 0; ii < 2; ++ii) {
2211     for (int jj = 0; jj < 8; ++jj) {
2212       data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2213     }
2214   }
2215   expected.cmd.Init(1, 2, true, &data[0][0]);
2216   gl_->UniformMatrix2x4fv(1, 2, true, &data[0][0]);
2217   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2218 }
2219 
TEST_F(GLES2ImplementationTest,UniformMatrix3fv)2220 TEST_F(GLES2ImplementationTest, UniformMatrix3fv) {
2221   GLfloat data[2][9] = {{0}};
2222   struct Cmds {
2223     cmds::UniformMatrix3fvImmediate cmd;
2224     GLfloat data[2][9];
2225   };
2226 
2227   Cmds expected;
2228   for (int ii = 0; ii < 2; ++ii) {
2229     for (int jj = 0; jj < 9; ++jj) {
2230       data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj);
2231     }
2232   }
2233   expected.cmd.Init(1, 2, true, &data[0][0]);
2234   gl_->UniformMatrix3fv(1, 2, true, &data[0][0]);
2235   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2236 }
2237 
TEST_F(GLES2ImplementationTest,UniformMatrix3x2fv)2238 TEST_F(GLES2ImplementationTest, UniformMatrix3x2fv) {
2239   GLfloat data[2][6] = {{0}};
2240   struct Cmds {
2241     cmds::UniformMatrix3x2fvImmediate cmd;
2242     GLfloat data[2][6];
2243   };
2244 
2245   Cmds expected;
2246   for (int ii = 0; ii < 2; ++ii) {
2247     for (int jj = 0; jj < 6; ++jj) {
2248       data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2249     }
2250   }
2251   expected.cmd.Init(1, 2, true, &data[0][0]);
2252   gl_->UniformMatrix3x2fv(1, 2, true, &data[0][0]);
2253   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2254 }
2255 
TEST_F(GLES2ImplementationTest,UniformMatrix3x4fv)2256 TEST_F(GLES2ImplementationTest, UniformMatrix3x4fv) {
2257   GLfloat data[2][12] = {{0}};
2258   struct Cmds {
2259     cmds::UniformMatrix3x4fvImmediate cmd;
2260     GLfloat data[2][12];
2261   };
2262 
2263   Cmds expected;
2264   for (int ii = 0; ii < 2; ++ii) {
2265     for (int jj = 0; jj < 12; ++jj) {
2266       data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2267     }
2268   }
2269   expected.cmd.Init(1, 2, true, &data[0][0]);
2270   gl_->UniformMatrix3x4fv(1, 2, true, &data[0][0]);
2271   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2272 }
2273 
TEST_F(GLES2ImplementationTest,UniformMatrix4fv)2274 TEST_F(GLES2ImplementationTest, UniformMatrix4fv) {
2275   GLfloat data[2][16] = {{0}};
2276   struct Cmds {
2277     cmds::UniformMatrix4fvImmediate cmd;
2278     GLfloat data[2][16];
2279   };
2280 
2281   Cmds expected;
2282   for (int ii = 0; ii < 2; ++ii) {
2283     for (int jj = 0; jj < 16; ++jj) {
2284       data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj);
2285     }
2286   }
2287   expected.cmd.Init(1, 2, true, &data[0][0]);
2288   gl_->UniformMatrix4fv(1, 2, true, &data[0][0]);
2289   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2290 }
2291 
TEST_F(GLES2ImplementationTest,UniformMatrix4x2fv)2292 TEST_F(GLES2ImplementationTest, UniformMatrix4x2fv) {
2293   GLfloat data[2][8] = {{0}};
2294   struct Cmds {
2295     cmds::UniformMatrix4x2fvImmediate cmd;
2296     GLfloat data[2][8];
2297   };
2298 
2299   Cmds expected;
2300   for (int ii = 0; ii < 2; ++ii) {
2301     for (int jj = 0; jj < 8; ++jj) {
2302       data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2303     }
2304   }
2305   expected.cmd.Init(1, 2, true, &data[0][0]);
2306   gl_->UniformMatrix4x2fv(1, 2, true, &data[0][0]);
2307   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2308 }
2309 
TEST_F(GLES2ImplementationTest,UniformMatrix4x3fv)2310 TEST_F(GLES2ImplementationTest, UniformMatrix4x3fv) {
2311   GLfloat data[2][12] = {{0}};
2312   struct Cmds {
2313     cmds::UniformMatrix4x3fvImmediate cmd;
2314     GLfloat data[2][12];
2315   };
2316 
2317   Cmds expected;
2318   for (int ii = 0; ii < 2; ++ii) {
2319     for (int jj = 0; jj < 12; ++jj) {
2320       data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2321     }
2322   }
2323   expected.cmd.Init(1, 2, true, &data[0][0]);
2324   gl_->UniformMatrix4x3fv(1, 2, true, &data[0][0]);
2325   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2326 }
2327 
TEST_F(GLES2ImplementationTest,UseProgram)2328 TEST_F(GLES2ImplementationTest, UseProgram) {
2329   struct Cmds {
2330     cmds::UseProgram cmd;
2331   };
2332   Cmds expected;
2333   expected.cmd.Init(1);
2334 
2335   gl_->UseProgram(1);
2336   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2337   ClearCommands();
2338   gl_->UseProgram(1);
2339   EXPECT_TRUE(NoCommandsWritten());
2340 }
2341 
TEST_F(GLES2ImplementationTest,ValidateProgram)2342 TEST_F(GLES2ImplementationTest, ValidateProgram) {
2343   struct Cmds {
2344     cmds::ValidateProgram cmd;
2345   };
2346   Cmds expected;
2347   expected.cmd.Init(1);
2348 
2349   gl_->ValidateProgram(1);
2350   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2351 }
2352 
TEST_F(GLES2ImplementationTest,VertexAttrib1f)2353 TEST_F(GLES2ImplementationTest, VertexAttrib1f) {
2354   struct Cmds {
2355     cmds::VertexAttrib1f cmd;
2356   };
2357   Cmds expected;
2358   expected.cmd.Init(1, 2);
2359 
2360   gl_->VertexAttrib1f(1, 2);
2361   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2362 }
2363 
TEST_F(GLES2ImplementationTest,VertexAttrib1fv)2364 TEST_F(GLES2ImplementationTest, VertexAttrib1fv) {
2365   GLfloat data[1] = {0};
2366   struct Cmds {
2367     cmds::VertexAttrib1fvImmediate cmd;
2368     GLfloat data[1];
2369   };
2370 
2371   for (int jj = 0; jj < 1; ++jj) {
2372     data[jj] = static_cast<GLfloat>(jj);
2373   }
2374   Cmds expected;
2375   expected.cmd.Init(1, &data[0]);
2376   gl_->VertexAttrib1fv(1, &data[0]);
2377   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2378 }
2379 
TEST_F(GLES2ImplementationTest,VertexAttrib2f)2380 TEST_F(GLES2ImplementationTest, VertexAttrib2f) {
2381   struct Cmds {
2382     cmds::VertexAttrib2f cmd;
2383   };
2384   Cmds expected;
2385   expected.cmd.Init(1, 2, 3);
2386 
2387   gl_->VertexAttrib2f(1, 2, 3);
2388   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2389 }
2390 
TEST_F(GLES2ImplementationTest,VertexAttrib2fv)2391 TEST_F(GLES2ImplementationTest, VertexAttrib2fv) {
2392   GLfloat data[2] = {0};
2393   struct Cmds {
2394     cmds::VertexAttrib2fvImmediate cmd;
2395     GLfloat data[2];
2396   };
2397 
2398   for (int jj = 0; jj < 2; ++jj) {
2399     data[jj] = static_cast<GLfloat>(jj);
2400   }
2401   Cmds expected;
2402   expected.cmd.Init(1, &data[0]);
2403   gl_->VertexAttrib2fv(1, &data[0]);
2404   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2405 }
2406 
TEST_F(GLES2ImplementationTest,VertexAttrib3f)2407 TEST_F(GLES2ImplementationTest, VertexAttrib3f) {
2408   struct Cmds {
2409     cmds::VertexAttrib3f cmd;
2410   };
2411   Cmds expected;
2412   expected.cmd.Init(1, 2, 3, 4);
2413 
2414   gl_->VertexAttrib3f(1, 2, 3, 4);
2415   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2416 }
2417 
TEST_F(GLES2ImplementationTest,VertexAttrib3fv)2418 TEST_F(GLES2ImplementationTest, VertexAttrib3fv) {
2419   GLfloat data[3] = {0};
2420   struct Cmds {
2421     cmds::VertexAttrib3fvImmediate cmd;
2422     GLfloat data[3];
2423   };
2424 
2425   for (int jj = 0; jj < 3; ++jj) {
2426     data[jj] = static_cast<GLfloat>(jj);
2427   }
2428   Cmds expected;
2429   expected.cmd.Init(1, &data[0]);
2430   gl_->VertexAttrib3fv(1, &data[0]);
2431   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2432 }
2433 
TEST_F(GLES2ImplementationTest,VertexAttrib4f)2434 TEST_F(GLES2ImplementationTest, VertexAttrib4f) {
2435   struct Cmds {
2436     cmds::VertexAttrib4f cmd;
2437   };
2438   Cmds expected;
2439   expected.cmd.Init(1, 2, 3, 4, 5);
2440 
2441   gl_->VertexAttrib4f(1, 2, 3, 4, 5);
2442   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2443 }
2444 
TEST_F(GLES2ImplementationTest,VertexAttrib4fv)2445 TEST_F(GLES2ImplementationTest, VertexAttrib4fv) {
2446   GLfloat data[4] = {0};
2447   struct Cmds {
2448     cmds::VertexAttrib4fvImmediate cmd;
2449     GLfloat data[4];
2450   };
2451 
2452   for (int jj = 0; jj < 4; ++jj) {
2453     data[jj] = static_cast<GLfloat>(jj);
2454   }
2455   Cmds expected;
2456   expected.cmd.Init(1, &data[0]);
2457   gl_->VertexAttrib4fv(1, &data[0]);
2458   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2459 }
2460 
TEST_F(GLES2ImplementationTest,VertexAttribI4i)2461 TEST_F(GLES2ImplementationTest, VertexAttribI4i) {
2462   struct Cmds {
2463     cmds::VertexAttribI4i cmd;
2464   };
2465   Cmds expected;
2466   expected.cmd.Init(1, 2, 3, 4, 5);
2467 
2468   gl_->VertexAttribI4i(1, 2, 3, 4, 5);
2469   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2470 }
2471 
TEST_F(GLES2ImplementationTest,VertexAttribI4iv)2472 TEST_F(GLES2ImplementationTest, VertexAttribI4iv) {
2473   GLint data[4] = {0};
2474   struct Cmds {
2475     cmds::VertexAttribI4ivImmediate cmd;
2476     GLint data[4];
2477   };
2478 
2479   for (int jj = 0; jj < 4; ++jj) {
2480     data[jj] = static_cast<GLint>(jj);
2481   }
2482   Cmds expected;
2483   expected.cmd.Init(1, &data[0]);
2484   gl_->VertexAttribI4iv(1, &data[0]);
2485   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2486 }
2487 
TEST_F(GLES2ImplementationTest,VertexAttribI4ui)2488 TEST_F(GLES2ImplementationTest, VertexAttribI4ui) {
2489   struct Cmds {
2490     cmds::VertexAttribI4ui cmd;
2491   };
2492   Cmds expected;
2493   expected.cmd.Init(1, 2, 3, 4, 5);
2494 
2495   gl_->VertexAttribI4ui(1, 2, 3, 4, 5);
2496   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2497 }
2498 
TEST_F(GLES2ImplementationTest,VertexAttribI4uiv)2499 TEST_F(GLES2ImplementationTest, VertexAttribI4uiv) {
2500   GLuint data[4] = {0};
2501   struct Cmds {
2502     cmds::VertexAttribI4uivImmediate cmd;
2503     GLuint data[4];
2504   };
2505 
2506   for (int jj = 0; jj < 4; ++jj) {
2507     data[jj] = static_cast<GLuint>(jj);
2508   }
2509   Cmds expected;
2510   expected.cmd.Init(1, &data[0]);
2511   gl_->VertexAttribI4uiv(1, &data[0]);
2512   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2513 }
2514 
TEST_F(GLES2ImplementationTest,Viewport)2515 TEST_F(GLES2ImplementationTest, Viewport) {
2516   struct Cmds {
2517     cmds::Viewport cmd;
2518   };
2519   Cmds expected;
2520   expected.cmd.Init(1, 2, 3, 4);
2521 
2522   gl_->Viewport(1, 2, 3, 4);
2523   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2524 }
2525 
TEST_F(GLES2ImplementationTest,BlitFramebufferCHROMIUM)2526 TEST_F(GLES2ImplementationTest, BlitFramebufferCHROMIUM) {
2527   struct Cmds {
2528     cmds::BlitFramebufferCHROMIUM cmd;
2529   };
2530   Cmds expected;
2531   expected.cmd.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
2532 
2533   gl_->BlitFramebufferCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
2534   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2535 }
2536 
TEST_F(GLES2ImplementationTest,RenderbufferStorageMultisampleCHROMIUM)2537 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleCHROMIUM) {
2538   struct Cmds {
2539     cmds::RenderbufferStorageMultisampleCHROMIUM cmd;
2540   };
2541   Cmds expected;
2542   expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2543 
2544   gl_->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, 2, GL_RGBA4, 4,
2545                                               5);
2546   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2547 }
2548 
TEST_F(GLES2ImplementationTest,RenderbufferStorageMultisampleAdvancedAMD)2549 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleAdvancedAMD) {
2550   struct Cmds {
2551     cmds::RenderbufferStorageMultisampleAdvancedAMD cmd;
2552   };
2553   Cmds expected;
2554   expected.cmd.Init(GL_RENDERBUFFER, 2, 3, GL_RGBA4, 5, 6);
2555 
2556   gl_->RenderbufferStorageMultisampleAdvancedAMD(GL_RENDERBUFFER, 2, 3,
2557                                                  GL_RGBA4, 5, 6);
2558   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2559 }
2560 
TEST_F(GLES2ImplementationTest,RenderbufferStorageMultisampleEXT)2561 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleEXT) {
2562   struct Cmds {
2563     cmds::RenderbufferStorageMultisampleEXT cmd;
2564   };
2565   Cmds expected;
2566   expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2567 
2568   gl_->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2569   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2570 }
2571 
TEST_F(GLES2ImplementationTest,FramebufferTexture2DMultisampleEXT)2572 TEST_F(GLES2ImplementationTest, FramebufferTexture2DMultisampleEXT) {
2573   struct Cmds {
2574     cmds::FramebufferTexture2DMultisampleEXT cmd;
2575   };
2576   Cmds expected;
2577   expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4, 5,
2578                     6);
2579 
2580   gl_->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2581                                           GL_TEXTURE_2D, 4, 5, 6);
2582   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2583 }
2584 
TEST_F(GLES2ImplementationTest,TexStorage2DEXT)2585 TEST_F(GLES2ImplementationTest, TexStorage2DEXT) {
2586   struct Cmds {
2587     cmds::TexStorage2DEXT cmd;
2588   };
2589   Cmds expected;
2590   expected.cmd.Init(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
2591 
2592   gl_->TexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
2593   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2594 }
2595 
TEST_F(GLES2ImplementationTest,GenQueriesEXT)2596 TEST_F(GLES2ImplementationTest, GenQueriesEXT) {
2597   GLuint ids[2] = {
2598       0,
2599   };
2600   struct Cmds {
2601     cmds::GenQueriesEXTImmediate gen;
2602     GLuint data[2];
2603   };
2604   Cmds expected;
2605   expected.gen.Init(base::size(ids), &ids[0]);
2606   expected.data[0] = kQueriesStartId;
2607   expected.data[1] = kQueriesStartId + 1;
2608   gl_->GenQueriesEXT(base::size(ids), &ids[0]);
2609   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2610   EXPECT_EQ(kQueriesStartId, ids[0]);
2611   EXPECT_EQ(kQueriesStartId + 1, ids[1]);
2612 }
2613 
TEST_F(GLES2ImplementationTest,DeleteQueriesEXT)2614 TEST_F(GLES2ImplementationTest, DeleteQueriesEXT) {
2615   GLuint ids[2] = {kQueriesStartId, kQueriesStartId + 1};
2616   struct Cmds {
2617     cmds::DeleteQueriesEXTImmediate del;
2618     GLuint data[2];
2619   };
2620   Cmds expected;
2621   expected.del.Init(base::size(ids), &ids[0]);
2622   expected.data[0] = kQueriesStartId;
2623   expected.data[1] = kQueriesStartId + 1;
2624   gl_->DeleteQueriesEXT(base::size(ids), &ids[0]);
2625   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2626 }
2627 
TEST_F(GLES2ImplementationTest,BeginTransformFeedback)2628 TEST_F(GLES2ImplementationTest, BeginTransformFeedback) {
2629   struct Cmds {
2630     cmds::BeginTransformFeedback cmd;
2631   };
2632   Cmds expected;
2633   expected.cmd.Init(GL_POINTS);
2634 
2635   gl_->BeginTransformFeedback(GL_POINTS);
2636   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2637 }
2638 
TEST_F(GLES2ImplementationTest,EndTransformFeedback)2639 TEST_F(GLES2ImplementationTest, EndTransformFeedback) {
2640   struct Cmds {
2641     cmds::EndTransformFeedback cmd;
2642   };
2643   Cmds expected;
2644   expected.cmd.Init();
2645 
2646   gl_->EndTransformFeedback();
2647   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2648 }
2649 
TEST_F(GLES2ImplementationTest,PopGroupMarkerEXT)2650 TEST_F(GLES2ImplementationTest, PopGroupMarkerEXT) {
2651   struct Cmds {
2652     cmds::PopGroupMarkerEXT cmd;
2653   };
2654   Cmds expected;
2655   expected.cmd.Init();
2656 
2657   gl_->PopGroupMarkerEXT();
2658   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2659 }
2660 
TEST_F(GLES2ImplementationTest,GenVertexArraysOES)2661 TEST_F(GLES2ImplementationTest, GenVertexArraysOES) {
2662   GLuint ids[2] = {
2663       0,
2664   };
2665   struct Cmds {
2666     cmds::GenVertexArraysOESImmediate gen;
2667     GLuint data[2];
2668   };
2669   Cmds expected;
2670   expected.gen.Init(base::size(ids), &ids[0]);
2671   expected.data[0] = kVertexArraysStartId;
2672   expected.data[1] = kVertexArraysStartId + 1;
2673   gl_->GenVertexArraysOES(base::size(ids), &ids[0]);
2674   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2675   EXPECT_EQ(kVertexArraysStartId, ids[0]);
2676   EXPECT_EQ(kVertexArraysStartId + 1, ids[1]);
2677 }
2678 
TEST_F(GLES2ImplementationTest,DeleteVertexArraysOES)2679 TEST_F(GLES2ImplementationTest, DeleteVertexArraysOES) {
2680   GLuint ids[2] = {kVertexArraysStartId, kVertexArraysStartId + 1};
2681   struct Cmds {
2682     cmds::DeleteVertexArraysOESImmediate del;
2683     GLuint data[2];
2684   };
2685   Cmds expected;
2686   expected.del.Init(base::size(ids), &ids[0]);
2687   expected.data[0] = kVertexArraysStartId;
2688   expected.data[1] = kVertexArraysStartId + 1;
2689   gl_->DeleteVertexArraysOES(base::size(ids), &ids[0]);
2690   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2691 }
2692 
TEST_F(GLES2ImplementationTest,IsVertexArrayOES)2693 TEST_F(GLES2ImplementationTest, IsVertexArrayOES) {
2694   struct Cmds {
2695     cmds::IsVertexArrayOES cmd;
2696   };
2697 
2698   Cmds expected;
2699   ExpectedMemoryInfo result1 =
2700       GetExpectedResultMemory(sizeof(cmds::IsVertexArrayOES::Result));
2701   expected.cmd.Init(1, result1.id, result1.offset);
2702 
2703   EXPECT_CALL(*command_buffer(), OnFlush())
2704       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
2705       .RetiresOnSaturation();
2706 
2707   GLboolean result = gl_->IsVertexArrayOES(1);
2708   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2709   EXPECT_TRUE(result);
2710 }
2711 
TEST_F(GLES2ImplementationTest,FramebufferParameteri)2712 TEST_F(GLES2ImplementationTest, FramebufferParameteri) {
2713   struct Cmds {
2714     cmds::FramebufferParameteri cmd;
2715   };
2716   Cmds expected;
2717   expected.cmd.Init(GL_FRAMEBUFFER, 2, 3);
2718 
2719   gl_->FramebufferParameteri(GL_FRAMEBUFFER, 2, 3);
2720   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2721 }
2722 
TEST_F(GLES2ImplementationTest,BindImageTexture)2723 TEST_F(GLES2ImplementationTest, BindImageTexture) {
2724   struct Cmds {
2725     cmds::BindImageTexture cmd;
2726   };
2727   Cmds expected;
2728   expected.cmd.Init(1, 2, 3, true, 5, 6, 7);
2729 
2730   gl_->BindImageTexture(1, 2, 3, true, 5, 6, 7);
2731   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2732 }
2733 
TEST_F(GLES2ImplementationTest,DispatchCompute)2734 TEST_F(GLES2ImplementationTest, DispatchCompute) {
2735   struct Cmds {
2736     cmds::DispatchCompute cmd;
2737   };
2738   Cmds expected;
2739   expected.cmd.Init(1, 2, 3);
2740 
2741   gl_->DispatchCompute(1, 2, 3);
2742   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2743 }
2744 
TEST_F(GLES2ImplementationTest,DispatchComputeIndirect)2745 TEST_F(GLES2ImplementationTest, DispatchComputeIndirect) {
2746   struct Cmds {
2747     cmds::DispatchComputeIndirect cmd;
2748   };
2749   Cmds expected;
2750   expected.cmd.Init(1);
2751 
2752   gl_->DispatchComputeIndirect(1);
2753   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2754 }
2755 
TEST_F(GLES2ImplementationTest,GetProgramInterfaceiv)2756 TEST_F(GLES2ImplementationTest, GetProgramInterfaceiv) {
2757   struct Cmds {
2758     cmds::GetProgramInterfaceiv cmd;
2759   };
2760   typedef cmds::GetProgramInterfaceiv::Result::Type ResultType;
2761   ResultType result = 0;
2762   Cmds expected;
2763   ExpectedMemoryInfo result1 =
2764       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
2765   expected.cmd.Init(123, 2, 3, result1.id, result1.offset);
2766   EXPECT_CALL(*command_buffer(), OnFlush())
2767       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
2768       .RetiresOnSaturation();
2769   gl_->GetProgramInterfaceiv(123, 2, 3, &result);
2770   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2771   EXPECT_EQ(static_cast<ResultType>(1), result);
2772 }
2773 
TEST_F(GLES2ImplementationTest,MemoryBarrierEXT)2774 TEST_F(GLES2ImplementationTest, MemoryBarrierEXT) {
2775   struct Cmds {
2776     cmds::MemoryBarrierEXT cmd;
2777   };
2778   Cmds expected;
2779   expected.cmd.Init(1);
2780 
2781   gl_->MemoryBarrierEXT(1);
2782   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2783 }
2784 
TEST_F(GLES2ImplementationTest,MemoryBarrierByRegion)2785 TEST_F(GLES2ImplementationTest, MemoryBarrierByRegion) {
2786   struct Cmds {
2787     cmds::MemoryBarrierByRegion cmd;
2788   };
2789   Cmds expected;
2790   expected.cmd.Init(1);
2791 
2792   gl_->MemoryBarrierByRegion(1);
2793   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2794 }
2795 
TEST_F(GLES2ImplementationTest,FlushMappedBufferRange)2796 TEST_F(GLES2ImplementationTest, FlushMappedBufferRange) {
2797   struct Cmds {
2798     cmds::FlushMappedBufferRange cmd;
2799   };
2800   Cmds expected;
2801   expected.cmd.Init(GL_ARRAY_BUFFER, 2, 3);
2802 
2803   gl_->FlushMappedBufferRange(GL_ARRAY_BUFFER, 2, 3);
2804   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2805 }
2806 
TEST_F(GLES2ImplementationTest,DescheduleUntilFinishedCHROMIUM)2807 TEST_F(GLES2ImplementationTest, DescheduleUntilFinishedCHROMIUM) {
2808   struct Cmds {
2809     cmds::DescheduleUntilFinishedCHROMIUM cmd;
2810   };
2811   Cmds expected;
2812   expected.cmd.Init();
2813 
2814   gl_->DescheduleUntilFinishedCHROMIUM();
2815   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2816 }
2817 
TEST_F(GLES2ImplementationTest,CopyTextureCHROMIUM)2818 TEST_F(GLES2ImplementationTest, CopyTextureCHROMIUM) {
2819   struct Cmds {
2820     cmds::CopyTextureCHROMIUM cmd;
2821   };
2822   Cmds expected;
2823   expected.cmd.Init(1, 2, GL_TEXTURE_2D, 4, 5, GL_ALPHA, GL_UNSIGNED_BYTE, true,
2824                     true, true);
2825 
2826   gl_->CopyTextureCHROMIUM(1, 2, GL_TEXTURE_2D, 4, 5, GL_ALPHA,
2827                            GL_UNSIGNED_BYTE, true, true, true);
2828   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2829 }
2830 
TEST_F(GLES2ImplementationTest,CopySubTextureCHROMIUM)2831 TEST_F(GLES2ImplementationTest, CopySubTextureCHROMIUM) {
2832   struct Cmds {
2833     cmds::CopySubTextureCHROMIUM cmd;
2834   };
2835   Cmds expected;
2836   expected.cmd.Init(1, 2, GL_TEXTURE_2D, 4, 5, 6, 7, 8, 9, 10, 11, true, true,
2837                     true);
2838 
2839   gl_->CopySubTextureCHROMIUM(1, 2, GL_TEXTURE_2D, 4, 5, 6, 7, 8, 9, 10, 11,
2840                               true, true, true);
2841   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2842 }
2843 
TEST_F(GLES2ImplementationTest,DrawArraysInstancedANGLE)2844 TEST_F(GLES2ImplementationTest, DrawArraysInstancedANGLE) {
2845   struct Cmds {
2846     cmds::DrawArraysInstancedANGLE cmd;
2847   };
2848   Cmds expected;
2849   expected.cmd.Init(GL_POINTS, 2, 3, 4);
2850 
2851   gl_->DrawArraysInstancedANGLE(GL_POINTS, 2, 3, 4);
2852   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2853 }
2854 
TEST_F(GLES2ImplementationTest,DrawArraysInstancedBaseInstanceANGLE)2855 TEST_F(GLES2ImplementationTest, DrawArraysInstancedBaseInstanceANGLE) {
2856   struct Cmds {
2857     cmds::DrawArraysInstancedBaseInstanceANGLE cmd;
2858   };
2859   Cmds expected;
2860   expected.cmd.Init(GL_POINTS, 2, 3, 4, 5);
2861 
2862   gl_->DrawArraysInstancedBaseInstanceANGLE(GL_POINTS, 2, 3, 4, 5);
2863   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2864 }
2865 
TEST_F(GLES2ImplementationTest,VertexAttribDivisorANGLE)2866 TEST_F(GLES2ImplementationTest, VertexAttribDivisorANGLE) {
2867   struct Cmds {
2868     cmds::VertexAttribDivisorANGLE cmd;
2869   };
2870   Cmds expected;
2871   expected.cmd.Init(1, 2);
2872 
2873   gl_->VertexAttribDivisorANGLE(1, 2);
2874   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2875 }
2876 
TEST_F(GLES2ImplementationTest,BindTexImage2DCHROMIUM)2877 TEST_F(GLES2ImplementationTest, BindTexImage2DCHROMIUM) {
2878   struct Cmds {
2879     cmds::BindTexImage2DCHROMIUM cmd;
2880   };
2881   Cmds expected;
2882   expected.cmd.Init(GL_TEXTURE_2D, 2);
2883 
2884   gl_->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
2885   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2886 }
2887 
TEST_F(GLES2ImplementationTest,BindTexImage2DWithInternalformatCHROMIUM)2888 TEST_F(GLES2ImplementationTest, BindTexImage2DWithInternalformatCHROMIUM) {
2889   struct Cmds {
2890     cmds::BindTexImage2DWithInternalformatCHROMIUM cmd;
2891   };
2892   Cmds expected;
2893   expected.cmd.Init(GL_TEXTURE_2D, GL_ALPHA, 3);
2894 
2895   gl_->BindTexImage2DWithInternalformatCHROMIUM(GL_TEXTURE_2D, GL_ALPHA, 3);
2896   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2897 }
2898 
TEST_F(GLES2ImplementationTest,ReleaseTexImage2DCHROMIUM)2899 TEST_F(GLES2ImplementationTest, ReleaseTexImage2DCHROMIUM) {
2900   struct Cmds {
2901     cmds::ReleaseTexImage2DCHROMIUM cmd;
2902   };
2903   Cmds expected;
2904   expected.cmd.Init(GL_TEXTURE_2D, 2);
2905 
2906   gl_->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
2907   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2908 }
2909 
TEST_F(GLES2ImplementationTest,DiscardFramebufferEXT)2910 TEST_F(GLES2ImplementationTest, DiscardFramebufferEXT) {
2911   GLenum data[2][1] = {{0}};
2912   struct Cmds {
2913     cmds::DiscardFramebufferEXTImmediate cmd;
2914     GLenum data[2][1];
2915   };
2916 
2917   Cmds expected;
2918   for (int ii = 0; ii < 2; ++ii) {
2919     for (int jj = 0; jj < 1; ++jj) {
2920       data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
2921     }
2922   }
2923   expected.cmd.Init(GL_FRAMEBUFFER, 2, &data[0][0]);
2924   gl_->DiscardFramebufferEXT(GL_FRAMEBUFFER, 2, &data[0][0]);
2925   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2926 }
2927 
TEST_F(GLES2ImplementationTest,LoseContextCHROMIUM)2928 TEST_F(GLES2ImplementationTest, LoseContextCHROMIUM) {
2929   struct Cmds {
2930     cmds::LoseContextCHROMIUM cmd;
2931   };
2932   Cmds expected;
2933   expected.cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_GUILTY_CONTEXT_RESET_ARB);
2934 
2935   gl_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
2936                            GL_GUILTY_CONTEXT_RESET_ARB);
2937   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2938 }
2939 
TEST_F(GLES2ImplementationTest,DrawBuffersEXT)2940 TEST_F(GLES2ImplementationTest, DrawBuffersEXT) {
2941   GLenum data[1][1] = {{0}};
2942   struct Cmds {
2943     cmds::DrawBuffersEXTImmediate cmd;
2944     GLenum data[1][1];
2945   };
2946 
2947   Cmds expected;
2948   for (int ii = 0; ii < 1; ++ii) {
2949     for (int jj = 0; jj < 1; ++jj) {
2950       data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
2951     }
2952   }
2953   expected.cmd.Init(1, &data[0][0]);
2954   gl_->DrawBuffersEXT(1, &data[0][0]);
2955   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2956 }
2957 
TEST_F(GLES2ImplementationTest,DiscardBackbufferCHROMIUM)2958 TEST_F(GLES2ImplementationTest, DiscardBackbufferCHROMIUM) {
2959   struct Cmds {
2960     cmds::DiscardBackbufferCHROMIUM cmd;
2961   };
2962   Cmds expected;
2963   expected.cmd.Init();
2964 
2965   gl_->DiscardBackbufferCHROMIUM();
2966   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2967 }
2968 
TEST_F(GLES2ImplementationTest,ScheduleCALayerInUseQueryCHROMIUM)2969 TEST_F(GLES2ImplementationTest, ScheduleCALayerInUseQueryCHROMIUM) {
2970   GLuint data[1][1] = {{0}};
2971   struct Cmds {
2972     cmds::ScheduleCALayerInUseQueryCHROMIUMImmediate cmd;
2973     GLuint data[1][1];
2974   };
2975 
2976   Cmds expected;
2977   for (int ii = 0; ii < 1; ++ii) {
2978     for (int jj = 0; jj < 1; ++jj) {
2979       data[ii][jj] = static_cast<GLuint>(ii * 1 + jj);
2980     }
2981   }
2982   expected.cmd.Init(1, &data[0][0]);
2983   gl_->ScheduleCALayerInUseQueryCHROMIUM(1, &data[0][0]);
2984   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2985 }
2986 
TEST_F(GLES2ImplementationTest,FlushDriverCachesCHROMIUM)2987 TEST_F(GLES2ImplementationTest, FlushDriverCachesCHROMIUM) {
2988   struct Cmds {
2989     cmds::FlushDriverCachesCHROMIUM cmd;
2990   };
2991   Cmds expected;
2992   expected.cmd.Init();
2993 
2994   gl_->FlushDriverCachesCHROMIUM();
2995   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2996 }
2997 
TEST_F(GLES2ImplementationTest,ScheduleDCLayerCHROMIUM)2998 TEST_F(GLES2ImplementationTest, ScheduleDCLayerCHROMIUM) {
2999   struct Cmds {
3000     cmds::ScheduleDCLayerCHROMIUM cmd;
3001   };
3002   Cmds expected;
3003   expected.cmd.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
3004                     true, 19, 20, 21, 22, 23);
3005 
3006   gl_->ScheduleDCLayerCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
3007                                15, 16, 17, true, 19, 20, 21, 22, 23);
3008   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3009 }
3010 
TEST_F(GLES2ImplementationTest,CoverageModulationCHROMIUM)3011 TEST_F(GLES2ImplementationTest, CoverageModulationCHROMIUM) {
3012   struct Cmds {
3013     cmds::CoverageModulationCHROMIUM cmd;
3014   };
3015   Cmds expected;
3016   expected.cmd.Init(GL_RGB);
3017 
3018   gl_->CoverageModulationCHROMIUM(GL_RGB);
3019   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3020 }
3021 
TEST_F(GLES2ImplementationTest,SetDrawRectangleCHROMIUM)3022 TEST_F(GLES2ImplementationTest, SetDrawRectangleCHROMIUM) {
3023   struct Cmds {
3024     cmds::SetDrawRectangleCHROMIUM cmd;
3025   };
3026   Cmds expected;
3027   expected.cmd.Init(1, 2, 3, 4);
3028 
3029   gl_->SetDrawRectangleCHROMIUM(1, 2, 3, 4);
3030   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3031 }
3032 
TEST_F(GLES2ImplementationTest,SetEnableDCLayersCHROMIUM)3033 TEST_F(GLES2ImplementationTest, SetEnableDCLayersCHROMIUM) {
3034   struct Cmds {
3035     cmds::SetEnableDCLayersCHROMIUM cmd;
3036   };
3037   Cmds expected;
3038   expected.cmd.Init(true);
3039 
3040   gl_->SetEnableDCLayersCHROMIUM(true);
3041   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3042 }
3043 
TEST_F(GLES2ImplementationTest,TexStorage2DImageCHROMIUM)3044 TEST_F(GLES2ImplementationTest, TexStorage2DImageCHROMIUM) {
3045   struct Cmds {
3046     cmds::TexStorage2DImageCHROMIUM cmd;
3047   };
3048   Cmds expected;
3049   expected.cmd.Init(GL_TEXTURE_2D, GL_RGB565, 4, 5);
3050 
3051   gl_->TexStorage2DImageCHROMIUM(GL_TEXTURE_2D, GL_RGB565, GL_SCANOUT_CHROMIUM,
3052                                  4, 5);
3053   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3054 }
3055 
TEST_F(GLES2ImplementationTest,TexStorage2DImageCHROMIUMInvalidConstantArg2)3056 TEST_F(GLES2ImplementationTest, TexStorage2DImageCHROMIUMInvalidConstantArg2) {
3057   gl_->TexStorage2DImageCHROMIUM(GL_TEXTURE_2D, GL_RGB565, GL_NONE, 4, 5);
3058   EXPECT_TRUE(NoCommandsWritten());
3059   EXPECT_EQ(GL_INVALID_ENUM, CheckError());
3060 }
3061 
TEST_F(GLES2ImplementationTest,WindowRectanglesEXT)3062 TEST_F(GLES2ImplementationTest, WindowRectanglesEXT) {
3063   GLint data[2][4] = {{0}};
3064   struct Cmds {
3065     cmds::WindowRectanglesEXTImmediate cmd;
3066     GLint data[2][4];
3067   };
3068 
3069   Cmds expected;
3070   for (int ii = 0; ii < 2; ++ii) {
3071     for (int jj = 0; jj < 4; ++jj) {
3072       data[ii][jj] = static_cast<GLint>(ii * 4 + jj);
3073     }
3074   }
3075   expected.cmd.Init(GL_INCLUSIVE_EXT, 2, &data[0][0]);
3076   gl_->WindowRectanglesEXT(GL_INCLUSIVE_EXT, 2, &data[0][0]);
3077   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3078 }
3079 
TEST_F(GLES2ImplementationTest,WaitGpuFenceCHROMIUM)3080 TEST_F(GLES2ImplementationTest, WaitGpuFenceCHROMIUM) {
3081   struct Cmds {
3082     cmds::WaitGpuFenceCHROMIUM cmd;
3083   };
3084   Cmds expected;
3085   expected.cmd.Init(1);
3086 
3087   gl_->WaitGpuFenceCHROMIUM(1);
3088   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3089 }
3090 
TEST_F(GLES2ImplementationTest,DestroyGpuFenceCHROMIUM)3091 TEST_F(GLES2ImplementationTest, DestroyGpuFenceCHROMIUM) {
3092   struct Cmds {
3093     cmds::DestroyGpuFenceCHROMIUM cmd;
3094   };
3095   Cmds expected;
3096   expected.cmd.Init(1);
3097 
3098   gl_->DestroyGpuFenceCHROMIUM(1);
3099   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3100 }
3101 
TEST_F(GLES2ImplementationTest,FramebufferTextureMultiviewOVR)3102 TEST_F(GLES2ImplementationTest, FramebufferTextureMultiviewOVR) {
3103   struct Cmds {
3104     cmds::FramebufferTextureMultiviewOVR cmd;
3105   };
3106   Cmds expected;
3107   expected.cmd.Init(1, 2, 3, 4, 5, 6);
3108 
3109   gl_->FramebufferTextureMultiviewOVR(1, 2, 3, 4, 5, 6);
3110   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3111 }
3112 
TEST_F(GLES2ImplementationTest,EndSharedImageAccessDirectCHROMIUM)3113 TEST_F(GLES2ImplementationTest, EndSharedImageAccessDirectCHROMIUM) {
3114   struct Cmds {
3115     cmds::EndSharedImageAccessDirectCHROMIUM cmd;
3116   };
3117   Cmds expected;
3118   expected.cmd.Init(1);
3119 
3120   gl_->EndSharedImageAccessDirectCHROMIUM(1);
3121   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3122 }
3123 
TEST_F(GLES2ImplementationTest,BeginBatchReadAccessSharedImageCHROMIUM)3124 TEST_F(GLES2ImplementationTest, BeginBatchReadAccessSharedImageCHROMIUM) {
3125   struct Cmds {
3126     cmds::BeginBatchReadAccessSharedImageCHROMIUM cmd;
3127   };
3128   Cmds expected;
3129   expected.cmd.Init();
3130 
3131   gl_->BeginBatchReadAccessSharedImageCHROMIUM();
3132   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3133 }
3134 
TEST_F(GLES2ImplementationTest,EndBatchReadAccessSharedImageCHROMIUM)3135 TEST_F(GLES2ImplementationTest, EndBatchReadAccessSharedImageCHROMIUM) {
3136   struct Cmds {
3137     cmds::EndBatchReadAccessSharedImageCHROMIUM cmd;
3138   };
3139   Cmds expected;
3140   expected.cmd.Init();
3141 
3142   gl_->EndBatchReadAccessSharedImageCHROMIUM();
3143   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3144 }
3145 
TEST_F(GLES2ImplementationTest,EnableiOES)3146 TEST_F(GLES2ImplementationTest, EnableiOES) {
3147   struct Cmds {
3148     cmds::EnableiOES cmd;
3149   };
3150   Cmds expected;
3151   expected.cmd.Init(1, 2);
3152 
3153   gl_->EnableiOES(1, 2);
3154   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3155 }
3156 
TEST_F(GLES2ImplementationTest,DisableiOES)3157 TEST_F(GLES2ImplementationTest, DisableiOES) {
3158   struct Cmds {
3159     cmds::DisableiOES cmd;
3160   };
3161   Cmds expected;
3162   expected.cmd.Init(1, 2);
3163 
3164   gl_->DisableiOES(1, 2);
3165   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3166 }
3167 
TEST_F(GLES2ImplementationTest,BlendEquationiOES)3168 TEST_F(GLES2ImplementationTest, BlendEquationiOES) {
3169   struct Cmds {
3170     cmds::BlendEquationiOES cmd;
3171   };
3172   Cmds expected;
3173   expected.cmd.Init(1, GL_FUNC_SUBTRACT);
3174 
3175   gl_->BlendEquationiOES(1, GL_FUNC_SUBTRACT);
3176   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3177 }
3178 
TEST_F(GLES2ImplementationTest,BlendEquationSeparateiOES)3179 TEST_F(GLES2ImplementationTest, BlendEquationSeparateiOES) {
3180   struct Cmds {
3181     cmds::BlendEquationSeparateiOES cmd;
3182   };
3183   Cmds expected;
3184   expected.cmd.Init(1, GL_FUNC_SUBTRACT, GL_FUNC_SUBTRACT);
3185 
3186   gl_->BlendEquationSeparateiOES(1, GL_FUNC_SUBTRACT, GL_FUNC_SUBTRACT);
3187   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3188 }
3189 
TEST_F(GLES2ImplementationTest,BlendFunciOES)3190 TEST_F(GLES2ImplementationTest, BlendFunciOES) {
3191   struct Cmds {
3192     cmds::BlendFunciOES cmd;
3193   };
3194   Cmds expected;
3195   expected.cmd.Init(1, 2, 3);
3196 
3197   gl_->BlendFunciOES(1, 2, 3);
3198   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3199 }
3200 
TEST_F(GLES2ImplementationTest,BlendFuncSeparateiOES)3201 TEST_F(GLES2ImplementationTest, BlendFuncSeparateiOES) {
3202   struct Cmds {
3203     cmds::BlendFuncSeparateiOES cmd;
3204   };
3205   Cmds expected;
3206   expected.cmd.Init(1, 2, 3, 4, 5);
3207 
3208   gl_->BlendFuncSeparateiOES(1, 2, 3, 4, 5);
3209   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3210 }
3211 
TEST_F(GLES2ImplementationTest,ColorMaskiOES)3212 TEST_F(GLES2ImplementationTest, ColorMaskiOES) {
3213   struct Cmds {
3214     cmds::ColorMaskiOES cmd;
3215   };
3216   Cmds expected;
3217   expected.cmd.Init(1, true, true, true, true);
3218 
3219   gl_->ColorMaskiOES(1, true, true, true, true);
3220   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3221 }
3222 #endif  // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_
3223