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