Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / gpu / command_buffer / client / gles2_implementation_unittest_autogen.h
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
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 // TODO: Implement unit test for BindAttribLocation
27
28 TEST_F(GLES2ImplementationTest, BindBuffer) {
29   struct Cmds {
30     cmds::BindBuffer cmd;
31   };
32   Cmds expected;
33   expected.cmd.Init(GL_ARRAY_BUFFER, 2);
34
35   gl_->BindBuffer(GL_ARRAY_BUFFER, 2);
36   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
37   ClearCommands();
38   gl_->BindBuffer(GL_ARRAY_BUFFER, 2);
39   EXPECT_TRUE(NoCommandsWritten());
40 }
41
42 TEST_F(GLES2ImplementationTest, BindFramebuffer) {
43   struct Cmds {
44     cmds::BindFramebuffer cmd;
45   };
46   Cmds expected;
47   expected.cmd.Init(GL_FRAMEBUFFER, 2);
48
49   gl_->BindFramebuffer(GL_FRAMEBUFFER, 2);
50   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
51   ClearCommands();
52   gl_->BindFramebuffer(GL_FRAMEBUFFER, 2);
53   EXPECT_TRUE(NoCommandsWritten());
54 }
55
56 TEST_F(GLES2ImplementationTest, BindRenderbuffer) {
57   struct Cmds {
58     cmds::BindRenderbuffer cmd;
59   };
60   Cmds expected;
61   expected.cmd.Init(GL_RENDERBUFFER, 2);
62
63   gl_->BindRenderbuffer(GL_RENDERBUFFER, 2);
64   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
65   ClearCommands();
66   gl_->BindRenderbuffer(GL_RENDERBUFFER, 2);
67   EXPECT_TRUE(NoCommandsWritten());
68 }
69
70 TEST_F(GLES2ImplementationTest, BlendColor) {
71   struct Cmds {
72     cmds::BlendColor cmd;
73   };
74   Cmds expected;
75   expected.cmd.Init(1, 2, 3, 4);
76
77   gl_->BlendColor(1, 2, 3, 4);
78   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
79 }
80
81 TEST_F(GLES2ImplementationTest, BlendEquation) {
82   struct Cmds {
83     cmds::BlendEquation cmd;
84   };
85   Cmds expected;
86   expected.cmd.Init(GL_FUNC_SUBTRACT);
87
88   gl_->BlendEquation(GL_FUNC_SUBTRACT);
89   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
90 }
91
92 TEST_F(GLES2ImplementationTest, BlendEquationSeparate) {
93   struct Cmds {
94     cmds::BlendEquationSeparate cmd;
95   };
96   Cmds expected;
97   expected.cmd.Init(GL_FUNC_SUBTRACT, GL_FUNC_ADD);
98
99   gl_->BlendEquationSeparate(GL_FUNC_SUBTRACT, GL_FUNC_ADD);
100   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
101 }
102
103 TEST_F(GLES2ImplementationTest, BlendFunc) {
104   struct Cmds {
105     cmds::BlendFunc cmd;
106   };
107   Cmds expected;
108   expected.cmd.Init(GL_ZERO, GL_ZERO);
109
110   gl_->BlendFunc(GL_ZERO, GL_ZERO);
111   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
112 }
113
114 TEST_F(GLES2ImplementationTest, BlendFuncSeparate) {
115   struct Cmds {
116     cmds::BlendFuncSeparate cmd;
117   };
118   Cmds expected;
119   expected.cmd.Init(GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO);
120
121   gl_->BlendFuncSeparate(GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO);
122   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
123 }
124
125 TEST_F(GLES2ImplementationTest, CheckFramebufferStatus) {
126   struct Cmds {
127     cmds::CheckFramebufferStatus cmd;
128   };
129
130   Cmds expected;
131   ExpectedMemoryInfo result1 =
132       GetExpectedResultMemory(sizeof(cmds::CheckFramebufferStatus::Result));
133   expected.cmd.Init(1, result1.id, result1.offset);
134
135   EXPECT_CALL(*command_buffer(), OnFlush())
136       .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
137       .RetiresOnSaturation();
138
139   GLboolean result = gl_->CheckFramebufferStatus(1);
140   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
141   EXPECT_TRUE(result);
142 }
143
144 TEST_F(GLES2ImplementationTest, Clear) {
145   struct Cmds {
146     cmds::Clear cmd;
147   };
148   Cmds expected;
149   expected.cmd.Init(1);
150
151   gl_->Clear(1);
152   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
153 }
154
155 TEST_F(GLES2ImplementationTest, ClearColor) {
156   struct Cmds {
157     cmds::ClearColor cmd;
158   };
159   Cmds expected;
160   expected.cmd.Init(1, 2, 3, 4);
161
162   gl_->ClearColor(1, 2, 3, 4);
163   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
164 }
165
166 TEST_F(GLES2ImplementationTest, ClearDepthf) {
167   struct Cmds {
168     cmds::ClearDepthf cmd;
169   };
170   Cmds expected;
171   expected.cmd.Init(0.5f);
172
173   gl_->ClearDepthf(0.5f);
174   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
175 }
176
177 TEST_F(GLES2ImplementationTest, ClearStencil) {
178   struct Cmds {
179     cmds::ClearStencil cmd;
180   };
181   Cmds expected;
182   expected.cmd.Init(1);
183
184   gl_->ClearStencil(1);
185   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
186 }
187
188 TEST_F(GLES2ImplementationTest, ColorMask) {
189   struct Cmds {
190     cmds::ColorMask cmd;
191   };
192   Cmds expected;
193   expected.cmd.Init(true, true, true, true);
194
195   gl_->ColorMask(true, true, true, true);
196   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
197 }
198
199 TEST_F(GLES2ImplementationTest, CompileShader) {
200   struct Cmds {
201     cmds::CompileShader cmd;
202   };
203   Cmds expected;
204   expected.cmd.Init(1);
205
206   gl_->CompileShader(1);
207   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
208 }
209 // TODO: Implement unit test for CompressedTexImage2D
210 // TODO: Implement unit test for CompressedTexSubImage2D
211
212 TEST_F(GLES2ImplementationTest, CopyTexImage2D) {
213   struct Cmds {
214     cmds::CopyTexImage2D cmd;
215   };
216   Cmds expected;
217   expected.cmd.Init(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7);
218
219   gl_->CopyTexImage2D(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7, 0);
220   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
221 }
222
223 TEST_F(GLES2ImplementationTest, CopyTexImage2DInvalidConstantArg7) {
224   gl_->CopyTexImage2D(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7, 1);
225   EXPECT_TRUE(NoCommandsWritten());
226   EXPECT_EQ(GL_INVALID_VALUE, CheckError());
227 }
228
229 TEST_F(GLES2ImplementationTest, CopyTexSubImage2D) {
230   struct Cmds {
231     cmds::CopyTexSubImage2D cmd;
232   };
233   Cmds expected;
234   expected.cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8);
235
236   gl_->CopyTexSubImage2D(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8);
237   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
238 }
239
240 TEST_F(GLES2ImplementationTest, CullFace) {
241   struct Cmds {
242     cmds::CullFace cmd;
243   };
244   Cmds expected;
245   expected.cmd.Init(GL_FRONT);
246
247   gl_->CullFace(GL_FRONT);
248   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
249 }
250
251 TEST_F(GLES2ImplementationTest, DeleteBuffers) {
252   GLuint ids[2] = {kBuffersStartId, kBuffersStartId + 1};
253   struct Cmds {
254     cmds::DeleteBuffersImmediate del;
255     GLuint data[2];
256   };
257   Cmds expected;
258   expected.del.Init(arraysize(ids), &ids[0]);
259   expected.data[0] = kBuffersStartId;
260   expected.data[1] = kBuffersStartId + 1;
261   gl_->DeleteBuffers(arraysize(ids), &ids[0]);
262   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
263 }
264
265 TEST_F(GLES2ImplementationTest, DeleteFramebuffers) {
266   GLuint ids[2] = {kFramebuffersStartId, kFramebuffersStartId + 1};
267   struct Cmds {
268     cmds::DeleteFramebuffersImmediate del;
269     GLuint data[2];
270   };
271   Cmds expected;
272   expected.del.Init(arraysize(ids), &ids[0]);
273   expected.data[0] = kFramebuffersStartId;
274   expected.data[1] = kFramebuffersStartId + 1;
275   gl_->DeleteFramebuffers(arraysize(ids), &ids[0]);
276   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
277 }
278
279 TEST_F(GLES2ImplementationTest, DeleteProgram) {
280   struct Cmds {
281     cmds::DeleteProgram cmd;
282   };
283   Cmds expected;
284   expected.cmd.Init(1);
285
286   gl_->DeleteProgram(1);
287   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
288 }
289
290 TEST_F(GLES2ImplementationTest, DeleteRenderbuffers) {
291   GLuint ids[2] = {kRenderbuffersStartId, kRenderbuffersStartId + 1};
292   struct Cmds {
293     cmds::DeleteRenderbuffersImmediate del;
294     GLuint data[2];
295   };
296   Cmds expected;
297   expected.del.Init(arraysize(ids), &ids[0]);
298   expected.data[0] = kRenderbuffersStartId;
299   expected.data[1] = kRenderbuffersStartId + 1;
300   gl_->DeleteRenderbuffers(arraysize(ids), &ids[0]);
301   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
302 }
303
304 TEST_F(GLES2ImplementationTest, DeleteShader) {
305   struct Cmds {
306     cmds::DeleteShader cmd;
307   };
308   Cmds expected;
309   expected.cmd.Init(1);
310
311   gl_->DeleteShader(1);
312   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
313 }
314
315 TEST_F(GLES2ImplementationTest, DeleteTextures) {
316   GLuint ids[2] = {kTexturesStartId, kTexturesStartId + 1};
317   struct Cmds {
318     cmds::DeleteTexturesImmediate del;
319     GLuint data[2];
320   };
321   Cmds expected;
322   expected.del.Init(arraysize(ids), &ids[0]);
323   expected.data[0] = kTexturesStartId;
324   expected.data[1] = kTexturesStartId + 1;
325   gl_->DeleteTextures(arraysize(ids), &ids[0]);
326   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
327 }
328
329 TEST_F(GLES2ImplementationTest, DepthFunc) {
330   struct Cmds {
331     cmds::DepthFunc cmd;
332   };
333   Cmds expected;
334   expected.cmd.Init(GL_NEVER);
335
336   gl_->DepthFunc(GL_NEVER);
337   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
338 }
339
340 TEST_F(GLES2ImplementationTest, DepthMask) {
341   struct Cmds {
342     cmds::DepthMask cmd;
343   };
344   Cmds expected;
345   expected.cmd.Init(true);
346
347   gl_->DepthMask(true);
348   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
349 }
350
351 TEST_F(GLES2ImplementationTest, DepthRangef) {
352   struct Cmds {
353     cmds::DepthRangef cmd;
354   };
355   Cmds expected;
356   expected.cmd.Init(1, 2);
357
358   gl_->DepthRangef(1, 2);
359   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
360 }
361
362 TEST_F(GLES2ImplementationTest, DetachShader) {
363   struct Cmds {
364     cmds::DetachShader cmd;
365   };
366   Cmds expected;
367   expected.cmd.Init(1, 2);
368
369   gl_->DetachShader(1, 2);
370   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
371 }
372
373 TEST_F(GLES2ImplementationTest, DisableVertexAttribArray) {
374   struct Cmds {
375     cmds::DisableVertexAttribArray cmd;
376   };
377   Cmds expected;
378   expected.cmd.Init(1);
379
380   gl_->DisableVertexAttribArray(1);
381   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
382 }
383
384 TEST_F(GLES2ImplementationTest, DrawArrays) {
385   struct Cmds {
386     cmds::DrawArrays cmd;
387   };
388   Cmds expected;
389   expected.cmd.Init(GL_POINTS, 2, 3);
390
391   gl_->DrawArrays(GL_POINTS, 2, 3);
392   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
393 }
394
395 TEST_F(GLES2ImplementationTest, EnableVertexAttribArray) {
396   struct Cmds {
397     cmds::EnableVertexAttribArray cmd;
398   };
399   Cmds expected;
400   expected.cmd.Init(1);
401
402   gl_->EnableVertexAttribArray(1);
403   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
404 }
405
406 TEST_F(GLES2ImplementationTest, Flush) {
407   struct Cmds {
408     cmds::Flush cmd;
409   };
410   Cmds expected;
411   expected.cmd.Init();
412
413   gl_->Flush();
414   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
415 }
416
417 TEST_F(GLES2ImplementationTest, FramebufferRenderbuffer) {
418   struct Cmds {
419     cmds::FramebufferRenderbuffer cmd;
420   };
421   Cmds expected;
422   expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 4);
423
424   gl_->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
425                                GL_RENDERBUFFER, 4);
426   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
427 }
428
429 TEST_F(GLES2ImplementationTest, FramebufferTexture2D) {
430   struct Cmds {
431     cmds::FramebufferTexture2D cmd;
432   };
433   Cmds expected;
434   expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4);
435
436   gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
437                             4, 0);
438   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
439 }
440
441 TEST_F(GLES2ImplementationTest, FramebufferTexture2DInvalidConstantArg4) {
442   gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
443                             4, 1);
444   EXPECT_TRUE(NoCommandsWritten());
445   EXPECT_EQ(GL_INVALID_VALUE, CheckError());
446 }
447
448 TEST_F(GLES2ImplementationTest, FrontFace) {
449   struct Cmds {
450     cmds::FrontFace cmd;
451   };
452   Cmds expected;
453   expected.cmd.Init(GL_CW);
454
455   gl_->FrontFace(GL_CW);
456   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
457 }
458
459 TEST_F(GLES2ImplementationTest, GenBuffers) {
460   GLuint ids[2] = {
461       0,
462   };
463   struct Cmds {
464     cmds::GenBuffersImmediate gen;
465     GLuint data[2];
466   };
467   Cmds expected;
468   expected.gen.Init(arraysize(ids), &ids[0]);
469   expected.data[0] = kBuffersStartId;
470   expected.data[1] = kBuffersStartId + 1;
471   gl_->GenBuffers(arraysize(ids), &ids[0]);
472   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
473   EXPECT_EQ(kBuffersStartId, ids[0]);
474   EXPECT_EQ(kBuffersStartId + 1, ids[1]);
475 }
476
477 TEST_F(GLES2ImplementationTest, GenerateMipmap) {
478   struct Cmds {
479     cmds::GenerateMipmap cmd;
480   };
481   Cmds expected;
482   expected.cmd.Init(GL_TEXTURE_2D);
483
484   gl_->GenerateMipmap(GL_TEXTURE_2D);
485   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
486 }
487
488 TEST_F(GLES2ImplementationTest, GenFramebuffers) {
489   GLuint ids[2] = {
490       0,
491   };
492   struct Cmds {
493     cmds::GenFramebuffersImmediate gen;
494     GLuint data[2];
495   };
496   Cmds expected;
497   expected.gen.Init(arraysize(ids), &ids[0]);
498   expected.data[0] = kFramebuffersStartId;
499   expected.data[1] = kFramebuffersStartId + 1;
500   gl_->GenFramebuffers(arraysize(ids), &ids[0]);
501   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
502   EXPECT_EQ(kFramebuffersStartId, ids[0]);
503   EXPECT_EQ(kFramebuffersStartId + 1, ids[1]);
504 }
505
506 TEST_F(GLES2ImplementationTest, GenRenderbuffers) {
507   GLuint ids[2] = {
508       0,
509   };
510   struct Cmds {
511     cmds::GenRenderbuffersImmediate gen;
512     GLuint data[2];
513   };
514   Cmds expected;
515   expected.gen.Init(arraysize(ids), &ids[0]);
516   expected.data[0] = kRenderbuffersStartId;
517   expected.data[1] = kRenderbuffersStartId + 1;
518   gl_->GenRenderbuffers(arraysize(ids), &ids[0]);
519   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
520   EXPECT_EQ(kRenderbuffersStartId, ids[0]);
521   EXPECT_EQ(kRenderbuffersStartId + 1, ids[1]);
522 }
523
524 TEST_F(GLES2ImplementationTest, GenTextures) {
525   GLuint ids[2] = {
526       0,
527   };
528   struct Cmds {
529     cmds::GenTexturesImmediate gen;
530     GLuint data[2];
531   };
532   Cmds expected;
533   expected.gen.Init(arraysize(ids), &ids[0]);
534   expected.data[0] = kTexturesStartId;
535   expected.data[1] = kTexturesStartId + 1;
536   gl_->GenTextures(arraysize(ids), &ids[0]);
537   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
538   EXPECT_EQ(kTexturesStartId, ids[0]);
539   EXPECT_EQ(kTexturesStartId + 1, ids[1]);
540 }
541 // TODO: Implement unit test for GetActiveAttrib
542 // TODO: Implement unit test for GetActiveUniform
543 // TODO: Implement unit test for GetAttachedShaders
544 // TODO: Implement unit test for GetAttribLocation
545
546 TEST_F(GLES2ImplementationTest, GetBooleanv) {
547   struct Cmds {
548     cmds::GetBooleanv cmd;
549   };
550   typedef cmds::GetBooleanv::Result Result;
551   Result::Type result = 0;
552   Cmds expected;
553   ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
554   expected.cmd.Init(123, result1.id, result1.offset);
555   EXPECT_CALL(*command_buffer(), OnFlush())
556       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
557       .RetiresOnSaturation();
558   gl_->GetBooleanv(123, &result);
559   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
560   EXPECT_EQ(static_cast<Result::Type>(1), result);
561 }
562
563 TEST_F(GLES2ImplementationTest, GetBufferParameteriv) {
564   struct Cmds {
565     cmds::GetBufferParameteriv cmd;
566   };
567   typedef cmds::GetBufferParameteriv::Result Result;
568   Result::Type result = 0;
569   Cmds expected;
570   ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
571   expected.cmd.Init(123, GL_BUFFER_SIZE, result1.id, result1.offset);
572   EXPECT_CALL(*command_buffer(), OnFlush())
573       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
574       .RetiresOnSaturation();
575   gl_->GetBufferParameteriv(123, GL_BUFFER_SIZE, &result);
576   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
577   EXPECT_EQ(static_cast<Result::Type>(1), result);
578 }
579
580 TEST_F(GLES2ImplementationTest, GetFloatv) {
581   struct Cmds {
582     cmds::GetFloatv cmd;
583   };
584   typedef cmds::GetFloatv::Result Result;
585   Result::Type result = 0;
586   Cmds expected;
587   ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
588   expected.cmd.Init(123, result1.id, result1.offset);
589   EXPECT_CALL(*command_buffer(), OnFlush())
590       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
591       .RetiresOnSaturation();
592   gl_->GetFloatv(123, &result);
593   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
594   EXPECT_EQ(static_cast<Result::Type>(1), result);
595 }
596
597 TEST_F(GLES2ImplementationTest, GetFramebufferAttachmentParameteriv) {
598   struct Cmds {
599     cmds::GetFramebufferAttachmentParameteriv cmd;
600   };
601   typedef cmds::GetFramebufferAttachmentParameteriv::Result Result;
602   Result::Type result = 0;
603   Cmds expected;
604   ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
605   expected.cmd.Init(123, GL_COLOR_ATTACHMENT0,
606                     GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, result1.id,
607                     result1.offset);
608   EXPECT_CALL(*command_buffer(), OnFlush())
609       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
610       .RetiresOnSaturation();
611   gl_->GetFramebufferAttachmentParameteriv(
612       123, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
613       &result);
614   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
615   EXPECT_EQ(static_cast<Result::Type>(1), result);
616 }
617
618 TEST_F(GLES2ImplementationTest, GetIntegerv) {
619   struct Cmds {
620     cmds::GetIntegerv cmd;
621   };
622   typedef cmds::GetIntegerv::Result Result;
623   Result::Type result = 0;
624   Cmds expected;
625   ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
626   expected.cmd.Init(123, result1.id, result1.offset);
627   EXPECT_CALL(*command_buffer(), OnFlush())
628       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
629       .RetiresOnSaturation();
630   gl_->GetIntegerv(123, &result);
631   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
632   EXPECT_EQ(static_cast<Result::Type>(1), result);
633 }
634
635 TEST_F(GLES2ImplementationTest, GetProgramiv) {
636   struct Cmds {
637     cmds::GetProgramiv cmd;
638   };
639   typedef cmds::GetProgramiv::Result Result;
640   Result::Type result = 0;
641   Cmds expected;
642   ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
643   expected.cmd.Init(123, GL_DELETE_STATUS, result1.id, result1.offset);
644   EXPECT_CALL(*command_buffer(), OnFlush())
645       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
646       .RetiresOnSaturation();
647   gl_->GetProgramiv(123, GL_DELETE_STATUS, &result);
648   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
649   EXPECT_EQ(static_cast<Result::Type>(1), result);
650 }
651 // TODO: Implement unit test for GetProgramInfoLog
652
653 TEST_F(GLES2ImplementationTest, GetRenderbufferParameteriv) {
654   struct Cmds {
655     cmds::GetRenderbufferParameteriv cmd;
656   };
657   typedef cmds::GetRenderbufferParameteriv::Result Result;
658   Result::Type result = 0;
659   Cmds expected;
660   ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
661   expected.cmd.Init(123, GL_RENDERBUFFER_RED_SIZE, result1.id, result1.offset);
662   EXPECT_CALL(*command_buffer(), OnFlush())
663       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
664       .RetiresOnSaturation();
665   gl_->GetRenderbufferParameteriv(123, GL_RENDERBUFFER_RED_SIZE, &result);
666   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
667   EXPECT_EQ(static_cast<Result::Type>(1), result);
668 }
669
670 TEST_F(GLES2ImplementationTest, GetShaderiv) {
671   struct Cmds {
672     cmds::GetShaderiv cmd;
673   };
674   typedef cmds::GetShaderiv::Result Result;
675   Result::Type result = 0;
676   Cmds expected;
677   ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
678   expected.cmd.Init(123, GL_SHADER_TYPE, result1.id, result1.offset);
679   EXPECT_CALL(*command_buffer(), OnFlush())
680       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
681       .RetiresOnSaturation();
682   gl_->GetShaderiv(123, GL_SHADER_TYPE, &result);
683   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
684   EXPECT_EQ(static_cast<Result::Type>(1), result);
685 }
686 // TODO: Implement unit test for GetShaderInfoLog
687 // TODO: Implement unit test for GetShaderPrecisionFormat
688
689 TEST_F(GLES2ImplementationTest, GetTexParameterfv) {
690   struct Cmds {
691     cmds::GetTexParameterfv cmd;
692   };
693   typedef cmds::GetTexParameterfv::Result Result;
694   Result::Type result = 0;
695   Cmds expected;
696   ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
697   expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
698   EXPECT_CALL(*command_buffer(), OnFlush())
699       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
700       .RetiresOnSaturation();
701   gl_->GetTexParameterfv(123, GL_TEXTURE_MAG_FILTER, &result);
702   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
703   EXPECT_EQ(static_cast<Result::Type>(1), result);
704 }
705
706 TEST_F(GLES2ImplementationTest, GetTexParameteriv) {
707   struct Cmds {
708     cmds::GetTexParameteriv cmd;
709   };
710   typedef cmds::GetTexParameteriv::Result Result;
711   Result::Type result = 0;
712   Cmds expected;
713   ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
714   expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset);
715   EXPECT_CALL(*command_buffer(), OnFlush())
716       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
717       .RetiresOnSaturation();
718   gl_->GetTexParameteriv(123, GL_TEXTURE_MAG_FILTER, &result);
719   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
720   EXPECT_EQ(static_cast<Result::Type>(1), result);
721 }
722 // TODO: Implement unit test for GetUniformfv
723 // TODO: Implement unit test for GetUniformiv
724 // TODO: Implement unit test for GetUniformLocation
725
726 TEST_F(GLES2ImplementationTest, GetVertexAttribfv) {
727   struct Cmds {
728     cmds::GetVertexAttribfv cmd;
729   };
730   typedef cmds::GetVertexAttribfv::Result Result;
731   Result::Type result = 0;
732   Cmds expected;
733   ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
734   expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
735                     result1.offset);
736   EXPECT_CALL(*command_buffer(), OnFlush())
737       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
738       .RetiresOnSaturation();
739   gl_->GetVertexAttribfv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
740   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
741   EXPECT_EQ(static_cast<Result::Type>(1), result);
742 }
743
744 TEST_F(GLES2ImplementationTest, GetVertexAttribiv) {
745   struct Cmds {
746     cmds::GetVertexAttribiv cmd;
747   };
748   typedef cmds::GetVertexAttribiv::Result Result;
749   Result::Type result = 0;
750   Cmds expected;
751   ExpectedMemoryInfo result1 = GetExpectedResultMemory(4);
752   expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id,
753                     result1.offset);
754   EXPECT_CALL(*command_buffer(), OnFlush())
755       .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1)))
756       .RetiresOnSaturation();
757   gl_->GetVertexAttribiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result);
758   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
759   EXPECT_EQ(static_cast<Result::Type>(1), result);
760 }
761
762 TEST_F(GLES2ImplementationTest, Hint) {
763   struct Cmds {
764     cmds::Hint cmd;
765   };
766   Cmds expected;
767   expected.cmd.Init(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
768
769   gl_->Hint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
770   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
771 }
772
773 TEST_F(GLES2ImplementationTest, IsBuffer) {
774   struct Cmds {
775     cmds::IsBuffer cmd;
776   };
777
778   Cmds expected;
779   ExpectedMemoryInfo result1 =
780       GetExpectedResultMemory(sizeof(cmds::IsBuffer::Result));
781   expected.cmd.Init(1, result1.id, result1.offset);
782
783   EXPECT_CALL(*command_buffer(), OnFlush())
784       .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
785       .RetiresOnSaturation();
786
787   GLboolean result = gl_->IsBuffer(1);
788   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
789   EXPECT_TRUE(result);
790 }
791
792 TEST_F(GLES2ImplementationTest, IsEnabled) {
793   struct Cmds {
794     cmds::IsEnabled cmd;
795   };
796
797   Cmds expected;
798   ExpectedMemoryInfo result1 =
799       GetExpectedResultMemory(sizeof(cmds::IsEnabled::Result));
800   expected.cmd.Init(1, result1.id, result1.offset);
801
802   EXPECT_CALL(*command_buffer(), OnFlush())
803       .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
804       .RetiresOnSaturation();
805
806   GLboolean result = gl_->IsEnabled(1);
807   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
808   EXPECT_TRUE(result);
809 }
810
811 TEST_F(GLES2ImplementationTest, IsFramebuffer) {
812   struct Cmds {
813     cmds::IsFramebuffer cmd;
814   };
815
816   Cmds expected;
817   ExpectedMemoryInfo result1 =
818       GetExpectedResultMemory(sizeof(cmds::IsFramebuffer::Result));
819   expected.cmd.Init(1, result1.id, result1.offset);
820
821   EXPECT_CALL(*command_buffer(), OnFlush())
822       .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
823       .RetiresOnSaturation();
824
825   GLboolean result = gl_->IsFramebuffer(1);
826   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
827   EXPECT_TRUE(result);
828 }
829
830 TEST_F(GLES2ImplementationTest, IsProgram) {
831   struct Cmds {
832     cmds::IsProgram cmd;
833   };
834
835   Cmds expected;
836   ExpectedMemoryInfo result1 =
837       GetExpectedResultMemory(sizeof(cmds::IsProgram::Result));
838   expected.cmd.Init(1, result1.id, result1.offset);
839
840   EXPECT_CALL(*command_buffer(), OnFlush())
841       .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
842       .RetiresOnSaturation();
843
844   GLboolean result = gl_->IsProgram(1);
845   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
846   EXPECT_TRUE(result);
847 }
848
849 TEST_F(GLES2ImplementationTest, IsRenderbuffer) {
850   struct Cmds {
851     cmds::IsRenderbuffer cmd;
852   };
853
854   Cmds expected;
855   ExpectedMemoryInfo result1 =
856       GetExpectedResultMemory(sizeof(cmds::IsRenderbuffer::Result));
857   expected.cmd.Init(1, result1.id, result1.offset);
858
859   EXPECT_CALL(*command_buffer(), OnFlush())
860       .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
861       .RetiresOnSaturation();
862
863   GLboolean result = gl_->IsRenderbuffer(1);
864   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
865   EXPECT_TRUE(result);
866 }
867
868 TEST_F(GLES2ImplementationTest, IsShader) {
869   struct Cmds {
870     cmds::IsShader cmd;
871   };
872
873   Cmds expected;
874   ExpectedMemoryInfo result1 =
875       GetExpectedResultMemory(sizeof(cmds::IsShader::Result));
876   expected.cmd.Init(1, result1.id, result1.offset);
877
878   EXPECT_CALL(*command_buffer(), OnFlush())
879       .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
880       .RetiresOnSaturation();
881
882   GLboolean result = gl_->IsShader(1);
883   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
884   EXPECT_TRUE(result);
885 }
886
887 TEST_F(GLES2ImplementationTest, IsTexture) {
888   struct Cmds {
889     cmds::IsTexture cmd;
890   };
891
892   Cmds expected;
893   ExpectedMemoryInfo result1 =
894       GetExpectedResultMemory(sizeof(cmds::IsTexture::Result));
895   expected.cmd.Init(1, result1.id, result1.offset);
896
897   EXPECT_CALL(*command_buffer(), OnFlush())
898       .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
899       .RetiresOnSaturation();
900
901   GLboolean result = gl_->IsTexture(1);
902   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
903   EXPECT_TRUE(result);
904 }
905
906 TEST_F(GLES2ImplementationTest, LineWidth) {
907   struct Cmds {
908     cmds::LineWidth cmd;
909   };
910   Cmds expected;
911   expected.cmd.Init(0.5f);
912
913   gl_->LineWidth(0.5f);
914   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
915 }
916
917 TEST_F(GLES2ImplementationTest, LinkProgram) {
918   struct Cmds {
919     cmds::LinkProgram cmd;
920   };
921   Cmds expected;
922   expected.cmd.Init(1);
923
924   gl_->LinkProgram(1);
925   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
926 }
927
928 TEST_F(GLES2ImplementationTest, PixelStorei) {
929   struct Cmds {
930     cmds::PixelStorei cmd;
931   };
932   Cmds expected;
933   expected.cmd.Init(GL_PACK_ALIGNMENT, 1);
934
935   gl_->PixelStorei(GL_PACK_ALIGNMENT, 1);
936   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
937 }
938
939 TEST_F(GLES2ImplementationTest, PolygonOffset) {
940   struct Cmds {
941     cmds::PolygonOffset cmd;
942   };
943   Cmds expected;
944   expected.cmd.Init(1, 2);
945
946   gl_->PolygonOffset(1, 2);
947   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
948 }
949
950 TEST_F(GLES2ImplementationTest, ReleaseShaderCompiler) {
951   struct Cmds {
952     cmds::ReleaseShaderCompiler cmd;
953   };
954   Cmds expected;
955   expected.cmd.Init();
956
957   gl_->ReleaseShaderCompiler();
958   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
959 }
960
961 TEST_F(GLES2ImplementationTest, RenderbufferStorage) {
962   struct Cmds {
963     cmds::RenderbufferStorage cmd;
964   };
965   Cmds expected;
966   expected.cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
967
968   gl_->RenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
969   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
970 }
971
972 TEST_F(GLES2ImplementationTest, SampleCoverage) {
973   struct Cmds {
974     cmds::SampleCoverage cmd;
975   };
976   Cmds expected;
977   expected.cmd.Init(1, true);
978
979   gl_->SampleCoverage(1, true);
980   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
981 }
982
983 TEST_F(GLES2ImplementationTest, Scissor) {
984   struct Cmds {
985     cmds::Scissor cmd;
986   };
987   Cmds expected;
988   expected.cmd.Init(1, 2, 3, 4);
989
990   gl_->Scissor(1, 2, 3, 4);
991   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
992 }
993
994 TEST_F(GLES2ImplementationTest, StencilFunc) {
995   struct Cmds {
996     cmds::StencilFunc cmd;
997   };
998   Cmds expected;
999   expected.cmd.Init(GL_NEVER, 2, 3);
1000
1001   gl_->StencilFunc(GL_NEVER, 2, 3);
1002   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1003 }
1004
1005 TEST_F(GLES2ImplementationTest, StencilFuncSeparate) {
1006   struct Cmds {
1007     cmds::StencilFuncSeparate cmd;
1008   };
1009   Cmds expected;
1010   expected.cmd.Init(GL_FRONT, GL_NEVER, 3, 4);
1011
1012   gl_->StencilFuncSeparate(GL_FRONT, GL_NEVER, 3, 4);
1013   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1014 }
1015
1016 TEST_F(GLES2ImplementationTest, StencilMask) {
1017   struct Cmds {
1018     cmds::StencilMask cmd;
1019   };
1020   Cmds expected;
1021   expected.cmd.Init(1);
1022
1023   gl_->StencilMask(1);
1024   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1025 }
1026
1027 TEST_F(GLES2ImplementationTest, StencilMaskSeparate) {
1028   struct Cmds {
1029     cmds::StencilMaskSeparate cmd;
1030   };
1031   Cmds expected;
1032   expected.cmd.Init(GL_FRONT, 2);
1033
1034   gl_->StencilMaskSeparate(GL_FRONT, 2);
1035   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1036 }
1037
1038 TEST_F(GLES2ImplementationTest, StencilOp) {
1039   struct Cmds {
1040     cmds::StencilOp cmd;
1041   };
1042   Cmds expected;
1043   expected.cmd.Init(GL_KEEP, GL_INCR, GL_KEEP);
1044
1045   gl_->StencilOp(GL_KEEP, GL_INCR, GL_KEEP);
1046   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1047 }
1048
1049 TEST_F(GLES2ImplementationTest, StencilOpSeparate) {
1050   struct Cmds {
1051     cmds::StencilOpSeparate cmd;
1052   };
1053   Cmds expected;
1054   expected.cmd.Init(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP);
1055
1056   gl_->StencilOpSeparate(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP);
1057   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1058 }
1059
1060 TEST_F(GLES2ImplementationTest, TexParameterf) {
1061   struct Cmds {
1062     cmds::TexParameterf cmd;
1063   };
1064   Cmds expected;
1065   expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1066
1067   gl_->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1068   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1069 }
1070
1071 TEST_F(GLES2ImplementationTest, TexParameterfv) {
1072   GLfloat data[1] = {0};
1073   struct Cmds {
1074     cmds::TexParameterfvImmediate cmd;
1075     GLfloat data[1];
1076   };
1077
1078   for (int jj = 0; jj < 1; ++jj) {
1079     data[jj] = static_cast<GLfloat>(jj);
1080   }
1081   Cmds expected;
1082   expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1083   gl_->TexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1084   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1085 }
1086
1087 TEST_F(GLES2ImplementationTest, TexParameteri) {
1088   struct Cmds {
1089     cmds::TexParameteri cmd;
1090   };
1091   Cmds expected;
1092   expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1093
1094   gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1095   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1096 }
1097
1098 TEST_F(GLES2ImplementationTest, TexParameteriv) {
1099   GLint data[1] = {0};
1100   struct Cmds {
1101     cmds::TexParameterivImmediate cmd;
1102     GLint data[1];
1103   };
1104
1105   for (int jj = 0; jj < 1; ++jj) {
1106     data[jj] = static_cast<GLint>(jj);
1107   }
1108   Cmds expected;
1109   expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1110   gl_->TexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]);
1111   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1112 }
1113
1114 TEST_F(GLES2ImplementationTest, Uniform1f) {
1115   struct Cmds {
1116     cmds::Uniform1f cmd;
1117   };
1118   Cmds expected;
1119   expected.cmd.Init(1, 2);
1120
1121   gl_->Uniform1f(1, 2);
1122   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1123 }
1124
1125 TEST_F(GLES2ImplementationTest, Uniform1fv) {
1126   GLfloat data[2][1] = {{0}};
1127   struct Cmds {
1128     cmds::Uniform1fvImmediate cmd;
1129     GLfloat data[2][1];
1130   };
1131
1132   Cmds expected;
1133   for (int ii = 0; ii < 2; ++ii) {
1134     for (int jj = 0; jj < 1; ++jj) {
1135       data[ii][jj] = static_cast<GLfloat>(ii * 1 + jj);
1136     }
1137   }
1138   expected.cmd.Init(1, 2, &data[0][0]);
1139   gl_->Uniform1fv(1, 2, &data[0][0]);
1140   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1141 }
1142
1143 TEST_F(GLES2ImplementationTest, Uniform1i) {
1144   struct Cmds {
1145     cmds::Uniform1i cmd;
1146   };
1147   Cmds expected;
1148   expected.cmd.Init(1, 2);
1149
1150   gl_->Uniform1i(1, 2);
1151   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1152 }
1153
1154 TEST_F(GLES2ImplementationTest, Uniform1iv) {
1155   GLint data[2][1] = {{0}};
1156   struct Cmds {
1157     cmds::Uniform1ivImmediate cmd;
1158     GLint data[2][1];
1159   };
1160
1161   Cmds expected;
1162   for (int ii = 0; ii < 2; ++ii) {
1163     for (int jj = 0; jj < 1; ++jj) {
1164       data[ii][jj] = static_cast<GLint>(ii * 1 + jj);
1165     }
1166   }
1167   expected.cmd.Init(1, 2, &data[0][0]);
1168   gl_->Uniform1iv(1, 2, &data[0][0]);
1169   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1170 }
1171
1172 TEST_F(GLES2ImplementationTest, Uniform2f) {
1173   struct Cmds {
1174     cmds::Uniform2f cmd;
1175   };
1176   Cmds expected;
1177   expected.cmd.Init(1, 2, 3);
1178
1179   gl_->Uniform2f(1, 2, 3);
1180   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1181 }
1182
1183 TEST_F(GLES2ImplementationTest, Uniform2fv) {
1184   GLfloat data[2][2] = {{0}};
1185   struct Cmds {
1186     cmds::Uniform2fvImmediate cmd;
1187     GLfloat data[2][2];
1188   };
1189
1190   Cmds expected;
1191   for (int ii = 0; ii < 2; ++ii) {
1192     for (int jj = 0; jj < 2; ++jj) {
1193       data[ii][jj] = static_cast<GLfloat>(ii * 2 + jj);
1194     }
1195   }
1196   expected.cmd.Init(1, 2, &data[0][0]);
1197   gl_->Uniform2fv(1, 2, &data[0][0]);
1198   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1199 }
1200
1201 TEST_F(GLES2ImplementationTest, Uniform2i) {
1202   struct Cmds {
1203     cmds::Uniform2i cmd;
1204   };
1205   Cmds expected;
1206   expected.cmd.Init(1, 2, 3);
1207
1208   gl_->Uniform2i(1, 2, 3);
1209   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1210 }
1211
1212 TEST_F(GLES2ImplementationTest, Uniform2iv) {
1213   GLint data[2][2] = {{0}};
1214   struct Cmds {
1215     cmds::Uniform2ivImmediate cmd;
1216     GLint data[2][2];
1217   };
1218
1219   Cmds expected;
1220   for (int ii = 0; ii < 2; ++ii) {
1221     for (int jj = 0; jj < 2; ++jj) {
1222       data[ii][jj] = static_cast<GLint>(ii * 2 + jj);
1223     }
1224   }
1225   expected.cmd.Init(1, 2, &data[0][0]);
1226   gl_->Uniform2iv(1, 2, &data[0][0]);
1227   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1228 }
1229
1230 TEST_F(GLES2ImplementationTest, Uniform3f) {
1231   struct Cmds {
1232     cmds::Uniform3f cmd;
1233   };
1234   Cmds expected;
1235   expected.cmd.Init(1, 2, 3, 4);
1236
1237   gl_->Uniform3f(1, 2, 3, 4);
1238   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1239 }
1240
1241 TEST_F(GLES2ImplementationTest, Uniform3fv) {
1242   GLfloat data[2][3] = {{0}};
1243   struct Cmds {
1244     cmds::Uniform3fvImmediate cmd;
1245     GLfloat data[2][3];
1246   };
1247
1248   Cmds expected;
1249   for (int ii = 0; ii < 2; ++ii) {
1250     for (int jj = 0; jj < 3; ++jj) {
1251       data[ii][jj] = static_cast<GLfloat>(ii * 3 + jj);
1252     }
1253   }
1254   expected.cmd.Init(1, 2, &data[0][0]);
1255   gl_->Uniform3fv(1, 2, &data[0][0]);
1256   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1257 }
1258
1259 TEST_F(GLES2ImplementationTest, Uniform3i) {
1260   struct Cmds {
1261     cmds::Uniform3i cmd;
1262   };
1263   Cmds expected;
1264   expected.cmd.Init(1, 2, 3, 4);
1265
1266   gl_->Uniform3i(1, 2, 3, 4);
1267   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1268 }
1269
1270 TEST_F(GLES2ImplementationTest, Uniform3iv) {
1271   GLint data[2][3] = {{0}};
1272   struct Cmds {
1273     cmds::Uniform3ivImmediate cmd;
1274     GLint data[2][3];
1275   };
1276
1277   Cmds expected;
1278   for (int ii = 0; ii < 2; ++ii) {
1279     for (int jj = 0; jj < 3; ++jj) {
1280       data[ii][jj] = static_cast<GLint>(ii * 3 + jj);
1281     }
1282   }
1283   expected.cmd.Init(1, 2, &data[0][0]);
1284   gl_->Uniform3iv(1, 2, &data[0][0]);
1285   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1286 }
1287
1288 TEST_F(GLES2ImplementationTest, Uniform4f) {
1289   struct Cmds {
1290     cmds::Uniform4f cmd;
1291   };
1292   Cmds expected;
1293   expected.cmd.Init(1, 2, 3, 4, 5);
1294
1295   gl_->Uniform4f(1, 2, 3, 4, 5);
1296   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1297 }
1298
1299 TEST_F(GLES2ImplementationTest, Uniform4fv) {
1300   GLfloat data[2][4] = {{0}};
1301   struct Cmds {
1302     cmds::Uniform4fvImmediate cmd;
1303     GLfloat data[2][4];
1304   };
1305
1306   Cmds expected;
1307   for (int ii = 0; ii < 2; ++ii) {
1308     for (int jj = 0; jj < 4; ++jj) {
1309       data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
1310     }
1311   }
1312   expected.cmd.Init(1, 2, &data[0][0]);
1313   gl_->Uniform4fv(1, 2, &data[0][0]);
1314   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1315 }
1316
1317 TEST_F(GLES2ImplementationTest, Uniform4i) {
1318   struct Cmds {
1319     cmds::Uniform4i cmd;
1320   };
1321   Cmds expected;
1322   expected.cmd.Init(1, 2, 3, 4, 5);
1323
1324   gl_->Uniform4i(1, 2, 3, 4, 5);
1325   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1326 }
1327
1328 TEST_F(GLES2ImplementationTest, Uniform4iv) {
1329   GLint data[2][4] = {{0}};
1330   struct Cmds {
1331     cmds::Uniform4ivImmediate cmd;
1332     GLint data[2][4];
1333   };
1334
1335   Cmds expected;
1336   for (int ii = 0; ii < 2; ++ii) {
1337     for (int jj = 0; jj < 4; ++jj) {
1338       data[ii][jj] = static_cast<GLint>(ii * 4 + jj);
1339     }
1340   }
1341   expected.cmd.Init(1, 2, &data[0][0]);
1342   gl_->Uniform4iv(1, 2, &data[0][0]);
1343   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1344 }
1345
1346 TEST_F(GLES2ImplementationTest, UniformMatrix2fv) {
1347   GLfloat data[2][4] = {{0}};
1348   struct Cmds {
1349     cmds::UniformMatrix2fvImmediate cmd;
1350     GLfloat data[2][4];
1351   };
1352
1353   Cmds expected;
1354   for (int ii = 0; ii < 2; ++ii) {
1355     for (int jj = 0; jj < 4; ++jj) {
1356       data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
1357     }
1358   }
1359   expected.cmd.Init(1, 2, &data[0][0]);
1360   gl_->UniformMatrix2fv(1, 2, false, &data[0][0]);
1361   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1362 }
1363
1364 TEST_F(GLES2ImplementationTest, UniformMatrix2fvInvalidConstantArg2) {
1365   GLfloat data[2][4] = {{0}};
1366   for (int ii = 0; ii < 2; ++ii) {
1367     for (int jj = 0; jj < 4; ++jj) {
1368       data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
1369     }
1370   }
1371   gl_->UniformMatrix2fv(1, 2, true, &data[0][0]);
1372   EXPECT_TRUE(NoCommandsWritten());
1373   EXPECT_EQ(GL_INVALID_VALUE, CheckError());
1374 }
1375
1376 TEST_F(GLES2ImplementationTest, UniformMatrix3fv) {
1377   GLfloat data[2][9] = {{0}};
1378   struct Cmds {
1379     cmds::UniformMatrix3fvImmediate cmd;
1380     GLfloat data[2][9];
1381   };
1382
1383   Cmds expected;
1384   for (int ii = 0; ii < 2; ++ii) {
1385     for (int jj = 0; jj < 9; ++jj) {
1386       data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj);
1387     }
1388   }
1389   expected.cmd.Init(1, 2, &data[0][0]);
1390   gl_->UniformMatrix3fv(1, 2, false, &data[0][0]);
1391   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1392 }
1393
1394 TEST_F(GLES2ImplementationTest, UniformMatrix3fvInvalidConstantArg2) {
1395   GLfloat data[2][9] = {{0}};
1396   for (int ii = 0; ii < 2; ++ii) {
1397     for (int jj = 0; jj < 9; ++jj) {
1398       data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj);
1399     }
1400   }
1401   gl_->UniformMatrix3fv(1, 2, true, &data[0][0]);
1402   EXPECT_TRUE(NoCommandsWritten());
1403   EXPECT_EQ(GL_INVALID_VALUE, CheckError());
1404 }
1405
1406 TEST_F(GLES2ImplementationTest, UniformMatrix4fv) {
1407   GLfloat data[2][16] = {{0}};
1408   struct Cmds {
1409     cmds::UniformMatrix4fvImmediate cmd;
1410     GLfloat data[2][16];
1411   };
1412
1413   Cmds expected;
1414   for (int ii = 0; ii < 2; ++ii) {
1415     for (int jj = 0; jj < 16; ++jj) {
1416       data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj);
1417     }
1418   }
1419   expected.cmd.Init(1, 2, &data[0][0]);
1420   gl_->UniformMatrix4fv(1, 2, false, &data[0][0]);
1421   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1422 }
1423
1424 TEST_F(GLES2ImplementationTest, UniformMatrix4fvInvalidConstantArg2) {
1425   GLfloat data[2][16] = {{0}};
1426   for (int ii = 0; ii < 2; ++ii) {
1427     for (int jj = 0; jj < 16; ++jj) {
1428       data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj);
1429     }
1430   }
1431   gl_->UniformMatrix4fv(1, 2, true, &data[0][0]);
1432   EXPECT_TRUE(NoCommandsWritten());
1433   EXPECT_EQ(GL_INVALID_VALUE, CheckError());
1434 }
1435
1436 TEST_F(GLES2ImplementationTest, UseProgram) {
1437   struct Cmds {
1438     cmds::UseProgram cmd;
1439   };
1440   Cmds expected;
1441   expected.cmd.Init(1);
1442
1443   gl_->UseProgram(1);
1444   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1445   ClearCommands();
1446   gl_->UseProgram(1);
1447   EXPECT_TRUE(NoCommandsWritten());
1448 }
1449
1450 TEST_F(GLES2ImplementationTest, ValidateProgram) {
1451   struct Cmds {
1452     cmds::ValidateProgram cmd;
1453   };
1454   Cmds expected;
1455   expected.cmd.Init(1);
1456
1457   gl_->ValidateProgram(1);
1458   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1459 }
1460
1461 TEST_F(GLES2ImplementationTest, VertexAttrib1f) {
1462   struct Cmds {
1463     cmds::VertexAttrib1f cmd;
1464   };
1465   Cmds expected;
1466   expected.cmd.Init(1, 2);
1467
1468   gl_->VertexAttrib1f(1, 2);
1469   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1470 }
1471
1472 TEST_F(GLES2ImplementationTest, VertexAttrib1fv) {
1473   GLfloat data[1] = {0};
1474   struct Cmds {
1475     cmds::VertexAttrib1fvImmediate cmd;
1476     GLfloat data[1];
1477   };
1478
1479   for (int jj = 0; jj < 1; ++jj) {
1480     data[jj] = static_cast<GLfloat>(jj);
1481   }
1482   Cmds expected;
1483   expected.cmd.Init(1, &data[0]);
1484   gl_->VertexAttrib1fv(1, &data[0]);
1485   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1486 }
1487
1488 TEST_F(GLES2ImplementationTest, VertexAttrib2f) {
1489   struct Cmds {
1490     cmds::VertexAttrib2f cmd;
1491   };
1492   Cmds expected;
1493   expected.cmd.Init(1, 2, 3);
1494
1495   gl_->VertexAttrib2f(1, 2, 3);
1496   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1497 }
1498
1499 TEST_F(GLES2ImplementationTest, VertexAttrib2fv) {
1500   GLfloat data[2] = {0};
1501   struct Cmds {
1502     cmds::VertexAttrib2fvImmediate cmd;
1503     GLfloat data[2];
1504   };
1505
1506   for (int jj = 0; jj < 2; ++jj) {
1507     data[jj] = static_cast<GLfloat>(jj);
1508   }
1509   Cmds expected;
1510   expected.cmd.Init(1, &data[0]);
1511   gl_->VertexAttrib2fv(1, &data[0]);
1512   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1513 }
1514
1515 TEST_F(GLES2ImplementationTest, VertexAttrib3f) {
1516   struct Cmds {
1517     cmds::VertexAttrib3f cmd;
1518   };
1519   Cmds expected;
1520   expected.cmd.Init(1, 2, 3, 4);
1521
1522   gl_->VertexAttrib3f(1, 2, 3, 4);
1523   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1524 }
1525
1526 TEST_F(GLES2ImplementationTest, VertexAttrib3fv) {
1527   GLfloat data[3] = {0};
1528   struct Cmds {
1529     cmds::VertexAttrib3fvImmediate cmd;
1530     GLfloat data[3];
1531   };
1532
1533   for (int jj = 0; jj < 3; ++jj) {
1534     data[jj] = static_cast<GLfloat>(jj);
1535   }
1536   Cmds expected;
1537   expected.cmd.Init(1, &data[0]);
1538   gl_->VertexAttrib3fv(1, &data[0]);
1539   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1540 }
1541
1542 TEST_F(GLES2ImplementationTest, VertexAttrib4f) {
1543   struct Cmds {
1544     cmds::VertexAttrib4f cmd;
1545   };
1546   Cmds expected;
1547   expected.cmd.Init(1, 2, 3, 4, 5);
1548
1549   gl_->VertexAttrib4f(1, 2, 3, 4, 5);
1550   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1551 }
1552
1553 TEST_F(GLES2ImplementationTest, VertexAttrib4fv) {
1554   GLfloat data[4] = {0};
1555   struct Cmds {
1556     cmds::VertexAttrib4fvImmediate cmd;
1557     GLfloat data[4];
1558   };
1559
1560   for (int jj = 0; jj < 4; ++jj) {
1561     data[jj] = static_cast<GLfloat>(jj);
1562   }
1563   Cmds expected;
1564   expected.cmd.Init(1, &data[0]);
1565   gl_->VertexAttrib4fv(1, &data[0]);
1566   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1567 }
1568
1569 TEST_F(GLES2ImplementationTest, Viewport) {
1570   struct Cmds {
1571     cmds::Viewport cmd;
1572   };
1573   Cmds expected;
1574   expected.cmd.Init(1, 2, 3, 4);
1575
1576   gl_->Viewport(1, 2, 3, 4);
1577   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1578 }
1579
1580 TEST_F(GLES2ImplementationTest, BlitFramebufferCHROMIUM) {
1581   struct Cmds {
1582     cmds::BlitFramebufferCHROMIUM cmd;
1583   };
1584   Cmds expected;
1585   expected.cmd.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
1586
1587   gl_->BlitFramebufferCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
1588   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1589 }
1590
1591 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleCHROMIUM) {
1592   struct Cmds {
1593     cmds::RenderbufferStorageMultisampleCHROMIUM cmd;
1594   };
1595   Cmds expected;
1596   expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
1597
1598   gl_->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, 2, GL_RGBA4, 4,
1599                                               5);
1600   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1601 }
1602
1603 TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleEXT) {
1604   struct Cmds {
1605     cmds::RenderbufferStorageMultisampleEXT cmd;
1606   };
1607   Cmds expected;
1608   expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
1609
1610   gl_->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
1611   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1612 }
1613
1614 TEST_F(GLES2ImplementationTest, FramebufferTexture2DMultisampleEXT) {
1615   struct Cmds {
1616     cmds::FramebufferTexture2DMultisampleEXT cmd;
1617   };
1618   Cmds expected;
1619   expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4, 6);
1620
1621   gl_->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
1622                                           GL_TEXTURE_2D, 4, 0, 6);
1623   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1624 }
1625
1626 TEST_F(GLES2ImplementationTest,
1627        FramebufferTexture2DMultisampleEXTInvalidConstantArg4) {
1628   gl_->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
1629                                           GL_TEXTURE_2D, 4, 1, 6);
1630   EXPECT_TRUE(NoCommandsWritten());
1631   EXPECT_EQ(GL_INVALID_VALUE, CheckError());
1632 }
1633
1634 TEST_F(GLES2ImplementationTest, TexStorage2DEXT) {
1635   struct Cmds {
1636     cmds::TexStorage2DEXT cmd;
1637   };
1638   Cmds expected;
1639   expected.cmd.Init(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
1640
1641   gl_->TexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
1642   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1643 }
1644
1645 TEST_F(GLES2ImplementationTest, GenQueriesEXT) {
1646   GLuint ids[2] = {
1647       0,
1648   };
1649   struct Cmds {
1650     cmds::GenQueriesEXTImmediate gen;
1651     GLuint data[2];
1652   };
1653   Cmds expected;
1654   expected.gen.Init(arraysize(ids), &ids[0]);
1655   expected.data[0] = kQueriesStartId;
1656   expected.data[1] = kQueriesStartId + 1;
1657   gl_->GenQueriesEXT(arraysize(ids), &ids[0]);
1658   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1659   EXPECT_EQ(kQueriesStartId, ids[0]);
1660   EXPECT_EQ(kQueriesStartId + 1, ids[1]);
1661 }
1662
1663 TEST_F(GLES2ImplementationTest, DeleteQueriesEXT) {
1664   GLuint ids[2] = {kQueriesStartId, kQueriesStartId + 1};
1665   struct Cmds {
1666     cmds::DeleteQueriesEXTImmediate del;
1667     GLuint data[2];
1668   };
1669   Cmds expected;
1670   expected.del.Init(arraysize(ids), &ids[0]);
1671   expected.data[0] = kQueriesStartId;
1672   expected.data[1] = kQueriesStartId + 1;
1673   gl_->DeleteQueriesEXT(arraysize(ids), &ids[0]);
1674   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1675 }
1676 // TODO: Implement unit test for BeginQueryEXT
1677 // TODO: Implement unit test for InsertEventMarkerEXT
1678 // TODO: Implement unit test for PushGroupMarkerEXT
1679
1680 TEST_F(GLES2ImplementationTest, PopGroupMarkerEXT) {
1681   struct Cmds {
1682     cmds::PopGroupMarkerEXT cmd;
1683   };
1684   Cmds expected;
1685   expected.cmd.Init();
1686
1687   gl_->PopGroupMarkerEXT();
1688   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1689 }
1690
1691 TEST_F(GLES2ImplementationTest, GenVertexArraysOES) {
1692   GLuint ids[2] = {
1693       0,
1694   };
1695   struct Cmds {
1696     cmds::GenVertexArraysOESImmediate gen;
1697     GLuint data[2];
1698   };
1699   Cmds expected;
1700   expected.gen.Init(arraysize(ids), &ids[0]);
1701   expected.data[0] = kVertexArraysStartId;
1702   expected.data[1] = kVertexArraysStartId + 1;
1703   gl_->GenVertexArraysOES(arraysize(ids), &ids[0]);
1704   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1705   EXPECT_EQ(kVertexArraysStartId, ids[0]);
1706   EXPECT_EQ(kVertexArraysStartId + 1, ids[1]);
1707 }
1708
1709 TEST_F(GLES2ImplementationTest, DeleteVertexArraysOES) {
1710   GLuint ids[2] = {kVertexArraysStartId, kVertexArraysStartId + 1};
1711   struct Cmds {
1712     cmds::DeleteVertexArraysOESImmediate del;
1713     GLuint data[2];
1714   };
1715   Cmds expected;
1716   expected.del.Init(arraysize(ids), &ids[0]);
1717   expected.data[0] = kVertexArraysStartId;
1718   expected.data[1] = kVertexArraysStartId + 1;
1719   gl_->DeleteVertexArraysOES(arraysize(ids), &ids[0]);
1720   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1721 }
1722
1723 TEST_F(GLES2ImplementationTest, IsVertexArrayOES) {
1724   struct Cmds {
1725     cmds::IsVertexArrayOES cmd;
1726   };
1727
1728   Cmds expected;
1729   ExpectedMemoryInfo result1 =
1730       GetExpectedResultMemory(sizeof(cmds::IsVertexArrayOES::Result));
1731   expected.cmd.Init(1, result1.id, result1.offset);
1732
1733   EXPECT_CALL(*command_buffer(), OnFlush())
1734       .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
1735       .RetiresOnSaturation();
1736
1737   GLboolean result = gl_->IsVertexArrayOES(1);
1738   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1739   EXPECT_TRUE(result);
1740 }
1741 // TODO: Implement unit test for EnableFeatureCHROMIUM
1742
1743 TEST_F(GLES2ImplementationTest, ResizeCHROMIUM) {
1744   struct Cmds {
1745     cmds::ResizeCHROMIUM cmd;
1746   };
1747   Cmds expected;
1748   expected.cmd.Init(1, 2, 3);
1749
1750   gl_->ResizeCHROMIUM(1, 2, 3);
1751   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1752 }
1753 // TODO: Implement unit test for GetRequestableExtensionsCHROMIUM
1754 // TODO: Implement unit test for CreateStreamTextureCHROMIUM
1755 // TODO: Implement unit test for GetTranslatedShaderSourceANGLE
1756
1757 TEST_F(GLES2ImplementationTest, TexImageIOSurface2DCHROMIUM) {
1758   struct Cmds {
1759     cmds::TexImageIOSurface2DCHROMIUM cmd;
1760   };
1761   Cmds expected;
1762   expected.cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5);
1763
1764   gl_->TexImageIOSurface2DCHROMIUM(GL_TEXTURE_2D, 2, 3, 4, 5);
1765   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1766 }
1767
1768 TEST_F(GLES2ImplementationTest, CopyTextureCHROMIUM) {
1769   struct Cmds {
1770     cmds::CopyTextureCHROMIUM cmd;
1771   };
1772   Cmds expected;
1773   expected.cmd.Init(1, 2, 3, 4, GL_ALPHA, GL_UNSIGNED_BYTE);
1774
1775   gl_->CopyTextureCHROMIUM(1, 2, 3, 4, GL_ALPHA, GL_UNSIGNED_BYTE);
1776   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1777 }
1778
1779 TEST_F(GLES2ImplementationTest, DrawArraysInstancedANGLE) {
1780   struct Cmds {
1781     cmds::DrawArraysInstancedANGLE cmd;
1782   };
1783   Cmds expected;
1784   expected.cmd.Init(GL_POINTS, 2, 3, 4);
1785
1786   gl_->DrawArraysInstancedANGLE(GL_POINTS, 2, 3, 4);
1787   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1788 }
1789
1790 TEST_F(GLES2ImplementationTest, VertexAttribDivisorANGLE) {
1791   struct Cmds {
1792     cmds::VertexAttribDivisorANGLE cmd;
1793   };
1794   Cmds expected;
1795   expected.cmd.Init(1, 2);
1796
1797   gl_->VertexAttribDivisorANGLE(1, 2);
1798   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1799 }
1800 // TODO: Implement unit test for GenMailboxCHROMIUM
1801 // TODO: Implement unit test for BindUniformLocationCHROMIUM
1802
1803 TEST_F(GLES2ImplementationTest, GenValuebuffersCHROMIUM) {
1804   GLuint ids[2] = {
1805       0,
1806   };
1807   struct Cmds {
1808     cmds::GenValuebuffersCHROMIUMImmediate gen;
1809     GLuint data[2];
1810   };
1811   Cmds expected;
1812   expected.gen.Init(arraysize(ids), &ids[0]);
1813   expected.data[0] = kValuebuffersStartId;
1814   expected.data[1] = kValuebuffersStartId + 1;
1815   gl_->GenValuebuffersCHROMIUM(arraysize(ids), &ids[0]);
1816   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1817   EXPECT_EQ(kValuebuffersStartId, ids[0]);
1818   EXPECT_EQ(kValuebuffersStartId + 1, ids[1]);
1819 }
1820
1821 TEST_F(GLES2ImplementationTest, DeleteValuebuffersCHROMIUM) {
1822   GLuint ids[2] = {kValuebuffersStartId, kValuebuffersStartId + 1};
1823   struct Cmds {
1824     cmds::DeleteValuebuffersCHROMIUMImmediate del;
1825     GLuint data[2];
1826   };
1827   Cmds expected;
1828   expected.del.Init(arraysize(ids), &ids[0]);
1829   expected.data[0] = kValuebuffersStartId;
1830   expected.data[1] = kValuebuffersStartId + 1;
1831   gl_->DeleteValuebuffersCHROMIUM(arraysize(ids), &ids[0]);
1832   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1833 }
1834
1835 TEST_F(GLES2ImplementationTest, IsValuebufferCHROMIUM) {
1836   struct Cmds {
1837     cmds::IsValuebufferCHROMIUM cmd;
1838   };
1839
1840   Cmds expected;
1841   ExpectedMemoryInfo result1 =
1842       GetExpectedResultMemory(sizeof(cmds::IsValuebufferCHROMIUM::Result));
1843   expected.cmd.Init(1, result1.id, result1.offset);
1844
1845   EXPECT_CALL(*command_buffer(), OnFlush())
1846       .WillOnce(SetMemory(result1.ptr, uint32_t(1)))
1847       .RetiresOnSaturation();
1848
1849   GLboolean result = gl_->IsValuebufferCHROMIUM(1);
1850   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1851   EXPECT_TRUE(result);
1852 }
1853
1854 TEST_F(GLES2ImplementationTest, BindValuebufferCHROMIUM) {
1855   struct Cmds {
1856     cmds::BindValuebufferCHROMIUM cmd;
1857   };
1858   Cmds expected;
1859   expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
1860
1861   gl_->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
1862   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1863   ClearCommands();
1864   gl_->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2);
1865   EXPECT_TRUE(NoCommandsWritten());
1866 }
1867
1868 TEST_F(GLES2ImplementationTest, SubscribeValueCHROMIUM) {
1869   struct Cmds {
1870     cmds::SubscribeValueCHROMIUM cmd;
1871   };
1872   Cmds expected;
1873   expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
1874                     GL_MOUSE_POSITION_CHROMIUM);
1875
1876   gl_->SubscribeValueCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
1877                               GL_MOUSE_POSITION_CHROMIUM);
1878   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1879 }
1880
1881 TEST_F(GLES2ImplementationTest, PopulateSubscribedValuesCHROMIUM) {
1882   struct Cmds {
1883     cmds::PopulateSubscribedValuesCHROMIUM cmd;
1884   };
1885   Cmds expected;
1886   expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM);
1887
1888   gl_->PopulateSubscribedValuesCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM);
1889   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1890 }
1891
1892 TEST_F(GLES2ImplementationTest, UniformValuebufferCHROMIUM) {
1893   struct Cmds {
1894     cmds::UniformValuebufferCHROMIUM cmd;
1895   };
1896   Cmds expected;
1897   expected.cmd.Init(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
1898                     GL_MOUSE_POSITION_CHROMIUM);
1899
1900   gl_->UniformValuebufferCHROMIUM(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM,
1901                                   GL_MOUSE_POSITION_CHROMIUM);
1902   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1903 }
1904
1905 TEST_F(GLES2ImplementationTest, BindTexImage2DCHROMIUM) {
1906   struct Cmds {
1907     cmds::BindTexImage2DCHROMIUM cmd;
1908   };
1909   Cmds expected;
1910   expected.cmd.Init(GL_TEXTURE_2D, 2);
1911
1912   gl_->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
1913   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1914 }
1915
1916 TEST_F(GLES2ImplementationTest, ReleaseTexImage2DCHROMIUM) {
1917   struct Cmds {
1918     cmds::ReleaseTexImage2DCHROMIUM cmd;
1919   };
1920   Cmds expected;
1921   expected.cmd.Init(GL_TEXTURE_2D, 2);
1922
1923   gl_->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
1924   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1925 }
1926
1927 TEST_F(GLES2ImplementationTest, DiscardFramebufferEXT) {
1928   GLenum data[2][1] = {{0}};
1929   struct Cmds {
1930     cmds::DiscardFramebufferEXTImmediate cmd;
1931     GLenum data[2][1];
1932   };
1933
1934   Cmds expected;
1935   for (int ii = 0; ii < 2; ++ii) {
1936     for (int jj = 0; jj < 1; ++jj) {
1937       data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
1938     }
1939   }
1940   expected.cmd.Init(1, 2, &data[0][0]);
1941   gl_->DiscardFramebufferEXT(1, 2, &data[0][0]);
1942   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1943 }
1944
1945 TEST_F(GLES2ImplementationTest, LoseContextCHROMIUM) {
1946   struct Cmds {
1947     cmds::LoseContextCHROMIUM cmd;
1948   };
1949   Cmds expected;
1950   expected.cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_GUILTY_CONTEXT_RESET_ARB);
1951
1952   gl_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
1953                            GL_GUILTY_CONTEXT_RESET_ARB);
1954   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1955 }
1956 // TODO: Implement unit test for InsertSyncPointCHROMIUM
1957
1958 TEST_F(GLES2ImplementationTest, WaitSyncPointCHROMIUM) {
1959   struct Cmds {
1960     cmds::WaitSyncPointCHROMIUM cmd;
1961   };
1962   Cmds expected;
1963   expected.cmd.Init(1);
1964
1965   gl_->WaitSyncPointCHROMIUM(1);
1966   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1967 }
1968
1969 TEST_F(GLES2ImplementationTest, DrawBuffersEXT) {
1970   GLenum data[1][1] = {{0}};
1971   struct Cmds {
1972     cmds::DrawBuffersEXTImmediate cmd;
1973     GLenum data[1][1];
1974   };
1975
1976   Cmds expected;
1977   for (int ii = 0; ii < 1; ++ii) {
1978     for (int jj = 0; jj < 1; ++jj) {
1979       data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
1980     }
1981   }
1982   expected.cmd.Init(1, &data[0][0]);
1983   gl_->DrawBuffersEXT(1, &data[0][0]);
1984   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1985 }
1986
1987 TEST_F(GLES2ImplementationTest, DiscardBackbufferCHROMIUM) {
1988   struct Cmds {
1989     cmds::DiscardBackbufferCHROMIUM cmd;
1990   };
1991   Cmds expected;
1992   expected.cmd.Init();
1993
1994   gl_->DiscardBackbufferCHROMIUM();
1995   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1996 }
1997
1998 TEST_F(GLES2ImplementationTest, MatrixLoadfCHROMIUM) {
1999   GLfloat data[16] = {0};
2000   struct Cmds {
2001     cmds::MatrixLoadfCHROMIUMImmediate cmd;
2002     GLfloat data[16];
2003   };
2004
2005   for (int jj = 0; jj < 16; ++jj) {
2006     data[jj] = static_cast<GLfloat>(jj);
2007   }
2008   Cmds expected;
2009   expected.cmd.Init(GL_PATH_PROJECTION_CHROMIUM, &data[0]);
2010   gl_->MatrixLoadfCHROMIUM(GL_PATH_PROJECTION_CHROMIUM, &data[0]);
2011   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2012 }
2013
2014 TEST_F(GLES2ImplementationTest, MatrixLoadIdentityCHROMIUM) {
2015   struct Cmds {
2016     cmds::MatrixLoadIdentityCHROMIUM cmd;
2017   };
2018   Cmds expected;
2019   expected.cmd.Init(GL_PATH_PROJECTION_CHROMIUM);
2020
2021   gl_->MatrixLoadIdentityCHROMIUM(GL_PATH_PROJECTION_CHROMIUM);
2022   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2023 }
2024 #endif  // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_