gles2_implementation_unittest_autogen.h revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
1// Copyright (c) 2012 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
15TEST_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
27TEST_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
41TEST_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
55TEST_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
69TEST_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
80TEST_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
91TEST_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
102TEST_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
113TEST_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
124TEST_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
144TEST_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
155TEST_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
166TEST_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
177TEST_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
188TEST_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
199TEST_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
212TEST_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
223TEST_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
234TEST_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
245TEST_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
259TEST_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
273TEST_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
284TEST_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
298TEST_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
309TEST_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
323TEST_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
334TEST_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
345TEST_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
356TEST_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
367TEST_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
378TEST_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
389TEST_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
400TEST_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
411TEST_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
423TEST_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
435TEST_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
446TEST_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
462TEST_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
473TEST_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
489TEST_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
505TEST_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
525TEST_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
542TEST_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
559TEST_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
576TEST_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
597TEST_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
614TEST_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
632TEST_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
649TEST_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
668TEST_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
685TEST_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
705TEST_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
723TEST_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
741TEST_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
752TEST_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
772TEST_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
792TEST_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
812TEST_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
832TEST_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
852TEST_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
872TEST_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
892TEST_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
903TEST_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
914TEST_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
925TEST_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
936TEST_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
947TEST_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
958TEST_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
969TEST_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
980TEST_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
991TEST_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
1002TEST_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
1013TEST_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
1024TEST_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
1035TEST_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
1046TEST_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
1057TEST_F(GLES2ImplementationTest, TexParameterfv) {
1058  struct Cmds {
1059    cmds::TexParameterfvImmediate cmd;
1060    GLfloat data[1];
1061  };
1062
1063  Cmds expected;
1064  for (int jj = 0; jj < 1; ++jj) {
1065    expected.data[jj] = static_cast<GLfloat>(jj);
1066  }
1067  expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &expected.data[0]);
1068  gl_->TexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &expected.data[0]);
1069  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1070}
1071
1072TEST_F(GLES2ImplementationTest, TexParameteri) {
1073  struct Cmds {
1074    cmds::TexParameteri cmd;
1075  };
1076  Cmds expected;
1077  expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 3);
1078
1079  gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 3);
1080  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1081}
1082
1083TEST_F(GLES2ImplementationTest, TexParameteriv) {
1084  struct Cmds {
1085    cmds::TexParameterivImmediate cmd;
1086    GLint data[1];
1087  };
1088
1089  Cmds expected;
1090  for (int jj = 0; jj < 1; ++jj) {
1091    expected.data[jj] = static_cast<GLint>(jj);
1092  }
1093  expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &expected.data[0]);
1094  gl_->TexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &expected.data[0]);
1095  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1096}
1097
1098TEST_F(GLES2ImplementationTest, Uniform1f) {
1099  struct Cmds {
1100    cmds::Uniform1f cmd;
1101  };
1102  Cmds expected;
1103  expected.cmd.Init(1, 2);
1104
1105  gl_->Uniform1f(1, 2);
1106  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1107}
1108
1109TEST_F(GLES2ImplementationTest, Uniform1fv) {
1110  struct Cmds {
1111    cmds::Uniform1fvImmediate cmd;
1112    GLfloat data[2][1];
1113  };
1114
1115  Cmds expected;
1116  for (int ii = 0; ii < 2; ++ii) {
1117    for (int jj = 0; jj < 1; ++jj) {
1118      expected.data[ii][jj] = static_cast<GLfloat>(ii * 1 + jj);
1119    }
1120  }
1121  expected.cmd.Init(1, 2, &expected.data[0][0]);
1122  gl_->Uniform1fv(1, 2, &expected.data[0][0]);
1123  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1124}
1125
1126TEST_F(GLES2ImplementationTest, Uniform1i) {
1127  struct Cmds {
1128    cmds::Uniform1i cmd;
1129  };
1130  Cmds expected;
1131  expected.cmd.Init(1, 2);
1132
1133  gl_->Uniform1i(1, 2);
1134  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1135}
1136
1137TEST_F(GLES2ImplementationTest, Uniform1iv) {
1138  struct Cmds {
1139    cmds::Uniform1ivImmediate cmd;
1140    GLint data[2][1];
1141  };
1142
1143  Cmds expected;
1144  for (int ii = 0; ii < 2; ++ii) {
1145    for (int jj = 0; jj < 1; ++jj) {
1146      expected.data[ii][jj] = static_cast<GLint>(ii * 1 + jj);
1147    }
1148  }
1149  expected.cmd.Init(1, 2, &expected.data[0][0]);
1150  gl_->Uniform1iv(1, 2, &expected.data[0][0]);
1151  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1152}
1153
1154TEST_F(GLES2ImplementationTest, Uniform2f) {
1155  struct Cmds {
1156    cmds::Uniform2f cmd;
1157  };
1158  Cmds expected;
1159  expected.cmd.Init(1, 2, 3);
1160
1161  gl_->Uniform2f(1, 2, 3);
1162  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1163}
1164
1165TEST_F(GLES2ImplementationTest, Uniform2fv) {
1166  struct Cmds {
1167    cmds::Uniform2fvImmediate cmd;
1168    GLfloat data[2][2];
1169  };
1170
1171  Cmds expected;
1172  for (int ii = 0; ii < 2; ++ii) {
1173    for (int jj = 0; jj < 2; ++jj) {
1174      expected.data[ii][jj] = static_cast<GLfloat>(ii * 2 + jj);
1175    }
1176  }
1177  expected.cmd.Init(1, 2, &expected.data[0][0]);
1178  gl_->Uniform2fv(1, 2, &expected.data[0][0]);
1179  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1180}
1181
1182TEST_F(GLES2ImplementationTest, Uniform2i) {
1183  struct Cmds {
1184    cmds::Uniform2i cmd;
1185  };
1186  Cmds expected;
1187  expected.cmd.Init(1, 2, 3);
1188
1189  gl_->Uniform2i(1, 2, 3);
1190  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1191}
1192
1193TEST_F(GLES2ImplementationTest, Uniform2iv) {
1194  struct Cmds {
1195    cmds::Uniform2ivImmediate cmd;
1196    GLint data[2][2];
1197  };
1198
1199  Cmds expected;
1200  for (int ii = 0; ii < 2; ++ii) {
1201    for (int jj = 0; jj < 2; ++jj) {
1202      expected.data[ii][jj] = static_cast<GLint>(ii * 2 + jj);
1203    }
1204  }
1205  expected.cmd.Init(1, 2, &expected.data[0][0]);
1206  gl_->Uniform2iv(1, 2, &expected.data[0][0]);
1207  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1208}
1209
1210TEST_F(GLES2ImplementationTest, Uniform3f) {
1211  struct Cmds {
1212    cmds::Uniform3f cmd;
1213  };
1214  Cmds expected;
1215  expected.cmd.Init(1, 2, 3, 4);
1216
1217  gl_->Uniform3f(1, 2, 3, 4);
1218  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1219}
1220
1221TEST_F(GLES2ImplementationTest, Uniform3fv) {
1222  struct Cmds {
1223    cmds::Uniform3fvImmediate cmd;
1224    GLfloat data[2][3];
1225  };
1226
1227  Cmds expected;
1228  for (int ii = 0; ii < 2; ++ii) {
1229    for (int jj = 0; jj < 3; ++jj) {
1230      expected.data[ii][jj] = static_cast<GLfloat>(ii * 3 + jj);
1231    }
1232  }
1233  expected.cmd.Init(1, 2, &expected.data[0][0]);
1234  gl_->Uniform3fv(1, 2, &expected.data[0][0]);
1235  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1236}
1237
1238TEST_F(GLES2ImplementationTest, Uniform3i) {
1239  struct Cmds {
1240    cmds::Uniform3i cmd;
1241  };
1242  Cmds expected;
1243  expected.cmd.Init(1, 2, 3, 4);
1244
1245  gl_->Uniform3i(1, 2, 3, 4);
1246  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1247}
1248
1249TEST_F(GLES2ImplementationTest, Uniform3iv) {
1250  struct Cmds {
1251    cmds::Uniform3ivImmediate cmd;
1252    GLint data[2][3];
1253  };
1254
1255  Cmds expected;
1256  for (int ii = 0; ii < 2; ++ii) {
1257    for (int jj = 0; jj < 3; ++jj) {
1258      expected.data[ii][jj] = static_cast<GLint>(ii * 3 + jj);
1259    }
1260  }
1261  expected.cmd.Init(1, 2, &expected.data[0][0]);
1262  gl_->Uniform3iv(1, 2, &expected.data[0][0]);
1263  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1264}
1265
1266TEST_F(GLES2ImplementationTest, Uniform4f) {
1267  struct Cmds {
1268    cmds::Uniform4f cmd;
1269  };
1270  Cmds expected;
1271  expected.cmd.Init(1, 2, 3, 4, 5);
1272
1273  gl_->Uniform4f(1, 2, 3, 4, 5);
1274  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1275}
1276
1277TEST_F(GLES2ImplementationTest, Uniform4fv) {
1278  struct Cmds {
1279    cmds::Uniform4fvImmediate cmd;
1280    GLfloat data[2][4];
1281  };
1282
1283  Cmds expected;
1284  for (int ii = 0; ii < 2; ++ii) {
1285    for (int jj = 0; jj < 4; ++jj) {
1286      expected.data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
1287    }
1288  }
1289  expected.cmd.Init(1, 2, &expected.data[0][0]);
1290  gl_->Uniform4fv(1, 2, &expected.data[0][0]);
1291  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1292}
1293
1294TEST_F(GLES2ImplementationTest, Uniform4i) {
1295  struct Cmds {
1296    cmds::Uniform4i cmd;
1297  };
1298  Cmds expected;
1299  expected.cmd.Init(1, 2, 3, 4, 5);
1300
1301  gl_->Uniform4i(1, 2, 3, 4, 5);
1302  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1303}
1304
1305TEST_F(GLES2ImplementationTest, Uniform4iv) {
1306  struct Cmds {
1307    cmds::Uniform4ivImmediate cmd;
1308    GLint data[2][4];
1309  };
1310
1311  Cmds expected;
1312  for (int ii = 0; ii < 2; ++ii) {
1313    for (int jj = 0; jj < 4; ++jj) {
1314      expected.data[ii][jj] = static_cast<GLint>(ii * 4 + jj);
1315    }
1316  }
1317  expected.cmd.Init(1, 2, &expected.data[0][0]);
1318  gl_->Uniform4iv(1, 2, &expected.data[0][0]);
1319  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1320}
1321
1322TEST_F(GLES2ImplementationTest, UniformMatrix2fv) {
1323  struct Cmds {
1324    cmds::UniformMatrix2fvImmediate cmd;
1325    GLfloat data[2][4];
1326  };
1327
1328  Cmds expected;
1329  for (int ii = 0; ii < 2; ++ii) {
1330    for (int jj = 0; jj < 4; ++jj) {
1331      expected.data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj);
1332    }
1333  }
1334  expected.cmd.Init(1, 2, false, &expected.data[0][0]);
1335  gl_->UniformMatrix2fv(1, 2, false, &expected.data[0][0]);
1336  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1337}
1338
1339TEST_F(GLES2ImplementationTest, UniformMatrix3fv) {
1340  struct Cmds {
1341    cmds::UniformMatrix3fvImmediate cmd;
1342    GLfloat data[2][9];
1343  };
1344
1345  Cmds expected;
1346  for (int ii = 0; ii < 2; ++ii) {
1347    for (int jj = 0; jj < 9; ++jj) {
1348      expected.data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj);
1349    }
1350  }
1351  expected.cmd.Init(1, 2, false, &expected.data[0][0]);
1352  gl_->UniformMatrix3fv(1, 2, false, &expected.data[0][0]);
1353  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1354}
1355
1356TEST_F(GLES2ImplementationTest, UniformMatrix4fv) {
1357  struct Cmds {
1358    cmds::UniformMatrix4fvImmediate cmd;
1359    GLfloat data[2][16];
1360  };
1361
1362  Cmds expected;
1363  for (int ii = 0; ii < 2; ++ii) {
1364    for (int jj = 0; jj < 16; ++jj) {
1365      expected.data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj);
1366    }
1367  }
1368  expected.cmd.Init(1, 2, false, &expected.data[0][0]);
1369  gl_->UniformMatrix4fv(1, 2, false, &expected.data[0][0]);
1370  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1371}
1372
1373TEST_F(GLES2ImplementationTest, UseProgram) {
1374  struct Cmds {
1375    cmds::UseProgram cmd;
1376  };
1377  Cmds expected;
1378  expected.cmd.Init(1);
1379
1380  gl_->UseProgram(1);
1381  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1382}
1383
1384TEST_F(GLES2ImplementationTest, ValidateProgram) {
1385  struct Cmds {
1386    cmds::ValidateProgram cmd;
1387  };
1388  Cmds expected;
1389  expected.cmd.Init(1);
1390
1391  gl_->ValidateProgram(1);
1392  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1393}
1394
1395TEST_F(GLES2ImplementationTest, VertexAttrib1f) {
1396  struct Cmds {
1397    cmds::VertexAttrib1f cmd;
1398  };
1399  Cmds expected;
1400  expected.cmd.Init(1, 2);
1401
1402  gl_->VertexAttrib1f(1, 2);
1403  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1404}
1405
1406TEST_F(GLES2ImplementationTest, VertexAttrib1fv) {
1407  struct Cmds {
1408    cmds::VertexAttrib1fvImmediate cmd;
1409    GLfloat data[1];
1410  };
1411
1412  Cmds expected;
1413  for (int jj = 0; jj < 1; ++jj) {
1414    expected.data[jj] = static_cast<GLfloat>(jj);
1415  }
1416  expected.cmd.Init(1, &expected.data[0]);
1417  gl_->VertexAttrib1fv(1, &expected.data[0]);
1418  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1419}
1420
1421TEST_F(GLES2ImplementationTest, VertexAttrib2f) {
1422  struct Cmds {
1423    cmds::VertexAttrib2f cmd;
1424  };
1425  Cmds expected;
1426  expected.cmd.Init(1, 2, 3);
1427
1428  gl_->VertexAttrib2f(1, 2, 3);
1429  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1430}
1431
1432TEST_F(GLES2ImplementationTest, VertexAttrib2fv) {
1433  struct Cmds {
1434    cmds::VertexAttrib2fvImmediate cmd;
1435    GLfloat data[2];
1436  };
1437
1438  Cmds expected;
1439  for (int jj = 0; jj < 2; ++jj) {
1440    expected.data[jj] = static_cast<GLfloat>(jj);
1441  }
1442  expected.cmd.Init(1, &expected.data[0]);
1443  gl_->VertexAttrib2fv(1, &expected.data[0]);
1444  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1445}
1446
1447TEST_F(GLES2ImplementationTest, VertexAttrib3f) {
1448  struct Cmds {
1449    cmds::VertexAttrib3f cmd;
1450  };
1451  Cmds expected;
1452  expected.cmd.Init(1, 2, 3, 4);
1453
1454  gl_->VertexAttrib3f(1, 2, 3, 4);
1455  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1456}
1457
1458TEST_F(GLES2ImplementationTest, VertexAttrib3fv) {
1459  struct Cmds {
1460    cmds::VertexAttrib3fvImmediate cmd;
1461    GLfloat data[3];
1462  };
1463
1464  Cmds expected;
1465  for (int jj = 0; jj < 3; ++jj) {
1466    expected.data[jj] = static_cast<GLfloat>(jj);
1467  }
1468  expected.cmd.Init(1, &expected.data[0]);
1469  gl_->VertexAttrib3fv(1, &expected.data[0]);
1470  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1471}
1472
1473TEST_F(GLES2ImplementationTest, VertexAttrib4f) {
1474  struct Cmds {
1475    cmds::VertexAttrib4f cmd;
1476  };
1477  Cmds expected;
1478  expected.cmd.Init(1, 2, 3, 4, 5);
1479
1480  gl_->VertexAttrib4f(1, 2, 3, 4, 5);
1481  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1482}
1483
1484TEST_F(GLES2ImplementationTest, VertexAttrib4fv) {
1485  struct Cmds {
1486    cmds::VertexAttrib4fvImmediate cmd;
1487    GLfloat data[4];
1488  };
1489
1490  Cmds expected;
1491  for (int jj = 0; jj < 4; ++jj) {
1492    expected.data[jj] = static_cast<GLfloat>(jj);
1493  }
1494  expected.cmd.Init(1, &expected.data[0]);
1495  gl_->VertexAttrib4fv(1, &expected.data[0]);
1496  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1497}
1498
1499TEST_F(GLES2ImplementationTest, Viewport) {
1500  struct Cmds {
1501    cmds::Viewport cmd;
1502  };
1503  Cmds expected;
1504  expected.cmd.Init(1, 2, 3, 4);
1505
1506  gl_->Viewport(1, 2, 3, 4);
1507  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1508}
1509
1510TEST_F(GLES2ImplementationTest, BlitFramebufferEXT) {
1511  struct Cmds {
1512    cmds::BlitFramebufferEXT cmd;
1513  };
1514  Cmds expected;
1515  expected.cmd.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
1516
1517  gl_->BlitFramebufferEXT(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST);
1518  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1519}
1520
1521TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleEXT) {
1522  struct Cmds {
1523    cmds::RenderbufferStorageMultisampleEXT cmd;
1524  };
1525  Cmds expected;
1526  expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
1527
1528  gl_->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5);
1529  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1530}
1531
1532TEST_F(GLES2ImplementationTest, TexStorage2DEXT) {
1533  struct Cmds {
1534    cmds::TexStorage2DEXT cmd;
1535  };
1536  Cmds expected;
1537  expected.cmd.Init(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
1538
1539  gl_->TexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5);
1540  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1541}
1542
1543TEST_F(GLES2ImplementationTest, GenQueriesEXT) {
1544  GLuint ids[2] = { 0, };
1545  struct Cmds {
1546    cmds::GenQueriesEXTImmediate gen;
1547    GLuint data[2];
1548  };
1549  Cmds expected;
1550  expected.gen.Init(arraysize(ids), &ids[0]);
1551  expected.data[0] = kQueriesStartId;
1552  expected.data[1] = kQueriesStartId + 1;
1553  gl_->GenQueriesEXT(arraysize(ids), &ids[0]);
1554  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1555  EXPECT_EQ(kQueriesStartId, ids[0]);
1556  EXPECT_EQ(kQueriesStartId + 1, ids[1]);
1557}
1558
1559TEST_F(GLES2ImplementationTest, DeleteQueriesEXT) {
1560  GLuint ids[2] = { kQueriesStartId, kQueriesStartId + 1 };
1561  struct Cmds {
1562    cmds::DeleteQueriesEXTImmediate del;
1563    GLuint data[2];
1564  };
1565  Cmds expected;
1566  expected.del.Init(arraysize(ids), &ids[0]);
1567  expected.data[0] = kQueriesStartId;
1568  expected.data[1] = kQueriesStartId + 1;
1569  gl_->DeleteQueriesEXT(arraysize(ids), &ids[0]);
1570  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1571}
1572// TODO: Implement unit test for BeginQueryEXT
1573// TODO: Implement unit test for InsertEventMarkerEXT
1574// TODO: Implement unit test for PushGroupMarkerEXT
1575
1576TEST_F(GLES2ImplementationTest, PopGroupMarkerEXT) {
1577  struct Cmds {
1578    cmds::PopGroupMarkerEXT cmd;
1579  };
1580  Cmds expected;
1581  expected.cmd.Init();
1582
1583  gl_->PopGroupMarkerEXT();
1584  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1585}
1586
1587TEST_F(GLES2ImplementationTest, GenVertexArraysOES) {
1588  GLuint ids[2] = { 0, };
1589  struct Cmds {
1590    cmds::GenVertexArraysOESImmediate gen;
1591    GLuint data[2];
1592  };
1593  Cmds expected;
1594  expected.gen.Init(arraysize(ids), &ids[0]);
1595  expected.data[0] = kVertexArraysStartId;
1596  expected.data[1] = kVertexArraysStartId + 1;
1597  gl_->GenVertexArraysOES(arraysize(ids), &ids[0]);
1598  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1599  EXPECT_EQ(kVertexArraysStartId, ids[0]);
1600  EXPECT_EQ(kVertexArraysStartId + 1, ids[1]);
1601}
1602
1603TEST_F(GLES2ImplementationTest, DeleteVertexArraysOES) {
1604  GLuint ids[2] = { kVertexArraysStartId, kVertexArraysStartId + 1 };
1605  struct Cmds {
1606    cmds::DeleteVertexArraysOESImmediate del;
1607    GLuint data[2];
1608  };
1609  Cmds expected;
1610  expected.del.Init(arraysize(ids), &ids[0]);
1611  expected.data[0] = kVertexArraysStartId;
1612  expected.data[1] = kVertexArraysStartId + 1;
1613  gl_->DeleteVertexArraysOES(arraysize(ids), &ids[0]);
1614  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1615}
1616
1617TEST_F(GLES2ImplementationTest, IsVertexArrayOES) {
1618  struct Cmds {
1619    cmds::IsVertexArrayOES cmd;
1620  };
1621
1622  typedef cmds::IsVertexArrayOES::Result Result;
1623  Cmds expected;
1624  ExpectedMemoryInfo result1 =
1625      GetExpectedResultMemory(sizeof(cmds::IsVertexArrayOES::Result));
1626  expected.cmd.Init(1, result1.id, result1.offset);
1627
1628  EXPECT_CALL(*command_buffer(), OnFlush())
1629      .WillOnce(SetMemory(result1.ptr, uint32(1)))
1630      .RetiresOnSaturation();
1631
1632  GLboolean result = gl_->IsVertexArrayOES(1);
1633  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1634  EXPECT_TRUE(result);
1635}
1636// TODO: Implement unit test for GenSharedIdsCHROMIUM
1637// TODO: Implement unit test for DeleteSharedIdsCHROMIUM
1638// TODO: Implement unit test for RegisterSharedIdsCHROMIUM
1639// TODO: Implement unit test for EnableFeatureCHROMIUM
1640
1641TEST_F(GLES2ImplementationTest, ResizeCHROMIUM) {
1642  struct Cmds {
1643    cmds::ResizeCHROMIUM cmd;
1644  };
1645  Cmds expected;
1646  expected.cmd.Init(1, 2, 3);
1647
1648  gl_->ResizeCHROMIUM(1, 2, 3);
1649  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1650}
1651// TODO: Implement unit test for GetRequestableExtensionsCHROMIUM
1652
1653TEST_F(GLES2ImplementationTest, DestroyStreamTextureCHROMIUM) {
1654  struct Cmds {
1655    cmds::DestroyStreamTextureCHROMIUM cmd;
1656  };
1657  Cmds expected;
1658  expected.cmd.Init(1);
1659
1660  gl_->DestroyStreamTextureCHROMIUM(1);
1661  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1662}
1663// TODO: Implement unit test for GetTranslatedShaderSourceANGLE
1664
1665TEST_F(GLES2ImplementationTest, TexImageIOSurface2DCHROMIUM) {
1666  struct Cmds {
1667    cmds::TexImageIOSurface2DCHROMIUM cmd;
1668  };
1669  Cmds expected;
1670  expected.cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5);
1671
1672  gl_->TexImageIOSurface2DCHROMIUM(GL_TEXTURE_2D, 2, 3, 4, 5);
1673  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1674}
1675
1676TEST_F(GLES2ImplementationTest, CopyTextureCHROMIUM) {
1677  struct Cmds {
1678    cmds::CopyTextureCHROMIUM cmd;
1679  };
1680  Cmds expected;
1681  expected.cmd.Init(1, 2, 3, 4, GL_ALPHA, GL_UNSIGNED_BYTE);
1682
1683  gl_->CopyTextureCHROMIUM(1, 2, 3, 4, GL_ALPHA, GL_UNSIGNED_BYTE);
1684  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1685}
1686
1687TEST_F(GLES2ImplementationTest, DrawArraysInstancedANGLE) {
1688  struct Cmds {
1689    cmds::DrawArraysInstancedANGLE cmd;
1690  };
1691  Cmds expected;
1692  expected.cmd.Init(GL_POINTS, 2, 3, 4);
1693
1694  gl_->DrawArraysInstancedANGLE(GL_POINTS, 2, 3, 4);
1695  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1696}
1697
1698TEST_F(GLES2ImplementationTest, VertexAttribDivisorANGLE) {
1699  struct Cmds {
1700    cmds::VertexAttribDivisorANGLE cmd;
1701  };
1702  Cmds expected;
1703  expected.cmd.Init(1, 2);
1704
1705  gl_->VertexAttribDivisorANGLE(1, 2);
1706  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1707}
1708
1709TEST_F(GLES2ImplementationTest, ProduceTextureCHROMIUM) {
1710  struct Cmds {
1711    cmds::ProduceTextureCHROMIUMImmediate cmd;
1712    GLbyte data[64];
1713  };
1714
1715  Cmds expected;
1716  for (int jj = 0; jj < 64; ++jj) {
1717    expected.data[jj] = static_cast<GLbyte>(jj);
1718  }
1719  expected.cmd.Init(GL_TEXTURE_2D, &expected.data[0]);
1720  gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, &expected.data[0]);
1721  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1722}
1723
1724TEST_F(GLES2ImplementationTest, ConsumeTextureCHROMIUM) {
1725  struct Cmds {
1726    cmds::ConsumeTextureCHROMIUMImmediate cmd;
1727    GLbyte data[64];
1728  };
1729
1730  Cmds expected;
1731  for (int jj = 0; jj < 64; ++jj) {
1732    expected.data[jj] = static_cast<GLbyte>(jj);
1733  }
1734  expected.cmd.Init(GL_TEXTURE_2D, &expected.data[0]);
1735  gl_->ConsumeTextureCHROMIUM(GL_TEXTURE_2D, &expected.data[0]);
1736  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1737}
1738// TODO: Implement unit test for BindUniformLocationCHROMIUM
1739
1740TEST_F(GLES2ImplementationTest, BindTexImage2DCHROMIUM) {
1741  struct Cmds {
1742    cmds::BindTexImage2DCHROMIUM cmd;
1743  };
1744  Cmds expected;
1745  expected.cmd.Init(GL_TEXTURE_2D, 2);
1746
1747  gl_->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
1748  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1749}
1750
1751TEST_F(GLES2ImplementationTest, ReleaseTexImage2DCHROMIUM) {
1752  struct Cmds {
1753    cmds::ReleaseTexImage2DCHROMIUM cmd;
1754  };
1755  Cmds expected;
1756  expected.cmd.Init(GL_TEXTURE_2D, 2);
1757
1758  gl_->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, 2);
1759  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1760}
1761
1762TEST_F(GLES2ImplementationTest, DiscardFramebufferEXT) {
1763  struct Cmds {
1764    cmds::DiscardFramebufferEXTImmediate cmd;
1765    GLenum data[2][1];
1766  };
1767
1768  Cmds expected;
1769  for (int ii = 0; ii < 2; ++ii) {
1770    for (int jj = 0; jj < 1; ++jj) {
1771      expected.data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
1772    }
1773  }
1774  expected.cmd.Init(1, 2, &expected.data[0][0]);
1775  gl_->DiscardFramebufferEXT(1, 2, &expected.data[0][0]);
1776  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1777}
1778
1779TEST_F(GLES2ImplementationTest, LoseContextCHROMIUM) {
1780  struct Cmds {
1781    cmds::LoseContextCHROMIUM cmd;
1782  };
1783  Cmds expected;
1784  expected.cmd.Init(1, 2);
1785
1786  gl_->LoseContextCHROMIUM(1, 2);
1787  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1788}
1789// TODO: Implement unit test for InsertSyncPointCHROMIUM
1790
1791TEST_F(GLES2ImplementationTest, WaitSyncPointCHROMIUM) {
1792  struct Cmds {
1793    cmds::WaitSyncPointCHROMIUM cmd;
1794  };
1795  Cmds expected;
1796  expected.cmd.Init(1);
1797
1798  gl_->WaitSyncPointCHROMIUM(1);
1799  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1800}
1801
1802TEST_F(GLES2ImplementationTest, DrawBuffersEXT) {
1803  struct Cmds {
1804    cmds::DrawBuffersEXTImmediate cmd;
1805    GLenum data[1][1];
1806  };
1807
1808  Cmds expected;
1809  for (int ii = 0; ii < 1; ++ii) {
1810    for (int jj = 0; jj < 1; ++jj) {
1811      expected.data[ii][jj] = static_cast<GLenum>(ii * 1 + jj);
1812    }
1813  }
1814  expected.cmd.Init(1, &expected.data[0][0]);
1815  gl_->DrawBuffersEXT(1, &expected.data[0][0]);
1816  EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
1817}
1818#endif  // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_
1819
1820