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