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,GetBufferParameteri64v)761 TEST_F(GLES2ImplementationTest, GetBufferParameteri64v) {
762   struct Cmds {
763     cmds::GetBufferParameteri64v cmd;
764   };
765   typedef cmds::GetBufferParameteri64v::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, GL_BUFFER_SIZE, result1.id, result1.offset);
771   EXPECT_CALL(*command_buffer(), OnFlush())
772       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
773       .RetiresOnSaturation();
774   gl_->GetBufferParameteri64v(123, GL_BUFFER_SIZE, &result);
775   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
776   EXPECT_EQ(static_cast<ResultType>(1), result);
777 }
778 
TEST_F(GLES2ImplementationTest,GetBufferParameteriv)779 TEST_F(GLES2ImplementationTest, GetBufferParameteriv) {
780   struct Cmds {
781     cmds::GetBufferParameteriv cmd;
782   };
783   typedef cmds::GetBufferParameteriv::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_->GetBufferParameteriv(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,GetFloatv)797 TEST_F(GLES2ImplementationTest, GetFloatv) {
798   struct Cmds {
799     cmds::GetFloatv cmd;
800   };
801   typedef cmds::GetFloatv::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, result1.id, result1.offset);
807   EXPECT_CALL(*command_buffer(), OnFlush())
808       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
809       .RetiresOnSaturation();
810   gl_->GetFloatv(123, &result);
811   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
812   EXPECT_EQ(static_cast<ResultType>(1), result);
813 }
814 
TEST_F(GLES2ImplementationTest,GetFramebufferAttachmentParameteriv)815 TEST_F(GLES2ImplementationTest, GetFramebufferAttachmentParameteriv) {
816   struct Cmds {
817     cmds::GetFramebufferAttachmentParameteriv cmd;
818   };
819   typedef cmds::GetFramebufferAttachmentParameteriv::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, GL_COLOR_ATTACHMENT0,
825                     GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, result1.id,
826                     result1.offset);
827   EXPECT_CALL(*command_buffer(), OnFlush())
828       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
829       .RetiresOnSaturation();
830   gl_->GetFramebufferAttachmentParameteriv(
831       123, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
832       &result);
833   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
834   EXPECT_EQ(static_cast<ResultType>(1), result);
835 }
836 
TEST_F(GLES2ImplementationTest,GetInteger64v)837 TEST_F(GLES2ImplementationTest, GetInteger64v) {
838   struct Cmds {
839     cmds::GetInteger64v cmd;
840   };
841   typedef cmds::GetInteger64v::Result::Type ResultType;
842   ResultType result = 0;
843   Cmds expected;
844   ExpectedMemoryInfo result1 =
845       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
846   expected.cmd.Init(123, result1.id, result1.offset);
847   EXPECT_CALL(*command_buffer(), OnFlush())
848       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
849       .RetiresOnSaturation();
850   gl_->GetInteger64v(123, &result);
851   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
852   EXPECT_EQ(static_cast<ResultType>(1), result);
853 }
854 
TEST_F(GLES2ImplementationTest,GetIntegeri_v)855 TEST_F(GLES2ImplementationTest, GetIntegeri_v) {
856   struct Cmds {
857     cmds::GetIntegeri_v cmd;
858   };
859   typedef cmds::GetIntegeri_v::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, 2, result1.id, result1.offset);
865   EXPECT_CALL(*command_buffer(), OnFlush())
866       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
867       .RetiresOnSaturation();
868   gl_->GetIntegeri_v(123, 2, &result);
869   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
870   EXPECT_EQ(static_cast<ResultType>(1), result);
871 }
872 
TEST_F(GLES2ImplementationTest,GetInteger64i_v)873 TEST_F(GLES2ImplementationTest, GetInteger64i_v) {
874   struct Cmds {
875     cmds::GetInteger64i_v cmd;
876   };
877   typedef cmds::GetInteger64i_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_->GetInteger64i_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,GetIntegerv)891 TEST_F(GLES2ImplementationTest, GetIntegerv) {
892   struct Cmds {
893     cmds::GetIntegerv cmd;
894   };
895   typedef cmds::GetIntegerv::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, result1.id, result1.offset);
901   EXPECT_CALL(*command_buffer(), OnFlush())
902       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
903       .RetiresOnSaturation();
904   gl_->GetIntegerv(123, &result);
905   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
906   EXPECT_EQ(static_cast<ResultType>(1), result);
907 }
908 
TEST_F(GLES2ImplementationTest,GetProgramiv)909 TEST_F(GLES2ImplementationTest, GetProgramiv) {
910   struct Cmds {
911     cmds::GetProgramiv cmd;
912   };
913   typedef cmds::GetProgramiv::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, GL_DELETE_STATUS, result1.id, result1.offset);
919   EXPECT_CALL(*command_buffer(), OnFlush())
920       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
921       .RetiresOnSaturation();
922   gl_->GetProgramiv(123, GL_DELETE_STATUS, &result);
923   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
924   EXPECT_EQ(static_cast<ResultType>(1), result);
925 }
926 
TEST_F(GLES2ImplementationTest,GetRenderbufferParameteriv)927 TEST_F(GLES2ImplementationTest, GetRenderbufferParameteriv) {
928   struct Cmds {
929     cmds::GetRenderbufferParameteriv cmd;
930   };
931   typedef cmds::GetRenderbufferParameteriv::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_RENDERBUFFER_RED_SIZE, result1.id, result1.offset);
937   EXPECT_CALL(*command_buffer(), OnFlush())
938       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
939       .RetiresOnSaturation();
940   gl_->GetRenderbufferParameteriv(123, GL_RENDERBUFFER_RED_SIZE, &result);
941   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
942   EXPECT_EQ(static_cast<ResultType>(1), result);
943 }
944 
TEST_F(GLES2ImplementationTest,GetSamplerParameterfv)945 TEST_F(GLES2ImplementationTest, GetSamplerParameterfv) {
946   struct Cmds {
947     cmds::GetSamplerParameterfv cmd;
948   };
949   typedef cmds::GetSamplerParameterfv::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_TEXTURE_MAG_FILTER, result1.id, result1.offset);
955   EXPECT_CALL(*command_buffer(), OnFlush())
956       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
957       .RetiresOnSaturation();
958   gl_->GetSamplerParameterfv(123, GL_TEXTURE_MAG_FILTER, &result);
959   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
960   EXPECT_EQ(static_cast<ResultType>(1), result);
961 }
962 
TEST_F(GLES2ImplementationTest,GetSamplerParameteriv)963 TEST_F(GLES2ImplementationTest, GetSamplerParameteriv) {
964   struct Cmds {
965     cmds::GetSamplerParameteriv cmd;
966   };
967   typedef cmds::GetSamplerParameteriv::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_->GetSamplerParameteriv(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,GetShaderiv)981 TEST_F(GLES2ImplementationTest, GetShaderiv) {
982   struct Cmds {
983     cmds::GetShaderiv cmd;
984   };
985   typedef cmds::GetShaderiv::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_SHADER_TYPE, result1.id, result1.offset);
991   EXPECT_CALL(*command_buffer(), OnFlush())
992       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
993       .RetiresOnSaturation();
994   gl_->GetShaderiv(123, GL_SHADER_TYPE, &result);
995   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
996   EXPECT_EQ(static_cast<ResultType>(1), result);
997 }
998 
TEST_F(GLES2ImplementationTest,GetSynciv)999 TEST_F(GLES2ImplementationTest, GetSynciv) {
1000   struct Cmds {
1001     cmds::GetSynciv cmd;
1002   };
1003   typedef cmds::GetSynciv::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_SYNC_STATUS, result1.id, result1.offset);
1009   EXPECT_CALL(*command_buffer(), OnFlush())
1010       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1011       .RetiresOnSaturation();
1012   gl_->GetSynciv(reinterpret_cast<GLsync>(123), GL_SYNC_STATUS, 3, nullptr,
1013                  &result);
1014   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1015   EXPECT_EQ(static_cast<ResultType>(1), result);
1016 }
1017 
TEST_F(GLES2ImplementationTest,GetTexParameterfv)1018 TEST_F(GLES2ImplementationTest, GetTexParameterfv) {
1019   struct Cmds {
1020     cmds::GetTexParameterfv cmd;
1021   };
1022   typedef cmds::GetTexParameterfv::Result::Type ResultType;
1023   ResultType result = 0;
1024   Cmds expected;
1025   ExpectedMemoryInfo result1 =
1026       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1027   expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
1028   EXPECT_CALL(*command_buffer(), OnFlush())
1029       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1030       .RetiresOnSaturation();
1031   gl_->GetTexParameterfv(123, GL_TEXTURE_MAG_FILTER, &result);
1032   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1033   EXPECT_EQ(static_cast<ResultType>(1), result);
1034 }
1035 
TEST_F(GLES2ImplementationTest,GetTexParameteriv)1036 TEST_F(GLES2ImplementationTest, GetTexParameteriv) {
1037   struct Cmds {
1038     cmds::GetTexParameteriv cmd;
1039   };
1040   typedef cmds::GetTexParameteriv::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_->GetTexParameteriv(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,GetVertexAttribfv)1054 TEST_F(GLES2ImplementationTest, GetVertexAttribfv) {
1055   struct Cmds {
1056     cmds::GetVertexAttribfv cmd;
1057   };
1058   typedef cmds::GetVertexAttribfv::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_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1064                     result1.offset);
1065   EXPECT_CALL(*command_buffer(), OnFlush())
1066       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1067       .RetiresOnSaturation();
1068   gl_->GetVertexAttribfv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1069   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1070   EXPECT_EQ(static_cast<ResultType>(1), result);
1071 }
1072 
TEST_F(GLES2ImplementationTest,GetVertexAttribiv)1073 TEST_F(GLES2ImplementationTest, GetVertexAttribiv) {
1074   struct Cmds {
1075     cmds::GetVertexAttribiv cmd;
1076   };
1077   typedef cmds::GetVertexAttribiv::Result::Type ResultType;
1078   ResultType result = 0;
1079   Cmds expected;
1080   ExpectedMemoryInfo result1 =
1081       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1082   expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1083                     result1.offset);
1084   EXPECT_CALL(*command_buffer(), OnFlush())
1085       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1086       .RetiresOnSaturation();
1087   gl_->GetVertexAttribiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1088   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1089   EXPECT_EQ(static_cast<ResultType>(1), result);
1090 }
1091 
TEST_F(GLES2ImplementationTest,GetVertexAttribIiv)1092 TEST_F(GLES2ImplementationTest, GetVertexAttribIiv) {
1093   struct Cmds {
1094     cmds::GetVertexAttribIiv cmd;
1095   };
1096   typedef cmds::GetVertexAttribIiv::Result::Type ResultType;
1097   ResultType result = 0;
1098   Cmds expected;
1099   ExpectedMemoryInfo result1 =
1100       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1101   expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1102                     result1.offset);
1103   EXPECT_CALL(*command_buffer(), OnFlush())
1104       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1105       .RetiresOnSaturation();
1106   gl_->GetVertexAttribIiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1107   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1108   EXPECT_EQ(static_cast<ResultType>(1), result);
1109 }
1110 
TEST_F(GLES2ImplementationTest,GetVertexAttribIuiv)1111 TEST_F(GLES2ImplementationTest, GetVertexAttribIuiv) {
1112   struct Cmds {
1113     cmds::GetVertexAttribIuiv cmd;
1114   };
1115   typedef cmds::GetVertexAttribIuiv::Result::Type ResultType;
1116   ResultType result = 0;
1117   Cmds expected;
1118   ExpectedMemoryInfo result1 =
1119       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
1120   expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
1121                     result1.offset);
1122   EXPECT_CALL(*command_buffer(), OnFlush())
1123       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
1124       .RetiresOnSaturation();
1125   gl_->GetVertexAttribIuiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
1126   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1127   EXPECT_EQ(static_cast<ResultType>(1), result);
1128 }
1129 
TEST_F(GLES2ImplementationTest,Hint)1130 TEST_F(GLES2ImplementationTest, Hint) {
1131   struct Cmds {
1132     cmds::Hint cmd;
1133   };
1134   Cmds expected;
1135   expected.cmd.Init(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
1136 
1137   gl_->Hint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
1138   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1139 }
1140 
TEST_F(GLES2ImplementationTest,InvalidateFramebuffer)1141 TEST_F(GLES2ImplementationTest, InvalidateFramebuffer) {
1142   GLenum data[2][1] = {{0}};
1143   struct Cmds {
1144     cmds::InvalidateFramebufferImmediate cmd;
1145     GLenum data[2][1];
1146   };
1147 
1148   Cmds expected;
1149   for (int ii = 0; ii < 2; ++ii) {
1150     for (int jj = 0; jj < 1; ++jj) {
1151       data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
1152     }
1153   }
1154   expected.cmd.Init(GL_FRAMEBUFFER, 2, &data[0][0]);
1155   gl_->InvalidateFramebuffer(GL_FRAMEBUFFER, 2, &data[0][0]);
1156   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1157 }
1158 
TEST_F(GLES2ImplementationTest,InvalidateSubFramebuffer)1159 TEST_F(GLES2ImplementationTest, InvalidateSubFramebuffer) {
1160   GLenum data[2][1] = {{0}};
1161   struct Cmds {
1162     cmds::InvalidateSubFramebufferImmediate 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], 4, 5, 6, 7);
1173   gl_->InvalidateSubFramebuffer(GL_FRAMEBUFFER, 2, &data[0][0], 4, 5, 6, 7);
1174   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1175 }
1176 
TEST_F(GLES2ImplementationTest,IsBuffer)1177 TEST_F(GLES2ImplementationTest, IsBuffer) {
1178   struct Cmds {
1179     cmds::IsBuffer cmd;
1180   };
1181 
1182   Cmds expected;
1183   ExpectedMemoryInfo result1 =
1184       GetExpectedResultMemory(sizeof(cmds::IsBuffer::Result));
1185   expected.cmd.Init(1, result1.id, result1.offset);
1186 
1187   EXPECT_CALL(*command_buffer(), OnFlush())
1188       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1189       .RetiresOnSaturation();
1190 
1191   GLboolean result = gl_->IsBuffer(1);
1192   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1193   EXPECT_TRUE(result);
1194 }
1195 
TEST_F(GLES2ImplementationTest,IsFramebuffer)1196 TEST_F(GLES2ImplementationTest, IsFramebuffer) {
1197   struct Cmds {
1198     cmds::IsFramebuffer cmd;
1199   };
1200 
1201   Cmds expected;
1202   ExpectedMemoryInfo result1 =
1203       GetExpectedResultMemory(sizeof(cmds::IsFramebuffer::Result));
1204   expected.cmd.Init(1, result1.id, result1.offset);
1205 
1206   EXPECT_CALL(*command_buffer(), OnFlush())
1207       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1208       .RetiresOnSaturation();
1209 
1210   GLboolean result = gl_->IsFramebuffer(1);
1211   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1212   EXPECT_TRUE(result);
1213 }
1214 
TEST_F(GLES2ImplementationTest,IsProgram)1215 TEST_F(GLES2ImplementationTest, IsProgram) {
1216   struct Cmds {
1217     cmds::IsProgram cmd;
1218   };
1219 
1220   Cmds expected;
1221   ExpectedMemoryInfo result1 =
1222       GetExpectedResultMemory(sizeof(cmds::IsProgram::Result));
1223   expected.cmd.Init(1, result1.id, result1.offset);
1224 
1225   EXPECT_CALL(*command_buffer(), OnFlush())
1226       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1227       .RetiresOnSaturation();
1228 
1229   GLboolean result = gl_->IsProgram(1);
1230   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1231   EXPECT_TRUE(result);
1232 }
1233 
TEST_F(GLES2ImplementationTest,IsRenderbuffer)1234 TEST_F(GLES2ImplementationTest, IsRenderbuffer) {
1235   struct Cmds {
1236     cmds::IsRenderbuffer cmd;
1237   };
1238 
1239   Cmds expected;
1240   ExpectedMemoryInfo result1 =
1241       GetExpectedResultMemory(sizeof(cmds::IsRenderbuffer::Result));
1242   expected.cmd.Init(1, result1.id, result1.offset);
1243 
1244   EXPECT_CALL(*command_buffer(), OnFlush())
1245       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1246       .RetiresOnSaturation();
1247 
1248   GLboolean result = gl_->IsRenderbuffer(1);
1249   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1250   EXPECT_TRUE(result);
1251 }
1252 
TEST_F(GLES2ImplementationTest,IsSampler)1253 TEST_F(GLES2ImplementationTest, IsSampler) {
1254   struct Cmds {
1255     cmds::IsSampler cmd;
1256   };
1257 
1258   Cmds expected;
1259   ExpectedMemoryInfo result1 =
1260       GetExpectedResultMemory(sizeof(cmds::IsSampler::Result));
1261   expected.cmd.Init(1, result1.id, result1.offset);
1262 
1263   EXPECT_CALL(*command_buffer(), OnFlush())
1264       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1265       .RetiresOnSaturation();
1266 
1267   GLboolean result = gl_->IsSampler(1);
1268   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1269   EXPECT_TRUE(result);
1270 }
1271 
TEST_F(GLES2ImplementationTest,IsShader)1272 TEST_F(GLES2ImplementationTest, IsShader) {
1273   struct Cmds {
1274     cmds::IsShader cmd;
1275   };
1276 
1277   Cmds expected;
1278   ExpectedMemoryInfo result1 =
1279       GetExpectedResultMemory(sizeof(cmds::IsShader::Result));
1280   expected.cmd.Init(1, result1.id, result1.offset);
1281 
1282   EXPECT_CALL(*command_buffer(), OnFlush())
1283       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1284       .RetiresOnSaturation();
1285 
1286   GLboolean result = gl_->IsShader(1);
1287   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1288   EXPECT_TRUE(result);
1289 }
1290 
TEST_F(GLES2ImplementationTest,IsSync)1291 TEST_F(GLES2ImplementationTest, IsSync) {
1292   struct Cmds {
1293     cmds::IsSync cmd;
1294   };
1295 
1296   Cmds expected;
1297   ExpectedMemoryInfo result1 =
1298       GetExpectedResultMemory(sizeof(cmds::IsSync::Result));
1299   expected.cmd.Init(1, result1.id, result1.offset);
1300 
1301   EXPECT_CALL(*command_buffer(), OnFlush())
1302       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1303       .RetiresOnSaturation();
1304 
1305   GLboolean result = gl_->IsSync(reinterpret_cast<GLsync>(1));
1306   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1307   EXPECT_TRUE(result);
1308 }
1309 
TEST_F(GLES2ImplementationTest,IsTexture)1310 TEST_F(GLES2ImplementationTest, IsTexture) {
1311   struct Cmds {
1312     cmds::IsTexture cmd;
1313   };
1314 
1315   Cmds expected;
1316   ExpectedMemoryInfo result1 =
1317       GetExpectedResultMemory(sizeof(cmds::IsTexture::Result));
1318   expected.cmd.Init(1, result1.id, result1.offset);
1319 
1320   EXPECT_CALL(*command_buffer(), OnFlush())
1321       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1322       .RetiresOnSaturation();
1323 
1324   GLboolean result = gl_->IsTexture(1);
1325   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1326   EXPECT_TRUE(result);
1327 }
1328 
TEST_F(GLES2ImplementationTest,IsTransformFeedback)1329 TEST_F(GLES2ImplementationTest, IsTransformFeedback) {
1330   struct Cmds {
1331     cmds::IsTransformFeedback cmd;
1332   };
1333 
1334   Cmds expected;
1335   ExpectedMemoryInfo result1 =
1336       GetExpectedResultMemory(sizeof(cmds::IsTransformFeedback::Result));
1337   expected.cmd.Init(1, result1.id, result1.offset);
1338 
1339   EXPECT_CALL(*command_buffer(), OnFlush())
1340       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
1341       .RetiresOnSaturation();
1342 
1343   GLboolean result = gl_->IsTransformFeedback(1);
1344   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1345   EXPECT_TRUE(result);
1346 }
1347 
TEST_F(GLES2ImplementationTest,LineWidth)1348 TEST_F(GLES2ImplementationTest, LineWidth) {
1349   struct Cmds {
1350     cmds::LineWidth cmd;
1351   };
1352   Cmds expected;
1353   expected.cmd.Init(2.0f);
1354 
1355   gl_->LineWidth(2.0f);
1356   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1357 }
1358 
TEST_F(GLES2ImplementationTest,LinkProgram)1359 TEST_F(GLES2ImplementationTest, LinkProgram) {
1360   struct Cmds {
1361     cmds::LinkProgram cmd;
1362   };
1363   Cmds expected;
1364   expected.cmd.Init(1);
1365 
1366   gl_->LinkProgram(1);
1367   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1368 }
1369 
TEST_F(GLES2ImplementationTest,PauseTransformFeedback)1370 TEST_F(GLES2ImplementationTest, PauseTransformFeedback) {
1371   struct Cmds {
1372     cmds::PauseTransformFeedback cmd;
1373   };
1374   Cmds expected;
1375   expected.cmd.Init();
1376 
1377   gl_->PauseTransformFeedback();
1378   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1379 }
1380 
TEST_F(GLES2ImplementationTest,PixelStorei)1381 TEST_F(GLES2ImplementationTest, PixelStorei) {
1382   struct Cmds {
1383     cmds::PixelStorei cmd;
1384   };
1385   Cmds expected;
1386   expected.cmd.Init(GL_PACK_ALIGNMENT, 1);
1387 
1388   gl_->PixelStorei(GL_PACK_ALIGNMENT, 1);
1389   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1390 }
1391 
TEST_F(GLES2ImplementationTest,PolygonOffset)1392 TEST_F(GLES2ImplementationTest, PolygonOffset) {
1393   struct Cmds {
1394     cmds::PolygonOffset cmd;
1395   };
1396   Cmds expected;
1397   expected.cmd.Init(1, 2);
1398 
1399   gl_->PolygonOffset(1, 2);
1400   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1401 }
1402 
TEST_F(GLES2ImplementationTest,ReadBuffer)1403 TEST_F(GLES2ImplementationTest, ReadBuffer) {
1404   struct Cmds {
1405     cmds::ReadBuffer cmd;
1406   };
1407   Cmds expected;
1408   expected.cmd.Init(GL_NONE);
1409 
1410   gl_->ReadBuffer(GL_NONE);
1411   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1412 }
1413 
TEST_F(GLES2ImplementationTest,ReleaseShaderCompiler)1414 TEST_F(GLES2ImplementationTest, ReleaseShaderCompiler) {
1415   struct Cmds {
1416     cmds::ReleaseShaderCompiler cmd;
1417   };
1418   Cmds expected;
1419   expected.cmd.Init();
1420 
1421   gl_->ReleaseShaderCompiler();
1422   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1423 }
1424 
TEST_F(GLES2ImplementationTest,RenderbufferStorage)1425 TEST_F(GLES2ImplementationTest, RenderbufferStorage) {
1426   struct Cmds {
1427     cmds::RenderbufferStorage cmd;
1428   };
1429   Cmds expected;
1430   expected.cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
1431 
1432   gl_->RenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
1433   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1434 }
1435 
TEST_F(GLES2ImplementationTest,ResumeTransformFeedback)1436 TEST_F(GLES2ImplementationTest, ResumeTransformFeedback) {
1437   struct Cmds {
1438     cmds::ResumeTransformFeedback cmd;
1439   };
1440   Cmds expected;
1441   expected.cmd.Init();
1442 
1443   gl_->ResumeTransformFeedback();
1444   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1445 }
1446 
TEST_F(GLES2ImplementationTest,SampleCoverage)1447 TEST_F(GLES2ImplementationTest, SampleCoverage) {
1448   struct Cmds {
1449     cmds::SampleCoverage cmd;
1450   };
1451   Cmds expected;
1452   expected.cmd.Init(1, true);
1453 
1454   gl_->SampleCoverage(1, true);
1455   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1456 }
1457 
TEST_F(GLES2ImplementationTest,SamplerParameterf)1458 TEST_F(GLES2ImplementationTest, SamplerParameterf) {
1459   struct Cmds {
1460     cmds::SamplerParameterf cmd;
1461   };
1462   Cmds expected;
1463   expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1464 
1465   gl_->SamplerParameterf(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1466   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1467 }
1468 
TEST_F(GLES2ImplementationTest,SamplerParameterfv)1469 TEST_F(GLES2ImplementationTest, SamplerParameterfv) {
1470   GLfloat data[1] = {0};
1471   struct Cmds {
1472     cmds::SamplerParameterfvImmediate cmd;
1473     GLfloat data[1];
1474   };
1475 
1476   for (int jj = 0; jj < 1; ++jj) {
1477     data[jj] = static_cast<GLfloat>(jj);
1478   }
1479   Cmds expected;
1480   expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1481   gl_->SamplerParameterfv(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1482   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1483 }
1484 
TEST_F(GLES2ImplementationTest,SamplerParameteri)1485 TEST_F(GLES2ImplementationTest, SamplerParameteri) {
1486   struct Cmds {
1487     cmds::SamplerParameteri cmd;
1488   };
1489   Cmds expected;
1490   expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1491 
1492   gl_->SamplerParameteri(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1493   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1494 }
1495 
TEST_F(GLES2ImplementationTest,SamplerParameteriv)1496 TEST_F(GLES2ImplementationTest, SamplerParameteriv) {
1497   GLint data[1] = {0};
1498   struct Cmds {
1499     cmds::SamplerParameterivImmediate cmd;
1500     GLint data[1];
1501   };
1502 
1503   for (int jj = 0; jj < 1; ++jj) {
1504     data[jj] = static_cast<GLint>(jj);
1505   }
1506   Cmds expected;
1507   expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1508   gl_->SamplerParameteriv(1, GL_TEXTURE_MAG_FILTER, &data[0]);
1509   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1510 }
1511 
TEST_F(GLES2ImplementationTest,Scissor)1512 TEST_F(GLES2ImplementationTest, Scissor) {
1513   struct Cmds {
1514     cmds::Scissor cmd;
1515   };
1516   Cmds expected;
1517   expected.cmd.Init(1, 2, 3, 4);
1518 
1519   gl_->Scissor(1, 2, 3, 4);
1520   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1521 }
1522 
TEST_F(GLES2ImplementationTest,ShaderSource)1523 TEST_F(GLES2ImplementationTest, ShaderSource) {
1524   const uint32_t kBucketId = GLES2Implementation::kResultBucketId;
1525   const char* kString1 = "happy";
1526   const char* kString2 = "ending";
1527   const size_t kString1Size = ::strlen(kString1) + 1;
1528   const size_t kString2Size = ::strlen(kString2) + 1;
1529   const size_t kHeaderSize = sizeof(GLint) * 3;
1530   const size_t kSourceSize = kHeaderSize + kString1Size + kString2Size;
1531   const size_t kPaddedHeaderSize =
1532       transfer_buffer_->RoundToAlignment(kHeaderSize);
1533   const size_t kPaddedString1Size =
1534       transfer_buffer_->RoundToAlignment(kString1Size);
1535   const size_t kPaddedString2Size =
1536       transfer_buffer_->RoundToAlignment(kString2Size);
1537   struct Cmds {
1538     cmd::SetBucketSize set_bucket_size;
1539     cmd::SetBucketData set_bucket_header;
1540     cmd::SetToken set_token1;
1541     cmd::SetBucketData set_bucket_data1;
1542     cmd::SetToken set_token2;
1543     cmd::SetBucketData set_bucket_data2;
1544     cmd::SetToken set_token3;
1545     cmds::ShaderSourceBucket cmd_bucket;
1546     cmd::SetBucketSize clear_bucket_size;
1547   };
1548 
1549   ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1550   ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedString1Size);
1551   ExpectedMemoryInfo mem2 = GetExpectedMemory(kPaddedString2Size);
1552 
1553   Cmds expected;
1554   expected.set_bucket_size.Init(kBucketId, kSourceSize);
1555   expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1556                                   mem0.offset);
1557   expected.set_token1.Init(GetNextToken());
1558   expected.set_bucket_data1.Init(kBucketId, kHeaderSize, kString1Size, mem1.id,
1559                                  mem1.offset);
1560   expected.set_token2.Init(GetNextToken());
1561   expected.set_bucket_data2.Init(kBucketId, kHeaderSize + kString1Size,
1562                                  kString2Size, mem2.id, mem2.offset);
1563   expected.set_token3.Init(GetNextToken());
1564   expected.cmd_bucket.Init(1, kBucketId);
1565   expected.clear_bucket_size.Init(kBucketId, 0);
1566   const char* kStrings[] = {kString1, kString2};
1567   gl_->ShaderSource(1, 2, kStrings, nullptr);
1568   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1569 }
1570 
TEST_F(GLES2ImplementationTest,ShaderSourceWithLength)1571 TEST_F(GLES2ImplementationTest, ShaderSourceWithLength) {
1572   const uint32_t kBucketId = GLES2Implementation::kResultBucketId;
1573   const char* kString = "foobar******";
1574   const size_t kStringSize = 6;  // We only need "foobar".
1575   const size_t kHeaderSize = sizeof(GLint) * 2;
1576   const size_t kSourceSize = kHeaderSize + kStringSize + 1;
1577   const size_t kPaddedHeaderSize =
1578       transfer_buffer_->RoundToAlignment(kHeaderSize);
1579   const size_t kPaddedStringSize =
1580       transfer_buffer_->RoundToAlignment(kStringSize + 1);
1581   struct Cmds {
1582     cmd::SetBucketSize set_bucket_size;
1583     cmd::SetBucketData set_bucket_header;
1584     cmd::SetToken set_token1;
1585     cmd::SetBucketData set_bucket_data;
1586     cmd::SetToken set_token2;
1587     cmds::ShaderSourceBucket shader_source_bucket;
1588     cmd::SetBucketSize clear_bucket_size;
1589   };
1590 
1591   ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1592   ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedStringSize);
1593 
1594   Cmds expected;
1595   expected.set_bucket_size.Init(kBucketId, kSourceSize);
1596   expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1597                                   mem0.offset);
1598   expected.set_token1.Init(GetNextToken());
1599   expected.set_bucket_data.Init(kBucketId, kHeaderSize, kStringSize + 1,
1600                                 mem1.id, mem1.offset);
1601   expected.set_token2.Init(GetNextToken());
1602   expected.shader_source_bucket.Init(1, kBucketId);
1603   expected.clear_bucket_size.Init(kBucketId, 0);
1604   const char* kStrings[] = {kString};
1605   const GLint kLength[] = {kStringSize};
1606   gl_->ShaderSource(1, 1, kStrings, kLength);
1607   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1608 }
1609 
TEST_F(GLES2ImplementationTest,StencilFunc)1610 TEST_F(GLES2ImplementationTest, StencilFunc) {
1611   struct Cmds {
1612     cmds::StencilFunc cmd;
1613   };
1614   Cmds expected;
1615   expected.cmd.Init(GL_NEVER, 2, 3);
1616 
1617   gl_->StencilFunc(GL_NEVER, 2, 3);
1618   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1619 }
1620 
TEST_F(GLES2ImplementationTest,StencilFuncSeparate)1621 TEST_F(GLES2ImplementationTest, StencilFuncSeparate) {
1622   struct Cmds {
1623     cmds::StencilFuncSeparate cmd;
1624   };
1625   Cmds expected;
1626   expected.cmd.Init(GL_FRONT, GL_NEVER, 3, 4);
1627 
1628   gl_->StencilFuncSeparate(GL_FRONT, GL_NEVER, 3, 4);
1629   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1630 }
1631 
TEST_F(GLES2ImplementationTest,StencilMask)1632 TEST_F(GLES2ImplementationTest, StencilMask) {
1633   struct Cmds {
1634     cmds::StencilMask cmd;
1635   };
1636   Cmds expected;
1637   expected.cmd.Init(1);
1638 
1639   gl_->StencilMask(1);
1640   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1641 }
1642 
TEST_F(GLES2ImplementationTest,StencilMaskSeparate)1643 TEST_F(GLES2ImplementationTest, StencilMaskSeparate) {
1644   struct Cmds {
1645     cmds::StencilMaskSeparate cmd;
1646   };
1647   Cmds expected;
1648   expected.cmd.Init(GL_FRONT, 2);
1649 
1650   gl_->StencilMaskSeparate(GL_FRONT, 2);
1651   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1652 }
1653 
TEST_F(GLES2ImplementationTest,StencilOp)1654 TEST_F(GLES2ImplementationTest, StencilOp) {
1655   struct Cmds {
1656     cmds::StencilOp cmd;
1657   };
1658   Cmds expected;
1659   expected.cmd.Init(GL_KEEP, GL_INCR, GL_KEEP);
1660 
1661   gl_->StencilOp(GL_KEEP, GL_INCR, GL_KEEP);
1662   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1663 }
1664 
TEST_F(GLES2ImplementationTest,StencilOpSeparate)1665 TEST_F(GLES2ImplementationTest, StencilOpSeparate) {
1666   struct Cmds {
1667     cmds::StencilOpSeparate cmd;
1668   };
1669   Cmds expected;
1670   expected.cmd.Init(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP);
1671 
1672   gl_->StencilOpSeparate(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP);
1673   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1674 }
1675 
TEST_F(GLES2ImplementationTest,TexParameterf)1676 TEST_F(GLES2ImplementationTest, TexParameterf) {
1677   struct Cmds {
1678     cmds::TexParameterf cmd;
1679   };
1680   Cmds expected;
1681   expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1682 
1683   gl_->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1684   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1685 }
1686 
TEST_F(GLES2ImplementationTest,TexParameterfv)1687 TEST_F(GLES2ImplementationTest, TexParameterfv) {
1688   GLfloat data[1] = {0};
1689   struct Cmds {
1690     cmds::TexParameterfvImmediate cmd;
1691     GLfloat data[1];
1692   };
1693 
1694   for (int jj = 0; jj < 1; ++jj) {
1695     data[jj] = static_cast<GLfloat>(jj);
1696   }
1697   Cmds expected;
1698   expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1699   gl_->TexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1700   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1701 }
1702 
TEST_F(GLES2ImplementationTest,TexParameteri)1703 TEST_F(GLES2ImplementationTest, TexParameteri) {
1704   struct Cmds {
1705     cmds::TexParameteri cmd;
1706   };
1707   Cmds expected;
1708   expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1709 
1710   gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1711   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1712 }
1713 
TEST_F(GLES2ImplementationTest,TexParameteriv)1714 TEST_F(GLES2ImplementationTest, TexParameteriv) {
1715   GLint data[1] = {0};
1716   struct Cmds {
1717     cmds::TexParameterivImmediate cmd;
1718     GLint data[1];
1719   };
1720 
1721   for (int jj = 0; jj < 1; ++jj) {
1722     data[jj] = static_cast<GLint>(jj);
1723   }
1724   Cmds expected;
1725   expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1726   gl_->TexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1727   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1728 }
1729 
TEST_F(GLES2ImplementationTest,TexStorage3D)1730 TEST_F(GLES2ImplementationTest, TexStorage3D) {
1731   struct Cmds {
1732     cmds::TexStorage3D cmd;
1733   };
1734   Cmds expected;
1735   expected.cmd.Init(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6);
1736 
1737   gl_->TexStorage3D(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6);
1738   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1739 }
1740 
TEST_F(GLES2ImplementationTest,TransformFeedbackVaryings)1741 TEST_F(GLES2ImplementationTest, TransformFeedbackVaryings) {
1742   const uint32_t kBucketId = GLES2Implementation::kResultBucketId;
1743   const char* kString1 = "happy";
1744   const char* kString2 = "ending";
1745   const size_t kString1Size = ::strlen(kString1) + 1;
1746   const size_t kString2Size = ::strlen(kString2) + 1;
1747   const size_t kHeaderSize = sizeof(GLint) * 3;
1748   const size_t kSourceSize = kHeaderSize + kString1Size + kString2Size;
1749   const size_t kPaddedHeaderSize =
1750       transfer_buffer_->RoundToAlignment(kHeaderSize);
1751   const size_t kPaddedString1Size =
1752       transfer_buffer_->RoundToAlignment(kString1Size);
1753   const size_t kPaddedString2Size =
1754       transfer_buffer_->RoundToAlignment(kString2Size);
1755   struct Cmds {
1756     cmd::SetBucketSize set_bucket_size;
1757     cmd::SetBucketData set_bucket_header;
1758     cmd::SetToken set_token1;
1759     cmd::SetBucketData set_bucket_data1;
1760     cmd::SetToken set_token2;
1761     cmd::SetBucketData set_bucket_data2;
1762     cmd::SetToken set_token3;
1763     cmds::TransformFeedbackVaryingsBucket cmd_bucket;
1764     cmd::SetBucketSize clear_bucket_size;
1765   };
1766 
1767   ExpectedMemoryInfo mem0 = GetExpectedMemory(kPaddedHeaderSize);
1768   ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedString1Size);
1769   ExpectedMemoryInfo mem2 = GetExpectedMemory(kPaddedString2Size);
1770 
1771   Cmds expected;
1772   expected.set_bucket_size.Init(kBucketId, kSourceSize);
1773   expected.set_bucket_header.Init(kBucketId, 0, kHeaderSize, mem0.id,
1774                                   mem0.offset);
1775   expected.set_token1.Init(GetNextToken());
1776   expected.set_bucket_data1.Init(kBucketId, kHeaderSize, kString1Size, mem1.id,
1777                                  mem1.offset);
1778   expected.set_token2.Init(GetNextToken());
1779   expected.set_bucket_data2.Init(kBucketId, kHeaderSize + kString1Size,
1780                                  kString2Size, mem2.id, mem2.offset);
1781   expected.set_token3.Init(GetNextToken());
1782   expected.cmd_bucket.Init(1, kBucketId, GL_INTERLEAVED_ATTRIBS);
1783   expected.clear_bucket_size.Init(kBucketId, 0);
1784   const char* kStrings[] = {kString1, kString2};
1785   gl_->TransformFeedbackVaryings(1, 2, kStrings, GL_INTERLEAVED_ATTRIBS);
1786   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1787 }
1788 
TEST_F(GLES2ImplementationTest,Uniform1f)1789 TEST_F(GLES2ImplementationTest, Uniform1f) {
1790   struct Cmds {
1791     cmds::Uniform1f cmd;
1792   };
1793   Cmds expected;
1794   expected.cmd.Init(1, 2);
1795 
1796   gl_->Uniform1f(1, 2);
1797   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1798 }
1799 
TEST_F(GLES2ImplementationTest,Uniform1fv)1800 TEST_F(GLES2ImplementationTest, Uniform1fv) {
1801   GLfloat data[2][1] = {{0}};
1802   struct Cmds {
1803     cmds::Uniform1fvImmediate cmd;
1804     GLfloat data[2][1];
1805   };
1806 
1807   Cmds expected;
1808   for (int ii = 0; ii < 2; ++ii) {
1809     for (int jj = 0; jj < 1; ++jj) {
1810       data[ii][jj] = static_cast<GLfloat>(ii * 1 + jj);
1811     }
1812   }
1813   expected.cmd.Init(1, 2, &data[0][0]);
1814   gl_->Uniform1fv(1, 2, &data[0][0]);
1815   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1816 }
1817 
TEST_F(GLES2ImplementationTest,Uniform1i)1818 TEST_F(GLES2ImplementationTest, Uniform1i) {
1819   struct Cmds {
1820     cmds::Uniform1i cmd;
1821   };
1822   Cmds expected;
1823   expected.cmd.Init(1, 2);
1824 
1825   gl_->Uniform1i(1, 2);
1826   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1827 }
1828 
TEST_F(GLES2ImplementationTest,Uniform1iv)1829 TEST_F(GLES2ImplementationTest, Uniform1iv) {
1830   GLint data[2][1] = {{0}};
1831   struct Cmds {
1832     cmds::Uniform1ivImmediate cmd;
1833     GLint data[2][1];
1834   };
1835 
1836   Cmds expected;
1837   for (int ii = 0; ii < 2; ++ii) {
1838     for (int jj = 0; jj < 1; ++jj) {
1839       data[ii][jj] = static_cast<GLint>(ii * 1 + jj);
1840     }
1841   }
1842   expected.cmd.Init(1, 2, &data[0][0]);
1843   gl_->Uniform1iv(1, 2, &data[0][0]);
1844   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1845 }
1846 
TEST_F(GLES2ImplementationTest,Uniform1ui)1847 TEST_F(GLES2ImplementationTest, Uniform1ui) {
1848   struct Cmds {
1849     cmds::Uniform1ui cmd;
1850   };
1851   Cmds expected;
1852   expected.cmd.Init(1, 2);
1853 
1854   gl_->Uniform1ui(1, 2);
1855   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1856 }
1857 
TEST_F(GLES2ImplementationTest,Uniform1uiv)1858 TEST_F(GLES2ImplementationTest, Uniform1uiv) {
1859   GLuint data[2][1] = {{0}};
1860   struct Cmds {
1861     cmds::Uniform1uivImmediate cmd;
1862     GLuint data[2][1];
1863   };
1864 
1865   Cmds expected;
1866   for (int ii = 0; ii < 2; ++ii) {
1867     for (int jj = 0; jj < 1; ++jj) {
1868       data[ii][jj] = static_cast<GLuint>(ii * 1 + jj);
1869     }
1870   }
1871   expected.cmd.Init(1, 2, &data[0][0]);
1872   gl_->Uniform1uiv(1, 2, &data[0][0]);
1873   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1874 }
1875 
TEST_F(GLES2ImplementationTest,Uniform2f)1876 TEST_F(GLES2ImplementationTest, Uniform2f) {
1877   struct Cmds {
1878     cmds::Uniform2f cmd;
1879   };
1880   Cmds expected;
1881   expected.cmd.Init(1, 2, 3);
1882 
1883   gl_->Uniform2f(1, 2, 3);
1884   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1885 }
1886 
TEST_F(GLES2ImplementationTest,Uniform2fv)1887 TEST_F(GLES2ImplementationTest, Uniform2fv) {
1888   GLfloat data[2][2] = {{0}};
1889   struct Cmds {
1890     cmds::Uniform2fvImmediate cmd;
1891     GLfloat data[2][2];
1892   };
1893 
1894   Cmds expected;
1895   for (int ii = 0; ii < 2; ++ii) {
1896     for (int jj = 0; jj < 2; ++jj) {
1897       data[ii][jj] = static_cast<GLfloat>(ii * 2 + jj);
1898     }
1899   }
1900   expected.cmd.Init(1, 2, &data[0][0]);
1901   gl_->Uniform2fv(1, 2, &data[0][0]);
1902   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1903 }
1904 
TEST_F(GLES2ImplementationTest,Uniform2i)1905 TEST_F(GLES2ImplementationTest, Uniform2i) {
1906   struct Cmds {
1907     cmds::Uniform2i cmd;
1908   };
1909   Cmds expected;
1910   expected.cmd.Init(1, 2, 3);
1911 
1912   gl_->Uniform2i(1, 2, 3);
1913   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1914 }
1915 
TEST_F(GLES2ImplementationTest,Uniform2iv)1916 TEST_F(GLES2ImplementationTest, Uniform2iv) {
1917   GLint data[2][2] = {{0}};
1918   struct Cmds {
1919     cmds::Uniform2ivImmediate cmd;
1920     GLint data[2][2];
1921   };
1922 
1923   Cmds expected;
1924   for (int ii = 0; ii < 2; ++ii) {
1925     for (int jj = 0; jj < 2; ++jj) {
1926       data[ii][jj] = static_cast<GLint>(ii * 2 + jj);
1927     }
1928   }
1929   expected.cmd.Init(1, 2, &data[0][0]);
1930   gl_->Uniform2iv(1, 2, &data[0][0]);
1931   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1932 }
1933 
TEST_F(GLES2ImplementationTest,Uniform2ui)1934 TEST_F(GLES2ImplementationTest, Uniform2ui) {
1935   struct Cmds {
1936     cmds::Uniform2ui cmd;
1937   };
1938   Cmds expected;
1939   expected.cmd.Init(1, 2, 3);
1940 
1941   gl_->Uniform2ui(1, 2, 3);
1942   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1943 }
1944 
TEST_F(GLES2ImplementationTest,Uniform2uiv)1945 TEST_F(GLES2ImplementationTest, Uniform2uiv) {
1946   GLuint data[2][2] = {{0}};
1947   struct Cmds {
1948     cmds::Uniform2uivImmediate cmd;
1949     GLuint data[2][2];
1950   };
1951 
1952   Cmds expected;
1953   for (int ii = 0; ii < 2; ++ii) {
1954     for (int jj = 0; jj < 2; ++jj) {
1955       data[ii][jj] = static_cast<GLuint>(ii * 2 + jj);
1956     }
1957   }
1958   expected.cmd.Init(1, 2, &data[0][0]);
1959   gl_->Uniform2uiv(1, 2, &data[0][0]);
1960   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1961 }
1962 
TEST_F(GLES2ImplementationTest,Uniform3f)1963 TEST_F(GLES2ImplementationTest, Uniform3f) {
1964   struct Cmds {
1965     cmds::Uniform3f cmd;
1966   };
1967   Cmds expected;
1968   expected.cmd.Init(1, 2, 3, 4);
1969 
1970   gl_->Uniform3f(1, 2, 3, 4);
1971   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1972 }
1973 
TEST_F(GLES2ImplementationTest,Uniform3fv)1974 TEST_F(GLES2ImplementationTest, Uniform3fv) {
1975   GLfloat data[2][3] = {{0}};
1976   struct Cmds {
1977     cmds::Uniform3fvImmediate cmd;
1978     GLfloat data[2][3];
1979   };
1980 
1981   Cmds expected;
1982   for (int ii = 0; ii < 2; ++ii) {
1983     for (int jj = 0; jj < 3; ++jj) {
1984       data[ii][jj] = static_cast<GLfloat>(ii * 3 + jj);
1985     }
1986   }
1987   expected.cmd.Init(1, 2, &data[0][0]);
1988   gl_->Uniform3fv(1, 2, &data[0][0]);
1989   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1990 }
1991 
TEST_F(GLES2ImplementationTest,Uniform3i)1992 TEST_F(GLES2ImplementationTest, Uniform3i) {
1993   struct Cmds {
1994     cmds::Uniform3i cmd;
1995   };
1996   Cmds expected;
1997   expected.cmd.Init(1, 2, 3, 4);
1998 
1999   gl_->Uniform3i(1, 2, 3, 4);
2000   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2001 }
2002 
TEST_F(GLES2ImplementationTest,Uniform3iv)2003 TEST_F(GLES2ImplementationTest, Uniform3iv) {
2004   GLint data[2][3] = {{0}};
2005   struct Cmds {
2006     cmds::Uniform3ivImmediate cmd;
2007     GLint data[2][3];
2008   };
2009 
2010   Cmds expected;
2011   for (int ii = 0; ii < 2; ++ii) {
2012     for (int jj = 0; jj < 3; ++jj) {
2013       data[ii][jj] = static_cast<GLint>(ii * 3 + jj);
2014     }
2015   }
2016   expected.cmd.Init(1, 2, &data[0][0]);
2017   gl_->Uniform3iv(1, 2, &data[0][0]);
2018   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2019 }
2020 
TEST_F(GLES2ImplementationTest,Uniform3ui)2021 TEST_F(GLES2ImplementationTest, Uniform3ui) {
2022   struct Cmds {
2023     cmds::Uniform3ui cmd;
2024   };
2025   Cmds expected;
2026   expected.cmd.Init(1, 2, 3, 4);
2027 
2028   gl_->Uniform3ui(1, 2, 3, 4);
2029   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2030 }
2031 
TEST_F(GLES2ImplementationTest,Uniform3uiv)2032 TEST_F(GLES2ImplementationTest, Uniform3uiv) {
2033   GLuint data[2][3] = {{0}};
2034   struct Cmds {
2035     cmds::Uniform3uivImmediate cmd;
2036     GLuint data[2][3];
2037   };
2038 
2039   Cmds expected;
2040   for (int ii = 0; ii < 2; ++ii) {
2041     for (int jj = 0; jj < 3; ++jj) {
2042       data[ii][jj] = static_cast<GLuint>(ii * 3 + jj);
2043     }
2044   }
2045   expected.cmd.Init(1, 2, &data[0][0]);
2046   gl_->Uniform3uiv(1, 2, &data[0][0]);
2047   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2048 }
2049 
TEST_F(GLES2ImplementationTest,Uniform4f)2050 TEST_F(GLES2ImplementationTest, Uniform4f) {
2051   struct Cmds {
2052     cmds::Uniform4f cmd;
2053   };
2054   Cmds expected;
2055   expected.cmd.Init(1, 2, 3, 4, 5);
2056 
2057   gl_->Uniform4f(1, 2, 3, 4, 5);
2058   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2059 }
2060 
TEST_F(GLES2ImplementationTest,Uniform4fv)2061 TEST_F(GLES2ImplementationTest, Uniform4fv) {
2062   GLfloat data[2][4] = {{0}};
2063   struct Cmds {
2064     cmds::Uniform4fvImmediate cmd;
2065     GLfloat data[2][4];
2066   };
2067 
2068   Cmds expected;
2069   for (int ii = 0; ii < 2; ++ii) {
2070     for (int jj = 0; jj < 4; ++jj) {
2071       data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
2072     }
2073   }
2074   expected.cmd.Init(1, 2, &data[0][0]);
2075   gl_->Uniform4fv(1, 2, &data[0][0]);
2076   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2077 }
2078 
TEST_F(GLES2ImplementationTest,Uniform4i)2079 TEST_F(GLES2ImplementationTest, Uniform4i) {
2080   struct Cmds {
2081     cmds::Uniform4i cmd;
2082   };
2083   Cmds expected;
2084   expected.cmd.Init(1, 2, 3, 4, 5);
2085 
2086   gl_->Uniform4i(1, 2, 3, 4, 5);
2087   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2088 }
2089 
TEST_F(GLES2ImplementationTest,Uniform4iv)2090 TEST_F(GLES2ImplementationTest, Uniform4iv) {
2091   GLint data[2][4] = {{0}};
2092   struct Cmds {
2093     cmds::Uniform4ivImmediate cmd;
2094     GLint data[2][4];
2095   };
2096 
2097   Cmds expected;
2098   for (int ii = 0; ii < 2; ++ii) {
2099     for (int jj = 0; jj < 4; ++jj) {
2100       data[ii][jj] = static_cast<GLint>(ii * 4 + jj);
2101     }
2102   }
2103   expected.cmd.Init(1, 2, &data[0][0]);
2104   gl_->Uniform4iv(1, 2, &data[0][0]);
2105   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2106 }
2107 
TEST_F(GLES2ImplementationTest,Uniform4ui)2108 TEST_F(GLES2ImplementationTest, Uniform4ui) {
2109   struct Cmds {
2110     cmds::Uniform4ui cmd;
2111   };
2112   Cmds expected;
2113   expected.cmd.Init(1, 2, 3, 4, 5);
2114 
2115   gl_->Uniform4ui(1, 2, 3, 4, 5);
2116   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2117 }
2118 
TEST_F(GLES2ImplementationTest,Uniform4uiv)2119 TEST_F(GLES2ImplementationTest, Uniform4uiv) {
2120   GLuint data[2][4] = {{0}};
2121   struct Cmds {
2122     cmds::Uniform4uivImmediate cmd;
2123     GLuint data[2][4];
2124   };
2125 
2126   Cmds expected;
2127   for (int ii = 0; ii < 2; ++ii) {
2128     for (int jj = 0; jj < 4; ++jj) {
2129       data[ii][jj] = static_cast<GLuint>(ii * 4 + jj);
2130     }
2131   }
2132   expected.cmd.Init(1, 2, &data[0][0]);
2133   gl_->Uniform4uiv(1, 2, &data[0][0]);
2134   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2135 }
2136 
TEST_F(GLES2ImplementationTest,UniformBlockBinding)2137 TEST_F(GLES2ImplementationTest, UniformBlockBinding) {
2138   struct Cmds {
2139     cmds::UniformBlockBinding cmd;
2140   };
2141   Cmds expected;
2142   expected.cmd.Init(1, 2, 3);
2143 
2144   gl_->UniformBlockBinding(1, 2, 3);
2145   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2146 }
2147 
TEST_F(GLES2ImplementationTest,UniformMatrix2fv)2148 TEST_F(GLES2ImplementationTest, UniformMatrix2fv) {
2149   GLfloat data[2][4] = {{0}};
2150   struct Cmds {
2151     cmds::UniformMatrix2fvImmediate cmd;
2152     GLfloat data[2][4];
2153   };
2154 
2155   Cmds expected;
2156   for (int ii = 0; ii < 2; ++ii) {
2157     for (int jj = 0; jj < 4; ++jj) {
2158       data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
2159     }
2160   }
2161   expected.cmd.Init(1, 2, true, &data[0][0]);
2162   gl_->UniformMatrix2fv(1, 2, true, &data[0][0]);
2163   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2164 }
2165 
TEST_F(GLES2ImplementationTest,UniformMatrix2x3fv)2166 TEST_F(GLES2ImplementationTest, UniformMatrix2x3fv) {
2167   GLfloat data[2][6] = {{0}};
2168   struct Cmds {
2169     cmds::UniformMatrix2x3fvImmediate cmd;
2170     GLfloat data[2][6];
2171   };
2172 
2173   Cmds expected;
2174   for (int ii = 0; ii < 2; ++ii) {
2175     for (int jj = 0; jj < 6; ++jj) {
2176       data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2177     }
2178   }
2179   expected.cmd.Init(1, 2, true, &data[0][0]);
2180   gl_->UniformMatrix2x3fv(1, 2, true, &data[0][0]);
2181   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2182 }
2183 
TEST_F(GLES2ImplementationTest,UniformMatrix2x4fv)2184 TEST_F(GLES2ImplementationTest, UniformMatrix2x4fv) {
2185   GLfloat data[2][8] = {{0}};
2186   struct Cmds {
2187     cmds::UniformMatrix2x4fvImmediate cmd;
2188     GLfloat data[2][8];
2189   };
2190 
2191   Cmds expected;
2192   for (int ii = 0; ii < 2; ++ii) {
2193     for (int jj = 0; jj < 8; ++jj) {
2194       data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2195     }
2196   }
2197   expected.cmd.Init(1, 2, true, &data[0][0]);
2198   gl_->UniformMatrix2x4fv(1, 2, true, &data[0][0]);
2199   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2200 }
2201 
TEST_F(GLES2ImplementationTest,UniformMatrix3fv)2202 TEST_F(GLES2ImplementationTest, UniformMatrix3fv) {
2203   GLfloat data[2][9] = {{0}};
2204   struct Cmds {
2205     cmds::UniformMatrix3fvImmediate cmd;
2206     GLfloat data[2][9];
2207   };
2208 
2209   Cmds expected;
2210   for (int ii = 0; ii < 2; ++ii) {
2211     for (int jj = 0; jj < 9; ++jj) {
2212       data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj);
2213     }
2214   }
2215   expected.cmd.Init(1, 2, true, &data[0][0]);
2216   gl_->UniformMatrix3fv(1, 2, true, &data[0][0]);
2217   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2218 }
2219 
TEST_F(GLES2ImplementationTest,UniformMatrix3x2fv)2220 TEST_F(GLES2ImplementationTest, UniformMatrix3x2fv) {
2221   GLfloat data[2][6] = {{0}};
2222   struct Cmds {
2223     cmds::UniformMatrix3x2fvImmediate cmd;
2224     GLfloat data[2][6];
2225   };
2226 
2227   Cmds expected;
2228   for (int ii = 0; ii < 2; ++ii) {
2229     for (int jj = 0; jj < 6; ++jj) {
2230       data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj);
2231     }
2232   }
2233   expected.cmd.Init(1, 2, true, &data[0][0]);
2234   gl_->UniformMatrix3x2fv(1, 2, true, &data[0][0]);
2235   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2236 }
2237 
TEST_F(GLES2ImplementationTest,UniformMatrix3x4fv)2238 TEST_F(GLES2ImplementationTest, UniformMatrix3x4fv) {
2239   GLfloat data[2][12] = {{0}};
2240   struct Cmds {
2241     cmds::UniformMatrix3x4fvImmediate cmd;
2242     GLfloat data[2][12];
2243   };
2244 
2245   Cmds expected;
2246   for (int ii = 0; ii < 2; ++ii) {
2247     for (int jj = 0; jj < 12; ++jj) {
2248       data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2249     }
2250   }
2251   expected.cmd.Init(1, 2, true, &data[0][0]);
2252   gl_->UniformMatrix3x4fv(1, 2, true, &data[0][0]);
2253   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2254 }
2255 
TEST_F(GLES2ImplementationTest,UniformMatrix4fv)2256 TEST_F(GLES2ImplementationTest, UniformMatrix4fv) {
2257   GLfloat data[2][16] = {{0}};
2258   struct Cmds {
2259     cmds::UniformMatrix4fvImmediate cmd;
2260     GLfloat data[2][16];
2261   };
2262 
2263   Cmds expected;
2264   for (int ii = 0; ii < 2; ++ii) {
2265     for (int jj = 0; jj < 16; ++jj) {
2266       data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj);
2267     }
2268   }
2269   expected.cmd.Init(1, 2, true, &data[0][0]);
2270   gl_->UniformMatrix4fv(1, 2, true, &data[0][0]);
2271   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2272 }
2273 
TEST_F(GLES2ImplementationTest,UniformMatrix4x2fv)2274 TEST_F(GLES2ImplementationTest, UniformMatrix4x2fv) {
2275   GLfloat data[2][8] = {{0}};
2276   struct Cmds {
2277     cmds::UniformMatrix4x2fvImmediate cmd;
2278     GLfloat data[2][8];
2279   };
2280 
2281   Cmds expected;
2282   for (int ii = 0; ii < 2; ++ii) {
2283     for (int jj = 0; jj < 8; ++jj) {
2284       data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj);
2285     }
2286   }
2287   expected.cmd.Init(1, 2, true, &data[0][0]);
2288   gl_->UniformMatrix4x2fv(1, 2, true, &data[0][0]);
2289   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2290 }
2291 
TEST_F(GLES2ImplementationTest,UniformMatrix4x3fv)2292 TEST_F(GLES2ImplementationTest, UniformMatrix4x3fv) {
2293   GLfloat data[2][12] = {{0}};
2294   struct Cmds {
2295     cmds::UniformMatrix4x3fvImmediate cmd;
2296     GLfloat data[2][12];
2297   };
2298 
2299   Cmds expected;
2300   for (int ii = 0; ii < 2; ++ii) {
2301     for (int jj = 0; jj < 12; ++jj) {
2302       data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj);
2303     }
2304   }
2305   expected.cmd.Init(1, 2, true, &data[0][0]);
2306   gl_->UniformMatrix4x3fv(1, 2, true, &data[0][0]);
2307   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2308 }
2309 
TEST_F(GLES2ImplementationTest,UseProgram)2310 TEST_F(GLES2ImplementationTest, UseProgram) {
2311   struct Cmds {
2312     cmds::UseProgram cmd;
2313   };
2314   Cmds expected;
2315   expected.cmd.Init(1);
2316 
2317   gl_->UseProgram(1);
2318   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2319   ClearCommands();
2320   gl_->UseProgram(1);
2321   EXPECT_TRUE(NoCommandsWritten());
2322 }
2323 
TEST_F(GLES2ImplementationTest,ValidateProgram)2324 TEST_F(GLES2ImplementationTest, ValidateProgram) {
2325   struct Cmds {
2326     cmds::ValidateProgram cmd;
2327   };
2328   Cmds expected;
2329   expected.cmd.Init(1);
2330 
2331   gl_->ValidateProgram(1);
2332   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2333 }
2334 
TEST_F(GLES2ImplementationTest,VertexAttrib1f)2335 TEST_F(GLES2ImplementationTest, VertexAttrib1f) {
2336   struct Cmds {
2337     cmds::VertexAttrib1f cmd;
2338   };
2339   Cmds expected;
2340   expected.cmd.Init(1, 2);
2341 
2342   gl_->VertexAttrib1f(1, 2);
2343   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2344 }
2345 
TEST_F(GLES2ImplementationTest,VertexAttrib1fv)2346 TEST_F(GLES2ImplementationTest, VertexAttrib1fv) {
2347   GLfloat data[1] = {0};
2348   struct Cmds {
2349     cmds::VertexAttrib1fvImmediate cmd;
2350     GLfloat data[1];
2351   };
2352 
2353   for (int jj = 0; jj < 1; ++jj) {
2354     data[jj] = static_cast<GLfloat>(jj);
2355   }
2356   Cmds expected;
2357   expected.cmd.Init(1, &data[0]);
2358   gl_->VertexAttrib1fv(1, &data[0]);
2359   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2360 }
2361 
TEST_F(GLES2ImplementationTest,VertexAttrib2f)2362 TEST_F(GLES2ImplementationTest, VertexAttrib2f) {
2363   struct Cmds {
2364     cmds::VertexAttrib2f cmd;
2365   };
2366   Cmds expected;
2367   expected.cmd.Init(1, 2, 3);
2368 
2369   gl_->VertexAttrib2f(1, 2, 3);
2370   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2371 }
2372 
TEST_F(GLES2ImplementationTest,VertexAttrib2fv)2373 TEST_F(GLES2ImplementationTest, VertexAttrib2fv) {
2374   GLfloat data[2] = {0};
2375   struct Cmds {
2376     cmds::VertexAttrib2fvImmediate cmd;
2377     GLfloat data[2];
2378   };
2379 
2380   for (int jj = 0; jj < 2; ++jj) {
2381     data[jj] = static_cast<GLfloat>(jj);
2382   }
2383   Cmds expected;
2384   expected.cmd.Init(1, &data[0]);
2385   gl_->VertexAttrib2fv(1, &data[0]);
2386   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2387 }
2388 
TEST_F(GLES2ImplementationTest,VertexAttrib3f)2389 TEST_F(GLES2ImplementationTest, VertexAttrib3f) {
2390   struct Cmds {
2391     cmds::VertexAttrib3f cmd;
2392   };
2393   Cmds expected;
2394   expected.cmd.Init(1, 2, 3, 4);
2395 
2396   gl_->VertexAttrib3f(1, 2, 3, 4);
2397   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2398 }
2399 
TEST_F(GLES2ImplementationTest,VertexAttrib3fv)2400 TEST_F(GLES2ImplementationTest, VertexAttrib3fv) {
2401   GLfloat data[3] = {0};
2402   struct Cmds {
2403     cmds::VertexAttrib3fvImmediate cmd;
2404     GLfloat data[3];
2405   };
2406 
2407   for (int jj = 0; jj < 3; ++jj) {
2408     data[jj] = static_cast<GLfloat>(jj);
2409   }
2410   Cmds expected;
2411   expected.cmd.Init(1, &data[0]);
2412   gl_->VertexAttrib3fv(1, &data[0]);
2413   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2414 }
2415 
TEST_F(GLES2ImplementationTest,VertexAttrib4f)2416 TEST_F(GLES2ImplementationTest, VertexAttrib4f) {
2417   struct Cmds {
2418     cmds::VertexAttrib4f cmd;
2419   };
2420   Cmds expected;
2421   expected.cmd.Init(1, 2, 3, 4, 5);
2422 
2423   gl_->VertexAttrib4f(1, 2, 3, 4, 5);
2424   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2425 }
2426 
TEST_F(GLES2ImplementationTest,VertexAttrib4fv)2427 TEST_F(GLES2ImplementationTest, VertexAttrib4fv) {
2428   GLfloat data[4] = {0};
2429   struct Cmds {
2430     cmds::VertexAttrib4fvImmediate cmd;
2431     GLfloat data[4];
2432   };
2433 
2434   for (int jj = 0; jj < 4; ++jj) {
2435     data[jj] = static_cast<GLfloat>(jj);
2436   }
2437   Cmds expected;
2438   expected.cmd.Init(1, &data[0]);
2439   gl_->VertexAttrib4fv(1, &data[0]);
2440   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2441 }
2442 
TEST_F(GLES2ImplementationTest,VertexAttribI4i)2443 TEST_F(GLES2ImplementationTest, VertexAttribI4i) {
2444   struct Cmds {
2445     cmds::VertexAttribI4i cmd;
2446   };
2447   Cmds expected;
2448   expected.cmd.Init(1, 2, 3, 4, 5);
2449 
2450   gl_->VertexAttribI4i(1, 2, 3, 4, 5);
2451   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2452 }
2453 
TEST_F(GLES2ImplementationTest,VertexAttribI4iv)2454 TEST_F(GLES2ImplementationTest, VertexAttribI4iv) {
2455   GLint data[4] = {0};
2456   struct Cmds {
2457     cmds::VertexAttribI4ivImmediate cmd;
2458     GLint data[4];
2459   };
2460 
2461   for (int jj = 0; jj < 4; ++jj) {
2462     data[jj] = static_cast<GLint>(jj);
2463   }
2464   Cmds expected;
2465   expected.cmd.Init(1, &data[0]);
2466   gl_->VertexAttribI4iv(1, &data[0]);
2467   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2468 }
2469 
TEST_F(GLES2ImplementationTest,VertexAttribI4ui)2470 TEST_F(GLES2ImplementationTest, VertexAttribI4ui) {
2471   struct Cmds {
2472     cmds::VertexAttribI4ui cmd;
2473   };
2474   Cmds expected;
2475   expected.cmd.Init(1, 2, 3, 4, 5);
2476 
2477   gl_->VertexAttribI4ui(1, 2, 3, 4, 5);
2478   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2479 }
2480 
TEST_F(GLES2ImplementationTest,VertexAttribI4uiv)2481 TEST_F(GLES2ImplementationTest, VertexAttribI4uiv) {
2482   GLuint data[4] = {0};
2483   struct Cmds {
2484     cmds::VertexAttribI4uivImmediate cmd;
2485     GLuint data[4];
2486   };
2487 
2488   for (int jj = 0; jj < 4; ++jj) {
2489     data[jj] = static_cast<GLuint>(jj);
2490   }
2491   Cmds expected;
2492   expected.cmd.Init(1, &data[0]);
2493   gl_->VertexAttribI4uiv(1, &data[0]);
2494   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2495 }
2496 
TEST_F(GLES2ImplementationTest,Viewport)2497 TEST_F(GLES2ImplementationTest, Viewport) {
2498   struct Cmds {
2499     cmds::Viewport cmd;
2500   };
2501   Cmds expected;
2502   expected.cmd.Init(1, 2, 3, 4);
2503 
2504   gl_->Viewport(1, 2, 3, 4);
2505   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2506 }
2507 
TEST_F(GLES2ImplementationTest,BlitFramebufferCHROMIUM)2508 TEST_F(GLES2ImplementationTest, BlitFramebufferCHROMIUM) {
2509   struct Cmds {
2510     cmds::BlitFramebufferCHROMIUM cmd;
2511   };
2512   Cmds expected;
2513   expected.cmd.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
2514 
2515   gl_->BlitFramebufferCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
2516   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2517 }
2518 
TEST_F(GLES2ImplementationTest,RenderbufferStorageMultisampleCHROMIUM)2519 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleCHROMIUM) {
2520   struct Cmds {
2521     cmds::RenderbufferStorageMultisampleCHROMIUM cmd;
2522   };
2523   Cmds expected;
2524   expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2525 
2526   gl_->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, 2, GL_RGBA4, 4,
2527                                               5);
2528   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2529 }
2530 
TEST_F(GLES2ImplementationTest,RenderbufferStorageMultisampleAdvancedAMD)2531 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleAdvancedAMD) {
2532   struct Cmds {
2533     cmds::RenderbufferStorageMultisampleAdvancedAMD cmd;
2534   };
2535   Cmds expected;
2536   expected.cmd.Init(GL_RENDERBUFFER, 2, 3, GL_RGBA4, 5, 6);
2537 
2538   gl_->RenderbufferStorageMultisampleAdvancedAMD(GL_RENDERBUFFER, 2, 3,
2539                                                  GL_RGBA4, 5, 6);
2540   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2541 }
2542 
TEST_F(GLES2ImplementationTest,RenderbufferStorageMultisampleEXT)2543 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleEXT) {
2544   struct Cmds {
2545     cmds::RenderbufferStorageMultisampleEXT cmd;
2546   };
2547   Cmds expected;
2548   expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2549 
2550   gl_->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
2551   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2552 }
2553 
TEST_F(GLES2ImplementationTest,FramebufferTexture2DMultisampleEXT)2554 TEST_F(GLES2ImplementationTest, FramebufferTexture2DMultisampleEXT) {
2555   struct Cmds {
2556     cmds::FramebufferTexture2DMultisampleEXT cmd;
2557   };
2558   Cmds expected;
2559   expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4, 5,
2560                     6);
2561 
2562   gl_->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2563                                           GL_TEXTURE_2D, 4, 5, 6);
2564   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2565 }
2566 
TEST_F(GLES2ImplementationTest,TexStorage2DEXT)2567 TEST_F(GLES2ImplementationTest, TexStorage2DEXT) {
2568   struct Cmds {
2569     cmds::TexStorage2DEXT cmd;
2570   };
2571   Cmds expected;
2572   expected.cmd.Init(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
2573 
2574   gl_->TexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
2575   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2576 }
2577 
TEST_F(GLES2ImplementationTest,GenQueriesEXT)2578 TEST_F(GLES2ImplementationTest, GenQueriesEXT) {
2579   GLuint ids[2] = {
2580       0,
2581   };
2582   struct Cmds {
2583     cmds::GenQueriesEXTImmediate gen;
2584     GLuint data[2];
2585   };
2586   Cmds expected;
2587   expected.gen.Init(base::size(ids), &ids[0]);
2588   expected.data[0] = kQueriesStartId;
2589   expected.data[1] = kQueriesStartId + 1;
2590   gl_->GenQueriesEXT(base::size(ids), &ids[0]);
2591   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2592   EXPECT_EQ(kQueriesStartId, ids[0]);
2593   EXPECT_EQ(kQueriesStartId + 1, ids[1]);
2594 }
2595 
TEST_F(GLES2ImplementationTest,DeleteQueriesEXT)2596 TEST_F(GLES2ImplementationTest, DeleteQueriesEXT) {
2597   GLuint ids[2] = {kQueriesStartId, kQueriesStartId + 1};
2598   struct Cmds {
2599     cmds::DeleteQueriesEXTImmediate del;
2600     GLuint data[2];
2601   };
2602   Cmds expected;
2603   expected.del.Init(base::size(ids), &ids[0]);
2604   expected.data[0] = kQueriesStartId;
2605   expected.data[1] = kQueriesStartId + 1;
2606   gl_->DeleteQueriesEXT(base::size(ids), &ids[0]);
2607   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2608 }
2609 
TEST_F(GLES2ImplementationTest,BeginTransformFeedback)2610 TEST_F(GLES2ImplementationTest, BeginTransformFeedback) {
2611   struct Cmds {
2612     cmds::BeginTransformFeedback cmd;
2613   };
2614   Cmds expected;
2615   expected.cmd.Init(GL_POINTS);
2616 
2617   gl_->BeginTransformFeedback(GL_POINTS);
2618   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2619 }
2620 
TEST_F(GLES2ImplementationTest,EndTransformFeedback)2621 TEST_F(GLES2ImplementationTest, EndTransformFeedback) {
2622   struct Cmds {
2623     cmds::EndTransformFeedback cmd;
2624   };
2625   Cmds expected;
2626   expected.cmd.Init();
2627 
2628   gl_->EndTransformFeedback();
2629   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2630 }
2631 
TEST_F(GLES2ImplementationTest,PopGroupMarkerEXT)2632 TEST_F(GLES2ImplementationTest, PopGroupMarkerEXT) {
2633   struct Cmds {
2634     cmds::PopGroupMarkerEXT cmd;
2635   };
2636   Cmds expected;
2637   expected.cmd.Init();
2638 
2639   gl_->PopGroupMarkerEXT();
2640   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2641 }
2642 
TEST_F(GLES2ImplementationTest,GenVertexArraysOES)2643 TEST_F(GLES2ImplementationTest, GenVertexArraysOES) {
2644   GLuint ids[2] = {
2645       0,
2646   };
2647   struct Cmds {
2648     cmds::GenVertexArraysOESImmediate gen;
2649     GLuint data[2];
2650   };
2651   Cmds expected;
2652   expected.gen.Init(base::size(ids), &ids[0]);
2653   expected.data[0] = kVertexArraysStartId;
2654   expected.data[1] = kVertexArraysStartId + 1;
2655   gl_->GenVertexArraysOES(base::size(ids), &ids[0]);
2656   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2657   EXPECT_EQ(kVertexArraysStartId, ids[0]);
2658   EXPECT_EQ(kVertexArraysStartId + 1, ids[1]);
2659 }
2660 
TEST_F(GLES2ImplementationTest,DeleteVertexArraysOES)2661 TEST_F(GLES2ImplementationTest, DeleteVertexArraysOES) {
2662   GLuint ids[2] = {kVertexArraysStartId, kVertexArraysStartId + 1};
2663   struct Cmds {
2664     cmds::DeleteVertexArraysOESImmediate del;
2665     GLuint data[2];
2666   };
2667   Cmds expected;
2668   expected.del.Init(base::size(ids), &ids[0]);
2669   expected.data[0] = kVertexArraysStartId;
2670   expected.data[1] = kVertexArraysStartId + 1;
2671   gl_->DeleteVertexArraysOES(base::size(ids), &ids[0]);
2672   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2673 }
2674 
TEST_F(GLES2ImplementationTest,IsVertexArrayOES)2675 TEST_F(GLES2ImplementationTest, IsVertexArrayOES) {
2676   struct Cmds {
2677     cmds::IsVertexArrayOES cmd;
2678   };
2679 
2680   Cmds expected;
2681   ExpectedMemoryInfo result1 =
2682       GetExpectedResultMemory(sizeof(cmds::IsVertexArrayOES::Result));
2683   expected.cmd.Init(1, result1.id, result1.offset);
2684 
2685   EXPECT_CALL(*command_buffer(), OnFlush())
2686       .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE)))
2687       .RetiresOnSaturation();
2688 
2689   GLboolean result = gl_->IsVertexArrayOES(1);
2690   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2691   EXPECT_TRUE(result);
2692 }
2693 
TEST_F(GLES2ImplementationTest,FramebufferParameteri)2694 TEST_F(GLES2ImplementationTest, FramebufferParameteri) {
2695   struct Cmds {
2696     cmds::FramebufferParameteri cmd;
2697   };
2698   Cmds expected;
2699   expected.cmd.Init(GL_FRAMEBUFFER, 2, 3);
2700 
2701   gl_->FramebufferParameteri(GL_FRAMEBUFFER, 2, 3);
2702   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2703 }
2704 
TEST_F(GLES2ImplementationTest,BindImageTexture)2705 TEST_F(GLES2ImplementationTest, BindImageTexture) {
2706   struct Cmds {
2707     cmds::BindImageTexture cmd;
2708   };
2709   Cmds expected;
2710   expected.cmd.Init(1, 2, 3, true, 5, 6, 7);
2711 
2712   gl_->BindImageTexture(1, 2, 3, true, 5, 6, 7);
2713   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2714 }
2715 
TEST_F(GLES2ImplementationTest,DispatchCompute)2716 TEST_F(GLES2ImplementationTest, DispatchCompute) {
2717   struct Cmds {
2718     cmds::DispatchCompute cmd;
2719   };
2720   Cmds expected;
2721   expected.cmd.Init(1, 2, 3);
2722 
2723   gl_->DispatchCompute(1, 2, 3);
2724   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2725 }
2726 
TEST_F(GLES2ImplementationTest,DispatchComputeIndirect)2727 TEST_F(GLES2ImplementationTest, DispatchComputeIndirect) {
2728   struct Cmds {
2729     cmds::DispatchComputeIndirect cmd;
2730   };
2731   Cmds expected;
2732   expected.cmd.Init(1);
2733 
2734   gl_->DispatchComputeIndirect(1);
2735   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2736 }
2737 
TEST_F(GLES2ImplementationTest,GetProgramInterfaceiv)2738 TEST_F(GLES2ImplementationTest, GetProgramInterfaceiv) {
2739   struct Cmds {
2740     cmds::GetProgramInterfaceiv cmd;
2741   };
2742   typedef cmds::GetProgramInterfaceiv::Result::Type ResultType;
2743   ResultType result = 0;
2744   Cmds expected;
2745   ExpectedMemoryInfo result1 =
2746       GetExpectedResultMemory(sizeof(uint32_t) + sizeof(ResultType));
2747   expected.cmd.Init(123, 2, 3, result1.id, result1.offset);
2748   EXPECT_CALL(*command_buffer(), OnFlush())
2749       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<ResultType>(1)))
2750       .RetiresOnSaturation();
2751   gl_->GetProgramInterfaceiv(123, 2, 3, &result);
2752   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2753   EXPECT_EQ(static_cast<ResultType>(1), result);
2754 }
2755 
TEST_F(GLES2ImplementationTest,MemoryBarrierEXT)2756 TEST_F(GLES2ImplementationTest, MemoryBarrierEXT) {
2757   struct Cmds {
2758     cmds::MemoryBarrierEXT cmd;
2759   };
2760   Cmds expected;
2761   expected.cmd.Init(1);
2762 
2763   gl_->MemoryBarrierEXT(1);
2764   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2765 }
2766 
TEST_F(GLES2ImplementationTest,MemoryBarrierByRegion)2767 TEST_F(GLES2ImplementationTest, MemoryBarrierByRegion) {
2768   struct Cmds {
2769     cmds::MemoryBarrierByRegion cmd;
2770   };
2771   Cmds expected;
2772   expected.cmd.Init(1);
2773 
2774   gl_->MemoryBarrierByRegion(1);
2775   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2776 }
2777 
TEST_F(GLES2ImplementationTest,FlushMappedBufferRange)2778 TEST_F(GLES2ImplementationTest, FlushMappedBufferRange) {
2779   struct Cmds {
2780     cmds::FlushMappedBufferRange cmd;
2781   };
2782   Cmds expected;
2783   expected.cmd.Init(GL_ARRAY_BUFFER, 2, 3);
2784 
2785   gl_->FlushMappedBufferRange(GL_ARRAY_BUFFER, 2, 3);
2786   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2787 }
2788 
TEST_F(GLES2ImplementationTest,DescheduleUntilFinishedCHROMIUM)2789 TEST_F(GLES2ImplementationTest, DescheduleUntilFinishedCHROMIUM) {
2790   struct Cmds {
2791     cmds::DescheduleUntilFinishedCHROMIUM cmd;
2792   };
2793   Cmds expected;
2794   expected.cmd.Init();
2795 
2796   gl_->DescheduleUntilFinishedCHROMIUM();
2797   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2798 }
2799 
TEST_F(GLES2ImplementationTest,CopyTextureCHROMIUM)2800 TEST_F(GLES2ImplementationTest, CopyTextureCHROMIUM) {
2801   struct Cmds {
2802     cmds::CopyTextureCHROMIUM cmd;
2803   };
2804   Cmds expected;
2805   expected.cmd.Init(1, 2, GL_TEXTURE_2D, 4, 5, GL_ALPHA, GL_UNSIGNED_BYTE, true,
2806                     true, true);
2807 
2808   gl_->CopyTextureCHROMIUM(1, 2, GL_TEXTURE_2D, 4, 5, GL_ALPHA,
2809                            GL_UNSIGNED_BYTE, true, true, true);
2810   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2811 }
2812 
TEST_F(GLES2ImplementationTest,CopySubTextureCHROMIUM)2813 TEST_F(GLES2ImplementationTest, CopySubTextureCHROMIUM) {
2814   struct Cmds {
2815     cmds::CopySubTextureCHROMIUM cmd;
2816   };
2817   Cmds expected;
2818   expected.cmd.Init(1, 2, GL_TEXTURE_2D, 4, 5, 6, 7, 8, 9, 10, 11, true, true,
2819                     true);
2820 
2821   gl_->CopySubTextureCHROMIUM(1, 2, GL_TEXTURE_2D, 4, 5, 6, 7, 8, 9, 10, 11,
2822                               true, true, true);
2823   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2824 }
2825 
TEST_F(GLES2ImplementationTest,DrawArraysInstancedANGLE)2826 TEST_F(GLES2ImplementationTest, DrawArraysInstancedANGLE) {
2827   struct Cmds {
2828     cmds::DrawArraysInstancedANGLE cmd;
2829   };
2830   Cmds expected;
2831   expected.cmd.Init(GL_POINTS, 2, 3, 4);
2832 
2833   gl_->DrawArraysInstancedANGLE(GL_POINTS, 2, 3, 4);
2834   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2835 }
2836 
TEST_F(GLES2ImplementationTest,DrawArraysInstancedBaseInstanceANGLE)2837 TEST_F(GLES2ImplementationTest, DrawArraysInstancedBaseInstanceANGLE) {
2838   struct Cmds {
2839     cmds::DrawArraysInstancedBaseInstanceANGLE cmd;
2840   };
2841   Cmds expected;
2842   expected.cmd.Init(GL_POINTS, 2, 3, 4, 5);
2843 
2844   gl_->DrawArraysInstancedBaseInstanceANGLE(GL_POINTS, 2, 3, 4, 5);
2845   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2846 }
2847 
TEST_F(GLES2ImplementationTest,VertexAttribDivisorANGLE)2848 TEST_F(GLES2ImplementationTest, VertexAttribDivisorANGLE) {
2849   struct Cmds {
2850     cmds::VertexAttribDivisorANGLE cmd;
2851   };
2852   Cmds expected;
2853   expected.cmd.Init(1, 2);
2854 
2855   gl_->VertexAttribDivisorANGLE(1, 2);
2856   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2857 }
2858 
TEST_F(GLES2ImplementationTest,BindTexImage2DCHROMIUM)2859 TEST_F(GLES2ImplementationTest, BindTexImage2DCHROMIUM) {
2860   struct Cmds {
2861     cmds::BindTexImage2DCHROMIUM cmd;
2862   };
2863   Cmds expected;
2864   expected.cmd.Init(GL_TEXTURE_2D, 2);
2865 
2866   gl_->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
2867   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2868 }
2869 
TEST_F(GLES2ImplementationTest,BindTexImage2DWithInternalformatCHROMIUM)2870 TEST_F(GLES2ImplementationTest, BindTexImage2DWithInternalformatCHROMIUM) {
2871   struct Cmds {
2872     cmds::BindTexImage2DWithInternalformatCHROMIUM cmd;
2873   };
2874   Cmds expected;
2875   expected.cmd.Init(GL_TEXTURE_2D, GL_ALPHA, 3);
2876 
2877   gl_->BindTexImage2DWithInternalformatCHROMIUM(GL_TEXTURE_2D, GL_ALPHA, 3);
2878   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2879 }
2880 
TEST_F(GLES2ImplementationTest,ReleaseTexImage2DCHROMIUM)2881 TEST_F(GLES2ImplementationTest, ReleaseTexImage2DCHROMIUM) {
2882   struct Cmds {
2883     cmds::ReleaseTexImage2DCHROMIUM cmd;
2884   };
2885   Cmds expected;
2886   expected.cmd.Init(GL_TEXTURE_2D, 2);
2887 
2888   gl_->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
2889   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2890 }
2891 
TEST_F(GLES2ImplementationTest,DiscardFramebufferEXT)2892 TEST_F(GLES2ImplementationTest, DiscardFramebufferEXT) {
2893   GLenum data[2][1] = {{0}};
2894   struct Cmds {
2895     cmds::DiscardFramebufferEXTImmediate cmd;
2896     GLenum data[2][1];
2897   };
2898 
2899   Cmds expected;
2900   for (int ii = 0; ii < 2; ++ii) {
2901     for (int jj = 0; jj < 1; ++jj) {
2902       data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
2903     }
2904   }
2905   expected.cmd.Init(GL_FRAMEBUFFER, 2, &data[0][0]);
2906   gl_->DiscardFramebufferEXT(GL_FRAMEBUFFER, 2, &data[0][0]);
2907   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2908 }
2909 
TEST_F(GLES2ImplementationTest,LoseContextCHROMIUM)2910 TEST_F(GLES2ImplementationTest, LoseContextCHROMIUM) {
2911   struct Cmds {
2912     cmds::LoseContextCHROMIUM cmd;
2913   };
2914   Cmds expected;
2915   expected.cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_GUILTY_CONTEXT_RESET_ARB);
2916 
2917   gl_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
2918                            GL_GUILTY_CONTEXT_RESET_ARB);
2919   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2920 }
2921 
TEST_F(GLES2ImplementationTest,DrawBuffersEXT)2922 TEST_F(GLES2ImplementationTest, DrawBuffersEXT) {
2923   GLenum data[1][1] = {{0}};
2924   struct Cmds {
2925     cmds::DrawBuffersEXTImmediate cmd;
2926     GLenum data[1][1];
2927   };
2928 
2929   Cmds expected;
2930   for (int ii = 0; ii < 1; ++ii) {
2931     for (int jj = 0; jj < 1; ++jj) {
2932       data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
2933     }
2934   }
2935   expected.cmd.Init(1, &data[0][0]);
2936   gl_->DrawBuffersEXT(1, &data[0][0]);
2937   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2938 }
2939 
TEST_F(GLES2ImplementationTest,DiscardBackbufferCHROMIUM)2940 TEST_F(GLES2ImplementationTest, DiscardBackbufferCHROMIUM) {
2941   struct Cmds {
2942     cmds::DiscardBackbufferCHROMIUM cmd;
2943   };
2944   Cmds expected;
2945   expected.cmd.Init();
2946 
2947   gl_->DiscardBackbufferCHROMIUM();
2948   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2949 }
2950 
TEST_F(GLES2ImplementationTest,ScheduleCALayerInUseQueryCHROMIUM)2951 TEST_F(GLES2ImplementationTest, ScheduleCALayerInUseQueryCHROMIUM) {
2952   GLuint data[1][1] = {{0}};
2953   struct Cmds {
2954     cmds::ScheduleCALayerInUseQueryCHROMIUMImmediate cmd;
2955     GLuint data[1][1];
2956   };
2957 
2958   Cmds expected;
2959   for (int ii = 0; ii < 1; ++ii) {
2960     for (int jj = 0; jj < 1; ++jj) {
2961       data[ii][jj] = static_cast<GLuint>(ii * 1 + jj);
2962     }
2963   }
2964   expected.cmd.Init(1, &data[0][0]);
2965   gl_->ScheduleCALayerInUseQueryCHROMIUM(1, &data[0][0]);
2966   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2967 }
2968 
TEST_F(GLES2ImplementationTest,FlushDriverCachesCHROMIUM)2969 TEST_F(GLES2ImplementationTest, FlushDriverCachesCHROMIUM) {
2970   struct Cmds {
2971     cmds::FlushDriverCachesCHROMIUM cmd;
2972   };
2973   Cmds expected;
2974   expected.cmd.Init();
2975 
2976   gl_->FlushDriverCachesCHROMIUM();
2977   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2978 }
2979 
TEST_F(GLES2ImplementationTest,ScheduleDCLayerCHROMIUM)2980 TEST_F(GLES2ImplementationTest, ScheduleDCLayerCHROMIUM) {
2981   struct Cmds {
2982     cmds::ScheduleDCLayerCHROMIUM cmd;
2983   };
2984   Cmds expected;
2985   expected.cmd.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2986                     true, 19, 20, 21, 22, 23);
2987 
2988   gl_->ScheduleDCLayerCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2989                                15, 16, 17, true, 19, 20, 21, 22, 23);
2990   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2991 }
2992 
TEST_F(GLES2ImplementationTest,CoverageModulationCHROMIUM)2993 TEST_F(GLES2ImplementationTest, CoverageModulationCHROMIUM) {
2994   struct Cmds {
2995     cmds::CoverageModulationCHROMIUM cmd;
2996   };
2997   Cmds expected;
2998   expected.cmd.Init(GL_RGB);
2999 
3000   gl_->CoverageModulationCHROMIUM(GL_RGB);
3001   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3002 }
3003 
TEST_F(GLES2ImplementationTest,SetDrawRectangleCHROMIUM)3004 TEST_F(GLES2ImplementationTest, SetDrawRectangleCHROMIUM) {
3005   struct Cmds {
3006     cmds::SetDrawRectangleCHROMIUM cmd;
3007   };
3008   Cmds expected;
3009   expected.cmd.Init(1, 2, 3, 4);
3010 
3011   gl_->SetDrawRectangleCHROMIUM(1, 2, 3, 4);
3012   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3013 }
3014 
TEST_F(GLES2ImplementationTest,SetEnableDCLayersCHROMIUM)3015 TEST_F(GLES2ImplementationTest, SetEnableDCLayersCHROMIUM) {
3016   struct Cmds {
3017     cmds::SetEnableDCLayersCHROMIUM cmd;
3018   };
3019   Cmds expected;
3020   expected.cmd.Init(true);
3021 
3022   gl_->SetEnableDCLayersCHROMIUM(true);
3023   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3024 }
3025 
TEST_F(GLES2ImplementationTest,TexStorage2DImageCHROMIUM)3026 TEST_F(GLES2ImplementationTest, TexStorage2DImageCHROMIUM) {
3027   struct Cmds {
3028     cmds::TexStorage2DImageCHROMIUM cmd;
3029   };
3030   Cmds expected;
3031   expected.cmd.Init(GL_TEXTURE_2D, GL_RGB565, 4, 5);
3032 
3033   gl_->TexStorage2DImageCHROMIUM(GL_TEXTURE_2D, GL_RGB565, GL_SCANOUT_CHROMIUM,
3034                                  4, 5);
3035   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3036 }
3037 
TEST_F(GLES2ImplementationTest,TexStorage2DImageCHROMIUMInvalidConstantArg2)3038 TEST_F(GLES2ImplementationTest, TexStorage2DImageCHROMIUMInvalidConstantArg2) {
3039   gl_->TexStorage2DImageCHROMIUM(GL_TEXTURE_2D, GL_RGB565, GL_NONE, 4, 5);
3040   EXPECT_TRUE(NoCommandsWritten());
3041   EXPECT_EQ(GL_INVALID_ENUM, CheckError());
3042 }
3043 
TEST_F(GLES2ImplementationTest,WindowRectanglesEXT)3044 TEST_F(GLES2ImplementationTest, WindowRectanglesEXT) {
3045   GLint data[2][4] = {{0}};
3046   struct Cmds {
3047     cmds::WindowRectanglesEXTImmediate cmd;
3048     GLint data[2][4];
3049   };
3050 
3051   Cmds expected;
3052   for (int ii = 0; ii < 2; ++ii) {
3053     for (int jj = 0; jj < 4; ++jj) {
3054       data[ii][jj] = static_cast<GLint>(ii * 4 + jj);
3055     }
3056   }
3057   expected.cmd.Init(GL_INCLUSIVE_EXT, 2, &data[0][0]);
3058   gl_->WindowRectanglesEXT(GL_INCLUSIVE_EXT, 2, &data[0][0]);
3059   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3060 }
3061 
TEST_F(GLES2ImplementationTest,WaitGpuFenceCHROMIUM)3062 TEST_F(GLES2ImplementationTest, WaitGpuFenceCHROMIUM) {
3063   struct Cmds {
3064     cmds::WaitGpuFenceCHROMIUM cmd;
3065   };
3066   Cmds expected;
3067   expected.cmd.Init(1);
3068 
3069   gl_->WaitGpuFenceCHROMIUM(1);
3070   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3071 }
3072 
TEST_F(GLES2ImplementationTest,DestroyGpuFenceCHROMIUM)3073 TEST_F(GLES2ImplementationTest, DestroyGpuFenceCHROMIUM) {
3074   struct Cmds {
3075     cmds::DestroyGpuFenceCHROMIUM cmd;
3076   };
3077   Cmds expected;
3078   expected.cmd.Init(1);
3079 
3080   gl_->DestroyGpuFenceCHROMIUM(1);
3081   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3082 }
3083 
TEST_F(GLES2ImplementationTest,FramebufferTextureMultiviewOVR)3084 TEST_F(GLES2ImplementationTest, FramebufferTextureMultiviewOVR) {
3085   struct Cmds {
3086     cmds::FramebufferTextureMultiviewOVR cmd;
3087   };
3088   Cmds expected;
3089   expected.cmd.Init(1, 2, 3, 4, 5, 6);
3090 
3091   gl_->FramebufferTextureMultiviewOVR(1, 2, 3, 4, 5, 6);
3092   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3093 }
3094 
TEST_F(GLES2ImplementationTest,EndSharedImageAccessDirectCHROMIUM)3095 TEST_F(GLES2ImplementationTest, EndSharedImageAccessDirectCHROMIUM) {
3096   struct Cmds {
3097     cmds::EndSharedImageAccessDirectCHROMIUM cmd;
3098   };
3099   Cmds expected;
3100   expected.cmd.Init(1);
3101 
3102   gl_->EndSharedImageAccessDirectCHROMIUM(1);
3103   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3104 }
3105 
TEST_F(GLES2ImplementationTest,BeginBatchReadAccessSharedImageCHROMIUM)3106 TEST_F(GLES2ImplementationTest, BeginBatchReadAccessSharedImageCHROMIUM) {
3107   struct Cmds {
3108     cmds::BeginBatchReadAccessSharedImageCHROMIUM cmd;
3109   };
3110   Cmds expected;
3111   expected.cmd.Init();
3112 
3113   gl_->BeginBatchReadAccessSharedImageCHROMIUM();
3114   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3115 }
3116 
TEST_F(GLES2ImplementationTest,EndBatchReadAccessSharedImageCHROMIUM)3117 TEST_F(GLES2ImplementationTest, EndBatchReadAccessSharedImageCHROMIUM) {
3118   struct Cmds {
3119     cmds::EndBatchReadAccessSharedImageCHROMIUM cmd;
3120   };
3121   Cmds expected;
3122   expected.cmd.Init();
3123 
3124   gl_->EndBatchReadAccessSharedImageCHROMIUM();
3125   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3126 }
3127 #endif  // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_
3128