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 contains unit tests for gles2 commmands
12// It is included by gles2_cmd_format_test.cc
13
14#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_TEST_AUTOGEN_H_
15#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_TEST_AUTOGEN_H_
16
17TEST_F(GLES2FormatTest, ActiveTexture) {
18  cmds::ActiveTexture& cmd = *GetBufferAs<cmds::ActiveTexture>();
19  void* next_cmd = cmd.Set(&cmd, static_cast<GLenum>(11));
20  EXPECT_EQ(static_cast<uint32_t>(cmds::ActiveTexture::kCmdId),
21            cmd.header.command);
22  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
23  EXPECT_EQ(static_cast<GLenum>(11), cmd.texture);
24  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
25}
26
27TEST_F(GLES2FormatTest, AttachShader) {
28  cmds::AttachShader& cmd = *GetBufferAs<cmds::AttachShader>();
29  void* next_cmd =
30      cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLuint>(12));
31  EXPECT_EQ(static_cast<uint32_t>(cmds::AttachShader::kCmdId),
32            cmd.header.command);
33  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
34  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
35  EXPECT_EQ(static_cast<GLuint>(12), cmd.shader);
36  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
37}
38
39TEST_F(GLES2FormatTest, BindAttribLocationBucket) {
40  cmds::BindAttribLocationBucket& cmd =
41      *GetBufferAs<cmds::BindAttribLocationBucket>();
42  void* next_cmd = cmd.Set(&cmd,
43                           static_cast<GLuint>(11),
44                           static_cast<GLuint>(12),
45                           static_cast<uint32_t>(13));
46  EXPECT_EQ(static_cast<uint32_t>(cmds::BindAttribLocationBucket::kCmdId),
47            cmd.header.command);
48  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
49  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
50  EXPECT_EQ(static_cast<GLuint>(12), cmd.index);
51  EXPECT_EQ(static_cast<uint32_t>(13), cmd.name_bucket_id);
52  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
53}
54
55TEST_F(GLES2FormatTest, BindBuffer) {
56  cmds::BindBuffer& cmd = *GetBufferAs<cmds::BindBuffer>();
57  void* next_cmd =
58      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLuint>(12));
59  EXPECT_EQ(static_cast<uint32_t>(cmds::BindBuffer::kCmdId),
60            cmd.header.command);
61  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
62  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
63  EXPECT_EQ(static_cast<GLuint>(12), cmd.buffer);
64  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
65}
66
67TEST_F(GLES2FormatTest, BindFramebuffer) {
68  cmds::BindFramebuffer& cmd = *GetBufferAs<cmds::BindFramebuffer>();
69  void* next_cmd =
70      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLuint>(12));
71  EXPECT_EQ(static_cast<uint32_t>(cmds::BindFramebuffer::kCmdId),
72            cmd.header.command);
73  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
74  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
75  EXPECT_EQ(static_cast<GLuint>(12), cmd.framebuffer);
76  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
77}
78
79TEST_F(GLES2FormatTest, BindRenderbuffer) {
80  cmds::BindRenderbuffer& cmd = *GetBufferAs<cmds::BindRenderbuffer>();
81  void* next_cmd =
82      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLuint>(12));
83  EXPECT_EQ(static_cast<uint32_t>(cmds::BindRenderbuffer::kCmdId),
84            cmd.header.command);
85  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
86  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
87  EXPECT_EQ(static_cast<GLuint>(12), cmd.renderbuffer);
88  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
89}
90
91TEST_F(GLES2FormatTest, BindTexture) {
92  cmds::BindTexture& cmd = *GetBufferAs<cmds::BindTexture>();
93  void* next_cmd =
94      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLuint>(12));
95  EXPECT_EQ(static_cast<uint32_t>(cmds::BindTexture::kCmdId),
96            cmd.header.command);
97  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
98  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
99  EXPECT_EQ(static_cast<GLuint>(12), cmd.texture);
100  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
101}
102
103TEST_F(GLES2FormatTest, BlendColor) {
104  cmds::BlendColor& cmd = *GetBufferAs<cmds::BlendColor>();
105  void* next_cmd = cmd.Set(&cmd,
106                           static_cast<GLclampf>(11),
107                           static_cast<GLclampf>(12),
108                           static_cast<GLclampf>(13),
109                           static_cast<GLclampf>(14));
110  EXPECT_EQ(static_cast<uint32_t>(cmds::BlendColor::kCmdId),
111            cmd.header.command);
112  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
113  EXPECT_EQ(static_cast<GLclampf>(11), cmd.red);
114  EXPECT_EQ(static_cast<GLclampf>(12), cmd.green);
115  EXPECT_EQ(static_cast<GLclampf>(13), cmd.blue);
116  EXPECT_EQ(static_cast<GLclampf>(14), cmd.alpha);
117  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
118}
119
120TEST_F(GLES2FormatTest, BlendEquation) {
121  cmds::BlendEquation& cmd = *GetBufferAs<cmds::BlendEquation>();
122  void* next_cmd = cmd.Set(&cmd, static_cast<GLenum>(11));
123  EXPECT_EQ(static_cast<uint32_t>(cmds::BlendEquation::kCmdId),
124            cmd.header.command);
125  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
126  EXPECT_EQ(static_cast<GLenum>(11), cmd.mode);
127  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
128}
129
130TEST_F(GLES2FormatTest, BlendEquationSeparate) {
131  cmds::BlendEquationSeparate& cmd =
132      *GetBufferAs<cmds::BlendEquationSeparate>();
133  void* next_cmd =
134      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLenum>(12));
135  EXPECT_EQ(static_cast<uint32_t>(cmds::BlendEquationSeparate::kCmdId),
136            cmd.header.command);
137  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
138  EXPECT_EQ(static_cast<GLenum>(11), cmd.modeRGB);
139  EXPECT_EQ(static_cast<GLenum>(12), cmd.modeAlpha);
140  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
141}
142
143TEST_F(GLES2FormatTest, BlendFunc) {
144  cmds::BlendFunc& cmd = *GetBufferAs<cmds::BlendFunc>();
145  void* next_cmd =
146      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLenum>(12));
147  EXPECT_EQ(static_cast<uint32_t>(cmds::BlendFunc::kCmdId), cmd.header.command);
148  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
149  EXPECT_EQ(static_cast<GLenum>(11), cmd.sfactor);
150  EXPECT_EQ(static_cast<GLenum>(12), cmd.dfactor);
151  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
152}
153
154TEST_F(GLES2FormatTest, BlendFuncSeparate) {
155  cmds::BlendFuncSeparate& cmd = *GetBufferAs<cmds::BlendFuncSeparate>();
156  void* next_cmd = cmd.Set(&cmd,
157                           static_cast<GLenum>(11),
158                           static_cast<GLenum>(12),
159                           static_cast<GLenum>(13),
160                           static_cast<GLenum>(14));
161  EXPECT_EQ(static_cast<uint32_t>(cmds::BlendFuncSeparate::kCmdId),
162            cmd.header.command);
163  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
164  EXPECT_EQ(static_cast<GLenum>(11), cmd.srcRGB);
165  EXPECT_EQ(static_cast<GLenum>(12), cmd.dstRGB);
166  EXPECT_EQ(static_cast<GLenum>(13), cmd.srcAlpha);
167  EXPECT_EQ(static_cast<GLenum>(14), cmd.dstAlpha);
168  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
169}
170
171TEST_F(GLES2FormatTest, BufferData) {
172  cmds::BufferData& cmd = *GetBufferAs<cmds::BufferData>();
173  void* next_cmd = cmd.Set(&cmd,
174                           static_cast<GLenum>(11),
175                           static_cast<GLsizeiptr>(12),
176                           static_cast<uint32_t>(13),
177                           static_cast<uint32_t>(14),
178                           static_cast<GLenum>(15));
179  EXPECT_EQ(static_cast<uint32_t>(cmds::BufferData::kCmdId),
180            cmd.header.command);
181  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
182  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
183  EXPECT_EQ(static_cast<GLsizeiptr>(12), cmd.size);
184  EXPECT_EQ(static_cast<uint32_t>(13), cmd.data_shm_id);
185  EXPECT_EQ(static_cast<uint32_t>(14), cmd.data_shm_offset);
186  EXPECT_EQ(static_cast<GLenum>(15), cmd.usage);
187  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
188}
189
190TEST_F(GLES2FormatTest, BufferSubData) {
191  cmds::BufferSubData& cmd = *GetBufferAs<cmds::BufferSubData>();
192  void* next_cmd = cmd.Set(&cmd,
193                           static_cast<GLenum>(11),
194                           static_cast<GLintptr>(12),
195                           static_cast<GLsizeiptr>(13),
196                           static_cast<uint32_t>(14),
197                           static_cast<uint32_t>(15));
198  EXPECT_EQ(static_cast<uint32_t>(cmds::BufferSubData::kCmdId),
199            cmd.header.command);
200  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
201  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
202  EXPECT_EQ(static_cast<GLintptr>(12), cmd.offset);
203  EXPECT_EQ(static_cast<GLsizeiptr>(13), cmd.size);
204  EXPECT_EQ(static_cast<uint32_t>(14), cmd.data_shm_id);
205  EXPECT_EQ(static_cast<uint32_t>(15), cmd.data_shm_offset);
206  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
207}
208
209TEST_F(GLES2FormatTest, CheckFramebufferStatus) {
210  cmds::CheckFramebufferStatus& cmd =
211      *GetBufferAs<cmds::CheckFramebufferStatus>();
212  void* next_cmd = cmd.Set(&cmd,
213                           static_cast<GLenum>(11),
214                           static_cast<uint32_t>(12),
215                           static_cast<uint32_t>(13));
216  EXPECT_EQ(static_cast<uint32_t>(cmds::CheckFramebufferStatus::kCmdId),
217            cmd.header.command);
218  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
219  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
220  EXPECT_EQ(static_cast<uint32_t>(12), cmd.result_shm_id);
221  EXPECT_EQ(static_cast<uint32_t>(13), cmd.result_shm_offset);
222  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
223}
224
225TEST_F(GLES2FormatTest, Clear) {
226  cmds::Clear& cmd = *GetBufferAs<cmds::Clear>();
227  void* next_cmd = cmd.Set(&cmd, static_cast<GLbitfield>(11));
228  EXPECT_EQ(static_cast<uint32_t>(cmds::Clear::kCmdId), cmd.header.command);
229  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
230  EXPECT_EQ(static_cast<GLbitfield>(11), cmd.mask);
231  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
232}
233
234TEST_F(GLES2FormatTest, ClearColor) {
235  cmds::ClearColor& cmd = *GetBufferAs<cmds::ClearColor>();
236  void* next_cmd = cmd.Set(&cmd,
237                           static_cast<GLclampf>(11),
238                           static_cast<GLclampf>(12),
239                           static_cast<GLclampf>(13),
240                           static_cast<GLclampf>(14));
241  EXPECT_EQ(static_cast<uint32_t>(cmds::ClearColor::kCmdId),
242            cmd.header.command);
243  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
244  EXPECT_EQ(static_cast<GLclampf>(11), cmd.red);
245  EXPECT_EQ(static_cast<GLclampf>(12), cmd.green);
246  EXPECT_EQ(static_cast<GLclampf>(13), cmd.blue);
247  EXPECT_EQ(static_cast<GLclampf>(14), cmd.alpha);
248  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
249}
250
251TEST_F(GLES2FormatTest, ClearDepthf) {
252  cmds::ClearDepthf& cmd = *GetBufferAs<cmds::ClearDepthf>();
253  void* next_cmd = cmd.Set(&cmd, static_cast<GLclampf>(11));
254  EXPECT_EQ(static_cast<uint32_t>(cmds::ClearDepthf::kCmdId),
255            cmd.header.command);
256  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
257  EXPECT_EQ(static_cast<GLclampf>(11), cmd.depth);
258  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
259}
260
261TEST_F(GLES2FormatTest, ClearStencil) {
262  cmds::ClearStencil& cmd = *GetBufferAs<cmds::ClearStencil>();
263  void* next_cmd = cmd.Set(&cmd, static_cast<GLint>(11));
264  EXPECT_EQ(static_cast<uint32_t>(cmds::ClearStencil::kCmdId),
265            cmd.header.command);
266  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
267  EXPECT_EQ(static_cast<GLint>(11), cmd.s);
268  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
269}
270
271TEST_F(GLES2FormatTest, ColorMask) {
272  cmds::ColorMask& cmd = *GetBufferAs<cmds::ColorMask>();
273  void* next_cmd = cmd.Set(&cmd,
274                           static_cast<GLboolean>(11),
275                           static_cast<GLboolean>(12),
276                           static_cast<GLboolean>(13),
277                           static_cast<GLboolean>(14));
278  EXPECT_EQ(static_cast<uint32_t>(cmds::ColorMask::kCmdId), cmd.header.command);
279  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
280  EXPECT_EQ(static_cast<GLboolean>(11), cmd.red);
281  EXPECT_EQ(static_cast<GLboolean>(12), cmd.green);
282  EXPECT_EQ(static_cast<GLboolean>(13), cmd.blue);
283  EXPECT_EQ(static_cast<GLboolean>(14), cmd.alpha);
284  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
285}
286
287TEST_F(GLES2FormatTest, CompileShader) {
288  cmds::CompileShader& cmd = *GetBufferAs<cmds::CompileShader>();
289  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
290  EXPECT_EQ(static_cast<uint32_t>(cmds::CompileShader::kCmdId),
291            cmd.header.command);
292  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
293  EXPECT_EQ(static_cast<GLuint>(11), cmd.shader);
294  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
295}
296
297TEST_F(GLES2FormatTest, CompressedTexImage2DBucket) {
298  cmds::CompressedTexImage2DBucket& cmd =
299      *GetBufferAs<cmds::CompressedTexImage2DBucket>();
300  void* next_cmd = cmd.Set(&cmd,
301                           static_cast<GLenum>(11),
302                           static_cast<GLint>(12),
303                           static_cast<GLenum>(13),
304                           static_cast<GLsizei>(14),
305                           static_cast<GLsizei>(15),
306                           static_cast<GLuint>(16));
307  EXPECT_EQ(static_cast<uint32_t>(cmds::CompressedTexImage2DBucket::kCmdId),
308            cmd.header.command);
309  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
310  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
311  EXPECT_EQ(static_cast<GLint>(12), cmd.level);
312  EXPECT_EQ(static_cast<GLenum>(13), cmd.internalformat);
313  EXPECT_EQ(static_cast<GLsizei>(14), cmd.width);
314  EXPECT_EQ(static_cast<GLsizei>(15), cmd.height);
315  EXPECT_EQ(static_cast<GLuint>(16), cmd.bucket_id);
316  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
317}
318
319TEST_F(GLES2FormatTest, CompressedTexImage2D) {
320  cmds::CompressedTexImage2D& cmd = *GetBufferAs<cmds::CompressedTexImage2D>();
321  void* next_cmd = cmd.Set(&cmd,
322                           static_cast<GLenum>(11),
323                           static_cast<GLint>(12),
324                           static_cast<GLenum>(13),
325                           static_cast<GLsizei>(14),
326                           static_cast<GLsizei>(15),
327                           static_cast<GLsizei>(16),
328                           static_cast<uint32_t>(17),
329                           static_cast<uint32_t>(18));
330  EXPECT_EQ(static_cast<uint32_t>(cmds::CompressedTexImage2D::kCmdId),
331            cmd.header.command);
332  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
333  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
334  EXPECT_EQ(static_cast<GLint>(12), cmd.level);
335  EXPECT_EQ(static_cast<GLenum>(13), cmd.internalformat);
336  EXPECT_EQ(static_cast<GLsizei>(14), cmd.width);
337  EXPECT_EQ(static_cast<GLsizei>(15), cmd.height);
338  EXPECT_EQ(static_cast<GLsizei>(16), cmd.imageSize);
339  EXPECT_EQ(static_cast<uint32_t>(17), cmd.data_shm_id);
340  EXPECT_EQ(static_cast<uint32_t>(18), cmd.data_shm_offset);
341  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
342}
343
344TEST_F(GLES2FormatTest, CompressedTexSubImage2DBucket) {
345  cmds::CompressedTexSubImage2DBucket& cmd =
346      *GetBufferAs<cmds::CompressedTexSubImage2DBucket>();
347  void* next_cmd = cmd.Set(&cmd,
348                           static_cast<GLenum>(11),
349                           static_cast<GLint>(12),
350                           static_cast<GLint>(13),
351                           static_cast<GLint>(14),
352                           static_cast<GLsizei>(15),
353                           static_cast<GLsizei>(16),
354                           static_cast<GLenum>(17),
355                           static_cast<GLuint>(18));
356  EXPECT_EQ(static_cast<uint32_t>(cmds::CompressedTexSubImage2DBucket::kCmdId),
357            cmd.header.command);
358  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
359  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
360  EXPECT_EQ(static_cast<GLint>(12), cmd.level);
361  EXPECT_EQ(static_cast<GLint>(13), cmd.xoffset);
362  EXPECT_EQ(static_cast<GLint>(14), cmd.yoffset);
363  EXPECT_EQ(static_cast<GLsizei>(15), cmd.width);
364  EXPECT_EQ(static_cast<GLsizei>(16), cmd.height);
365  EXPECT_EQ(static_cast<GLenum>(17), cmd.format);
366  EXPECT_EQ(static_cast<GLuint>(18), cmd.bucket_id);
367  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
368}
369
370TEST_F(GLES2FormatTest, CompressedTexSubImage2D) {
371  cmds::CompressedTexSubImage2D& cmd =
372      *GetBufferAs<cmds::CompressedTexSubImage2D>();
373  void* next_cmd = cmd.Set(&cmd,
374                           static_cast<GLenum>(11),
375                           static_cast<GLint>(12),
376                           static_cast<GLint>(13),
377                           static_cast<GLint>(14),
378                           static_cast<GLsizei>(15),
379                           static_cast<GLsizei>(16),
380                           static_cast<GLenum>(17),
381                           static_cast<GLsizei>(18),
382                           static_cast<uint32_t>(19),
383                           static_cast<uint32_t>(20));
384  EXPECT_EQ(static_cast<uint32_t>(cmds::CompressedTexSubImage2D::kCmdId),
385            cmd.header.command);
386  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
387  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
388  EXPECT_EQ(static_cast<GLint>(12), cmd.level);
389  EXPECT_EQ(static_cast<GLint>(13), cmd.xoffset);
390  EXPECT_EQ(static_cast<GLint>(14), cmd.yoffset);
391  EXPECT_EQ(static_cast<GLsizei>(15), cmd.width);
392  EXPECT_EQ(static_cast<GLsizei>(16), cmd.height);
393  EXPECT_EQ(static_cast<GLenum>(17), cmd.format);
394  EXPECT_EQ(static_cast<GLsizei>(18), cmd.imageSize);
395  EXPECT_EQ(static_cast<uint32_t>(19), cmd.data_shm_id);
396  EXPECT_EQ(static_cast<uint32_t>(20), cmd.data_shm_offset);
397  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
398}
399
400TEST_F(GLES2FormatTest, CopyTexImage2D) {
401  cmds::CopyTexImage2D& cmd = *GetBufferAs<cmds::CopyTexImage2D>();
402  void* next_cmd = cmd.Set(&cmd,
403                           static_cast<GLenum>(11),
404                           static_cast<GLint>(12),
405                           static_cast<GLenum>(13),
406                           static_cast<GLint>(14),
407                           static_cast<GLint>(15),
408                           static_cast<GLsizei>(16),
409                           static_cast<GLsizei>(17));
410  EXPECT_EQ(static_cast<uint32_t>(cmds::CopyTexImage2D::kCmdId),
411            cmd.header.command);
412  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
413  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
414  EXPECT_EQ(static_cast<GLint>(12), cmd.level);
415  EXPECT_EQ(static_cast<GLenum>(13), cmd.internalformat);
416  EXPECT_EQ(static_cast<GLint>(14), cmd.x);
417  EXPECT_EQ(static_cast<GLint>(15), cmd.y);
418  EXPECT_EQ(static_cast<GLsizei>(16), cmd.width);
419  EXPECT_EQ(static_cast<GLsizei>(17), cmd.height);
420  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
421}
422
423TEST_F(GLES2FormatTest, CopyTexSubImage2D) {
424  cmds::CopyTexSubImage2D& cmd = *GetBufferAs<cmds::CopyTexSubImage2D>();
425  void* next_cmd = cmd.Set(&cmd,
426                           static_cast<GLenum>(11),
427                           static_cast<GLint>(12),
428                           static_cast<GLint>(13),
429                           static_cast<GLint>(14),
430                           static_cast<GLint>(15),
431                           static_cast<GLint>(16),
432                           static_cast<GLsizei>(17),
433                           static_cast<GLsizei>(18));
434  EXPECT_EQ(static_cast<uint32_t>(cmds::CopyTexSubImage2D::kCmdId),
435            cmd.header.command);
436  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
437  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
438  EXPECT_EQ(static_cast<GLint>(12), cmd.level);
439  EXPECT_EQ(static_cast<GLint>(13), cmd.xoffset);
440  EXPECT_EQ(static_cast<GLint>(14), cmd.yoffset);
441  EXPECT_EQ(static_cast<GLint>(15), cmd.x);
442  EXPECT_EQ(static_cast<GLint>(16), cmd.y);
443  EXPECT_EQ(static_cast<GLsizei>(17), cmd.width);
444  EXPECT_EQ(static_cast<GLsizei>(18), cmd.height);
445  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
446}
447
448TEST_F(GLES2FormatTest, CreateProgram) {
449  cmds::CreateProgram& cmd = *GetBufferAs<cmds::CreateProgram>();
450  void* next_cmd = cmd.Set(&cmd, static_cast<uint32_t>(11));
451  EXPECT_EQ(static_cast<uint32_t>(cmds::CreateProgram::kCmdId),
452            cmd.header.command);
453  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
454  EXPECT_EQ(static_cast<uint32_t>(11), cmd.client_id);
455  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
456}
457
458TEST_F(GLES2FormatTest, CreateShader) {
459  cmds::CreateShader& cmd = *GetBufferAs<cmds::CreateShader>();
460  void* next_cmd =
461      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<uint32_t>(12));
462  EXPECT_EQ(static_cast<uint32_t>(cmds::CreateShader::kCmdId),
463            cmd.header.command);
464  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
465  EXPECT_EQ(static_cast<GLenum>(11), cmd.type);
466  EXPECT_EQ(static_cast<uint32_t>(12), cmd.client_id);
467  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
468}
469
470TEST_F(GLES2FormatTest, CullFace) {
471  cmds::CullFace& cmd = *GetBufferAs<cmds::CullFace>();
472  void* next_cmd = cmd.Set(&cmd, static_cast<GLenum>(11));
473  EXPECT_EQ(static_cast<uint32_t>(cmds::CullFace::kCmdId), cmd.header.command);
474  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
475  EXPECT_EQ(static_cast<GLenum>(11), cmd.mode);
476  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
477}
478
479TEST_F(GLES2FormatTest, DeleteBuffersImmediate) {
480  static GLuint ids[] = {
481      12, 23, 34,
482  };
483  cmds::DeleteBuffersImmediate& cmd =
484      *GetBufferAs<cmds::DeleteBuffersImmediate>();
485  void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(arraysize(ids)), ids);
486  EXPECT_EQ(static_cast<uint32_t>(cmds::DeleteBuffersImmediate::kCmdId),
487            cmd.header.command);
488  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
489            cmd.header.size * 4u);
490  EXPECT_EQ(static_cast<GLsizei>(arraysize(ids)), cmd.n);
491  CheckBytesWrittenMatchesExpectedSize(
492      next_cmd,
493      sizeof(cmd) + RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));
494  // TODO(gman): Check that ids were inserted;
495}
496
497TEST_F(GLES2FormatTest, DeleteFramebuffersImmediate) {
498  static GLuint ids[] = {
499      12, 23, 34,
500  };
501  cmds::DeleteFramebuffersImmediate& cmd =
502      *GetBufferAs<cmds::DeleteFramebuffersImmediate>();
503  void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(arraysize(ids)), ids);
504  EXPECT_EQ(static_cast<uint32_t>(cmds::DeleteFramebuffersImmediate::kCmdId),
505            cmd.header.command);
506  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
507            cmd.header.size * 4u);
508  EXPECT_EQ(static_cast<GLsizei>(arraysize(ids)), cmd.n);
509  CheckBytesWrittenMatchesExpectedSize(
510      next_cmd,
511      sizeof(cmd) + RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));
512  // TODO(gman): Check that ids were inserted;
513}
514
515TEST_F(GLES2FormatTest, DeleteProgram) {
516  cmds::DeleteProgram& cmd = *GetBufferAs<cmds::DeleteProgram>();
517  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
518  EXPECT_EQ(static_cast<uint32_t>(cmds::DeleteProgram::kCmdId),
519            cmd.header.command);
520  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
521  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
522  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
523}
524
525TEST_F(GLES2FormatTest, DeleteRenderbuffersImmediate) {
526  static GLuint ids[] = {
527      12, 23, 34,
528  };
529  cmds::DeleteRenderbuffersImmediate& cmd =
530      *GetBufferAs<cmds::DeleteRenderbuffersImmediate>();
531  void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(arraysize(ids)), ids);
532  EXPECT_EQ(static_cast<uint32_t>(cmds::DeleteRenderbuffersImmediate::kCmdId),
533            cmd.header.command);
534  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
535            cmd.header.size * 4u);
536  EXPECT_EQ(static_cast<GLsizei>(arraysize(ids)), cmd.n);
537  CheckBytesWrittenMatchesExpectedSize(
538      next_cmd,
539      sizeof(cmd) + RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));
540  // TODO(gman): Check that ids were inserted;
541}
542
543TEST_F(GLES2FormatTest, DeleteShader) {
544  cmds::DeleteShader& cmd = *GetBufferAs<cmds::DeleteShader>();
545  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
546  EXPECT_EQ(static_cast<uint32_t>(cmds::DeleteShader::kCmdId),
547            cmd.header.command);
548  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
549  EXPECT_EQ(static_cast<GLuint>(11), cmd.shader);
550  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
551}
552
553TEST_F(GLES2FormatTest, DeleteTexturesImmediate) {
554  static GLuint ids[] = {
555      12, 23, 34,
556  };
557  cmds::DeleteTexturesImmediate& cmd =
558      *GetBufferAs<cmds::DeleteTexturesImmediate>();
559  void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(arraysize(ids)), ids);
560  EXPECT_EQ(static_cast<uint32_t>(cmds::DeleteTexturesImmediate::kCmdId),
561            cmd.header.command);
562  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
563            cmd.header.size * 4u);
564  EXPECT_EQ(static_cast<GLsizei>(arraysize(ids)), cmd.n);
565  CheckBytesWrittenMatchesExpectedSize(
566      next_cmd,
567      sizeof(cmd) + RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));
568  // TODO(gman): Check that ids were inserted;
569}
570
571TEST_F(GLES2FormatTest, DepthFunc) {
572  cmds::DepthFunc& cmd = *GetBufferAs<cmds::DepthFunc>();
573  void* next_cmd = cmd.Set(&cmd, static_cast<GLenum>(11));
574  EXPECT_EQ(static_cast<uint32_t>(cmds::DepthFunc::kCmdId), cmd.header.command);
575  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
576  EXPECT_EQ(static_cast<GLenum>(11), cmd.func);
577  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
578}
579
580TEST_F(GLES2FormatTest, DepthMask) {
581  cmds::DepthMask& cmd = *GetBufferAs<cmds::DepthMask>();
582  void* next_cmd = cmd.Set(&cmd, static_cast<GLboolean>(11));
583  EXPECT_EQ(static_cast<uint32_t>(cmds::DepthMask::kCmdId), cmd.header.command);
584  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
585  EXPECT_EQ(static_cast<GLboolean>(11), cmd.flag);
586  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
587}
588
589TEST_F(GLES2FormatTest, DepthRangef) {
590  cmds::DepthRangef& cmd = *GetBufferAs<cmds::DepthRangef>();
591  void* next_cmd =
592      cmd.Set(&cmd, static_cast<GLclampf>(11), static_cast<GLclampf>(12));
593  EXPECT_EQ(static_cast<uint32_t>(cmds::DepthRangef::kCmdId),
594            cmd.header.command);
595  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
596  EXPECT_EQ(static_cast<GLclampf>(11), cmd.zNear);
597  EXPECT_EQ(static_cast<GLclampf>(12), cmd.zFar);
598  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
599}
600
601TEST_F(GLES2FormatTest, DetachShader) {
602  cmds::DetachShader& cmd = *GetBufferAs<cmds::DetachShader>();
603  void* next_cmd =
604      cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLuint>(12));
605  EXPECT_EQ(static_cast<uint32_t>(cmds::DetachShader::kCmdId),
606            cmd.header.command);
607  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
608  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
609  EXPECT_EQ(static_cast<GLuint>(12), cmd.shader);
610  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
611}
612
613TEST_F(GLES2FormatTest, Disable) {
614  cmds::Disable& cmd = *GetBufferAs<cmds::Disable>();
615  void* next_cmd = cmd.Set(&cmd, static_cast<GLenum>(11));
616  EXPECT_EQ(static_cast<uint32_t>(cmds::Disable::kCmdId), cmd.header.command);
617  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
618  EXPECT_EQ(static_cast<GLenum>(11), cmd.cap);
619  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
620}
621
622TEST_F(GLES2FormatTest, DisableVertexAttribArray) {
623  cmds::DisableVertexAttribArray& cmd =
624      *GetBufferAs<cmds::DisableVertexAttribArray>();
625  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
626  EXPECT_EQ(static_cast<uint32_t>(cmds::DisableVertexAttribArray::kCmdId),
627            cmd.header.command);
628  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
629  EXPECT_EQ(static_cast<GLuint>(11), cmd.index);
630  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
631}
632
633TEST_F(GLES2FormatTest, DrawArrays) {
634  cmds::DrawArrays& cmd = *GetBufferAs<cmds::DrawArrays>();
635  void* next_cmd = cmd.Set(&cmd,
636                           static_cast<GLenum>(11),
637                           static_cast<GLint>(12),
638                           static_cast<GLsizei>(13));
639  EXPECT_EQ(static_cast<uint32_t>(cmds::DrawArrays::kCmdId),
640            cmd.header.command);
641  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
642  EXPECT_EQ(static_cast<GLenum>(11), cmd.mode);
643  EXPECT_EQ(static_cast<GLint>(12), cmd.first);
644  EXPECT_EQ(static_cast<GLsizei>(13), cmd.count);
645  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
646}
647
648TEST_F(GLES2FormatTest, DrawElements) {
649  cmds::DrawElements& cmd = *GetBufferAs<cmds::DrawElements>();
650  void* next_cmd = cmd.Set(&cmd,
651                           static_cast<GLenum>(11),
652                           static_cast<GLsizei>(12),
653                           static_cast<GLenum>(13),
654                           static_cast<GLuint>(14));
655  EXPECT_EQ(static_cast<uint32_t>(cmds::DrawElements::kCmdId),
656            cmd.header.command);
657  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
658  EXPECT_EQ(static_cast<GLenum>(11), cmd.mode);
659  EXPECT_EQ(static_cast<GLsizei>(12), cmd.count);
660  EXPECT_EQ(static_cast<GLenum>(13), cmd.type);
661  EXPECT_EQ(static_cast<GLuint>(14), cmd.index_offset);
662  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
663}
664
665TEST_F(GLES2FormatTest, Enable) {
666  cmds::Enable& cmd = *GetBufferAs<cmds::Enable>();
667  void* next_cmd = cmd.Set(&cmd, static_cast<GLenum>(11));
668  EXPECT_EQ(static_cast<uint32_t>(cmds::Enable::kCmdId), cmd.header.command);
669  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
670  EXPECT_EQ(static_cast<GLenum>(11), cmd.cap);
671  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
672}
673
674TEST_F(GLES2FormatTest, EnableVertexAttribArray) {
675  cmds::EnableVertexAttribArray& cmd =
676      *GetBufferAs<cmds::EnableVertexAttribArray>();
677  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
678  EXPECT_EQ(static_cast<uint32_t>(cmds::EnableVertexAttribArray::kCmdId),
679            cmd.header.command);
680  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
681  EXPECT_EQ(static_cast<GLuint>(11), cmd.index);
682  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
683}
684
685TEST_F(GLES2FormatTest, Finish) {
686  cmds::Finish& cmd = *GetBufferAs<cmds::Finish>();
687  void* next_cmd = cmd.Set(&cmd);
688  EXPECT_EQ(static_cast<uint32_t>(cmds::Finish::kCmdId), cmd.header.command);
689  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
690  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
691}
692
693TEST_F(GLES2FormatTest, Flush) {
694  cmds::Flush& cmd = *GetBufferAs<cmds::Flush>();
695  void* next_cmd = cmd.Set(&cmd);
696  EXPECT_EQ(static_cast<uint32_t>(cmds::Flush::kCmdId), cmd.header.command);
697  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
698  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
699}
700
701TEST_F(GLES2FormatTest, FramebufferRenderbuffer) {
702  cmds::FramebufferRenderbuffer& cmd =
703      *GetBufferAs<cmds::FramebufferRenderbuffer>();
704  void* next_cmd = cmd.Set(&cmd,
705                           static_cast<GLenum>(11),
706                           static_cast<GLenum>(12),
707                           static_cast<GLenum>(13),
708                           static_cast<GLuint>(14));
709  EXPECT_EQ(static_cast<uint32_t>(cmds::FramebufferRenderbuffer::kCmdId),
710            cmd.header.command);
711  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
712  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
713  EXPECT_EQ(static_cast<GLenum>(12), cmd.attachment);
714  EXPECT_EQ(static_cast<GLenum>(13), cmd.renderbuffertarget);
715  EXPECT_EQ(static_cast<GLuint>(14), cmd.renderbuffer);
716  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
717}
718
719TEST_F(GLES2FormatTest, FramebufferTexture2D) {
720  cmds::FramebufferTexture2D& cmd = *GetBufferAs<cmds::FramebufferTexture2D>();
721  void* next_cmd = cmd.Set(&cmd,
722                           static_cast<GLenum>(11),
723                           static_cast<GLenum>(12),
724                           static_cast<GLenum>(13),
725                           static_cast<GLuint>(14));
726  EXPECT_EQ(static_cast<uint32_t>(cmds::FramebufferTexture2D::kCmdId),
727            cmd.header.command);
728  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
729  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
730  EXPECT_EQ(static_cast<GLenum>(12), cmd.attachment);
731  EXPECT_EQ(static_cast<GLenum>(13), cmd.textarget);
732  EXPECT_EQ(static_cast<GLuint>(14), cmd.texture);
733  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
734}
735
736TEST_F(GLES2FormatTest, FrontFace) {
737  cmds::FrontFace& cmd = *GetBufferAs<cmds::FrontFace>();
738  void* next_cmd = cmd.Set(&cmd, static_cast<GLenum>(11));
739  EXPECT_EQ(static_cast<uint32_t>(cmds::FrontFace::kCmdId), cmd.header.command);
740  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
741  EXPECT_EQ(static_cast<GLenum>(11), cmd.mode);
742  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
743}
744
745TEST_F(GLES2FormatTest, GenBuffersImmediate) {
746  static GLuint ids[] = {
747      12, 23, 34,
748  };
749  cmds::GenBuffersImmediate& cmd = *GetBufferAs<cmds::GenBuffersImmediate>();
750  void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(arraysize(ids)), ids);
751  EXPECT_EQ(static_cast<uint32_t>(cmds::GenBuffersImmediate::kCmdId),
752            cmd.header.command);
753  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
754            cmd.header.size * 4u);
755  EXPECT_EQ(static_cast<GLsizei>(arraysize(ids)), cmd.n);
756  CheckBytesWrittenMatchesExpectedSize(
757      next_cmd,
758      sizeof(cmd) + RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));
759  // TODO(gman): Check that ids were inserted;
760}
761
762TEST_F(GLES2FormatTest, GenerateMipmap) {
763  cmds::GenerateMipmap& cmd = *GetBufferAs<cmds::GenerateMipmap>();
764  void* next_cmd = cmd.Set(&cmd, static_cast<GLenum>(11));
765  EXPECT_EQ(static_cast<uint32_t>(cmds::GenerateMipmap::kCmdId),
766            cmd.header.command);
767  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
768  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
769  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
770}
771
772TEST_F(GLES2FormatTest, GenFramebuffersImmediate) {
773  static GLuint ids[] = {
774      12, 23, 34,
775  };
776  cmds::GenFramebuffersImmediate& cmd =
777      *GetBufferAs<cmds::GenFramebuffersImmediate>();
778  void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(arraysize(ids)), ids);
779  EXPECT_EQ(static_cast<uint32_t>(cmds::GenFramebuffersImmediate::kCmdId),
780            cmd.header.command);
781  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
782            cmd.header.size * 4u);
783  EXPECT_EQ(static_cast<GLsizei>(arraysize(ids)), cmd.n);
784  CheckBytesWrittenMatchesExpectedSize(
785      next_cmd,
786      sizeof(cmd) + RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));
787  // TODO(gman): Check that ids were inserted;
788}
789
790TEST_F(GLES2FormatTest, GenRenderbuffersImmediate) {
791  static GLuint ids[] = {
792      12, 23, 34,
793  };
794  cmds::GenRenderbuffersImmediate& cmd =
795      *GetBufferAs<cmds::GenRenderbuffersImmediate>();
796  void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(arraysize(ids)), ids);
797  EXPECT_EQ(static_cast<uint32_t>(cmds::GenRenderbuffersImmediate::kCmdId),
798            cmd.header.command);
799  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
800            cmd.header.size * 4u);
801  EXPECT_EQ(static_cast<GLsizei>(arraysize(ids)), cmd.n);
802  CheckBytesWrittenMatchesExpectedSize(
803      next_cmd,
804      sizeof(cmd) + RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));
805  // TODO(gman): Check that ids were inserted;
806}
807
808TEST_F(GLES2FormatTest, GenTexturesImmediate) {
809  static GLuint ids[] = {
810      12, 23, 34,
811  };
812  cmds::GenTexturesImmediate& cmd = *GetBufferAs<cmds::GenTexturesImmediate>();
813  void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(arraysize(ids)), ids);
814  EXPECT_EQ(static_cast<uint32_t>(cmds::GenTexturesImmediate::kCmdId),
815            cmd.header.command);
816  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
817            cmd.header.size * 4u);
818  EXPECT_EQ(static_cast<GLsizei>(arraysize(ids)), cmd.n);
819  CheckBytesWrittenMatchesExpectedSize(
820      next_cmd,
821      sizeof(cmd) + RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));
822  // TODO(gman): Check that ids were inserted;
823}
824
825TEST_F(GLES2FormatTest, GetActiveAttrib) {
826  cmds::GetActiveAttrib& cmd = *GetBufferAs<cmds::GetActiveAttrib>();
827  void* next_cmd = cmd.Set(&cmd,
828                           static_cast<GLuint>(11),
829                           static_cast<GLuint>(12),
830                           static_cast<uint32_t>(13),
831                           static_cast<uint32_t>(14),
832                           static_cast<uint32_t>(15));
833  EXPECT_EQ(static_cast<uint32_t>(cmds::GetActiveAttrib::kCmdId),
834            cmd.header.command);
835  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
836  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
837  EXPECT_EQ(static_cast<GLuint>(12), cmd.index);
838  EXPECT_EQ(static_cast<uint32_t>(13), cmd.name_bucket_id);
839  EXPECT_EQ(static_cast<uint32_t>(14), cmd.result_shm_id);
840  EXPECT_EQ(static_cast<uint32_t>(15), cmd.result_shm_offset);
841  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
842}
843
844TEST_F(GLES2FormatTest, GetActiveUniform) {
845  cmds::GetActiveUniform& cmd = *GetBufferAs<cmds::GetActiveUniform>();
846  void* next_cmd = cmd.Set(&cmd,
847                           static_cast<GLuint>(11),
848                           static_cast<GLuint>(12),
849                           static_cast<uint32_t>(13),
850                           static_cast<uint32_t>(14),
851                           static_cast<uint32_t>(15));
852  EXPECT_EQ(static_cast<uint32_t>(cmds::GetActiveUniform::kCmdId),
853            cmd.header.command);
854  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
855  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
856  EXPECT_EQ(static_cast<GLuint>(12), cmd.index);
857  EXPECT_EQ(static_cast<uint32_t>(13), cmd.name_bucket_id);
858  EXPECT_EQ(static_cast<uint32_t>(14), cmd.result_shm_id);
859  EXPECT_EQ(static_cast<uint32_t>(15), cmd.result_shm_offset);
860  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
861}
862
863TEST_F(GLES2FormatTest, GetAttachedShaders) {
864  cmds::GetAttachedShaders& cmd = *GetBufferAs<cmds::GetAttachedShaders>();
865  void* next_cmd = cmd.Set(&cmd,
866                           static_cast<GLuint>(11),
867                           static_cast<uint32_t>(12),
868                           static_cast<uint32_t>(13),
869                           static_cast<uint32_t>(14));
870  EXPECT_EQ(static_cast<uint32_t>(cmds::GetAttachedShaders::kCmdId),
871            cmd.header.command);
872  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
873  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
874  EXPECT_EQ(static_cast<uint32_t>(12), cmd.result_shm_id);
875  EXPECT_EQ(static_cast<uint32_t>(13), cmd.result_shm_offset);
876  EXPECT_EQ(static_cast<uint32_t>(14), cmd.result_size);
877  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
878}
879
880TEST_F(GLES2FormatTest, GetAttribLocation) {
881  cmds::GetAttribLocation& cmd = *GetBufferAs<cmds::GetAttribLocation>();
882  void* next_cmd = cmd.Set(&cmd,
883                           static_cast<GLuint>(11),
884                           static_cast<uint32_t>(12),
885                           static_cast<uint32_t>(13),
886                           static_cast<uint32_t>(14));
887  EXPECT_EQ(static_cast<uint32_t>(cmds::GetAttribLocation::kCmdId),
888            cmd.header.command);
889  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
890  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
891  EXPECT_EQ(static_cast<uint32_t>(12), cmd.name_bucket_id);
892  EXPECT_EQ(static_cast<uint32_t>(13), cmd.location_shm_id);
893  EXPECT_EQ(static_cast<uint32_t>(14), cmd.location_shm_offset);
894  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
895}
896
897TEST_F(GLES2FormatTest, GetBooleanv) {
898  cmds::GetBooleanv& cmd = *GetBufferAs<cmds::GetBooleanv>();
899  void* next_cmd = cmd.Set(&cmd,
900                           static_cast<GLenum>(11),
901                           static_cast<uint32_t>(12),
902                           static_cast<uint32_t>(13));
903  EXPECT_EQ(static_cast<uint32_t>(cmds::GetBooleanv::kCmdId),
904            cmd.header.command);
905  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
906  EXPECT_EQ(static_cast<GLenum>(11), cmd.pname);
907  EXPECT_EQ(static_cast<uint32_t>(12), cmd.params_shm_id);
908  EXPECT_EQ(static_cast<uint32_t>(13), cmd.params_shm_offset);
909  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
910}
911
912TEST_F(GLES2FormatTest, GetBufferParameteriv) {
913  cmds::GetBufferParameteriv& cmd = *GetBufferAs<cmds::GetBufferParameteriv>();
914  void* next_cmd = cmd.Set(&cmd,
915                           static_cast<GLenum>(11),
916                           static_cast<GLenum>(12),
917                           static_cast<uint32_t>(13),
918                           static_cast<uint32_t>(14));
919  EXPECT_EQ(static_cast<uint32_t>(cmds::GetBufferParameteriv::kCmdId),
920            cmd.header.command);
921  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
922  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
923  EXPECT_EQ(static_cast<GLenum>(12), cmd.pname);
924  EXPECT_EQ(static_cast<uint32_t>(13), cmd.params_shm_id);
925  EXPECT_EQ(static_cast<uint32_t>(14), cmd.params_shm_offset);
926  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
927}
928
929TEST_F(GLES2FormatTest, GetError) {
930  cmds::GetError& cmd = *GetBufferAs<cmds::GetError>();
931  void* next_cmd =
932      cmd.Set(&cmd, static_cast<uint32_t>(11), static_cast<uint32_t>(12));
933  EXPECT_EQ(static_cast<uint32_t>(cmds::GetError::kCmdId), cmd.header.command);
934  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
935  EXPECT_EQ(static_cast<uint32_t>(11), cmd.result_shm_id);
936  EXPECT_EQ(static_cast<uint32_t>(12), cmd.result_shm_offset);
937  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
938}
939
940TEST_F(GLES2FormatTest, GetFloatv) {
941  cmds::GetFloatv& cmd = *GetBufferAs<cmds::GetFloatv>();
942  void* next_cmd = cmd.Set(&cmd,
943                           static_cast<GLenum>(11),
944                           static_cast<uint32_t>(12),
945                           static_cast<uint32_t>(13));
946  EXPECT_EQ(static_cast<uint32_t>(cmds::GetFloatv::kCmdId), cmd.header.command);
947  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
948  EXPECT_EQ(static_cast<GLenum>(11), cmd.pname);
949  EXPECT_EQ(static_cast<uint32_t>(12), cmd.params_shm_id);
950  EXPECT_EQ(static_cast<uint32_t>(13), cmd.params_shm_offset);
951  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
952}
953
954TEST_F(GLES2FormatTest, GetFramebufferAttachmentParameteriv) {
955  cmds::GetFramebufferAttachmentParameteriv& cmd =
956      *GetBufferAs<cmds::GetFramebufferAttachmentParameteriv>();
957  void* next_cmd = cmd.Set(&cmd,
958                           static_cast<GLenum>(11),
959                           static_cast<GLenum>(12),
960                           static_cast<GLenum>(13),
961                           static_cast<uint32_t>(14),
962                           static_cast<uint32_t>(15));
963  EXPECT_EQ(
964      static_cast<uint32_t>(cmds::GetFramebufferAttachmentParameteriv::kCmdId),
965      cmd.header.command);
966  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
967  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
968  EXPECT_EQ(static_cast<GLenum>(12), cmd.attachment);
969  EXPECT_EQ(static_cast<GLenum>(13), cmd.pname);
970  EXPECT_EQ(static_cast<uint32_t>(14), cmd.params_shm_id);
971  EXPECT_EQ(static_cast<uint32_t>(15), cmd.params_shm_offset);
972  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
973}
974
975TEST_F(GLES2FormatTest, GetIntegerv) {
976  cmds::GetIntegerv& cmd = *GetBufferAs<cmds::GetIntegerv>();
977  void* next_cmd = cmd.Set(&cmd,
978                           static_cast<GLenum>(11),
979                           static_cast<uint32_t>(12),
980                           static_cast<uint32_t>(13));
981  EXPECT_EQ(static_cast<uint32_t>(cmds::GetIntegerv::kCmdId),
982            cmd.header.command);
983  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
984  EXPECT_EQ(static_cast<GLenum>(11), cmd.pname);
985  EXPECT_EQ(static_cast<uint32_t>(12), cmd.params_shm_id);
986  EXPECT_EQ(static_cast<uint32_t>(13), cmd.params_shm_offset);
987  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
988}
989
990TEST_F(GLES2FormatTest, GetProgramiv) {
991  cmds::GetProgramiv& cmd = *GetBufferAs<cmds::GetProgramiv>();
992  void* next_cmd = cmd.Set(&cmd,
993                           static_cast<GLuint>(11),
994                           static_cast<GLenum>(12),
995                           static_cast<uint32_t>(13),
996                           static_cast<uint32_t>(14));
997  EXPECT_EQ(static_cast<uint32_t>(cmds::GetProgramiv::kCmdId),
998            cmd.header.command);
999  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1000  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
1001  EXPECT_EQ(static_cast<GLenum>(12), cmd.pname);
1002  EXPECT_EQ(static_cast<uint32_t>(13), cmd.params_shm_id);
1003  EXPECT_EQ(static_cast<uint32_t>(14), cmd.params_shm_offset);
1004  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1005}
1006
1007TEST_F(GLES2FormatTest, GetProgramInfoLog) {
1008  cmds::GetProgramInfoLog& cmd = *GetBufferAs<cmds::GetProgramInfoLog>();
1009  void* next_cmd =
1010      cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<uint32_t>(12));
1011  EXPECT_EQ(static_cast<uint32_t>(cmds::GetProgramInfoLog::kCmdId),
1012            cmd.header.command);
1013  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1014  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
1015  EXPECT_EQ(static_cast<uint32_t>(12), cmd.bucket_id);
1016  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1017}
1018
1019TEST_F(GLES2FormatTest, GetRenderbufferParameteriv) {
1020  cmds::GetRenderbufferParameteriv& cmd =
1021      *GetBufferAs<cmds::GetRenderbufferParameteriv>();
1022  void* next_cmd = cmd.Set(&cmd,
1023                           static_cast<GLenum>(11),
1024                           static_cast<GLenum>(12),
1025                           static_cast<uint32_t>(13),
1026                           static_cast<uint32_t>(14));
1027  EXPECT_EQ(static_cast<uint32_t>(cmds::GetRenderbufferParameteriv::kCmdId),
1028            cmd.header.command);
1029  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1030  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
1031  EXPECT_EQ(static_cast<GLenum>(12), cmd.pname);
1032  EXPECT_EQ(static_cast<uint32_t>(13), cmd.params_shm_id);
1033  EXPECT_EQ(static_cast<uint32_t>(14), cmd.params_shm_offset);
1034  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1035}
1036
1037TEST_F(GLES2FormatTest, GetShaderiv) {
1038  cmds::GetShaderiv& cmd = *GetBufferAs<cmds::GetShaderiv>();
1039  void* next_cmd = cmd.Set(&cmd,
1040                           static_cast<GLuint>(11),
1041                           static_cast<GLenum>(12),
1042                           static_cast<uint32_t>(13),
1043                           static_cast<uint32_t>(14));
1044  EXPECT_EQ(static_cast<uint32_t>(cmds::GetShaderiv::kCmdId),
1045            cmd.header.command);
1046  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1047  EXPECT_EQ(static_cast<GLuint>(11), cmd.shader);
1048  EXPECT_EQ(static_cast<GLenum>(12), cmd.pname);
1049  EXPECT_EQ(static_cast<uint32_t>(13), cmd.params_shm_id);
1050  EXPECT_EQ(static_cast<uint32_t>(14), cmd.params_shm_offset);
1051  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1052}
1053
1054TEST_F(GLES2FormatTest, GetShaderInfoLog) {
1055  cmds::GetShaderInfoLog& cmd = *GetBufferAs<cmds::GetShaderInfoLog>();
1056  void* next_cmd =
1057      cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<uint32_t>(12));
1058  EXPECT_EQ(static_cast<uint32_t>(cmds::GetShaderInfoLog::kCmdId),
1059            cmd.header.command);
1060  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1061  EXPECT_EQ(static_cast<GLuint>(11), cmd.shader);
1062  EXPECT_EQ(static_cast<uint32_t>(12), cmd.bucket_id);
1063  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1064}
1065
1066TEST_F(GLES2FormatTest, GetShaderPrecisionFormat) {
1067  cmds::GetShaderPrecisionFormat& cmd =
1068      *GetBufferAs<cmds::GetShaderPrecisionFormat>();
1069  void* next_cmd = cmd.Set(&cmd,
1070                           static_cast<GLenum>(11),
1071                           static_cast<GLenum>(12),
1072                           static_cast<uint32_t>(13),
1073                           static_cast<uint32_t>(14));
1074  EXPECT_EQ(static_cast<uint32_t>(cmds::GetShaderPrecisionFormat::kCmdId),
1075            cmd.header.command);
1076  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1077  EXPECT_EQ(static_cast<GLenum>(11), cmd.shadertype);
1078  EXPECT_EQ(static_cast<GLenum>(12), cmd.precisiontype);
1079  EXPECT_EQ(static_cast<uint32_t>(13), cmd.result_shm_id);
1080  EXPECT_EQ(static_cast<uint32_t>(14), cmd.result_shm_offset);
1081  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1082}
1083
1084TEST_F(GLES2FormatTest, GetShaderSource) {
1085  cmds::GetShaderSource& cmd = *GetBufferAs<cmds::GetShaderSource>();
1086  void* next_cmd =
1087      cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<uint32_t>(12));
1088  EXPECT_EQ(static_cast<uint32_t>(cmds::GetShaderSource::kCmdId),
1089            cmd.header.command);
1090  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1091  EXPECT_EQ(static_cast<GLuint>(11), cmd.shader);
1092  EXPECT_EQ(static_cast<uint32_t>(12), cmd.bucket_id);
1093  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1094}
1095
1096TEST_F(GLES2FormatTest, GetString) {
1097  cmds::GetString& cmd = *GetBufferAs<cmds::GetString>();
1098  void* next_cmd =
1099      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<uint32_t>(12));
1100  EXPECT_EQ(static_cast<uint32_t>(cmds::GetString::kCmdId), cmd.header.command);
1101  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1102  EXPECT_EQ(static_cast<GLenum>(11), cmd.name);
1103  EXPECT_EQ(static_cast<uint32_t>(12), cmd.bucket_id);
1104  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1105}
1106
1107TEST_F(GLES2FormatTest, GetTexParameterfv) {
1108  cmds::GetTexParameterfv& cmd = *GetBufferAs<cmds::GetTexParameterfv>();
1109  void* next_cmd = cmd.Set(&cmd,
1110                           static_cast<GLenum>(11),
1111                           static_cast<GLenum>(12),
1112                           static_cast<uint32_t>(13),
1113                           static_cast<uint32_t>(14));
1114  EXPECT_EQ(static_cast<uint32_t>(cmds::GetTexParameterfv::kCmdId),
1115            cmd.header.command);
1116  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1117  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
1118  EXPECT_EQ(static_cast<GLenum>(12), cmd.pname);
1119  EXPECT_EQ(static_cast<uint32_t>(13), cmd.params_shm_id);
1120  EXPECT_EQ(static_cast<uint32_t>(14), cmd.params_shm_offset);
1121  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1122}
1123
1124TEST_F(GLES2FormatTest, GetTexParameteriv) {
1125  cmds::GetTexParameteriv& cmd = *GetBufferAs<cmds::GetTexParameteriv>();
1126  void* next_cmd = cmd.Set(&cmd,
1127                           static_cast<GLenum>(11),
1128                           static_cast<GLenum>(12),
1129                           static_cast<uint32_t>(13),
1130                           static_cast<uint32_t>(14));
1131  EXPECT_EQ(static_cast<uint32_t>(cmds::GetTexParameteriv::kCmdId),
1132            cmd.header.command);
1133  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1134  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
1135  EXPECT_EQ(static_cast<GLenum>(12), cmd.pname);
1136  EXPECT_EQ(static_cast<uint32_t>(13), cmd.params_shm_id);
1137  EXPECT_EQ(static_cast<uint32_t>(14), cmd.params_shm_offset);
1138  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1139}
1140
1141TEST_F(GLES2FormatTest, GetUniformfv) {
1142  cmds::GetUniformfv& cmd = *GetBufferAs<cmds::GetUniformfv>();
1143  void* next_cmd = cmd.Set(&cmd,
1144                           static_cast<GLuint>(11),
1145                           static_cast<GLint>(12),
1146                           static_cast<uint32_t>(13),
1147                           static_cast<uint32_t>(14));
1148  EXPECT_EQ(static_cast<uint32_t>(cmds::GetUniformfv::kCmdId),
1149            cmd.header.command);
1150  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1151  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
1152  EXPECT_EQ(static_cast<GLint>(12), cmd.location);
1153  EXPECT_EQ(static_cast<uint32_t>(13), cmd.params_shm_id);
1154  EXPECT_EQ(static_cast<uint32_t>(14), cmd.params_shm_offset);
1155  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1156}
1157
1158TEST_F(GLES2FormatTest, GetUniformiv) {
1159  cmds::GetUniformiv& cmd = *GetBufferAs<cmds::GetUniformiv>();
1160  void* next_cmd = cmd.Set(&cmd,
1161                           static_cast<GLuint>(11),
1162                           static_cast<GLint>(12),
1163                           static_cast<uint32_t>(13),
1164                           static_cast<uint32_t>(14));
1165  EXPECT_EQ(static_cast<uint32_t>(cmds::GetUniformiv::kCmdId),
1166            cmd.header.command);
1167  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1168  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
1169  EXPECT_EQ(static_cast<GLint>(12), cmd.location);
1170  EXPECT_EQ(static_cast<uint32_t>(13), cmd.params_shm_id);
1171  EXPECT_EQ(static_cast<uint32_t>(14), cmd.params_shm_offset);
1172  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1173}
1174
1175TEST_F(GLES2FormatTest, GetUniformLocation) {
1176  cmds::GetUniformLocation& cmd = *GetBufferAs<cmds::GetUniformLocation>();
1177  void* next_cmd = cmd.Set(&cmd,
1178                           static_cast<GLuint>(11),
1179                           static_cast<uint32_t>(12),
1180                           static_cast<uint32_t>(13),
1181                           static_cast<uint32_t>(14));
1182  EXPECT_EQ(static_cast<uint32_t>(cmds::GetUniformLocation::kCmdId),
1183            cmd.header.command);
1184  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1185  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
1186  EXPECT_EQ(static_cast<uint32_t>(12), cmd.name_bucket_id);
1187  EXPECT_EQ(static_cast<uint32_t>(13), cmd.location_shm_id);
1188  EXPECT_EQ(static_cast<uint32_t>(14), cmd.location_shm_offset);
1189  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1190}
1191
1192TEST_F(GLES2FormatTest, GetVertexAttribfv) {
1193  cmds::GetVertexAttribfv& cmd = *GetBufferAs<cmds::GetVertexAttribfv>();
1194  void* next_cmd = cmd.Set(&cmd,
1195                           static_cast<GLuint>(11),
1196                           static_cast<GLenum>(12),
1197                           static_cast<uint32_t>(13),
1198                           static_cast<uint32_t>(14));
1199  EXPECT_EQ(static_cast<uint32_t>(cmds::GetVertexAttribfv::kCmdId),
1200            cmd.header.command);
1201  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1202  EXPECT_EQ(static_cast<GLuint>(11), cmd.index);
1203  EXPECT_EQ(static_cast<GLenum>(12), cmd.pname);
1204  EXPECT_EQ(static_cast<uint32_t>(13), cmd.params_shm_id);
1205  EXPECT_EQ(static_cast<uint32_t>(14), cmd.params_shm_offset);
1206  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1207}
1208
1209TEST_F(GLES2FormatTest, GetVertexAttribiv) {
1210  cmds::GetVertexAttribiv& cmd = *GetBufferAs<cmds::GetVertexAttribiv>();
1211  void* next_cmd = cmd.Set(&cmd,
1212                           static_cast<GLuint>(11),
1213                           static_cast<GLenum>(12),
1214                           static_cast<uint32_t>(13),
1215                           static_cast<uint32_t>(14));
1216  EXPECT_EQ(static_cast<uint32_t>(cmds::GetVertexAttribiv::kCmdId),
1217            cmd.header.command);
1218  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1219  EXPECT_EQ(static_cast<GLuint>(11), cmd.index);
1220  EXPECT_EQ(static_cast<GLenum>(12), cmd.pname);
1221  EXPECT_EQ(static_cast<uint32_t>(13), cmd.params_shm_id);
1222  EXPECT_EQ(static_cast<uint32_t>(14), cmd.params_shm_offset);
1223  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1224}
1225
1226TEST_F(GLES2FormatTest, GetVertexAttribPointerv) {
1227  cmds::GetVertexAttribPointerv& cmd =
1228      *GetBufferAs<cmds::GetVertexAttribPointerv>();
1229  void* next_cmd = cmd.Set(&cmd,
1230                           static_cast<GLuint>(11),
1231                           static_cast<GLenum>(12),
1232                           static_cast<uint32_t>(13),
1233                           static_cast<uint32_t>(14));
1234  EXPECT_EQ(static_cast<uint32_t>(cmds::GetVertexAttribPointerv::kCmdId),
1235            cmd.header.command);
1236  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1237  EXPECT_EQ(static_cast<GLuint>(11), cmd.index);
1238  EXPECT_EQ(static_cast<GLenum>(12), cmd.pname);
1239  EXPECT_EQ(static_cast<uint32_t>(13), cmd.pointer_shm_id);
1240  EXPECT_EQ(static_cast<uint32_t>(14), cmd.pointer_shm_offset);
1241  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1242}
1243
1244TEST_F(GLES2FormatTest, Hint) {
1245  cmds::Hint& cmd = *GetBufferAs<cmds::Hint>();
1246  void* next_cmd =
1247      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLenum>(12));
1248  EXPECT_EQ(static_cast<uint32_t>(cmds::Hint::kCmdId), cmd.header.command);
1249  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1250  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
1251  EXPECT_EQ(static_cast<GLenum>(12), cmd.mode);
1252  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1253}
1254
1255TEST_F(GLES2FormatTest, IsBuffer) {
1256  cmds::IsBuffer& cmd = *GetBufferAs<cmds::IsBuffer>();
1257  void* next_cmd = cmd.Set(&cmd,
1258                           static_cast<GLuint>(11),
1259                           static_cast<uint32_t>(12),
1260                           static_cast<uint32_t>(13));
1261  EXPECT_EQ(static_cast<uint32_t>(cmds::IsBuffer::kCmdId), cmd.header.command);
1262  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1263  EXPECT_EQ(static_cast<GLuint>(11), cmd.buffer);
1264  EXPECT_EQ(static_cast<uint32_t>(12), cmd.result_shm_id);
1265  EXPECT_EQ(static_cast<uint32_t>(13), cmd.result_shm_offset);
1266  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1267}
1268
1269TEST_F(GLES2FormatTest, IsEnabled) {
1270  cmds::IsEnabled& cmd = *GetBufferAs<cmds::IsEnabled>();
1271  void* next_cmd = cmd.Set(&cmd,
1272                           static_cast<GLenum>(11),
1273                           static_cast<uint32_t>(12),
1274                           static_cast<uint32_t>(13));
1275  EXPECT_EQ(static_cast<uint32_t>(cmds::IsEnabled::kCmdId), cmd.header.command);
1276  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1277  EXPECT_EQ(static_cast<GLenum>(11), cmd.cap);
1278  EXPECT_EQ(static_cast<uint32_t>(12), cmd.result_shm_id);
1279  EXPECT_EQ(static_cast<uint32_t>(13), cmd.result_shm_offset);
1280  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1281}
1282
1283TEST_F(GLES2FormatTest, IsFramebuffer) {
1284  cmds::IsFramebuffer& cmd = *GetBufferAs<cmds::IsFramebuffer>();
1285  void* next_cmd = cmd.Set(&cmd,
1286                           static_cast<GLuint>(11),
1287                           static_cast<uint32_t>(12),
1288                           static_cast<uint32_t>(13));
1289  EXPECT_EQ(static_cast<uint32_t>(cmds::IsFramebuffer::kCmdId),
1290            cmd.header.command);
1291  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1292  EXPECT_EQ(static_cast<GLuint>(11), cmd.framebuffer);
1293  EXPECT_EQ(static_cast<uint32_t>(12), cmd.result_shm_id);
1294  EXPECT_EQ(static_cast<uint32_t>(13), cmd.result_shm_offset);
1295  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1296}
1297
1298TEST_F(GLES2FormatTest, IsProgram) {
1299  cmds::IsProgram& cmd = *GetBufferAs<cmds::IsProgram>();
1300  void* next_cmd = cmd.Set(&cmd,
1301                           static_cast<GLuint>(11),
1302                           static_cast<uint32_t>(12),
1303                           static_cast<uint32_t>(13));
1304  EXPECT_EQ(static_cast<uint32_t>(cmds::IsProgram::kCmdId), cmd.header.command);
1305  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1306  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
1307  EXPECT_EQ(static_cast<uint32_t>(12), cmd.result_shm_id);
1308  EXPECT_EQ(static_cast<uint32_t>(13), cmd.result_shm_offset);
1309  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1310}
1311
1312TEST_F(GLES2FormatTest, IsRenderbuffer) {
1313  cmds::IsRenderbuffer& cmd = *GetBufferAs<cmds::IsRenderbuffer>();
1314  void* next_cmd = cmd.Set(&cmd,
1315                           static_cast<GLuint>(11),
1316                           static_cast<uint32_t>(12),
1317                           static_cast<uint32_t>(13));
1318  EXPECT_EQ(static_cast<uint32_t>(cmds::IsRenderbuffer::kCmdId),
1319            cmd.header.command);
1320  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1321  EXPECT_EQ(static_cast<GLuint>(11), cmd.renderbuffer);
1322  EXPECT_EQ(static_cast<uint32_t>(12), cmd.result_shm_id);
1323  EXPECT_EQ(static_cast<uint32_t>(13), cmd.result_shm_offset);
1324  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1325}
1326
1327TEST_F(GLES2FormatTest, IsShader) {
1328  cmds::IsShader& cmd = *GetBufferAs<cmds::IsShader>();
1329  void* next_cmd = cmd.Set(&cmd,
1330                           static_cast<GLuint>(11),
1331                           static_cast<uint32_t>(12),
1332                           static_cast<uint32_t>(13));
1333  EXPECT_EQ(static_cast<uint32_t>(cmds::IsShader::kCmdId), cmd.header.command);
1334  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1335  EXPECT_EQ(static_cast<GLuint>(11), cmd.shader);
1336  EXPECT_EQ(static_cast<uint32_t>(12), cmd.result_shm_id);
1337  EXPECT_EQ(static_cast<uint32_t>(13), cmd.result_shm_offset);
1338  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1339}
1340
1341TEST_F(GLES2FormatTest, IsTexture) {
1342  cmds::IsTexture& cmd = *GetBufferAs<cmds::IsTexture>();
1343  void* next_cmd = cmd.Set(&cmd,
1344                           static_cast<GLuint>(11),
1345                           static_cast<uint32_t>(12),
1346                           static_cast<uint32_t>(13));
1347  EXPECT_EQ(static_cast<uint32_t>(cmds::IsTexture::kCmdId), cmd.header.command);
1348  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1349  EXPECT_EQ(static_cast<GLuint>(11), cmd.texture);
1350  EXPECT_EQ(static_cast<uint32_t>(12), cmd.result_shm_id);
1351  EXPECT_EQ(static_cast<uint32_t>(13), cmd.result_shm_offset);
1352  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1353}
1354
1355TEST_F(GLES2FormatTest, LineWidth) {
1356  cmds::LineWidth& cmd = *GetBufferAs<cmds::LineWidth>();
1357  void* next_cmd = cmd.Set(&cmd, static_cast<GLfloat>(11));
1358  EXPECT_EQ(static_cast<uint32_t>(cmds::LineWidth::kCmdId), cmd.header.command);
1359  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1360  EXPECT_EQ(static_cast<GLfloat>(11), cmd.width);
1361  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1362}
1363
1364TEST_F(GLES2FormatTest, LinkProgram) {
1365  cmds::LinkProgram& cmd = *GetBufferAs<cmds::LinkProgram>();
1366  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
1367  EXPECT_EQ(static_cast<uint32_t>(cmds::LinkProgram::kCmdId),
1368            cmd.header.command);
1369  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1370  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
1371  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1372}
1373
1374TEST_F(GLES2FormatTest, PixelStorei) {
1375  cmds::PixelStorei& cmd = *GetBufferAs<cmds::PixelStorei>();
1376  void* next_cmd =
1377      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLint>(12));
1378  EXPECT_EQ(static_cast<uint32_t>(cmds::PixelStorei::kCmdId),
1379            cmd.header.command);
1380  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1381  EXPECT_EQ(static_cast<GLenum>(11), cmd.pname);
1382  EXPECT_EQ(static_cast<GLint>(12), cmd.param);
1383  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1384}
1385
1386TEST_F(GLES2FormatTest, PolygonOffset) {
1387  cmds::PolygonOffset& cmd = *GetBufferAs<cmds::PolygonOffset>();
1388  void* next_cmd =
1389      cmd.Set(&cmd, static_cast<GLfloat>(11), static_cast<GLfloat>(12));
1390  EXPECT_EQ(static_cast<uint32_t>(cmds::PolygonOffset::kCmdId),
1391            cmd.header.command);
1392  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1393  EXPECT_EQ(static_cast<GLfloat>(11), cmd.factor);
1394  EXPECT_EQ(static_cast<GLfloat>(12), cmd.units);
1395  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1396}
1397
1398TEST_F(GLES2FormatTest, ReadPixels) {
1399  cmds::ReadPixels& cmd = *GetBufferAs<cmds::ReadPixels>();
1400  void* next_cmd = cmd.Set(&cmd,
1401                           static_cast<GLint>(11),
1402                           static_cast<GLint>(12),
1403                           static_cast<GLsizei>(13),
1404                           static_cast<GLsizei>(14),
1405                           static_cast<GLenum>(15),
1406                           static_cast<GLenum>(16),
1407                           static_cast<uint32_t>(17),
1408                           static_cast<uint32_t>(18),
1409                           static_cast<uint32_t>(19),
1410                           static_cast<uint32_t>(20),
1411                           static_cast<GLboolean>(21));
1412  EXPECT_EQ(static_cast<uint32_t>(cmds::ReadPixels::kCmdId),
1413            cmd.header.command);
1414  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1415  EXPECT_EQ(static_cast<GLint>(11), cmd.x);
1416  EXPECT_EQ(static_cast<GLint>(12), cmd.y);
1417  EXPECT_EQ(static_cast<GLsizei>(13), cmd.width);
1418  EXPECT_EQ(static_cast<GLsizei>(14), cmd.height);
1419  EXPECT_EQ(static_cast<GLenum>(15), cmd.format);
1420  EXPECT_EQ(static_cast<GLenum>(16), cmd.type);
1421  EXPECT_EQ(static_cast<uint32_t>(17), cmd.pixels_shm_id);
1422  EXPECT_EQ(static_cast<uint32_t>(18), cmd.pixels_shm_offset);
1423  EXPECT_EQ(static_cast<uint32_t>(19), cmd.result_shm_id);
1424  EXPECT_EQ(static_cast<uint32_t>(20), cmd.result_shm_offset);
1425  EXPECT_EQ(static_cast<GLboolean>(21), cmd.async);
1426  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1427}
1428
1429TEST_F(GLES2FormatTest, ReleaseShaderCompiler) {
1430  cmds::ReleaseShaderCompiler& cmd =
1431      *GetBufferAs<cmds::ReleaseShaderCompiler>();
1432  void* next_cmd = cmd.Set(&cmd);
1433  EXPECT_EQ(static_cast<uint32_t>(cmds::ReleaseShaderCompiler::kCmdId),
1434            cmd.header.command);
1435  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1436  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1437}
1438
1439TEST_F(GLES2FormatTest, RenderbufferStorage) {
1440  cmds::RenderbufferStorage& cmd = *GetBufferAs<cmds::RenderbufferStorage>();
1441  void* next_cmd = cmd.Set(&cmd,
1442                           static_cast<GLenum>(11),
1443                           static_cast<GLenum>(12),
1444                           static_cast<GLsizei>(13),
1445                           static_cast<GLsizei>(14));
1446  EXPECT_EQ(static_cast<uint32_t>(cmds::RenderbufferStorage::kCmdId),
1447            cmd.header.command);
1448  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1449  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
1450  EXPECT_EQ(static_cast<GLenum>(12), cmd.internalformat);
1451  EXPECT_EQ(static_cast<GLsizei>(13), cmd.width);
1452  EXPECT_EQ(static_cast<GLsizei>(14), cmd.height);
1453  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1454}
1455
1456TEST_F(GLES2FormatTest, SampleCoverage) {
1457  cmds::SampleCoverage& cmd = *GetBufferAs<cmds::SampleCoverage>();
1458  void* next_cmd =
1459      cmd.Set(&cmd, static_cast<GLclampf>(11), static_cast<GLboolean>(12));
1460  EXPECT_EQ(static_cast<uint32_t>(cmds::SampleCoverage::kCmdId),
1461            cmd.header.command);
1462  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1463  EXPECT_EQ(static_cast<GLclampf>(11), cmd.value);
1464  EXPECT_EQ(static_cast<GLboolean>(12), cmd.invert);
1465  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1466}
1467
1468TEST_F(GLES2FormatTest, Scissor) {
1469  cmds::Scissor& cmd = *GetBufferAs<cmds::Scissor>();
1470  void* next_cmd = cmd.Set(&cmd,
1471                           static_cast<GLint>(11),
1472                           static_cast<GLint>(12),
1473                           static_cast<GLsizei>(13),
1474                           static_cast<GLsizei>(14));
1475  EXPECT_EQ(static_cast<uint32_t>(cmds::Scissor::kCmdId), cmd.header.command);
1476  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1477  EXPECT_EQ(static_cast<GLint>(11), cmd.x);
1478  EXPECT_EQ(static_cast<GLint>(12), cmd.y);
1479  EXPECT_EQ(static_cast<GLsizei>(13), cmd.width);
1480  EXPECT_EQ(static_cast<GLsizei>(14), cmd.height);
1481  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1482}
1483
1484TEST_F(GLES2FormatTest, ShaderBinary) {
1485  cmds::ShaderBinary& cmd = *GetBufferAs<cmds::ShaderBinary>();
1486  void* next_cmd = cmd.Set(&cmd,
1487                           static_cast<GLsizei>(11),
1488                           static_cast<uint32_t>(12),
1489                           static_cast<uint32_t>(13),
1490                           static_cast<GLenum>(14),
1491                           static_cast<uint32_t>(15),
1492                           static_cast<uint32_t>(16),
1493                           static_cast<GLsizei>(17));
1494  EXPECT_EQ(static_cast<uint32_t>(cmds::ShaderBinary::kCmdId),
1495            cmd.header.command);
1496  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1497  EXPECT_EQ(static_cast<GLsizei>(11), cmd.n);
1498  EXPECT_EQ(static_cast<uint32_t>(12), cmd.shaders_shm_id);
1499  EXPECT_EQ(static_cast<uint32_t>(13), cmd.shaders_shm_offset);
1500  EXPECT_EQ(static_cast<GLenum>(14), cmd.binaryformat);
1501  EXPECT_EQ(static_cast<uint32_t>(15), cmd.binary_shm_id);
1502  EXPECT_EQ(static_cast<uint32_t>(16), cmd.binary_shm_offset);
1503  EXPECT_EQ(static_cast<GLsizei>(17), cmd.length);
1504  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1505}
1506
1507TEST_F(GLES2FormatTest, ShaderSourceBucket) {
1508  cmds::ShaderSourceBucket& cmd = *GetBufferAs<cmds::ShaderSourceBucket>();
1509  void* next_cmd =
1510      cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<uint32_t>(12));
1511  EXPECT_EQ(static_cast<uint32_t>(cmds::ShaderSourceBucket::kCmdId),
1512            cmd.header.command);
1513  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1514  EXPECT_EQ(static_cast<GLuint>(11), cmd.shader);
1515  EXPECT_EQ(static_cast<uint32_t>(12), cmd.data_bucket_id);
1516  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1517}
1518
1519TEST_F(GLES2FormatTest, StencilFunc) {
1520  cmds::StencilFunc& cmd = *GetBufferAs<cmds::StencilFunc>();
1521  void* next_cmd = cmd.Set(&cmd,
1522                           static_cast<GLenum>(11),
1523                           static_cast<GLint>(12),
1524                           static_cast<GLuint>(13));
1525  EXPECT_EQ(static_cast<uint32_t>(cmds::StencilFunc::kCmdId),
1526            cmd.header.command);
1527  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1528  EXPECT_EQ(static_cast<GLenum>(11), cmd.func);
1529  EXPECT_EQ(static_cast<GLint>(12), cmd.ref);
1530  EXPECT_EQ(static_cast<GLuint>(13), cmd.mask);
1531  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1532}
1533
1534TEST_F(GLES2FormatTest, StencilFuncSeparate) {
1535  cmds::StencilFuncSeparate& cmd = *GetBufferAs<cmds::StencilFuncSeparate>();
1536  void* next_cmd = cmd.Set(&cmd,
1537                           static_cast<GLenum>(11),
1538                           static_cast<GLenum>(12),
1539                           static_cast<GLint>(13),
1540                           static_cast<GLuint>(14));
1541  EXPECT_EQ(static_cast<uint32_t>(cmds::StencilFuncSeparate::kCmdId),
1542            cmd.header.command);
1543  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1544  EXPECT_EQ(static_cast<GLenum>(11), cmd.face);
1545  EXPECT_EQ(static_cast<GLenum>(12), cmd.func);
1546  EXPECT_EQ(static_cast<GLint>(13), cmd.ref);
1547  EXPECT_EQ(static_cast<GLuint>(14), cmd.mask);
1548  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1549}
1550
1551TEST_F(GLES2FormatTest, StencilMask) {
1552  cmds::StencilMask& cmd = *GetBufferAs<cmds::StencilMask>();
1553  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
1554  EXPECT_EQ(static_cast<uint32_t>(cmds::StencilMask::kCmdId),
1555            cmd.header.command);
1556  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1557  EXPECT_EQ(static_cast<GLuint>(11), cmd.mask);
1558  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1559}
1560
1561TEST_F(GLES2FormatTest, StencilMaskSeparate) {
1562  cmds::StencilMaskSeparate& cmd = *GetBufferAs<cmds::StencilMaskSeparate>();
1563  void* next_cmd =
1564      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLuint>(12));
1565  EXPECT_EQ(static_cast<uint32_t>(cmds::StencilMaskSeparate::kCmdId),
1566            cmd.header.command);
1567  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1568  EXPECT_EQ(static_cast<GLenum>(11), cmd.face);
1569  EXPECT_EQ(static_cast<GLuint>(12), cmd.mask);
1570  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1571}
1572
1573TEST_F(GLES2FormatTest, StencilOp) {
1574  cmds::StencilOp& cmd = *GetBufferAs<cmds::StencilOp>();
1575  void* next_cmd = cmd.Set(&cmd,
1576                           static_cast<GLenum>(11),
1577                           static_cast<GLenum>(12),
1578                           static_cast<GLenum>(13));
1579  EXPECT_EQ(static_cast<uint32_t>(cmds::StencilOp::kCmdId), cmd.header.command);
1580  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1581  EXPECT_EQ(static_cast<GLenum>(11), cmd.fail);
1582  EXPECT_EQ(static_cast<GLenum>(12), cmd.zfail);
1583  EXPECT_EQ(static_cast<GLenum>(13), cmd.zpass);
1584  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1585}
1586
1587TEST_F(GLES2FormatTest, StencilOpSeparate) {
1588  cmds::StencilOpSeparate& cmd = *GetBufferAs<cmds::StencilOpSeparate>();
1589  void* next_cmd = cmd.Set(&cmd,
1590                           static_cast<GLenum>(11),
1591                           static_cast<GLenum>(12),
1592                           static_cast<GLenum>(13),
1593                           static_cast<GLenum>(14));
1594  EXPECT_EQ(static_cast<uint32_t>(cmds::StencilOpSeparate::kCmdId),
1595            cmd.header.command);
1596  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1597  EXPECT_EQ(static_cast<GLenum>(11), cmd.face);
1598  EXPECT_EQ(static_cast<GLenum>(12), cmd.fail);
1599  EXPECT_EQ(static_cast<GLenum>(13), cmd.zfail);
1600  EXPECT_EQ(static_cast<GLenum>(14), cmd.zpass);
1601  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1602}
1603
1604TEST_F(GLES2FormatTest, TexImage2D) {
1605  cmds::TexImage2D& cmd = *GetBufferAs<cmds::TexImage2D>();
1606  void* next_cmd = cmd.Set(&cmd,
1607                           static_cast<GLenum>(11),
1608                           static_cast<GLint>(12),
1609                           static_cast<GLint>(13),
1610                           static_cast<GLsizei>(14),
1611                           static_cast<GLsizei>(15),
1612                           static_cast<GLenum>(16),
1613                           static_cast<GLenum>(17),
1614                           static_cast<uint32_t>(18),
1615                           static_cast<uint32_t>(19));
1616  EXPECT_EQ(static_cast<uint32_t>(cmds::TexImage2D::kCmdId),
1617            cmd.header.command);
1618  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1619  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
1620  EXPECT_EQ(static_cast<GLint>(12), cmd.level);
1621  EXPECT_EQ(static_cast<GLint>(13), cmd.internalformat);
1622  EXPECT_EQ(static_cast<GLsizei>(14), cmd.width);
1623  EXPECT_EQ(static_cast<GLsizei>(15), cmd.height);
1624  EXPECT_EQ(static_cast<GLenum>(16), cmd.format);
1625  EXPECT_EQ(static_cast<GLenum>(17), cmd.type);
1626  EXPECT_EQ(static_cast<uint32_t>(18), cmd.pixels_shm_id);
1627  EXPECT_EQ(static_cast<uint32_t>(19), cmd.pixels_shm_offset);
1628  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1629}
1630
1631TEST_F(GLES2FormatTest, TexParameterf) {
1632  cmds::TexParameterf& cmd = *GetBufferAs<cmds::TexParameterf>();
1633  void* next_cmd = cmd.Set(&cmd,
1634                           static_cast<GLenum>(11),
1635                           static_cast<GLenum>(12),
1636                           static_cast<GLfloat>(13));
1637  EXPECT_EQ(static_cast<uint32_t>(cmds::TexParameterf::kCmdId),
1638            cmd.header.command);
1639  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1640  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
1641  EXPECT_EQ(static_cast<GLenum>(12), cmd.pname);
1642  EXPECT_EQ(static_cast<GLfloat>(13), cmd.param);
1643  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1644}
1645
1646TEST_F(GLES2FormatTest, TexParameterfvImmediate) {
1647  const int kSomeBaseValueToTestWith = 51;
1648  static GLfloat data[] = {
1649      static_cast<GLfloat>(kSomeBaseValueToTestWith + 0),
1650  };
1651  cmds::TexParameterfvImmediate& cmd =
1652      *GetBufferAs<cmds::TexParameterfvImmediate>();
1653  void* next_cmd =
1654      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLenum>(12), data);
1655  EXPECT_EQ(static_cast<uint32_t>(cmds::TexParameterfvImmediate::kCmdId),
1656            cmd.header.command);
1657  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
1658            cmd.header.size * 4u);
1659  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
1660  EXPECT_EQ(static_cast<GLenum>(12), cmd.pname);
1661  CheckBytesWrittenMatchesExpectedSize(
1662      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
1663  // TODO(gman): Check that data was inserted;
1664}
1665
1666TEST_F(GLES2FormatTest, TexParameteri) {
1667  cmds::TexParameteri& cmd = *GetBufferAs<cmds::TexParameteri>();
1668  void* next_cmd = cmd.Set(&cmd,
1669                           static_cast<GLenum>(11),
1670                           static_cast<GLenum>(12),
1671                           static_cast<GLint>(13));
1672  EXPECT_EQ(static_cast<uint32_t>(cmds::TexParameteri::kCmdId),
1673            cmd.header.command);
1674  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1675  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
1676  EXPECT_EQ(static_cast<GLenum>(12), cmd.pname);
1677  EXPECT_EQ(static_cast<GLint>(13), cmd.param);
1678  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1679}
1680
1681TEST_F(GLES2FormatTest, TexParameterivImmediate) {
1682  const int kSomeBaseValueToTestWith = 51;
1683  static GLint data[] = {
1684      static_cast<GLint>(kSomeBaseValueToTestWith + 0),
1685  };
1686  cmds::TexParameterivImmediate& cmd =
1687      *GetBufferAs<cmds::TexParameterivImmediate>();
1688  void* next_cmd =
1689      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLenum>(12), data);
1690  EXPECT_EQ(static_cast<uint32_t>(cmds::TexParameterivImmediate::kCmdId),
1691            cmd.header.command);
1692  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
1693            cmd.header.size * 4u);
1694  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
1695  EXPECT_EQ(static_cast<GLenum>(12), cmd.pname);
1696  CheckBytesWrittenMatchesExpectedSize(
1697      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
1698  // TODO(gman): Check that data was inserted;
1699}
1700
1701TEST_F(GLES2FormatTest, TexSubImage2D) {
1702  cmds::TexSubImage2D& cmd = *GetBufferAs<cmds::TexSubImage2D>();
1703  void* next_cmd = cmd.Set(&cmd,
1704                           static_cast<GLenum>(11),
1705                           static_cast<GLint>(12),
1706                           static_cast<GLint>(13),
1707                           static_cast<GLint>(14),
1708                           static_cast<GLsizei>(15),
1709                           static_cast<GLsizei>(16),
1710                           static_cast<GLenum>(17),
1711                           static_cast<GLenum>(18),
1712                           static_cast<uint32_t>(19),
1713                           static_cast<uint32_t>(20),
1714                           static_cast<GLboolean>(21));
1715  EXPECT_EQ(static_cast<uint32_t>(cmds::TexSubImage2D::kCmdId),
1716            cmd.header.command);
1717  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1718  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
1719  EXPECT_EQ(static_cast<GLint>(12), cmd.level);
1720  EXPECT_EQ(static_cast<GLint>(13), cmd.xoffset);
1721  EXPECT_EQ(static_cast<GLint>(14), cmd.yoffset);
1722  EXPECT_EQ(static_cast<GLsizei>(15), cmd.width);
1723  EXPECT_EQ(static_cast<GLsizei>(16), cmd.height);
1724  EXPECT_EQ(static_cast<GLenum>(17), cmd.format);
1725  EXPECT_EQ(static_cast<GLenum>(18), cmd.type);
1726  EXPECT_EQ(static_cast<uint32_t>(19), cmd.pixels_shm_id);
1727  EXPECT_EQ(static_cast<uint32_t>(20), cmd.pixels_shm_offset);
1728  EXPECT_EQ(static_cast<GLboolean>(21), cmd.internal);
1729  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1730}
1731
1732TEST_F(GLES2FormatTest, Uniform1f) {
1733  cmds::Uniform1f& cmd = *GetBufferAs<cmds::Uniform1f>();
1734  void* next_cmd =
1735      cmd.Set(&cmd, static_cast<GLint>(11), static_cast<GLfloat>(12));
1736  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform1f::kCmdId), cmd.header.command);
1737  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1738  EXPECT_EQ(static_cast<GLint>(11), cmd.location);
1739  EXPECT_EQ(static_cast<GLfloat>(12), cmd.x);
1740  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1741}
1742
1743TEST_F(GLES2FormatTest, Uniform1fvImmediate) {
1744  const int kSomeBaseValueToTestWith = 51;
1745  static GLfloat data[] = {
1746      static_cast<GLfloat>(kSomeBaseValueToTestWith + 0),
1747      static_cast<GLfloat>(kSomeBaseValueToTestWith + 1),
1748  };
1749  cmds::Uniform1fvImmediate& cmd = *GetBufferAs<cmds::Uniform1fvImmediate>();
1750  const GLsizei kNumElements = 2;
1751  const size_t kExpectedCmdSize =
1752      sizeof(cmd) + kNumElements * sizeof(GLfloat) * 1;
1753  void* next_cmd =
1754      cmd.Set(&cmd, static_cast<GLint>(1), static_cast<GLsizei>(2), data);
1755  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform1fvImmediate::kCmdId),
1756            cmd.header.command);
1757  EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);
1758  EXPECT_EQ(static_cast<GLint>(1), cmd.location);
1759  EXPECT_EQ(static_cast<GLsizei>(2), cmd.count);
1760  CheckBytesWrittenMatchesExpectedSize(
1761      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
1762  // TODO(gman): Check that data was inserted;
1763}
1764
1765TEST_F(GLES2FormatTest, Uniform1i) {
1766  cmds::Uniform1i& cmd = *GetBufferAs<cmds::Uniform1i>();
1767  void* next_cmd =
1768      cmd.Set(&cmd, static_cast<GLint>(11), static_cast<GLint>(12));
1769  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform1i::kCmdId), cmd.header.command);
1770  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1771  EXPECT_EQ(static_cast<GLint>(11), cmd.location);
1772  EXPECT_EQ(static_cast<GLint>(12), cmd.x);
1773  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1774}
1775
1776TEST_F(GLES2FormatTest, Uniform1ivImmediate) {
1777  const int kSomeBaseValueToTestWith = 51;
1778  static GLint data[] = {
1779      static_cast<GLint>(kSomeBaseValueToTestWith + 0),
1780      static_cast<GLint>(kSomeBaseValueToTestWith + 1),
1781  };
1782  cmds::Uniform1ivImmediate& cmd = *GetBufferAs<cmds::Uniform1ivImmediate>();
1783  const GLsizei kNumElements = 2;
1784  const size_t kExpectedCmdSize =
1785      sizeof(cmd) + kNumElements * sizeof(GLint) * 1;
1786  void* next_cmd =
1787      cmd.Set(&cmd, static_cast<GLint>(1), static_cast<GLsizei>(2), data);
1788  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform1ivImmediate::kCmdId),
1789            cmd.header.command);
1790  EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);
1791  EXPECT_EQ(static_cast<GLint>(1), cmd.location);
1792  EXPECT_EQ(static_cast<GLsizei>(2), cmd.count);
1793  CheckBytesWrittenMatchesExpectedSize(
1794      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
1795  // TODO(gman): Check that data was inserted;
1796}
1797
1798TEST_F(GLES2FormatTest, Uniform2f) {
1799  cmds::Uniform2f& cmd = *GetBufferAs<cmds::Uniform2f>();
1800  void* next_cmd = cmd.Set(&cmd,
1801                           static_cast<GLint>(11),
1802                           static_cast<GLfloat>(12),
1803                           static_cast<GLfloat>(13));
1804  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform2f::kCmdId), cmd.header.command);
1805  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1806  EXPECT_EQ(static_cast<GLint>(11), cmd.location);
1807  EXPECT_EQ(static_cast<GLfloat>(12), cmd.x);
1808  EXPECT_EQ(static_cast<GLfloat>(13), cmd.y);
1809  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1810}
1811
1812TEST_F(GLES2FormatTest, Uniform2fvImmediate) {
1813  const int kSomeBaseValueToTestWith = 51;
1814  static GLfloat data[] = {
1815      static_cast<GLfloat>(kSomeBaseValueToTestWith + 0),
1816      static_cast<GLfloat>(kSomeBaseValueToTestWith + 1),
1817      static_cast<GLfloat>(kSomeBaseValueToTestWith + 2),
1818      static_cast<GLfloat>(kSomeBaseValueToTestWith + 3),
1819  };
1820  cmds::Uniform2fvImmediate& cmd = *GetBufferAs<cmds::Uniform2fvImmediate>();
1821  const GLsizei kNumElements = 2;
1822  const size_t kExpectedCmdSize =
1823      sizeof(cmd) + kNumElements * sizeof(GLfloat) * 2;
1824  void* next_cmd =
1825      cmd.Set(&cmd, static_cast<GLint>(1), static_cast<GLsizei>(2), data);
1826  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform2fvImmediate::kCmdId),
1827            cmd.header.command);
1828  EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);
1829  EXPECT_EQ(static_cast<GLint>(1), cmd.location);
1830  EXPECT_EQ(static_cast<GLsizei>(2), cmd.count);
1831  CheckBytesWrittenMatchesExpectedSize(
1832      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
1833  // TODO(gman): Check that data was inserted;
1834}
1835
1836TEST_F(GLES2FormatTest, Uniform2i) {
1837  cmds::Uniform2i& cmd = *GetBufferAs<cmds::Uniform2i>();
1838  void* next_cmd = cmd.Set(&cmd,
1839                           static_cast<GLint>(11),
1840                           static_cast<GLint>(12),
1841                           static_cast<GLint>(13));
1842  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform2i::kCmdId), cmd.header.command);
1843  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1844  EXPECT_EQ(static_cast<GLint>(11), cmd.location);
1845  EXPECT_EQ(static_cast<GLint>(12), cmd.x);
1846  EXPECT_EQ(static_cast<GLint>(13), cmd.y);
1847  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1848}
1849
1850TEST_F(GLES2FormatTest, Uniform2ivImmediate) {
1851  const int kSomeBaseValueToTestWith = 51;
1852  static GLint data[] = {
1853      static_cast<GLint>(kSomeBaseValueToTestWith + 0),
1854      static_cast<GLint>(kSomeBaseValueToTestWith + 1),
1855      static_cast<GLint>(kSomeBaseValueToTestWith + 2),
1856      static_cast<GLint>(kSomeBaseValueToTestWith + 3),
1857  };
1858  cmds::Uniform2ivImmediate& cmd = *GetBufferAs<cmds::Uniform2ivImmediate>();
1859  const GLsizei kNumElements = 2;
1860  const size_t kExpectedCmdSize =
1861      sizeof(cmd) + kNumElements * sizeof(GLint) * 2;
1862  void* next_cmd =
1863      cmd.Set(&cmd, static_cast<GLint>(1), static_cast<GLsizei>(2), data);
1864  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform2ivImmediate::kCmdId),
1865            cmd.header.command);
1866  EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);
1867  EXPECT_EQ(static_cast<GLint>(1), cmd.location);
1868  EXPECT_EQ(static_cast<GLsizei>(2), cmd.count);
1869  CheckBytesWrittenMatchesExpectedSize(
1870      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
1871  // TODO(gman): Check that data was inserted;
1872}
1873
1874TEST_F(GLES2FormatTest, Uniform3f) {
1875  cmds::Uniform3f& cmd = *GetBufferAs<cmds::Uniform3f>();
1876  void* next_cmd = cmd.Set(&cmd,
1877                           static_cast<GLint>(11),
1878                           static_cast<GLfloat>(12),
1879                           static_cast<GLfloat>(13),
1880                           static_cast<GLfloat>(14));
1881  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform3f::kCmdId), cmd.header.command);
1882  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1883  EXPECT_EQ(static_cast<GLint>(11), cmd.location);
1884  EXPECT_EQ(static_cast<GLfloat>(12), cmd.x);
1885  EXPECT_EQ(static_cast<GLfloat>(13), cmd.y);
1886  EXPECT_EQ(static_cast<GLfloat>(14), cmd.z);
1887  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1888}
1889
1890TEST_F(GLES2FormatTest, Uniform3fvImmediate) {
1891  const int kSomeBaseValueToTestWith = 51;
1892  static GLfloat data[] = {
1893      static_cast<GLfloat>(kSomeBaseValueToTestWith + 0),
1894      static_cast<GLfloat>(kSomeBaseValueToTestWith + 1),
1895      static_cast<GLfloat>(kSomeBaseValueToTestWith + 2),
1896      static_cast<GLfloat>(kSomeBaseValueToTestWith + 3),
1897      static_cast<GLfloat>(kSomeBaseValueToTestWith + 4),
1898      static_cast<GLfloat>(kSomeBaseValueToTestWith + 5),
1899  };
1900  cmds::Uniform3fvImmediate& cmd = *GetBufferAs<cmds::Uniform3fvImmediate>();
1901  const GLsizei kNumElements = 2;
1902  const size_t kExpectedCmdSize =
1903      sizeof(cmd) + kNumElements * sizeof(GLfloat) * 3;
1904  void* next_cmd =
1905      cmd.Set(&cmd, static_cast<GLint>(1), static_cast<GLsizei>(2), data);
1906  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform3fvImmediate::kCmdId),
1907            cmd.header.command);
1908  EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);
1909  EXPECT_EQ(static_cast<GLint>(1), cmd.location);
1910  EXPECT_EQ(static_cast<GLsizei>(2), cmd.count);
1911  CheckBytesWrittenMatchesExpectedSize(
1912      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
1913  // TODO(gman): Check that data was inserted;
1914}
1915
1916TEST_F(GLES2FormatTest, Uniform3i) {
1917  cmds::Uniform3i& cmd = *GetBufferAs<cmds::Uniform3i>();
1918  void* next_cmd = cmd.Set(&cmd,
1919                           static_cast<GLint>(11),
1920                           static_cast<GLint>(12),
1921                           static_cast<GLint>(13),
1922                           static_cast<GLint>(14));
1923  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform3i::kCmdId), cmd.header.command);
1924  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1925  EXPECT_EQ(static_cast<GLint>(11), cmd.location);
1926  EXPECT_EQ(static_cast<GLint>(12), cmd.x);
1927  EXPECT_EQ(static_cast<GLint>(13), cmd.y);
1928  EXPECT_EQ(static_cast<GLint>(14), cmd.z);
1929  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1930}
1931
1932TEST_F(GLES2FormatTest, Uniform3ivImmediate) {
1933  const int kSomeBaseValueToTestWith = 51;
1934  static GLint data[] = {
1935      static_cast<GLint>(kSomeBaseValueToTestWith + 0),
1936      static_cast<GLint>(kSomeBaseValueToTestWith + 1),
1937      static_cast<GLint>(kSomeBaseValueToTestWith + 2),
1938      static_cast<GLint>(kSomeBaseValueToTestWith + 3),
1939      static_cast<GLint>(kSomeBaseValueToTestWith + 4),
1940      static_cast<GLint>(kSomeBaseValueToTestWith + 5),
1941  };
1942  cmds::Uniform3ivImmediate& cmd = *GetBufferAs<cmds::Uniform3ivImmediate>();
1943  const GLsizei kNumElements = 2;
1944  const size_t kExpectedCmdSize =
1945      sizeof(cmd) + kNumElements * sizeof(GLint) * 3;
1946  void* next_cmd =
1947      cmd.Set(&cmd, static_cast<GLint>(1), static_cast<GLsizei>(2), data);
1948  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform3ivImmediate::kCmdId),
1949            cmd.header.command);
1950  EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);
1951  EXPECT_EQ(static_cast<GLint>(1), cmd.location);
1952  EXPECT_EQ(static_cast<GLsizei>(2), cmd.count);
1953  CheckBytesWrittenMatchesExpectedSize(
1954      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
1955  // TODO(gman): Check that data was inserted;
1956}
1957
1958TEST_F(GLES2FormatTest, Uniform4f) {
1959  cmds::Uniform4f& cmd = *GetBufferAs<cmds::Uniform4f>();
1960  void* next_cmd = cmd.Set(&cmd,
1961                           static_cast<GLint>(11),
1962                           static_cast<GLfloat>(12),
1963                           static_cast<GLfloat>(13),
1964                           static_cast<GLfloat>(14),
1965                           static_cast<GLfloat>(15));
1966  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform4f::kCmdId), cmd.header.command);
1967  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
1968  EXPECT_EQ(static_cast<GLint>(11), cmd.location);
1969  EXPECT_EQ(static_cast<GLfloat>(12), cmd.x);
1970  EXPECT_EQ(static_cast<GLfloat>(13), cmd.y);
1971  EXPECT_EQ(static_cast<GLfloat>(14), cmd.z);
1972  EXPECT_EQ(static_cast<GLfloat>(15), cmd.w);
1973  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
1974}
1975
1976TEST_F(GLES2FormatTest, Uniform4fvImmediate) {
1977  const int kSomeBaseValueToTestWith = 51;
1978  static GLfloat data[] = {
1979      static_cast<GLfloat>(kSomeBaseValueToTestWith + 0),
1980      static_cast<GLfloat>(kSomeBaseValueToTestWith + 1),
1981      static_cast<GLfloat>(kSomeBaseValueToTestWith + 2),
1982      static_cast<GLfloat>(kSomeBaseValueToTestWith + 3),
1983      static_cast<GLfloat>(kSomeBaseValueToTestWith + 4),
1984      static_cast<GLfloat>(kSomeBaseValueToTestWith + 5),
1985      static_cast<GLfloat>(kSomeBaseValueToTestWith + 6),
1986      static_cast<GLfloat>(kSomeBaseValueToTestWith + 7),
1987  };
1988  cmds::Uniform4fvImmediate& cmd = *GetBufferAs<cmds::Uniform4fvImmediate>();
1989  const GLsizei kNumElements = 2;
1990  const size_t kExpectedCmdSize =
1991      sizeof(cmd) + kNumElements * sizeof(GLfloat) * 4;
1992  void* next_cmd =
1993      cmd.Set(&cmd, static_cast<GLint>(1), static_cast<GLsizei>(2), data);
1994  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform4fvImmediate::kCmdId),
1995            cmd.header.command);
1996  EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);
1997  EXPECT_EQ(static_cast<GLint>(1), cmd.location);
1998  EXPECT_EQ(static_cast<GLsizei>(2), cmd.count);
1999  CheckBytesWrittenMatchesExpectedSize(
2000      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
2001  // TODO(gman): Check that data was inserted;
2002}
2003
2004TEST_F(GLES2FormatTest, Uniform4i) {
2005  cmds::Uniform4i& cmd = *GetBufferAs<cmds::Uniform4i>();
2006  void* next_cmd = cmd.Set(&cmd,
2007                           static_cast<GLint>(11),
2008                           static_cast<GLint>(12),
2009                           static_cast<GLint>(13),
2010                           static_cast<GLint>(14),
2011                           static_cast<GLint>(15));
2012  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform4i::kCmdId), cmd.header.command);
2013  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2014  EXPECT_EQ(static_cast<GLint>(11), cmd.location);
2015  EXPECT_EQ(static_cast<GLint>(12), cmd.x);
2016  EXPECT_EQ(static_cast<GLint>(13), cmd.y);
2017  EXPECT_EQ(static_cast<GLint>(14), cmd.z);
2018  EXPECT_EQ(static_cast<GLint>(15), cmd.w);
2019  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2020}
2021
2022TEST_F(GLES2FormatTest, Uniform4ivImmediate) {
2023  const int kSomeBaseValueToTestWith = 51;
2024  static GLint data[] = {
2025      static_cast<GLint>(kSomeBaseValueToTestWith + 0),
2026      static_cast<GLint>(kSomeBaseValueToTestWith + 1),
2027      static_cast<GLint>(kSomeBaseValueToTestWith + 2),
2028      static_cast<GLint>(kSomeBaseValueToTestWith + 3),
2029      static_cast<GLint>(kSomeBaseValueToTestWith + 4),
2030      static_cast<GLint>(kSomeBaseValueToTestWith + 5),
2031      static_cast<GLint>(kSomeBaseValueToTestWith + 6),
2032      static_cast<GLint>(kSomeBaseValueToTestWith + 7),
2033  };
2034  cmds::Uniform4ivImmediate& cmd = *GetBufferAs<cmds::Uniform4ivImmediate>();
2035  const GLsizei kNumElements = 2;
2036  const size_t kExpectedCmdSize =
2037      sizeof(cmd) + kNumElements * sizeof(GLint) * 4;
2038  void* next_cmd =
2039      cmd.Set(&cmd, static_cast<GLint>(1), static_cast<GLsizei>(2), data);
2040  EXPECT_EQ(static_cast<uint32_t>(cmds::Uniform4ivImmediate::kCmdId),
2041            cmd.header.command);
2042  EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);
2043  EXPECT_EQ(static_cast<GLint>(1), cmd.location);
2044  EXPECT_EQ(static_cast<GLsizei>(2), cmd.count);
2045  CheckBytesWrittenMatchesExpectedSize(
2046      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
2047  // TODO(gman): Check that data was inserted;
2048}
2049
2050TEST_F(GLES2FormatTest, UniformMatrix2fvImmediate) {
2051  const int kSomeBaseValueToTestWith = 51;
2052  static GLfloat data[] = {
2053      static_cast<GLfloat>(kSomeBaseValueToTestWith + 0),
2054      static_cast<GLfloat>(kSomeBaseValueToTestWith + 1),
2055      static_cast<GLfloat>(kSomeBaseValueToTestWith + 2),
2056      static_cast<GLfloat>(kSomeBaseValueToTestWith + 3),
2057      static_cast<GLfloat>(kSomeBaseValueToTestWith + 4),
2058      static_cast<GLfloat>(kSomeBaseValueToTestWith + 5),
2059      static_cast<GLfloat>(kSomeBaseValueToTestWith + 6),
2060      static_cast<GLfloat>(kSomeBaseValueToTestWith + 7),
2061  };
2062  cmds::UniformMatrix2fvImmediate& cmd =
2063      *GetBufferAs<cmds::UniformMatrix2fvImmediate>();
2064  const GLsizei kNumElements = 2;
2065  const size_t kExpectedCmdSize =
2066      sizeof(cmd) + kNumElements * sizeof(GLfloat) * 4;
2067  void* next_cmd =
2068      cmd.Set(&cmd, static_cast<GLint>(1), static_cast<GLsizei>(2), data);
2069  EXPECT_EQ(static_cast<uint32_t>(cmds::UniformMatrix2fvImmediate::kCmdId),
2070            cmd.header.command);
2071  EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);
2072  EXPECT_EQ(static_cast<GLint>(1), cmd.location);
2073  EXPECT_EQ(static_cast<GLsizei>(2), cmd.count);
2074  CheckBytesWrittenMatchesExpectedSize(
2075      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
2076  // TODO(gman): Check that data was inserted;
2077}
2078
2079TEST_F(GLES2FormatTest, UniformMatrix3fvImmediate) {
2080  const int kSomeBaseValueToTestWith = 51;
2081  static GLfloat data[] = {
2082      static_cast<GLfloat>(kSomeBaseValueToTestWith + 0),
2083      static_cast<GLfloat>(kSomeBaseValueToTestWith + 1),
2084      static_cast<GLfloat>(kSomeBaseValueToTestWith + 2),
2085      static_cast<GLfloat>(kSomeBaseValueToTestWith + 3),
2086      static_cast<GLfloat>(kSomeBaseValueToTestWith + 4),
2087      static_cast<GLfloat>(kSomeBaseValueToTestWith + 5),
2088      static_cast<GLfloat>(kSomeBaseValueToTestWith + 6),
2089      static_cast<GLfloat>(kSomeBaseValueToTestWith + 7),
2090      static_cast<GLfloat>(kSomeBaseValueToTestWith + 8),
2091      static_cast<GLfloat>(kSomeBaseValueToTestWith + 9),
2092      static_cast<GLfloat>(kSomeBaseValueToTestWith + 10),
2093      static_cast<GLfloat>(kSomeBaseValueToTestWith + 11),
2094      static_cast<GLfloat>(kSomeBaseValueToTestWith + 12),
2095      static_cast<GLfloat>(kSomeBaseValueToTestWith + 13),
2096      static_cast<GLfloat>(kSomeBaseValueToTestWith + 14),
2097      static_cast<GLfloat>(kSomeBaseValueToTestWith + 15),
2098      static_cast<GLfloat>(kSomeBaseValueToTestWith + 16),
2099      static_cast<GLfloat>(kSomeBaseValueToTestWith + 17),
2100  };
2101  cmds::UniformMatrix3fvImmediate& cmd =
2102      *GetBufferAs<cmds::UniformMatrix3fvImmediate>();
2103  const GLsizei kNumElements = 2;
2104  const size_t kExpectedCmdSize =
2105      sizeof(cmd) + kNumElements * sizeof(GLfloat) * 9;
2106  void* next_cmd =
2107      cmd.Set(&cmd, static_cast<GLint>(1), static_cast<GLsizei>(2), data);
2108  EXPECT_EQ(static_cast<uint32_t>(cmds::UniformMatrix3fvImmediate::kCmdId),
2109            cmd.header.command);
2110  EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);
2111  EXPECT_EQ(static_cast<GLint>(1), cmd.location);
2112  EXPECT_EQ(static_cast<GLsizei>(2), cmd.count);
2113  CheckBytesWrittenMatchesExpectedSize(
2114      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
2115  // TODO(gman): Check that data was inserted;
2116}
2117
2118TEST_F(GLES2FormatTest, UniformMatrix4fvImmediate) {
2119  const int kSomeBaseValueToTestWith = 51;
2120  static GLfloat data[] = {
2121      static_cast<GLfloat>(kSomeBaseValueToTestWith + 0),
2122      static_cast<GLfloat>(kSomeBaseValueToTestWith + 1),
2123      static_cast<GLfloat>(kSomeBaseValueToTestWith + 2),
2124      static_cast<GLfloat>(kSomeBaseValueToTestWith + 3),
2125      static_cast<GLfloat>(kSomeBaseValueToTestWith + 4),
2126      static_cast<GLfloat>(kSomeBaseValueToTestWith + 5),
2127      static_cast<GLfloat>(kSomeBaseValueToTestWith + 6),
2128      static_cast<GLfloat>(kSomeBaseValueToTestWith + 7),
2129      static_cast<GLfloat>(kSomeBaseValueToTestWith + 8),
2130      static_cast<GLfloat>(kSomeBaseValueToTestWith + 9),
2131      static_cast<GLfloat>(kSomeBaseValueToTestWith + 10),
2132      static_cast<GLfloat>(kSomeBaseValueToTestWith + 11),
2133      static_cast<GLfloat>(kSomeBaseValueToTestWith + 12),
2134      static_cast<GLfloat>(kSomeBaseValueToTestWith + 13),
2135      static_cast<GLfloat>(kSomeBaseValueToTestWith + 14),
2136      static_cast<GLfloat>(kSomeBaseValueToTestWith + 15),
2137      static_cast<GLfloat>(kSomeBaseValueToTestWith + 16),
2138      static_cast<GLfloat>(kSomeBaseValueToTestWith + 17),
2139      static_cast<GLfloat>(kSomeBaseValueToTestWith + 18),
2140      static_cast<GLfloat>(kSomeBaseValueToTestWith + 19),
2141      static_cast<GLfloat>(kSomeBaseValueToTestWith + 20),
2142      static_cast<GLfloat>(kSomeBaseValueToTestWith + 21),
2143      static_cast<GLfloat>(kSomeBaseValueToTestWith + 22),
2144      static_cast<GLfloat>(kSomeBaseValueToTestWith + 23),
2145      static_cast<GLfloat>(kSomeBaseValueToTestWith + 24),
2146      static_cast<GLfloat>(kSomeBaseValueToTestWith + 25),
2147      static_cast<GLfloat>(kSomeBaseValueToTestWith + 26),
2148      static_cast<GLfloat>(kSomeBaseValueToTestWith + 27),
2149      static_cast<GLfloat>(kSomeBaseValueToTestWith + 28),
2150      static_cast<GLfloat>(kSomeBaseValueToTestWith + 29),
2151      static_cast<GLfloat>(kSomeBaseValueToTestWith + 30),
2152      static_cast<GLfloat>(kSomeBaseValueToTestWith + 31),
2153  };
2154  cmds::UniformMatrix4fvImmediate& cmd =
2155      *GetBufferAs<cmds::UniformMatrix4fvImmediate>();
2156  const GLsizei kNumElements = 2;
2157  const size_t kExpectedCmdSize =
2158      sizeof(cmd) + kNumElements * sizeof(GLfloat) * 16;
2159  void* next_cmd =
2160      cmd.Set(&cmd, static_cast<GLint>(1), static_cast<GLsizei>(2), data);
2161  EXPECT_EQ(static_cast<uint32_t>(cmds::UniformMatrix4fvImmediate::kCmdId),
2162            cmd.header.command);
2163  EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);
2164  EXPECT_EQ(static_cast<GLint>(1), cmd.location);
2165  EXPECT_EQ(static_cast<GLsizei>(2), cmd.count);
2166  CheckBytesWrittenMatchesExpectedSize(
2167      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
2168  // TODO(gman): Check that data was inserted;
2169}
2170
2171TEST_F(GLES2FormatTest, UseProgram) {
2172  cmds::UseProgram& cmd = *GetBufferAs<cmds::UseProgram>();
2173  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
2174  EXPECT_EQ(static_cast<uint32_t>(cmds::UseProgram::kCmdId),
2175            cmd.header.command);
2176  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2177  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
2178  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2179}
2180
2181TEST_F(GLES2FormatTest, ValidateProgram) {
2182  cmds::ValidateProgram& cmd = *GetBufferAs<cmds::ValidateProgram>();
2183  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
2184  EXPECT_EQ(static_cast<uint32_t>(cmds::ValidateProgram::kCmdId),
2185            cmd.header.command);
2186  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2187  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
2188  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2189}
2190
2191TEST_F(GLES2FormatTest, VertexAttrib1f) {
2192  cmds::VertexAttrib1f& cmd = *GetBufferAs<cmds::VertexAttrib1f>();
2193  void* next_cmd =
2194      cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLfloat>(12));
2195  EXPECT_EQ(static_cast<uint32_t>(cmds::VertexAttrib1f::kCmdId),
2196            cmd.header.command);
2197  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2198  EXPECT_EQ(static_cast<GLuint>(11), cmd.indx);
2199  EXPECT_EQ(static_cast<GLfloat>(12), cmd.x);
2200  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2201}
2202
2203TEST_F(GLES2FormatTest, VertexAttrib1fvImmediate) {
2204  const int kSomeBaseValueToTestWith = 51;
2205  static GLfloat data[] = {
2206      static_cast<GLfloat>(kSomeBaseValueToTestWith + 0),
2207  };
2208  cmds::VertexAttrib1fvImmediate& cmd =
2209      *GetBufferAs<cmds::VertexAttrib1fvImmediate>();
2210  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11), data);
2211  EXPECT_EQ(static_cast<uint32_t>(cmds::VertexAttrib1fvImmediate::kCmdId),
2212            cmd.header.command);
2213  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
2214            cmd.header.size * 4u);
2215  EXPECT_EQ(static_cast<GLuint>(11), cmd.indx);
2216  CheckBytesWrittenMatchesExpectedSize(
2217      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
2218  // TODO(gman): Check that data was inserted;
2219}
2220
2221TEST_F(GLES2FormatTest, VertexAttrib2f) {
2222  cmds::VertexAttrib2f& cmd = *GetBufferAs<cmds::VertexAttrib2f>();
2223  void* next_cmd = cmd.Set(&cmd,
2224                           static_cast<GLuint>(11),
2225                           static_cast<GLfloat>(12),
2226                           static_cast<GLfloat>(13));
2227  EXPECT_EQ(static_cast<uint32_t>(cmds::VertexAttrib2f::kCmdId),
2228            cmd.header.command);
2229  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2230  EXPECT_EQ(static_cast<GLuint>(11), cmd.indx);
2231  EXPECT_EQ(static_cast<GLfloat>(12), cmd.x);
2232  EXPECT_EQ(static_cast<GLfloat>(13), cmd.y);
2233  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2234}
2235
2236TEST_F(GLES2FormatTest, VertexAttrib2fvImmediate) {
2237  const int kSomeBaseValueToTestWith = 51;
2238  static GLfloat data[] = {
2239      static_cast<GLfloat>(kSomeBaseValueToTestWith + 0),
2240      static_cast<GLfloat>(kSomeBaseValueToTestWith + 1),
2241  };
2242  cmds::VertexAttrib2fvImmediate& cmd =
2243      *GetBufferAs<cmds::VertexAttrib2fvImmediate>();
2244  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11), data);
2245  EXPECT_EQ(static_cast<uint32_t>(cmds::VertexAttrib2fvImmediate::kCmdId),
2246            cmd.header.command);
2247  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
2248            cmd.header.size * 4u);
2249  EXPECT_EQ(static_cast<GLuint>(11), cmd.indx);
2250  CheckBytesWrittenMatchesExpectedSize(
2251      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
2252  // TODO(gman): Check that data was inserted;
2253}
2254
2255TEST_F(GLES2FormatTest, VertexAttrib3f) {
2256  cmds::VertexAttrib3f& cmd = *GetBufferAs<cmds::VertexAttrib3f>();
2257  void* next_cmd = cmd.Set(&cmd,
2258                           static_cast<GLuint>(11),
2259                           static_cast<GLfloat>(12),
2260                           static_cast<GLfloat>(13),
2261                           static_cast<GLfloat>(14));
2262  EXPECT_EQ(static_cast<uint32_t>(cmds::VertexAttrib3f::kCmdId),
2263            cmd.header.command);
2264  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2265  EXPECT_EQ(static_cast<GLuint>(11), cmd.indx);
2266  EXPECT_EQ(static_cast<GLfloat>(12), cmd.x);
2267  EXPECT_EQ(static_cast<GLfloat>(13), cmd.y);
2268  EXPECT_EQ(static_cast<GLfloat>(14), cmd.z);
2269  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2270}
2271
2272TEST_F(GLES2FormatTest, VertexAttrib3fvImmediate) {
2273  const int kSomeBaseValueToTestWith = 51;
2274  static GLfloat data[] = {
2275      static_cast<GLfloat>(kSomeBaseValueToTestWith + 0),
2276      static_cast<GLfloat>(kSomeBaseValueToTestWith + 1),
2277      static_cast<GLfloat>(kSomeBaseValueToTestWith + 2),
2278  };
2279  cmds::VertexAttrib3fvImmediate& cmd =
2280      *GetBufferAs<cmds::VertexAttrib3fvImmediate>();
2281  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11), data);
2282  EXPECT_EQ(static_cast<uint32_t>(cmds::VertexAttrib3fvImmediate::kCmdId),
2283            cmd.header.command);
2284  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
2285            cmd.header.size * 4u);
2286  EXPECT_EQ(static_cast<GLuint>(11), cmd.indx);
2287  CheckBytesWrittenMatchesExpectedSize(
2288      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
2289  // TODO(gman): Check that data was inserted;
2290}
2291
2292TEST_F(GLES2FormatTest, VertexAttrib4f) {
2293  cmds::VertexAttrib4f& cmd = *GetBufferAs<cmds::VertexAttrib4f>();
2294  void* next_cmd = cmd.Set(&cmd,
2295                           static_cast<GLuint>(11),
2296                           static_cast<GLfloat>(12),
2297                           static_cast<GLfloat>(13),
2298                           static_cast<GLfloat>(14),
2299                           static_cast<GLfloat>(15));
2300  EXPECT_EQ(static_cast<uint32_t>(cmds::VertexAttrib4f::kCmdId),
2301            cmd.header.command);
2302  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2303  EXPECT_EQ(static_cast<GLuint>(11), cmd.indx);
2304  EXPECT_EQ(static_cast<GLfloat>(12), cmd.x);
2305  EXPECT_EQ(static_cast<GLfloat>(13), cmd.y);
2306  EXPECT_EQ(static_cast<GLfloat>(14), cmd.z);
2307  EXPECT_EQ(static_cast<GLfloat>(15), cmd.w);
2308  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2309}
2310
2311TEST_F(GLES2FormatTest, VertexAttrib4fvImmediate) {
2312  const int kSomeBaseValueToTestWith = 51;
2313  static GLfloat data[] = {
2314      static_cast<GLfloat>(kSomeBaseValueToTestWith + 0),
2315      static_cast<GLfloat>(kSomeBaseValueToTestWith + 1),
2316      static_cast<GLfloat>(kSomeBaseValueToTestWith + 2),
2317      static_cast<GLfloat>(kSomeBaseValueToTestWith + 3),
2318  };
2319  cmds::VertexAttrib4fvImmediate& cmd =
2320      *GetBufferAs<cmds::VertexAttrib4fvImmediate>();
2321  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11), data);
2322  EXPECT_EQ(static_cast<uint32_t>(cmds::VertexAttrib4fvImmediate::kCmdId),
2323            cmd.header.command);
2324  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
2325            cmd.header.size * 4u);
2326  EXPECT_EQ(static_cast<GLuint>(11), cmd.indx);
2327  CheckBytesWrittenMatchesExpectedSize(
2328      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
2329  // TODO(gman): Check that data was inserted;
2330}
2331
2332TEST_F(GLES2FormatTest, VertexAttribPointer) {
2333  cmds::VertexAttribPointer& cmd = *GetBufferAs<cmds::VertexAttribPointer>();
2334  void* next_cmd = cmd.Set(&cmd,
2335                           static_cast<GLuint>(11),
2336                           static_cast<GLint>(12),
2337                           static_cast<GLenum>(13),
2338                           static_cast<GLboolean>(14),
2339                           static_cast<GLsizei>(15),
2340                           static_cast<GLuint>(16));
2341  EXPECT_EQ(static_cast<uint32_t>(cmds::VertexAttribPointer::kCmdId),
2342            cmd.header.command);
2343  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2344  EXPECT_EQ(static_cast<GLuint>(11), cmd.indx);
2345  EXPECT_EQ(static_cast<GLint>(12), cmd.size);
2346  EXPECT_EQ(static_cast<GLenum>(13), cmd.type);
2347  EXPECT_EQ(static_cast<GLboolean>(14), cmd.normalized);
2348  EXPECT_EQ(static_cast<GLsizei>(15), cmd.stride);
2349  EXPECT_EQ(static_cast<GLuint>(16), cmd.offset);
2350  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2351}
2352
2353TEST_F(GLES2FormatTest, Viewport) {
2354  cmds::Viewport& cmd = *GetBufferAs<cmds::Viewport>();
2355  void* next_cmd = cmd.Set(&cmd,
2356                           static_cast<GLint>(11),
2357                           static_cast<GLint>(12),
2358                           static_cast<GLsizei>(13),
2359                           static_cast<GLsizei>(14));
2360  EXPECT_EQ(static_cast<uint32_t>(cmds::Viewport::kCmdId), cmd.header.command);
2361  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2362  EXPECT_EQ(static_cast<GLint>(11), cmd.x);
2363  EXPECT_EQ(static_cast<GLint>(12), cmd.y);
2364  EXPECT_EQ(static_cast<GLsizei>(13), cmd.width);
2365  EXPECT_EQ(static_cast<GLsizei>(14), cmd.height);
2366  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2367}
2368
2369TEST_F(GLES2FormatTest, BlitFramebufferCHROMIUM) {
2370  cmds::BlitFramebufferCHROMIUM& cmd =
2371      *GetBufferAs<cmds::BlitFramebufferCHROMIUM>();
2372  void* next_cmd = cmd.Set(&cmd,
2373                           static_cast<GLint>(11),
2374                           static_cast<GLint>(12),
2375                           static_cast<GLint>(13),
2376                           static_cast<GLint>(14),
2377                           static_cast<GLint>(15),
2378                           static_cast<GLint>(16),
2379                           static_cast<GLint>(17),
2380                           static_cast<GLint>(18),
2381                           static_cast<GLbitfield>(19),
2382                           static_cast<GLenum>(20));
2383  EXPECT_EQ(static_cast<uint32_t>(cmds::BlitFramebufferCHROMIUM::kCmdId),
2384            cmd.header.command);
2385  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2386  EXPECT_EQ(static_cast<GLint>(11), cmd.srcX0);
2387  EXPECT_EQ(static_cast<GLint>(12), cmd.srcY0);
2388  EXPECT_EQ(static_cast<GLint>(13), cmd.srcX1);
2389  EXPECT_EQ(static_cast<GLint>(14), cmd.srcY1);
2390  EXPECT_EQ(static_cast<GLint>(15), cmd.dstX0);
2391  EXPECT_EQ(static_cast<GLint>(16), cmd.dstY0);
2392  EXPECT_EQ(static_cast<GLint>(17), cmd.dstX1);
2393  EXPECT_EQ(static_cast<GLint>(18), cmd.dstY1);
2394  EXPECT_EQ(static_cast<GLbitfield>(19), cmd.mask);
2395  EXPECT_EQ(static_cast<GLenum>(20), cmd.filter);
2396  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2397}
2398
2399TEST_F(GLES2FormatTest, RenderbufferStorageMultisampleCHROMIUM) {
2400  cmds::RenderbufferStorageMultisampleCHROMIUM& cmd =
2401      *GetBufferAs<cmds::RenderbufferStorageMultisampleCHROMIUM>();
2402  void* next_cmd = cmd.Set(&cmd,
2403                           static_cast<GLenum>(11),
2404                           static_cast<GLsizei>(12),
2405                           static_cast<GLenum>(13),
2406                           static_cast<GLsizei>(14),
2407                           static_cast<GLsizei>(15));
2408  EXPECT_EQ(static_cast<uint32_t>(
2409                cmds::RenderbufferStorageMultisampleCHROMIUM::kCmdId),
2410            cmd.header.command);
2411  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2412  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
2413  EXPECT_EQ(static_cast<GLsizei>(12), cmd.samples);
2414  EXPECT_EQ(static_cast<GLenum>(13), cmd.internalformat);
2415  EXPECT_EQ(static_cast<GLsizei>(14), cmd.width);
2416  EXPECT_EQ(static_cast<GLsizei>(15), cmd.height);
2417  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2418}
2419
2420TEST_F(GLES2FormatTest, RenderbufferStorageMultisampleEXT) {
2421  cmds::RenderbufferStorageMultisampleEXT& cmd =
2422      *GetBufferAs<cmds::RenderbufferStorageMultisampleEXT>();
2423  void* next_cmd = cmd.Set(&cmd,
2424                           static_cast<GLenum>(11),
2425                           static_cast<GLsizei>(12),
2426                           static_cast<GLenum>(13),
2427                           static_cast<GLsizei>(14),
2428                           static_cast<GLsizei>(15));
2429  EXPECT_EQ(
2430      static_cast<uint32_t>(cmds::RenderbufferStorageMultisampleEXT::kCmdId),
2431      cmd.header.command);
2432  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2433  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
2434  EXPECT_EQ(static_cast<GLsizei>(12), cmd.samples);
2435  EXPECT_EQ(static_cast<GLenum>(13), cmd.internalformat);
2436  EXPECT_EQ(static_cast<GLsizei>(14), cmd.width);
2437  EXPECT_EQ(static_cast<GLsizei>(15), cmd.height);
2438  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2439}
2440
2441TEST_F(GLES2FormatTest, FramebufferTexture2DMultisampleEXT) {
2442  cmds::FramebufferTexture2DMultisampleEXT& cmd =
2443      *GetBufferAs<cmds::FramebufferTexture2DMultisampleEXT>();
2444  void* next_cmd = cmd.Set(&cmd,
2445                           static_cast<GLenum>(11),
2446                           static_cast<GLenum>(12),
2447                           static_cast<GLenum>(13),
2448                           static_cast<GLuint>(14),
2449                           static_cast<GLsizei>(15));
2450  EXPECT_EQ(
2451      static_cast<uint32_t>(cmds::FramebufferTexture2DMultisampleEXT::kCmdId),
2452      cmd.header.command);
2453  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2454  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
2455  EXPECT_EQ(static_cast<GLenum>(12), cmd.attachment);
2456  EXPECT_EQ(static_cast<GLenum>(13), cmd.textarget);
2457  EXPECT_EQ(static_cast<GLuint>(14), cmd.texture);
2458  EXPECT_EQ(static_cast<GLsizei>(15), cmd.samples);
2459  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2460}
2461
2462TEST_F(GLES2FormatTest, TexStorage2DEXT) {
2463  cmds::TexStorage2DEXT& cmd = *GetBufferAs<cmds::TexStorage2DEXT>();
2464  void* next_cmd = cmd.Set(&cmd,
2465                           static_cast<GLenum>(11),
2466                           static_cast<GLsizei>(12),
2467                           static_cast<GLenum>(13),
2468                           static_cast<GLsizei>(14),
2469                           static_cast<GLsizei>(15));
2470  EXPECT_EQ(static_cast<uint32_t>(cmds::TexStorage2DEXT::kCmdId),
2471            cmd.header.command);
2472  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2473  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
2474  EXPECT_EQ(static_cast<GLsizei>(12), cmd.levels);
2475  EXPECT_EQ(static_cast<GLenum>(13), cmd.internalFormat);
2476  EXPECT_EQ(static_cast<GLsizei>(14), cmd.width);
2477  EXPECT_EQ(static_cast<GLsizei>(15), cmd.height);
2478  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2479}
2480
2481TEST_F(GLES2FormatTest, GenQueriesEXTImmediate) {
2482  static GLuint ids[] = {
2483      12, 23, 34,
2484  };
2485  cmds::GenQueriesEXTImmediate& cmd =
2486      *GetBufferAs<cmds::GenQueriesEXTImmediate>();
2487  void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(arraysize(ids)), ids);
2488  EXPECT_EQ(static_cast<uint32_t>(cmds::GenQueriesEXTImmediate::kCmdId),
2489            cmd.header.command);
2490  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
2491            cmd.header.size * 4u);
2492  EXPECT_EQ(static_cast<GLsizei>(arraysize(ids)), cmd.n);
2493  CheckBytesWrittenMatchesExpectedSize(
2494      next_cmd,
2495      sizeof(cmd) + RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));
2496  // TODO(gman): Check that ids were inserted;
2497}
2498
2499TEST_F(GLES2FormatTest, DeleteQueriesEXTImmediate) {
2500  static GLuint ids[] = {
2501      12, 23, 34,
2502  };
2503  cmds::DeleteQueriesEXTImmediate& cmd =
2504      *GetBufferAs<cmds::DeleteQueriesEXTImmediate>();
2505  void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(arraysize(ids)), ids);
2506  EXPECT_EQ(static_cast<uint32_t>(cmds::DeleteQueriesEXTImmediate::kCmdId),
2507            cmd.header.command);
2508  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
2509            cmd.header.size * 4u);
2510  EXPECT_EQ(static_cast<GLsizei>(arraysize(ids)), cmd.n);
2511  CheckBytesWrittenMatchesExpectedSize(
2512      next_cmd,
2513      sizeof(cmd) + RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));
2514  // TODO(gman): Check that ids were inserted;
2515}
2516
2517TEST_F(GLES2FormatTest, BeginQueryEXT) {
2518  cmds::BeginQueryEXT& cmd = *GetBufferAs<cmds::BeginQueryEXT>();
2519  void* next_cmd = cmd.Set(&cmd,
2520                           static_cast<GLenum>(11),
2521                           static_cast<GLuint>(12),
2522                           static_cast<uint32_t>(13),
2523                           static_cast<uint32_t>(14));
2524  EXPECT_EQ(static_cast<uint32_t>(cmds::BeginQueryEXT::kCmdId),
2525            cmd.header.command);
2526  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2527  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
2528  EXPECT_EQ(static_cast<GLuint>(12), cmd.id);
2529  EXPECT_EQ(static_cast<uint32_t>(13), cmd.sync_data_shm_id);
2530  EXPECT_EQ(static_cast<uint32_t>(14), cmd.sync_data_shm_offset);
2531  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2532}
2533
2534TEST_F(GLES2FormatTest, EndQueryEXT) {
2535  cmds::EndQueryEXT& cmd = *GetBufferAs<cmds::EndQueryEXT>();
2536  void* next_cmd =
2537      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLuint>(12));
2538  EXPECT_EQ(static_cast<uint32_t>(cmds::EndQueryEXT::kCmdId),
2539            cmd.header.command);
2540  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2541  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
2542  EXPECT_EQ(static_cast<GLuint>(12), cmd.submit_count);
2543  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2544}
2545
2546TEST_F(GLES2FormatTest, InsertEventMarkerEXT) {
2547  cmds::InsertEventMarkerEXT& cmd = *GetBufferAs<cmds::InsertEventMarkerEXT>();
2548  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
2549  EXPECT_EQ(static_cast<uint32_t>(cmds::InsertEventMarkerEXT::kCmdId),
2550            cmd.header.command);
2551  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2552  EXPECT_EQ(static_cast<GLuint>(11), cmd.bucket_id);
2553  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2554}
2555
2556TEST_F(GLES2FormatTest, PushGroupMarkerEXT) {
2557  cmds::PushGroupMarkerEXT& cmd = *GetBufferAs<cmds::PushGroupMarkerEXT>();
2558  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
2559  EXPECT_EQ(static_cast<uint32_t>(cmds::PushGroupMarkerEXT::kCmdId),
2560            cmd.header.command);
2561  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2562  EXPECT_EQ(static_cast<GLuint>(11), cmd.bucket_id);
2563  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2564}
2565
2566TEST_F(GLES2FormatTest, PopGroupMarkerEXT) {
2567  cmds::PopGroupMarkerEXT& cmd = *GetBufferAs<cmds::PopGroupMarkerEXT>();
2568  void* next_cmd = cmd.Set(&cmd);
2569  EXPECT_EQ(static_cast<uint32_t>(cmds::PopGroupMarkerEXT::kCmdId),
2570            cmd.header.command);
2571  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2572  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2573}
2574
2575TEST_F(GLES2FormatTest, GenVertexArraysOESImmediate) {
2576  static GLuint ids[] = {
2577      12, 23, 34,
2578  };
2579  cmds::GenVertexArraysOESImmediate& cmd =
2580      *GetBufferAs<cmds::GenVertexArraysOESImmediate>();
2581  void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(arraysize(ids)), ids);
2582  EXPECT_EQ(static_cast<uint32_t>(cmds::GenVertexArraysOESImmediate::kCmdId),
2583            cmd.header.command);
2584  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
2585            cmd.header.size * 4u);
2586  EXPECT_EQ(static_cast<GLsizei>(arraysize(ids)), cmd.n);
2587  CheckBytesWrittenMatchesExpectedSize(
2588      next_cmd,
2589      sizeof(cmd) + RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));
2590  // TODO(gman): Check that ids were inserted;
2591}
2592
2593TEST_F(GLES2FormatTest, DeleteVertexArraysOESImmediate) {
2594  static GLuint ids[] = {
2595      12, 23, 34,
2596  };
2597  cmds::DeleteVertexArraysOESImmediate& cmd =
2598      *GetBufferAs<cmds::DeleteVertexArraysOESImmediate>();
2599  void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(arraysize(ids)), ids);
2600  EXPECT_EQ(static_cast<uint32_t>(cmds::DeleteVertexArraysOESImmediate::kCmdId),
2601            cmd.header.command);
2602  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
2603            cmd.header.size * 4u);
2604  EXPECT_EQ(static_cast<GLsizei>(arraysize(ids)), cmd.n);
2605  CheckBytesWrittenMatchesExpectedSize(
2606      next_cmd,
2607      sizeof(cmd) + RoundSizeToMultipleOfEntries(arraysize(ids) * 4u));
2608  // TODO(gman): Check that ids were inserted;
2609}
2610
2611TEST_F(GLES2FormatTest, IsVertexArrayOES) {
2612  cmds::IsVertexArrayOES& cmd = *GetBufferAs<cmds::IsVertexArrayOES>();
2613  void* next_cmd = cmd.Set(&cmd,
2614                           static_cast<GLuint>(11),
2615                           static_cast<uint32_t>(12),
2616                           static_cast<uint32_t>(13));
2617  EXPECT_EQ(static_cast<uint32_t>(cmds::IsVertexArrayOES::kCmdId),
2618            cmd.header.command);
2619  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2620  EXPECT_EQ(static_cast<GLuint>(11), cmd.array);
2621  EXPECT_EQ(static_cast<uint32_t>(12), cmd.result_shm_id);
2622  EXPECT_EQ(static_cast<uint32_t>(13), cmd.result_shm_offset);
2623  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2624}
2625
2626TEST_F(GLES2FormatTest, BindVertexArrayOES) {
2627  cmds::BindVertexArrayOES& cmd = *GetBufferAs<cmds::BindVertexArrayOES>();
2628  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
2629  EXPECT_EQ(static_cast<uint32_t>(cmds::BindVertexArrayOES::kCmdId),
2630            cmd.header.command);
2631  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2632  EXPECT_EQ(static_cast<GLuint>(11), cmd.array);
2633  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2634}
2635
2636TEST_F(GLES2FormatTest, SwapBuffers) {
2637  cmds::SwapBuffers& cmd = *GetBufferAs<cmds::SwapBuffers>();
2638  void* next_cmd = cmd.Set(&cmd);
2639  EXPECT_EQ(static_cast<uint32_t>(cmds::SwapBuffers::kCmdId),
2640            cmd.header.command);
2641  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2642  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2643}
2644
2645TEST_F(GLES2FormatTest, GetMaxValueInBufferCHROMIUM) {
2646  cmds::GetMaxValueInBufferCHROMIUM& cmd =
2647      *GetBufferAs<cmds::GetMaxValueInBufferCHROMIUM>();
2648  void* next_cmd = cmd.Set(&cmd,
2649                           static_cast<GLuint>(11),
2650                           static_cast<GLsizei>(12),
2651                           static_cast<GLenum>(13),
2652                           static_cast<GLuint>(14),
2653                           static_cast<uint32_t>(15),
2654                           static_cast<uint32_t>(16));
2655  EXPECT_EQ(static_cast<uint32_t>(cmds::GetMaxValueInBufferCHROMIUM::kCmdId),
2656            cmd.header.command);
2657  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2658  EXPECT_EQ(static_cast<GLuint>(11), cmd.buffer_id);
2659  EXPECT_EQ(static_cast<GLsizei>(12), cmd.count);
2660  EXPECT_EQ(static_cast<GLenum>(13), cmd.type);
2661  EXPECT_EQ(static_cast<GLuint>(14), cmd.offset);
2662  EXPECT_EQ(static_cast<uint32_t>(15), cmd.result_shm_id);
2663  EXPECT_EQ(static_cast<uint32_t>(16), cmd.result_shm_offset);
2664  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2665}
2666
2667TEST_F(GLES2FormatTest, GenSharedIdsCHROMIUM) {
2668  cmds::GenSharedIdsCHROMIUM& cmd = *GetBufferAs<cmds::GenSharedIdsCHROMIUM>();
2669  void* next_cmd = cmd.Set(&cmd,
2670                           static_cast<GLuint>(11),
2671                           static_cast<GLuint>(12),
2672                           static_cast<GLsizei>(13),
2673                           static_cast<uint32_t>(14),
2674                           static_cast<uint32_t>(15));
2675  EXPECT_EQ(static_cast<uint32_t>(cmds::GenSharedIdsCHROMIUM::kCmdId),
2676            cmd.header.command);
2677  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2678  EXPECT_EQ(static_cast<GLuint>(11), cmd.namespace_id);
2679  EXPECT_EQ(static_cast<GLuint>(12), cmd.id_offset);
2680  EXPECT_EQ(static_cast<GLsizei>(13), cmd.n);
2681  EXPECT_EQ(static_cast<uint32_t>(14), cmd.ids_shm_id);
2682  EXPECT_EQ(static_cast<uint32_t>(15), cmd.ids_shm_offset);
2683  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2684}
2685
2686TEST_F(GLES2FormatTest, DeleteSharedIdsCHROMIUM) {
2687  cmds::DeleteSharedIdsCHROMIUM& cmd =
2688      *GetBufferAs<cmds::DeleteSharedIdsCHROMIUM>();
2689  void* next_cmd = cmd.Set(&cmd,
2690                           static_cast<GLuint>(11),
2691                           static_cast<GLsizei>(12),
2692                           static_cast<uint32_t>(13),
2693                           static_cast<uint32_t>(14));
2694  EXPECT_EQ(static_cast<uint32_t>(cmds::DeleteSharedIdsCHROMIUM::kCmdId),
2695            cmd.header.command);
2696  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2697  EXPECT_EQ(static_cast<GLuint>(11), cmd.namespace_id);
2698  EXPECT_EQ(static_cast<GLsizei>(12), cmd.n);
2699  EXPECT_EQ(static_cast<uint32_t>(13), cmd.ids_shm_id);
2700  EXPECT_EQ(static_cast<uint32_t>(14), cmd.ids_shm_offset);
2701  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2702}
2703
2704TEST_F(GLES2FormatTest, RegisterSharedIdsCHROMIUM) {
2705  cmds::RegisterSharedIdsCHROMIUM& cmd =
2706      *GetBufferAs<cmds::RegisterSharedIdsCHROMIUM>();
2707  void* next_cmd = cmd.Set(&cmd,
2708                           static_cast<GLuint>(11),
2709                           static_cast<GLsizei>(12),
2710                           static_cast<uint32_t>(13),
2711                           static_cast<uint32_t>(14));
2712  EXPECT_EQ(static_cast<uint32_t>(cmds::RegisterSharedIdsCHROMIUM::kCmdId),
2713            cmd.header.command);
2714  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2715  EXPECT_EQ(static_cast<GLuint>(11), cmd.namespace_id);
2716  EXPECT_EQ(static_cast<GLsizei>(12), cmd.n);
2717  EXPECT_EQ(static_cast<uint32_t>(13), cmd.ids_shm_id);
2718  EXPECT_EQ(static_cast<uint32_t>(14), cmd.ids_shm_offset);
2719  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2720}
2721
2722TEST_F(GLES2FormatTest, EnableFeatureCHROMIUM) {
2723  cmds::EnableFeatureCHROMIUM& cmd =
2724      *GetBufferAs<cmds::EnableFeatureCHROMIUM>();
2725  void* next_cmd = cmd.Set(&cmd,
2726                           static_cast<GLuint>(11),
2727                           static_cast<uint32_t>(12),
2728                           static_cast<uint32_t>(13));
2729  EXPECT_EQ(static_cast<uint32_t>(cmds::EnableFeatureCHROMIUM::kCmdId),
2730            cmd.header.command);
2731  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2732  EXPECT_EQ(static_cast<GLuint>(11), cmd.bucket_id);
2733  EXPECT_EQ(static_cast<uint32_t>(12), cmd.result_shm_id);
2734  EXPECT_EQ(static_cast<uint32_t>(13), cmd.result_shm_offset);
2735  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2736}
2737
2738TEST_F(GLES2FormatTest, ResizeCHROMIUM) {
2739  cmds::ResizeCHROMIUM& cmd = *GetBufferAs<cmds::ResizeCHROMIUM>();
2740  void* next_cmd = cmd.Set(&cmd,
2741                           static_cast<GLuint>(11),
2742                           static_cast<GLuint>(12),
2743                           static_cast<GLfloat>(13));
2744  EXPECT_EQ(static_cast<uint32_t>(cmds::ResizeCHROMIUM::kCmdId),
2745            cmd.header.command);
2746  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2747  EXPECT_EQ(static_cast<GLuint>(11), cmd.width);
2748  EXPECT_EQ(static_cast<GLuint>(12), cmd.height);
2749  EXPECT_EQ(static_cast<GLfloat>(13), cmd.scale_factor);
2750  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2751}
2752
2753TEST_F(GLES2FormatTest, GetRequestableExtensionsCHROMIUM) {
2754  cmds::GetRequestableExtensionsCHROMIUM& cmd =
2755      *GetBufferAs<cmds::GetRequestableExtensionsCHROMIUM>();
2756  void* next_cmd = cmd.Set(&cmd, static_cast<uint32_t>(11));
2757  EXPECT_EQ(
2758      static_cast<uint32_t>(cmds::GetRequestableExtensionsCHROMIUM::kCmdId),
2759      cmd.header.command);
2760  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2761  EXPECT_EQ(static_cast<uint32_t>(11), cmd.bucket_id);
2762  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2763}
2764
2765TEST_F(GLES2FormatTest, RequestExtensionCHROMIUM) {
2766  cmds::RequestExtensionCHROMIUM& cmd =
2767      *GetBufferAs<cmds::RequestExtensionCHROMIUM>();
2768  void* next_cmd = cmd.Set(&cmd, static_cast<uint32_t>(11));
2769  EXPECT_EQ(static_cast<uint32_t>(cmds::RequestExtensionCHROMIUM::kCmdId),
2770            cmd.header.command);
2771  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2772  EXPECT_EQ(static_cast<uint32_t>(11), cmd.bucket_id);
2773  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2774}
2775
2776TEST_F(GLES2FormatTest, GetMultipleIntegervCHROMIUM) {
2777  cmds::GetMultipleIntegervCHROMIUM& cmd =
2778      *GetBufferAs<cmds::GetMultipleIntegervCHROMIUM>();
2779  void* next_cmd = cmd.Set(&cmd,
2780                           static_cast<uint32_t>(11),
2781                           static_cast<uint32_t>(12),
2782                           static_cast<GLuint>(13),
2783                           static_cast<uint32_t>(14),
2784                           static_cast<uint32_t>(15),
2785                           static_cast<GLsizeiptr>(16));
2786  EXPECT_EQ(static_cast<uint32_t>(cmds::GetMultipleIntegervCHROMIUM::kCmdId),
2787            cmd.header.command);
2788  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2789  EXPECT_EQ(static_cast<uint32_t>(11), cmd.pnames_shm_id);
2790  EXPECT_EQ(static_cast<uint32_t>(12), cmd.pnames_shm_offset);
2791  EXPECT_EQ(static_cast<GLuint>(13), cmd.count);
2792  EXPECT_EQ(static_cast<uint32_t>(14), cmd.results_shm_id);
2793  EXPECT_EQ(static_cast<uint32_t>(15), cmd.results_shm_offset);
2794  EXPECT_EQ(static_cast<GLsizeiptr>(16), cmd.size);
2795  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2796}
2797
2798TEST_F(GLES2FormatTest, GetProgramInfoCHROMIUM) {
2799  cmds::GetProgramInfoCHROMIUM& cmd =
2800      *GetBufferAs<cmds::GetProgramInfoCHROMIUM>();
2801  void* next_cmd =
2802      cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<uint32_t>(12));
2803  EXPECT_EQ(static_cast<uint32_t>(cmds::GetProgramInfoCHROMIUM::kCmdId),
2804            cmd.header.command);
2805  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2806  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
2807  EXPECT_EQ(static_cast<uint32_t>(12), cmd.bucket_id);
2808  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2809}
2810
2811TEST_F(GLES2FormatTest, GetTranslatedShaderSourceANGLE) {
2812  cmds::GetTranslatedShaderSourceANGLE& cmd =
2813      *GetBufferAs<cmds::GetTranslatedShaderSourceANGLE>();
2814  void* next_cmd =
2815      cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<uint32_t>(12));
2816  EXPECT_EQ(static_cast<uint32_t>(cmds::GetTranslatedShaderSourceANGLE::kCmdId),
2817            cmd.header.command);
2818  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2819  EXPECT_EQ(static_cast<GLuint>(11), cmd.shader);
2820  EXPECT_EQ(static_cast<uint32_t>(12), cmd.bucket_id);
2821  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2822}
2823
2824TEST_F(GLES2FormatTest, PostSubBufferCHROMIUM) {
2825  cmds::PostSubBufferCHROMIUM& cmd =
2826      *GetBufferAs<cmds::PostSubBufferCHROMIUM>();
2827  void* next_cmd = cmd.Set(&cmd,
2828                           static_cast<GLint>(11),
2829                           static_cast<GLint>(12),
2830                           static_cast<GLint>(13),
2831                           static_cast<GLint>(14));
2832  EXPECT_EQ(static_cast<uint32_t>(cmds::PostSubBufferCHROMIUM::kCmdId),
2833            cmd.header.command);
2834  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2835  EXPECT_EQ(static_cast<GLint>(11), cmd.x);
2836  EXPECT_EQ(static_cast<GLint>(12), cmd.y);
2837  EXPECT_EQ(static_cast<GLint>(13), cmd.width);
2838  EXPECT_EQ(static_cast<GLint>(14), cmd.height);
2839  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2840}
2841
2842TEST_F(GLES2FormatTest, TexImageIOSurface2DCHROMIUM) {
2843  cmds::TexImageIOSurface2DCHROMIUM& cmd =
2844      *GetBufferAs<cmds::TexImageIOSurface2DCHROMIUM>();
2845  void* next_cmd = cmd.Set(&cmd,
2846                           static_cast<GLenum>(11),
2847                           static_cast<GLsizei>(12),
2848                           static_cast<GLsizei>(13),
2849                           static_cast<GLuint>(14),
2850                           static_cast<GLuint>(15));
2851  EXPECT_EQ(static_cast<uint32_t>(cmds::TexImageIOSurface2DCHROMIUM::kCmdId),
2852            cmd.header.command);
2853  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2854  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
2855  EXPECT_EQ(static_cast<GLsizei>(12), cmd.width);
2856  EXPECT_EQ(static_cast<GLsizei>(13), cmd.height);
2857  EXPECT_EQ(static_cast<GLuint>(14), cmd.ioSurfaceId);
2858  EXPECT_EQ(static_cast<GLuint>(15), cmd.plane);
2859  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2860}
2861
2862TEST_F(GLES2FormatTest, CopyTextureCHROMIUM) {
2863  cmds::CopyTextureCHROMIUM& cmd = *GetBufferAs<cmds::CopyTextureCHROMIUM>();
2864  void* next_cmd = cmd.Set(&cmd,
2865                           static_cast<GLenum>(11),
2866                           static_cast<GLenum>(12),
2867                           static_cast<GLenum>(13),
2868                           static_cast<GLint>(14),
2869                           static_cast<GLint>(15),
2870                           static_cast<GLenum>(16));
2871  EXPECT_EQ(static_cast<uint32_t>(cmds::CopyTextureCHROMIUM::kCmdId),
2872            cmd.header.command);
2873  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2874  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
2875  EXPECT_EQ(static_cast<GLenum>(12), cmd.source_id);
2876  EXPECT_EQ(static_cast<GLenum>(13), cmd.dest_id);
2877  EXPECT_EQ(static_cast<GLint>(14), cmd.level);
2878  EXPECT_EQ(static_cast<GLint>(15), cmd.internalformat);
2879  EXPECT_EQ(static_cast<GLenum>(16), cmd.dest_type);
2880  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2881}
2882
2883TEST_F(GLES2FormatTest, DrawArraysInstancedANGLE) {
2884  cmds::DrawArraysInstancedANGLE& cmd =
2885      *GetBufferAs<cmds::DrawArraysInstancedANGLE>();
2886  void* next_cmd = cmd.Set(&cmd,
2887                           static_cast<GLenum>(11),
2888                           static_cast<GLint>(12),
2889                           static_cast<GLsizei>(13),
2890                           static_cast<GLsizei>(14));
2891  EXPECT_EQ(static_cast<uint32_t>(cmds::DrawArraysInstancedANGLE::kCmdId),
2892            cmd.header.command);
2893  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2894  EXPECT_EQ(static_cast<GLenum>(11), cmd.mode);
2895  EXPECT_EQ(static_cast<GLint>(12), cmd.first);
2896  EXPECT_EQ(static_cast<GLsizei>(13), cmd.count);
2897  EXPECT_EQ(static_cast<GLsizei>(14), cmd.primcount);
2898  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2899}
2900
2901TEST_F(GLES2FormatTest, DrawElementsInstancedANGLE) {
2902  cmds::DrawElementsInstancedANGLE& cmd =
2903      *GetBufferAs<cmds::DrawElementsInstancedANGLE>();
2904  void* next_cmd = cmd.Set(&cmd,
2905                           static_cast<GLenum>(11),
2906                           static_cast<GLsizei>(12),
2907                           static_cast<GLenum>(13),
2908                           static_cast<GLuint>(14),
2909                           static_cast<GLsizei>(15));
2910  EXPECT_EQ(static_cast<uint32_t>(cmds::DrawElementsInstancedANGLE::kCmdId),
2911            cmd.header.command);
2912  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2913  EXPECT_EQ(static_cast<GLenum>(11), cmd.mode);
2914  EXPECT_EQ(static_cast<GLsizei>(12), cmd.count);
2915  EXPECT_EQ(static_cast<GLenum>(13), cmd.type);
2916  EXPECT_EQ(static_cast<GLuint>(14), cmd.index_offset);
2917  EXPECT_EQ(static_cast<GLsizei>(15), cmd.primcount);
2918  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2919}
2920
2921TEST_F(GLES2FormatTest, VertexAttribDivisorANGLE) {
2922  cmds::VertexAttribDivisorANGLE& cmd =
2923      *GetBufferAs<cmds::VertexAttribDivisorANGLE>();
2924  void* next_cmd =
2925      cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLuint>(12));
2926  EXPECT_EQ(static_cast<uint32_t>(cmds::VertexAttribDivisorANGLE::kCmdId),
2927            cmd.header.command);
2928  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
2929  EXPECT_EQ(static_cast<GLuint>(11), cmd.index);
2930  EXPECT_EQ(static_cast<GLuint>(12), cmd.divisor);
2931  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
2932}
2933
2934// TODO(gman): Write test for GenMailboxCHROMIUM
2935TEST_F(GLES2FormatTest, ProduceTextureCHROMIUMImmediate) {
2936  const int kSomeBaseValueToTestWith = 51;
2937  static GLbyte data[] = {
2938      static_cast<GLbyte>(kSomeBaseValueToTestWith + 0),
2939      static_cast<GLbyte>(kSomeBaseValueToTestWith + 1),
2940      static_cast<GLbyte>(kSomeBaseValueToTestWith + 2),
2941      static_cast<GLbyte>(kSomeBaseValueToTestWith + 3),
2942      static_cast<GLbyte>(kSomeBaseValueToTestWith + 4),
2943      static_cast<GLbyte>(kSomeBaseValueToTestWith + 5),
2944      static_cast<GLbyte>(kSomeBaseValueToTestWith + 6),
2945      static_cast<GLbyte>(kSomeBaseValueToTestWith + 7),
2946      static_cast<GLbyte>(kSomeBaseValueToTestWith + 8),
2947      static_cast<GLbyte>(kSomeBaseValueToTestWith + 9),
2948      static_cast<GLbyte>(kSomeBaseValueToTestWith + 10),
2949      static_cast<GLbyte>(kSomeBaseValueToTestWith + 11),
2950      static_cast<GLbyte>(kSomeBaseValueToTestWith + 12),
2951      static_cast<GLbyte>(kSomeBaseValueToTestWith + 13),
2952      static_cast<GLbyte>(kSomeBaseValueToTestWith + 14),
2953      static_cast<GLbyte>(kSomeBaseValueToTestWith + 15),
2954      static_cast<GLbyte>(kSomeBaseValueToTestWith + 16),
2955      static_cast<GLbyte>(kSomeBaseValueToTestWith + 17),
2956      static_cast<GLbyte>(kSomeBaseValueToTestWith + 18),
2957      static_cast<GLbyte>(kSomeBaseValueToTestWith + 19),
2958      static_cast<GLbyte>(kSomeBaseValueToTestWith + 20),
2959      static_cast<GLbyte>(kSomeBaseValueToTestWith + 21),
2960      static_cast<GLbyte>(kSomeBaseValueToTestWith + 22),
2961      static_cast<GLbyte>(kSomeBaseValueToTestWith + 23),
2962      static_cast<GLbyte>(kSomeBaseValueToTestWith + 24),
2963      static_cast<GLbyte>(kSomeBaseValueToTestWith + 25),
2964      static_cast<GLbyte>(kSomeBaseValueToTestWith + 26),
2965      static_cast<GLbyte>(kSomeBaseValueToTestWith + 27),
2966      static_cast<GLbyte>(kSomeBaseValueToTestWith + 28),
2967      static_cast<GLbyte>(kSomeBaseValueToTestWith + 29),
2968      static_cast<GLbyte>(kSomeBaseValueToTestWith + 30),
2969      static_cast<GLbyte>(kSomeBaseValueToTestWith + 31),
2970      static_cast<GLbyte>(kSomeBaseValueToTestWith + 32),
2971      static_cast<GLbyte>(kSomeBaseValueToTestWith + 33),
2972      static_cast<GLbyte>(kSomeBaseValueToTestWith + 34),
2973      static_cast<GLbyte>(kSomeBaseValueToTestWith + 35),
2974      static_cast<GLbyte>(kSomeBaseValueToTestWith + 36),
2975      static_cast<GLbyte>(kSomeBaseValueToTestWith + 37),
2976      static_cast<GLbyte>(kSomeBaseValueToTestWith + 38),
2977      static_cast<GLbyte>(kSomeBaseValueToTestWith + 39),
2978      static_cast<GLbyte>(kSomeBaseValueToTestWith + 40),
2979      static_cast<GLbyte>(kSomeBaseValueToTestWith + 41),
2980      static_cast<GLbyte>(kSomeBaseValueToTestWith + 42),
2981      static_cast<GLbyte>(kSomeBaseValueToTestWith + 43),
2982      static_cast<GLbyte>(kSomeBaseValueToTestWith + 44),
2983      static_cast<GLbyte>(kSomeBaseValueToTestWith + 45),
2984      static_cast<GLbyte>(kSomeBaseValueToTestWith + 46),
2985      static_cast<GLbyte>(kSomeBaseValueToTestWith + 47),
2986      static_cast<GLbyte>(kSomeBaseValueToTestWith + 48),
2987      static_cast<GLbyte>(kSomeBaseValueToTestWith + 49),
2988      static_cast<GLbyte>(kSomeBaseValueToTestWith + 50),
2989      static_cast<GLbyte>(kSomeBaseValueToTestWith + 51),
2990      static_cast<GLbyte>(kSomeBaseValueToTestWith + 52),
2991      static_cast<GLbyte>(kSomeBaseValueToTestWith + 53),
2992      static_cast<GLbyte>(kSomeBaseValueToTestWith + 54),
2993      static_cast<GLbyte>(kSomeBaseValueToTestWith + 55),
2994      static_cast<GLbyte>(kSomeBaseValueToTestWith + 56),
2995      static_cast<GLbyte>(kSomeBaseValueToTestWith + 57),
2996      static_cast<GLbyte>(kSomeBaseValueToTestWith + 58),
2997      static_cast<GLbyte>(kSomeBaseValueToTestWith + 59),
2998      static_cast<GLbyte>(kSomeBaseValueToTestWith + 60),
2999      static_cast<GLbyte>(kSomeBaseValueToTestWith + 61),
3000      static_cast<GLbyte>(kSomeBaseValueToTestWith + 62),
3001      static_cast<GLbyte>(kSomeBaseValueToTestWith + 63),
3002  };
3003  cmds::ProduceTextureCHROMIUMImmediate& cmd =
3004      *GetBufferAs<cmds::ProduceTextureCHROMIUMImmediate>();
3005  void* next_cmd = cmd.Set(&cmd, static_cast<GLenum>(11), data);
3006  EXPECT_EQ(
3007      static_cast<uint32_t>(cmds::ProduceTextureCHROMIUMImmediate::kCmdId),
3008      cmd.header.command);
3009  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
3010            cmd.header.size * 4u);
3011  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
3012  CheckBytesWrittenMatchesExpectedSize(
3013      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
3014  // TODO(gman): Check that data was inserted;
3015}
3016
3017TEST_F(GLES2FormatTest, ProduceTextureDirectCHROMIUMImmediate) {
3018  const int kSomeBaseValueToTestWith = 51;
3019  static GLbyte data[] = {
3020      static_cast<GLbyte>(kSomeBaseValueToTestWith + 0),
3021      static_cast<GLbyte>(kSomeBaseValueToTestWith + 1),
3022      static_cast<GLbyte>(kSomeBaseValueToTestWith + 2),
3023      static_cast<GLbyte>(kSomeBaseValueToTestWith + 3),
3024      static_cast<GLbyte>(kSomeBaseValueToTestWith + 4),
3025      static_cast<GLbyte>(kSomeBaseValueToTestWith + 5),
3026      static_cast<GLbyte>(kSomeBaseValueToTestWith + 6),
3027      static_cast<GLbyte>(kSomeBaseValueToTestWith + 7),
3028      static_cast<GLbyte>(kSomeBaseValueToTestWith + 8),
3029      static_cast<GLbyte>(kSomeBaseValueToTestWith + 9),
3030      static_cast<GLbyte>(kSomeBaseValueToTestWith + 10),
3031      static_cast<GLbyte>(kSomeBaseValueToTestWith + 11),
3032      static_cast<GLbyte>(kSomeBaseValueToTestWith + 12),
3033      static_cast<GLbyte>(kSomeBaseValueToTestWith + 13),
3034      static_cast<GLbyte>(kSomeBaseValueToTestWith + 14),
3035      static_cast<GLbyte>(kSomeBaseValueToTestWith + 15),
3036      static_cast<GLbyte>(kSomeBaseValueToTestWith + 16),
3037      static_cast<GLbyte>(kSomeBaseValueToTestWith + 17),
3038      static_cast<GLbyte>(kSomeBaseValueToTestWith + 18),
3039      static_cast<GLbyte>(kSomeBaseValueToTestWith + 19),
3040      static_cast<GLbyte>(kSomeBaseValueToTestWith + 20),
3041      static_cast<GLbyte>(kSomeBaseValueToTestWith + 21),
3042      static_cast<GLbyte>(kSomeBaseValueToTestWith + 22),
3043      static_cast<GLbyte>(kSomeBaseValueToTestWith + 23),
3044      static_cast<GLbyte>(kSomeBaseValueToTestWith + 24),
3045      static_cast<GLbyte>(kSomeBaseValueToTestWith + 25),
3046      static_cast<GLbyte>(kSomeBaseValueToTestWith + 26),
3047      static_cast<GLbyte>(kSomeBaseValueToTestWith + 27),
3048      static_cast<GLbyte>(kSomeBaseValueToTestWith + 28),
3049      static_cast<GLbyte>(kSomeBaseValueToTestWith + 29),
3050      static_cast<GLbyte>(kSomeBaseValueToTestWith + 30),
3051      static_cast<GLbyte>(kSomeBaseValueToTestWith + 31),
3052      static_cast<GLbyte>(kSomeBaseValueToTestWith + 32),
3053      static_cast<GLbyte>(kSomeBaseValueToTestWith + 33),
3054      static_cast<GLbyte>(kSomeBaseValueToTestWith + 34),
3055      static_cast<GLbyte>(kSomeBaseValueToTestWith + 35),
3056      static_cast<GLbyte>(kSomeBaseValueToTestWith + 36),
3057      static_cast<GLbyte>(kSomeBaseValueToTestWith + 37),
3058      static_cast<GLbyte>(kSomeBaseValueToTestWith + 38),
3059      static_cast<GLbyte>(kSomeBaseValueToTestWith + 39),
3060      static_cast<GLbyte>(kSomeBaseValueToTestWith + 40),
3061      static_cast<GLbyte>(kSomeBaseValueToTestWith + 41),
3062      static_cast<GLbyte>(kSomeBaseValueToTestWith + 42),
3063      static_cast<GLbyte>(kSomeBaseValueToTestWith + 43),
3064      static_cast<GLbyte>(kSomeBaseValueToTestWith + 44),
3065      static_cast<GLbyte>(kSomeBaseValueToTestWith + 45),
3066      static_cast<GLbyte>(kSomeBaseValueToTestWith + 46),
3067      static_cast<GLbyte>(kSomeBaseValueToTestWith + 47),
3068      static_cast<GLbyte>(kSomeBaseValueToTestWith + 48),
3069      static_cast<GLbyte>(kSomeBaseValueToTestWith + 49),
3070      static_cast<GLbyte>(kSomeBaseValueToTestWith + 50),
3071      static_cast<GLbyte>(kSomeBaseValueToTestWith + 51),
3072      static_cast<GLbyte>(kSomeBaseValueToTestWith + 52),
3073      static_cast<GLbyte>(kSomeBaseValueToTestWith + 53),
3074      static_cast<GLbyte>(kSomeBaseValueToTestWith + 54),
3075      static_cast<GLbyte>(kSomeBaseValueToTestWith + 55),
3076      static_cast<GLbyte>(kSomeBaseValueToTestWith + 56),
3077      static_cast<GLbyte>(kSomeBaseValueToTestWith + 57),
3078      static_cast<GLbyte>(kSomeBaseValueToTestWith + 58),
3079      static_cast<GLbyte>(kSomeBaseValueToTestWith + 59),
3080      static_cast<GLbyte>(kSomeBaseValueToTestWith + 60),
3081      static_cast<GLbyte>(kSomeBaseValueToTestWith + 61),
3082      static_cast<GLbyte>(kSomeBaseValueToTestWith + 62),
3083      static_cast<GLbyte>(kSomeBaseValueToTestWith + 63),
3084  };
3085  cmds::ProduceTextureDirectCHROMIUMImmediate& cmd =
3086      *GetBufferAs<cmds::ProduceTextureDirectCHROMIUMImmediate>();
3087  void* next_cmd =
3088      cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLenum>(12), data);
3089  EXPECT_EQ(static_cast<uint32_t>(
3090                cmds::ProduceTextureDirectCHROMIUMImmediate::kCmdId),
3091            cmd.header.command);
3092  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
3093            cmd.header.size * 4u);
3094  EXPECT_EQ(static_cast<GLuint>(11), cmd.texture);
3095  EXPECT_EQ(static_cast<GLenum>(12), cmd.target);
3096  CheckBytesWrittenMatchesExpectedSize(
3097      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
3098  // TODO(gman): Check that data was inserted;
3099}
3100
3101TEST_F(GLES2FormatTest, ConsumeTextureCHROMIUMImmediate) {
3102  const int kSomeBaseValueToTestWith = 51;
3103  static GLbyte data[] = {
3104      static_cast<GLbyte>(kSomeBaseValueToTestWith + 0),
3105      static_cast<GLbyte>(kSomeBaseValueToTestWith + 1),
3106      static_cast<GLbyte>(kSomeBaseValueToTestWith + 2),
3107      static_cast<GLbyte>(kSomeBaseValueToTestWith + 3),
3108      static_cast<GLbyte>(kSomeBaseValueToTestWith + 4),
3109      static_cast<GLbyte>(kSomeBaseValueToTestWith + 5),
3110      static_cast<GLbyte>(kSomeBaseValueToTestWith + 6),
3111      static_cast<GLbyte>(kSomeBaseValueToTestWith + 7),
3112      static_cast<GLbyte>(kSomeBaseValueToTestWith + 8),
3113      static_cast<GLbyte>(kSomeBaseValueToTestWith + 9),
3114      static_cast<GLbyte>(kSomeBaseValueToTestWith + 10),
3115      static_cast<GLbyte>(kSomeBaseValueToTestWith + 11),
3116      static_cast<GLbyte>(kSomeBaseValueToTestWith + 12),
3117      static_cast<GLbyte>(kSomeBaseValueToTestWith + 13),
3118      static_cast<GLbyte>(kSomeBaseValueToTestWith + 14),
3119      static_cast<GLbyte>(kSomeBaseValueToTestWith + 15),
3120      static_cast<GLbyte>(kSomeBaseValueToTestWith + 16),
3121      static_cast<GLbyte>(kSomeBaseValueToTestWith + 17),
3122      static_cast<GLbyte>(kSomeBaseValueToTestWith + 18),
3123      static_cast<GLbyte>(kSomeBaseValueToTestWith + 19),
3124      static_cast<GLbyte>(kSomeBaseValueToTestWith + 20),
3125      static_cast<GLbyte>(kSomeBaseValueToTestWith + 21),
3126      static_cast<GLbyte>(kSomeBaseValueToTestWith + 22),
3127      static_cast<GLbyte>(kSomeBaseValueToTestWith + 23),
3128      static_cast<GLbyte>(kSomeBaseValueToTestWith + 24),
3129      static_cast<GLbyte>(kSomeBaseValueToTestWith + 25),
3130      static_cast<GLbyte>(kSomeBaseValueToTestWith + 26),
3131      static_cast<GLbyte>(kSomeBaseValueToTestWith + 27),
3132      static_cast<GLbyte>(kSomeBaseValueToTestWith + 28),
3133      static_cast<GLbyte>(kSomeBaseValueToTestWith + 29),
3134      static_cast<GLbyte>(kSomeBaseValueToTestWith + 30),
3135      static_cast<GLbyte>(kSomeBaseValueToTestWith + 31),
3136      static_cast<GLbyte>(kSomeBaseValueToTestWith + 32),
3137      static_cast<GLbyte>(kSomeBaseValueToTestWith + 33),
3138      static_cast<GLbyte>(kSomeBaseValueToTestWith + 34),
3139      static_cast<GLbyte>(kSomeBaseValueToTestWith + 35),
3140      static_cast<GLbyte>(kSomeBaseValueToTestWith + 36),
3141      static_cast<GLbyte>(kSomeBaseValueToTestWith + 37),
3142      static_cast<GLbyte>(kSomeBaseValueToTestWith + 38),
3143      static_cast<GLbyte>(kSomeBaseValueToTestWith + 39),
3144      static_cast<GLbyte>(kSomeBaseValueToTestWith + 40),
3145      static_cast<GLbyte>(kSomeBaseValueToTestWith + 41),
3146      static_cast<GLbyte>(kSomeBaseValueToTestWith + 42),
3147      static_cast<GLbyte>(kSomeBaseValueToTestWith + 43),
3148      static_cast<GLbyte>(kSomeBaseValueToTestWith + 44),
3149      static_cast<GLbyte>(kSomeBaseValueToTestWith + 45),
3150      static_cast<GLbyte>(kSomeBaseValueToTestWith + 46),
3151      static_cast<GLbyte>(kSomeBaseValueToTestWith + 47),
3152      static_cast<GLbyte>(kSomeBaseValueToTestWith + 48),
3153      static_cast<GLbyte>(kSomeBaseValueToTestWith + 49),
3154      static_cast<GLbyte>(kSomeBaseValueToTestWith + 50),
3155      static_cast<GLbyte>(kSomeBaseValueToTestWith + 51),
3156      static_cast<GLbyte>(kSomeBaseValueToTestWith + 52),
3157      static_cast<GLbyte>(kSomeBaseValueToTestWith + 53),
3158      static_cast<GLbyte>(kSomeBaseValueToTestWith + 54),
3159      static_cast<GLbyte>(kSomeBaseValueToTestWith + 55),
3160      static_cast<GLbyte>(kSomeBaseValueToTestWith + 56),
3161      static_cast<GLbyte>(kSomeBaseValueToTestWith + 57),
3162      static_cast<GLbyte>(kSomeBaseValueToTestWith + 58),
3163      static_cast<GLbyte>(kSomeBaseValueToTestWith + 59),
3164      static_cast<GLbyte>(kSomeBaseValueToTestWith + 60),
3165      static_cast<GLbyte>(kSomeBaseValueToTestWith + 61),
3166      static_cast<GLbyte>(kSomeBaseValueToTestWith + 62),
3167      static_cast<GLbyte>(kSomeBaseValueToTestWith + 63),
3168  };
3169  cmds::ConsumeTextureCHROMIUMImmediate& cmd =
3170      *GetBufferAs<cmds::ConsumeTextureCHROMIUMImmediate>();
3171  void* next_cmd = cmd.Set(&cmd, static_cast<GLenum>(11), data);
3172  EXPECT_EQ(
3173      static_cast<uint32_t>(cmds::ConsumeTextureCHROMIUMImmediate::kCmdId),
3174      cmd.header.command);
3175  EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
3176            cmd.header.size * 4u);
3177  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
3178  CheckBytesWrittenMatchesExpectedSize(
3179      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
3180  // TODO(gman): Check that data was inserted;
3181}
3182
3183// TODO(gman): Write test for CreateAndConsumeTextureCHROMIUMImmediate
3184TEST_F(GLES2FormatTest, BindUniformLocationCHROMIUMBucket) {
3185  cmds::BindUniformLocationCHROMIUMBucket& cmd =
3186      *GetBufferAs<cmds::BindUniformLocationCHROMIUMBucket>();
3187  void* next_cmd = cmd.Set(&cmd,
3188                           static_cast<GLuint>(11),
3189                           static_cast<GLint>(12),
3190                           static_cast<uint32_t>(13));
3191  EXPECT_EQ(
3192      static_cast<uint32_t>(cmds::BindUniformLocationCHROMIUMBucket::kCmdId),
3193      cmd.header.command);
3194  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
3195  EXPECT_EQ(static_cast<GLuint>(11), cmd.program);
3196  EXPECT_EQ(static_cast<GLint>(12), cmd.location);
3197  EXPECT_EQ(static_cast<uint32_t>(13), cmd.name_bucket_id);
3198  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
3199}
3200
3201TEST_F(GLES2FormatTest, BindTexImage2DCHROMIUM) {
3202  cmds::BindTexImage2DCHROMIUM& cmd =
3203      *GetBufferAs<cmds::BindTexImage2DCHROMIUM>();
3204  void* next_cmd =
3205      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLint>(12));
3206  EXPECT_EQ(static_cast<uint32_t>(cmds::BindTexImage2DCHROMIUM::kCmdId),
3207            cmd.header.command);
3208  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
3209  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
3210  EXPECT_EQ(static_cast<GLint>(12), cmd.imageId);
3211  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
3212}
3213
3214TEST_F(GLES2FormatTest, ReleaseTexImage2DCHROMIUM) {
3215  cmds::ReleaseTexImage2DCHROMIUM& cmd =
3216      *GetBufferAs<cmds::ReleaseTexImage2DCHROMIUM>();
3217  void* next_cmd =
3218      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLint>(12));
3219  EXPECT_EQ(static_cast<uint32_t>(cmds::ReleaseTexImage2DCHROMIUM::kCmdId),
3220            cmd.header.command);
3221  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
3222  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
3223  EXPECT_EQ(static_cast<GLint>(12), cmd.imageId);
3224  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
3225}
3226
3227TEST_F(GLES2FormatTest, TraceBeginCHROMIUM) {
3228  cmds::TraceBeginCHROMIUM& cmd = *GetBufferAs<cmds::TraceBeginCHROMIUM>();
3229  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
3230  EXPECT_EQ(static_cast<uint32_t>(cmds::TraceBeginCHROMIUM::kCmdId),
3231            cmd.header.command);
3232  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
3233  EXPECT_EQ(static_cast<GLuint>(11), cmd.bucket_id);
3234  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
3235}
3236
3237TEST_F(GLES2FormatTest, TraceEndCHROMIUM) {
3238  cmds::TraceEndCHROMIUM& cmd = *GetBufferAs<cmds::TraceEndCHROMIUM>();
3239  void* next_cmd = cmd.Set(&cmd);
3240  EXPECT_EQ(static_cast<uint32_t>(cmds::TraceEndCHROMIUM::kCmdId),
3241            cmd.header.command);
3242  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
3243  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
3244}
3245
3246TEST_F(GLES2FormatTest, AsyncTexSubImage2DCHROMIUM) {
3247  cmds::AsyncTexSubImage2DCHROMIUM& cmd =
3248      *GetBufferAs<cmds::AsyncTexSubImage2DCHROMIUM>();
3249  void* next_cmd = cmd.Set(&cmd,
3250                           static_cast<GLenum>(11),
3251                           static_cast<GLint>(12),
3252                           static_cast<GLint>(13),
3253                           static_cast<GLint>(14),
3254                           static_cast<GLsizei>(15),
3255                           static_cast<GLsizei>(16),
3256                           static_cast<GLenum>(17),
3257                           static_cast<GLenum>(18),
3258                           static_cast<uint32_t>(19),
3259                           static_cast<uint32_t>(20),
3260                           static_cast<uint32_t>(21),
3261                           static_cast<uint32_t>(22),
3262                           static_cast<uint32_t>(23));
3263  EXPECT_EQ(static_cast<uint32_t>(cmds::AsyncTexSubImage2DCHROMIUM::kCmdId),
3264            cmd.header.command);
3265  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
3266  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
3267  EXPECT_EQ(static_cast<GLint>(12), cmd.level);
3268  EXPECT_EQ(static_cast<GLint>(13), cmd.xoffset);
3269  EXPECT_EQ(static_cast<GLint>(14), cmd.yoffset);
3270  EXPECT_EQ(static_cast<GLsizei>(15), cmd.width);
3271  EXPECT_EQ(static_cast<GLsizei>(16), cmd.height);
3272  EXPECT_EQ(static_cast<GLenum>(17), cmd.format);
3273  EXPECT_EQ(static_cast<GLenum>(18), cmd.type);
3274  EXPECT_EQ(static_cast<uint32_t>(19), cmd.data_shm_id);
3275  EXPECT_EQ(static_cast<uint32_t>(20), cmd.data_shm_offset);
3276  EXPECT_EQ(static_cast<uint32_t>(21), cmd.async_upload_token);
3277  EXPECT_EQ(static_cast<uint32_t>(22), cmd.sync_data_shm_id);
3278  EXPECT_EQ(static_cast<uint32_t>(23), cmd.sync_data_shm_offset);
3279  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
3280}
3281
3282TEST_F(GLES2FormatTest, AsyncTexImage2DCHROMIUM) {
3283  cmds::AsyncTexImage2DCHROMIUM& cmd =
3284      *GetBufferAs<cmds::AsyncTexImage2DCHROMIUM>();
3285  void* next_cmd = cmd.Set(&cmd,
3286                           static_cast<GLenum>(11),
3287                           static_cast<GLint>(12),
3288                           static_cast<GLint>(13),
3289                           static_cast<GLsizei>(14),
3290                           static_cast<GLsizei>(15),
3291                           static_cast<GLenum>(16),
3292                           static_cast<GLenum>(17),
3293                           static_cast<uint32_t>(18),
3294                           static_cast<uint32_t>(19),
3295                           static_cast<uint32_t>(20),
3296                           static_cast<uint32_t>(21),
3297                           static_cast<uint32_t>(22));
3298  EXPECT_EQ(static_cast<uint32_t>(cmds::AsyncTexImage2DCHROMIUM::kCmdId),
3299            cmd.header.command);
3300  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
3301  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
3302  EXPECT_EQ(static_cast<GLint>(12), cmd.level);
3303  EXPECT_EQ(static_cast<GLint>(13), cmd.internalformat);
3304  EXPECT_EQ(static_cast<GLsizei>(14), cmd.width);
3305  EXPECT_EQ(static_cast<GLsizei>(15), cmd.height);
3306  EXPECT_EQ(static_cast<GLenum>(16), cmd.format);
3307  EXPECT_EQ(static_cast<GLenum>(17), cmd.type);
3308  EXPECT_EQ(static_cast<uint32_t>(18), cmd.pixels_shm_id);
3309  EXPECT_EQ(static_cast<uint32_t>(19), cmd.pixels_shm_offset);
3310  EXPECT_EQ(static_cast<uint32_t>(20), cmd.async_upload_token);
3311  EXPECT_EQ(static_cast<uint32_t>(21), cmd.sync_data_shm_id);
3312  EXPECT_EQ(static_cast<uint32_t>(22), cmd.sync_data_shm_offset);
3313  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
3314}
3315
3316TEST_F(GLES2FormatTest, WaitAsyncTexImage2DCHROMIUM) {
3317  cmds::WaitAsyncTexImage2DCHROMIUM& cmd =
3318      *GetBufferAs<cmds::WaitAsyncTexImage2DCHROMIUM>();
3319  void* next_cmd = cmd.Set(&cmd, static_cast<GLenum>(11));
3320  EXPECT_EQ(static_cast<uint32_t>(cmds::WaitAsyncTexImage2DCHROMIUM::kCmdId),
3321            cmd.header.command);
3322  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
3323  EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
3324  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
3325}
3326
3327TEST_F(GLES2FormatTest, WaitAllAsyncTexImage2DCHROMIUM) {
3328  cmds::WaitAllAsyncTexImage2DCHROMIUM& cmd =
3329      *GetBufferAs<cmds::WaitAllAsyncTexImage2DCHROMIUM>();
3330  void* next_cmd = cmd.Set(&cmd);
3331  EXPECT_EQ(static_cast<uint32_t>(cmds::WaitAllAsyncTexImage2DCHROMIUM::kCmdId),
3332            cmd.header.command);
3333  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
3334  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
3335}
3336
3337TEST_F(GLES2FormatTest, DiscardFramebufferEXTImmediate) {
3338  const int kSomeBaseValueToTestWith = 51;
3339  static GLenum data[] = {
3340      static_cast<GLenum>(kSomeBaseValueToTestWith + 0),
3341      static_cast<GLenum>(kSomeBaseValueToTestWith + 1),
3342  };
3343  cmds::DiscardFramebufferEXTImmediate& cmd =
3344      *GetBufferAs<cmds::DiscardFramebufferEXTImmediate>();
3345  const GLsizei kNumElements = 2;
3346  const size_t kExpectedCmdSize =
3347      sizeof(cmd) + kNumElements * sizeof(GLenum) * 1;
3348  void* next_cmd =
3349      cmd.Set(&cmd, static_cast<GLenum>(1), static_cast<GLsizei>(2), data);
3350  EXPECT_EQ(static_cast<uint32_t>(cmds::DiscardFramebufferEXTImmediate::kCmdId),
3351            cmd.header.command);
3352  EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);
3353  EXPECT_EQ(static_cast<GLenum>(1), cmd.target);
3354  EXPECT_EQ(static_cast<GLsizei>(2), cmd.count);
3355  CheckBytesWrittenMatchesExpectedSize(
3356      next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
3357  // TODO(gman): Check that data was inserted;
3358}
3359
3360TEST_F(GLES2FormatTest, LoseContextCHROMIUM) {
3361  cmds::LoseContextCHROMIUM& cmd = *GetBufferAs<cmds::LoseContextCHROMIUM>();
3362  void* next_cmd =
3363      cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLenum>(12));
3364  EXPECT_EQ(static_cast<uint32_t>(cmds::LoseContextCHROMIUM::kCmdId),
3365            cmd.header.command);
3366  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
3367  EXPECT_EQ(static_cast<GLenum>(11), cmd.current);
3368  EXPECT_EQ(static_cast<GLenum>(12), cmd.other);
3369  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
3370}
3371
3372// TODO(gman): Write test for InsertSyncPointCHROMIUM
3373TEST_F(GLES2FormatTest, WaitSyncPointCHROMIUM) {
3374  cmds::WaitSyncPointCHROMIUM& cmd =
3375      *GetBufferAs<cmds::WaitSyncPointCHROMIUM>();
3376  void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
3377  EXPECT_EQ(static_cast<uint32_t>(cmds::WaitSyncPointCHROMIUM::kCmdId),
3378            cmd.header.command);
3379  EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
3380  EXPECT_EQ(static_cast<GLuint>(11), cmd.sync_point);
3381  CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
3382}
3383
3384TEST_F(GLES2FormatTest, DrawBuffersEXTImmediate) {
3385  const int kSomeBaseValueToTestWith = 51;
3386  static GLenum data[] = {
3387      static_cast<GLenum>(kSomeBaseValueToTestWith + 0),
3388  };
3389  cmds::DrawBuffersEXTImmediate& cmd =
3390      *