James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // This file is auto-generated from |
| 6 | // gpu/command_buffer/build_gles2_cmd_buffer.py |
| 7 | // It's formatted by clang-format using chromium coding style: |
| 8 | // clang-format -i -style=chromium filename |
| 9 | // DO NOT EDIT! |
| 10 | |
| 11 | // This file is included by gles2_implementation.h to declare the |
| 12 | // GL api functions. |
| 13 | #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_ |
| 14 | #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_ |
| 15 | |
| 16 | TEST_F(GLES2ImplementationTest, AttachShader) { |
| 17 | struct Cmds { |
| 18 | cmds::AttachShader cmd; |
| 19 | }; |
| 20 | Cmds expected; |
| 21 | expected.cmd.Init(1, 2); |
| 22 | |
| 23 | gl_->AttachShader(1, 2); |
| 24 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 25 | } |
| 26 | // TODO: Implement unit test for BindAttribLocation |
| 27 | |
| 28 | TEST_F(GLES2ImplementationTest, BindBuffer) { |
| 29 | struct Cmds { |
| 30 | cmds::BindBuffer cmd; |
| 31 | }; |
| 32 | Cmds expected; |
| 33 | expected.cmd.Init(GL_ARRAY_BUFFER, 2); |
| 34 | |
| 35 | gl_->BindBuffer(GL_ARRAY_BUFFER, 2); |
| 36 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 37 | ClearCommands(); |
| 38 | gl_->BindBuffer(GL_ARRAY_BUFFER, 2); |
| 39 | EXPECT_TRUE(NoCommandsWritten()); |
| 40 | } |
| 41 | |
James Robinson | d753aca | 2015-01-12 13:07:20 -0800 | [diff] [blame] | 42 | TEST_F(GLES2ImplementationTest, BindBufferBase) { |
| 43 | struct Cmds { |
| 44 | cmds::BindBufferBase cmd; |
| 45 | }; |
| 46 | Cmds expected; |
| 47 | expected.cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3); |
| 48 | |
| 49 | gl_->BindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3); |
| 50 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 51 | } |
| 52 | |
Etienne Membrives | 18cca09 | 2015-01-14 00:46:18 +0100 | [diff] [blame] | 53 | TEST_F(GLES2ImplementationTest, BindBufferRange) { |
| 54 | struct Cmds { |
| 55 | cmds::BindBufferRange cmd; |
| 56 | }; |
| 57 | Cmds expected; |
| 58 | expected.cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3, 4, 5); |
| 59 | |
| 60 | gl_->BindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3, 4, 5); |
| 61 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 62 | } |
| 63 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 64 | TEST_F(GLES2ImplementationTest, BindFramebuffer) { |
| 65 | struct Cmds { |
| 66 | cmds::BindFramebuffer cmd; |
| 67 | }; |
| 68 | Cmds expected; |
| 69 | expected.cmd.Init(GL_FRAMEBUFFER, 2); |
| 70 | |
| 71 | gl_->BindFramebuffer(GL_FRAMEBUFFER, 2); |
| 72 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 73 | ClearCommands(); |
| 74 | gl_->BindFramebuffer(GL_FRAMEBUFFER, 2); |
| 75 | EXPECT_TRUE(NoCommandsWritten()); |
| 76 | } |
| 77 | |
| 78 | TEST_F(GLES2ImplementationTest, BindRenderbuffer) { |
| 79 | struct Cmds { |
| 80 | cmds::BindRenderbuffer cmd; |
| 81 | }; |
| 82 | Cmds expected; |
| 83 | expected.cmd.Init(GL_RENDERBUFFER, 2); |
| 84 | |
| 85 | gl_->BindRenderbuffer(GL_RENDERBUFFER, 2); |
| 86 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 87 | ClearCommands(); |
| 88 | gl_->BindRenderbuffer(GL_RENDERBUFFER, 2); |
| 89 | EXPECT_TRUE(NoCommandsWritten()); |
| 90 | } |
| 91 | |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 92 | TEST_F(GLES2ImplementationTest, BindSampler) { |
| 93 | struct Cmds { |
| 94 | cmds::BindSampler cmd; |
| 95 | }; |
| 96 | Cmds expected; |
| 97 | expected.cmd.Init(1, 2); |
| 98 | |
| 99 | gl_->BindSampler(1, 2); |
| 100 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 101 | } |
| 102 | |
| 103 | TEST_F(GLES2ImplementationTest, BindTransformFeedback) { |
| 104 | struct Cmds { |
| 105 | cmds::BindTransformFeedback cmd; |
| 106 | }; |
| 107 | Cmds expected; |
| 108 | expected.cmd.Init(GL_TRANSFORM_FEEDBACK, 2); |
| 109 | |
| 110 | gl_->BindTransformFeedback(GL_TRANSFORM_FEEDBACK, 2); |
| 111 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 112 | } |
| 113 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 114 | TEST_F(GLES2ImplementationTest, BlendColor) { |
| 115 | struct Cmds { |
| 116 | cmds::BlendColor cmd; |
| 117 | }; |
| 118 | Cmds expected; |
| 119 | expected.cmd.Init(1, 2, 3, 4); |
| 120 | |
| 121 | gl_->BlendColor(1, 2, 3, 4); |
| 122 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 123 | } |
| 124 | |
| 125 | TEST_F(GLES2ImplementationTest, BlendEquation) { |
| 126 | struct Cmds { |
| 127 | cmds::BlendEquation cmd; |
| 128 | }; |
| 129 | Cmds expected; |
| 130 | expected.cmd.Init(GL_FUNC_SUBTRACT); |
| 131 | |
| 132 | gl_->BlendEquation(GL_FUNC_SUBTRACT); |
| 133 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 134 | } |
| 135 | |
| 136 | TEST_F(GLES2ImplementationTest, BlendEquationSeparate) { |
| 137 | struct Cmds { |
| 138 | cmds::BlendEquationSeparate cmd; |
| 139 | }; |
| 140 | Cmds expected; |
| 141 | expected.cmd.Init(GL_FUNC_SUBTRACT, GL_FUNC_ADD); |
| 142 | |
| 143 | gl_->BlendEquationSeparate(GL_FUNC_SUBTRACT, GL_FUNC_ADD); |
| 144 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 145 | } |
| 146 | |
| 147 | TEST_F(GLES2ImplementationTest, BlendFunc) { |
| 148 | struct Cmds { |
| 149 | cmds::BlendFunc cmd; |
| 150 | }; |
| 151 | Cmds expected; |
| 152 | expected.cmd.Init(GL_ZERO, GL_ZERO); |
| 153 | |
| 154 | gl_->BlendFunc(GL_ZERO, GL_ZERO); |
| 155 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 156 | } |
| 157 | |
| 158 | TEST_F(GLES2ImplementationTest, BlendFuncSeparate) { |
| 159 | struct Cmds { |
| 160 | cmds::BlendFuncSeparate cmd; |
| 161 | }; |
| 162 | Cmds expected; |
| 163 | expected.cmd.Init(GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO); |
| 164 | |
| 165 | gl_->BlendFuncSeparate(GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO); |
| 166 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 167 | } |
| 168 | |
| 169 | TEST_F(GLES2ImplementationTest, CheckFramebufferStatus) { |
| 170 | struct Cmds { |
| 171 | cmds::CheckFramebufferStatus cmd; |
| 172 | }; |
| 173 | |
| 174 | Cmds expected; |
| 175 | ExpectedMemoryInfo result1 = |
| 176 | GetExpectedResultMemory(sizeof(cmds::CheckFramebufferStatus::Result)); |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 177 | expected.cmd.Init(GL_FRAMEBUFFER, result1.id, result1.offset); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 178 | |
| 179 | EXPECT_CALL(*command_buffer(), OnFlush()) |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 180 | .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE))) |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 181 | .RetiresOnSaturation(); |
| 182 | |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 183 | GLboolean result = gl_->CheckFramebufferStatus(GL_FRAMEBUFFER); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 184 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 185 | EXPECT_TRUE(result); |
| 186 | } |
| 187 | |
| 188 | TEST_F(GLES2ImplementationTest, Clear) { |
| 189 | struct Cmds { |
| 190 | cmds::Clear cmd; |
| 191 | }; |
| 192 | Cmds expected; |
| 193 | expected.cmd.Init(1); |
| 194 | |
| 195 | gl_->Clear(1); |
| 196 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 197 | } |
| 198 | |
James Robinson | 5e66a79 | 2015-01-21 17:02:08 -0800 | [diff] [blame] | 199 | TEST_F(GLES2ImplementationTest, ClearBufferfi) { |
| 200 | struct Cmds { |
| 201 | cmds::ClearBufferfi cmd; |
| 202 | }; |
| 203 | Cmds expected; |
| 204 | expected.cmd.Init(GL_COLOR, 2, 3, 4); |
| 205 | |
| 206 | gl_->ClearBufferfi(GL_COLOR, 2, 3, 4); |
| 207 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 208 | } |
| 209 | |
| 210 | TEST_F(GLES2ImplementationTest, ClearBufferfv) { |
| 211 | GLfloat data[4] = {0}; |
| 212 | struct Cmds { |
| 213 | cmds::ClearBufferfvImmediate cmd; |
| 214 | GLfloat data[4]; |
| 215 | }; |
| 216 | |
| 217 | for (int jj = 0; jj < 4; ++jj) { |
| 218 | data[jj] = static_cast<GLfloat>(jj); |
| 219 | } |
| 220 | Cmds expected; |
| 221 | expected.cmd.Init(GL_COLOR, 2, &data[0]); |
| 222 | gl_->ClearBufferfv(GL_COLOR, 2, &data[0]); |
| 223 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 224 | } |
| 225 | |
| 226 | TEST_F(GLES2ImplementationTest, ClearBufferiv) { |
| 227 | GLint data[4] = {0}; |
| 228 | struct Cmds { |
| 229 | cmds::ClearBufferivImmediate cmd; |
| 230 | GLint data[4]; |
| 231 | }; |
| 232 | |
| 233 | for (int jj = 0; jj < 4; ++jj) { |
| 234 | data[jj] = static_cast<GLint>(jj); |
| 235 | } |
| 236 | Cmds expected; |
| 237 | expected.cmd.Init(GL_COLOR, 2, &data[0]); |
| 238 | gl_->ClearBufferiv(GL_COLOR, 2, &data[0]); |
| 239 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 240 | } |
| 241 | |
| 242 | TEST_F(GLES2ImplementationTest, ClearBufferuiv) { |
| 243 | GLuint data[4] = {0}; |
| 244 | struct Cmds { |
| 245 | cmds::ClearBufferuivImmediate cmd; |
| 246 | GLuint data[4]; |
| 247 | }; |
| 248 | |
| 249 | for (int jj = 0; jj < 4; ++jj) { |
| 250 | data[jj] = static_cast<GLuint>(jj); |
| 251 | } |
| 252 | Cmds expected; |
| 253 | expected.cmd.Init(GL_COLOR, 2, &data[0]); |
| 254 | gl_->ClearBufferuiv(GL_COLOR, 2, &data[0]); |
| 255 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 256 | } |
| 257 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 258 | TEST_F(GLES2ImplementationTest, ClearColor) { |
| 259 | struct Cmds { |
| 260 | cmds::ClearColor cmd; |
| 261 | }; |
| 262 | Cmds expected; |
| 263 | expected.cmd.Init(1, 2, 3, 4); |
| 264 | |
| 265 | gl_->ClearColor(1, 2, 3, 4); |
| 266 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 267 | } |
| 268 | |
| 269 | TEST_F(GLES2ImplementationTest, ClearDepthf) { |
| 270 | struct Cmds { |
| 271 | cmds::ClearDepthf cmd; |
| 272 | }; |
| 273 | Cmds expected; |
| 274 | expected.cmd.Init(0.5f); |
| 275 | |
| 276 | gl_->ClearDepthf(0.5f); |
| 277 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 278 | } |
| 279 | |
| 280 | TEST_F(GLES2ImplementationTest, ClearStencil) { |
| 281 | struct Cmds { |
| 282 | cmds::ClearStencil cmd; |
| 283 | }; |
| 284 | Cmds expected; |
| 285 | expected.cmd.Init(1); |
| 286 | |
| 287 | gl_->ClearStencil(1); |
| 288 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 289 | } |
| 290 | |
| 291 | TEST_F(GLES2ImplementationTest, ColorMask) { |
| 292 | struct Cmds { |
| 293 | cmds::ColorMask cmd; |
| 294 | }; |
| 295 | Cmds expected; |
| 296 | expected.cmd.Init(true, true, true, true); |
| 297 | |
| 298 | gl_->ColorMask(true, true, true, true); |
| 299 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 300 | } |
| 301 | |
| 302 | TEST_F(GLES2ImplementationTest, CompileShader) { |
| 303 | struct Cmds { |
| 304 | cmds::CompileShader cmd; |
| 305 | }; |
| 306 | Cmds expected; |
| 307 | expected.cmd.Init(1); |
| 308 | |
| 309 | gl_->CompileShader(1); |
| 310 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 311 | } |
| 312 | // TODO: Implement unit test for CompressedTexImage2D |
| 313 | // TODO: Implement unit test for CompressedTexSubImage2D |
| 314 | |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 315 | TEST_F(GLES2ImplementationTest, CopyBufferSubData) { |
| 316 | struct Cmds { |
| 317 | cmds::CopyBufferSubData cmd; |
| 318 | }; |
| 319 | Cmds expected; |
| 320 | expected.cmd.Init(GL_ARRAY_BUFFER, GL_ARRAY_BUFFER, 3, 4, 5); |
| 321 | |
| 322 | gl_->CopyBufferSubData(GL_ARRAY_BUFFER, GL_ARRAY_BUFFER, 3, 4, 5); |
| 323 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 324 | } |
| 325 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 326 | TEST_F(GLES2ImplementationTest, CopyTexImage2D) { |
| 327 | struct Cmds { |
| 328 | cmds::CopyTexImage2D cmd; |
| 329 | }; |
| 330 | Cmds expected; |
| 331 | expected.cmd.Init(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7); |
| 332 | |
| 333 | gl_->CopyTexImage2D(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7, 0); |
| 334 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 335 | } |
| 336 | |
| 337 | TEST_F(GLES2ImplementationTest, CopyTexImage2DInvalidConstantArg7) { |
| 338 | gl_->CopyTexImage2D(GL_TEXTURE_2D, 2, GL_ALPHA, 4, 5, 6, 7, 1); |
| 339 | EXPECT_TRUE(NoCommandsWritten()); |
| 340 | EXPECT_EQ(GL_INVALID_VALUE, CheckError()); |
| 341 | } |
| 342 | |
| 343 | TEST_F(GLES2ImplementationTest, CopyTexSubImage2D) { |
| 344 | struct Cmds { |
| 345 | cmds::CopyTexSubImage2D cmd; |
| 346 | }; |
| 347 | Cmds expected; |
| 348 | expected.cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8); |
| 349 | |
| 350 | gl_->CopyTexSubImage2D(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8); |
| 351 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 352 | } |
| 353 | |
| 354 | TEST_F(GLES2ImplementationTest, CullFace) { |
| 355 | struct Cmds { |
| 356 | cmds::CullFace cmd; |
| 357 | }; |
| 358 | Cmds expected; |
| 359 | expected.cmd.Init(GL_FRONT); |
| 360 | |
| 361 | gl_->CullFace(GL_FRONT); |
| 362 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 363 | } |
| 364 | |
| 365 | TEST_F(GLES2ImplementationTest, DeleteBuffers) { |
| 366 | GLuint ids[2] = {kBuffersStartId, kBuffersStartId + 1}; |
| 367 | struct Cmds { |
| 368 | cmds::DeleteBuffersImmediate del; |
| 369 | GLuint data[2]; |
| 370 | }; |
| 371 | Cmds expected; |
| 372 | expected.del.Init(arraysize(ids), &ids[0]); |
| 373 | expected.data[0] = kBuffersStartId; |
| 374 | expected.data[1] = kBuffersStartId + 1; |
| 375 | gl_->DeleteBuffers(arraysize(ids), &ids[0]); |
| 376 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 377 | } |
| 378 | |
| 379 | TEST_F(GLES2ImplementationTest, DeleteFramebuffers) { |
| 380 | GLuint ids[2] = {kFramebuffersStartId, kFramebuffersStartId + 1}; |
| 381 | struct Cmds { |
| 382 | cmds::DeleteFramebuffersImmediate del; |
| 383 | GLuint data[2]; |
| 384 | }; |
| 385 | Cmds expected; |
| 386 | expected.del.Init(arraysize(ids), &ids[0]); |
| 387 | expected.data[0] = kFramebuffersStartId; |
| 388 | expected.data[1] = kFramebuffersStartId + 1; |
| 389 | gl_->DeleteFramebuffers(arraysize(ids), &ids[0]); |
| 390 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 391 | } |
| 392 | |
| 393 | TEST_F(GLES2ImplementationTest, DeleteProgram) { |
| 394 | struct Cmds { |
| 395 | cmds::DeleteProgram cmd; |
| 396 | }; |
| 397 | Cmds expected; |
| 398 | expected.cmd.Init(1); |
| 399 | |
| 400 | gl_->DeleteProgram(1); |
| 401 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 402 | } |
| 403 | |
| 404 | TEST_F(GLES2ImplementationTest, DeleteRenderbuffers) { |
| 405 | GLuint ids[2] = {kRenderbuffersStartId, kRenderbuffersStartId + 1}; |
| 406 | struct Cmds { |
| 407 | cmds::DeleteRenderbuffersImmediate del; |
| 408 | GLuint data[2]; |
| 409 | }; |
| 410 | Cmds expected; |
| 411 | expected.del.Init(arraysize(ids), &ids[0]); |
| 412 | expected.data[0] = kRenderbuffersStartId; |
| 413 | expected.data[1] = kRenderbuffersStartId + 1; |
| 414 | gl_->DeleteRenderbuffers(arraysize(ids), &ids[0]); |
| 415 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 416 | } |
| 417 | |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 418 | TEST_F(GLES2ImplementationTest, DeleteSamplers) { |
| 419 | GLuint ids[2] = {kSamplersStartId, kSamplersStartId + 1}; |
| 420 | struct Cmds { |
| 421 | cmds::DeleteSamplersImmediate del; |
| 422 | GLuint data[2]; |
| 423 | }; |
| 424 | Cmds expected; |
| 425 | expected.del.Init(arraysize(ids), &ids[0]); |
| 426 | expected.data[0] = kSamplersStartId; |
| 427 | expected.data[1] = kSamplersStartId + 1; |
| 428 | gl_->DeleteSamplers(arraysize(ids), &ids[0]); |
| 429 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 430 | } |
| 431 | |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 432 | TEST_F(GLES2ImplementationTest, DeleteSync) { |
| 433 | struct Cmds { |
| 434 | cmds::DeleteSync cmd; |
| 435 | }; |
| 436 | Cmds expected; |
| 437 | expected.cmd.Init(1); |
| 438 | |
| 439 | gl_->DeleteSync(reinterpret_cast<GLsync>(1)); |
| 440 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 441 | } |
| 442 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 443 | TEST_F(GLES2ImplementationTest, DeleteShader) { |
| 444 | struct Cmds { |
| 445 | cmds::DeleteShader cmd; |
| 446 | }; |
| 447 | Cmds expected; |
| 448 | expected.cmd.Init(1); |
| 449 | |
| 450 | gl_->DeleteShader(1); |
| 451 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 452 | } |
| 453 | |
| 454 | TEST_F(GLES2ImplementationTest, DeleteTextures) { |
| 455 | GLuint ids[2] = {kTexturesStartId, kTexturesStartId + 1}; |
| 456 | struct Cmds { |
| 457 | cmds::DeleteTexturesImmediate del; |
| 458 | GLuint data[2]; |
| 459 | }; |
| 460 | Cmds expected; |
| 461 | expected.del.Init(arraysize(ids), &ids[0]); |
| 462 | expected.data[0] = kTexturesStartId; |
| 463 | expected.data[1] = kTexturesStartId + 1; |
| 464 | gl_->DeleteTextures(arraysize(ids), &ids[0]); |
| 465 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 466 | } |
| 467 | |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 468 | TEST_F(GLES2ImplementationTest, DeleteTransformFeedbacks) { |
| 469 | GLuint ids[2] = {kTransformFeedbacksStartId, kTransformFeedbacksStartId + 1}; |
| 470 | struct Cmds { |
| 471 | cmds::DeleteTransformFeedbacksImmediate del; |
| 472 | GLuint data[2]; |
| 473 | }; |
| 474 | Cmds expected; |
| 475 | expected.del.Init(arraysize(ids), &ids[0]); |
| 476 | expected.data[0] = kTransformFeedbacksStartId; |
| 477 | expected.data[1] = kTransformFeedbacksStartId + 1; |
| 478 | gl_->DeleteTransformFeedbacks(arraysize(ids), &ids[0]); |
| 479 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 480 | } |
| 481 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 482 | TEST_F(GLES2ImplementationTest, DepthFunc) { |
| 483 | struct Cmds { |
| 484 | cmds::DepthFunc cmd; |
| 485 | }; |
| 486 | Cmds expected; |
| 487 | expected.cmd.Init(GL_NEVER); |
| 488 | |
| 489 | gl_->DepthFunc(GL_NEVER); |
| 490 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 491 | } |
| 492 | |
| 493 | TEST_F(GLES2ImplementationTest, DepthMask) { |
| 494 | struct Cmds { |
| 495 | cmds::DepthMask cmd; |
| 496 | }; |
| 497 | Cmds expected; |
| 498 | expected.cmd.Init(true); |
| 499 | |
| 500 | gl_->DepthMask(true); |
| 501 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 502 | } |
| 503 | |
| 504 | TEST_F(GLES2ImplementationTest, DepthRangef) { |
| 505 | struct Cmds { |
| 506 | cmds::DepthRangef cmd; |
| 507 | }; |
| 508 | Cmds expected; |
| 509 | expected.cmd.Init(1, 2); |
| 510 | |
| 511 | gl_->DepthRangef(1, 2); |
| 512 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 513 | } |
| 514 | |
| 515 | TEST_F(GLES2ImplementationTest, DetachShader) { |
| 516 | struct Cmds { |
| 517 | cmds::DetachShader cmd; |
| 518 | }; |
| 519 | Cmds expected; |
| 520 | expected.cmd.Init(1, 2); |
| 521 | |
| 522 | gl_->DetachShader(1, 2); |
| 523 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 524 | } |
| 525 | |
| 526 | TEST_F(GLES2ImplementationTest, DisableVertexAttribArray) { |
| 527 | struct Cmds { |
| 528 | cmds::DisableVertexAttribArray cmd; |
| 529 | }; |
| 530 | Cmds expected; |
| 531 | expected.cmd.Init(1); |
| 532 | |
| 533 | gl_->DisableVertexAttribArray(1); |
| 534 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 535 | } |
| 536 | |
| 537 | TEST_F(GLES2ImplementationTest, DrawArrays) { |
| 538 | struct Cmds { |
| 539 | cmds::DrawArrays cmd; |
| 540 | }; |
| 541 | Cmds expected; |
| 542 | expected.cmd.Init(GL_POINTS, 2, 3); |
| 543 | |
| 544 | gl_->DrawArrays(GL_POINTS, 2, 3); |
| 545 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 546 | } |
| 547 | |
| 548 | TEST_F(GLES2ImplementationTest, EnableVertexAttribArray) { |
| 549 | struct Cmds { |
| 550 | cmds::EnableVertexAttribArray cmd; |
| 551 | }; |
| 552 | Cmds expected; |
| 553 | expected.cmd.Init(1); |
| 554 | |
| 555 | gl_->EnableVertexAttribArray(1); |
| 556 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 557 | } |
| 558 | |
| 559 | TEST_F(GLES2ImplementationTest, Flush) { |
| 560 | struct Cmds { |
| 561 | cmds::Flush cmd; |
| 562 | }; |
| 563 | Cmds expected; |
| 564 | expected.cmd.Init(); |
| 565 | |
| 566 | gl_->Flush(); |
| 567 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 568 | } |
| 569 | |
| 570 | TEST_F(GLES2ImplementationTest, FramebufferRenderbuffer) { |
| 571 | struct Cmds { |
| 572 | cmds::FramebufferRenderbuffer cmd; |
| 573 | }; |
| 574 | Cmds expected; |
| 575 | expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 4); |
| 576 | |
James Robinson | 1ae030a | 2014-11-07 08:32:47 -0800 | [diff] [blame] | 577 | gl_->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 578 | GL_RENDERBUFFER, 4); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 579 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 580 | } |
| 581 | |
| 582 | TEST_F(GLES2ImplementationTest, FramebufferTexture2D) { |
| 583 | struct Cmds { |
| 584 | cmds::FramebufferTexture2D cmd; |
| 585 | }; |
| 586 | Cmds expected; |
| 587 | expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4); |
| 588 | |
James Robinson | 1ae030a | 2014-11-07 08:32:47 -0800 | [diff] [blame] | 589 | gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 590 | 4, 0); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 591 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 592 | } |
| 593 | |
| 594 | TEST_F(GLES2ImplementationTest, FramebufferTexture2DInvalidConstantArg4) { |
James Robinson | 1ae030a | 2014-11-07 08:32:47 -0800 | [diff] [blame] | 595 | gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 596 | 4, 1); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 597 | EXPECT_TRUE(NoCommandsWritten()); |
| 598 | EXPECT_EQ(GL_INVALID_VALUE, CheckError()); |
| 599 | } |
| 600 | |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 601 | TEST_F(GLES2ImplementationTest, FramebufferTextureLayer) { |
| 602 | struct Cmds { |
| 603 | cmds::FramebufferTextureLayer cmd; |
| 604 | }; |
| 605 | Cmds expected; |
| 606 | expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 3, 4, 5); |
| 607 | |
| 608 | gl_->FramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 3, 4, 5); |
| 609 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 610 | } |
| 611 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 612 | TEST_F(GLES2ImplementationTest, FrontFace) { |
| 613 | struct Cmds { |
| 614 | cmds::FrontFace cmd; |
| 615 | }; |
| 616 | Cmds expected; |
| 617 | expected.cmd.Init(GL_CW); |
| 618 | |
| 619 | gl_->FrontFace(GL_CW); |
| 620 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 621 | } |
| 622 | |
| 623 | TEST_F(GLES2ImplementationTest, GenBuffers) { |
| 624 | GLuint ids[2] = { |
| 625 | 0, |
| 626 | }; |
| 627 | struct Cmds { |
| 628 | cmds::GenBuffersImmediate gen; |
| 629 | GLuint data[2]; |
| 630 | }; |
| 631 | Cmds expected; |
| 632 | expected.gen.Init(arraysize(ids), &ids[0]); |
| 633 | expected.data[0] = kBuffersStartId; |
| 634 | expected.data[1] = kBuffersStartId + 1; |
| 635 | gl_->GenBuffers(arraysize(ids), &ids[0]); |
| 636 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 637 | EXPECT_EQ(kBuffersStartId, ids[0]); |
| 638 | EXPECT_EQ(kBuffersStartId + 1, ids[1]); |
| 639 | } |
| 640 | |
| 641 | TEST_F(GLES2ImplementationTest, GenerateMipmap) { |
| 642 | struct Cmds { |
| 643 | cmds::GenerateMipmap cmd; |
| 644 | }; |
| 645 | Cmds expected; |
| 646 | expected.cmd.Init(GL_TEXTURE_2D); |
| 647 | |
| 648 | gl_->GenerateMipmap(GL_TEXTURE_2D); |
| 649 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 650 | } |
| 651 | |
| 652 | TEST_F(GLES2ImplementationTest, GenFramebuffers) { |
| 653 | GLuint ids[2] = { |
| 654 | 0, |
| 655 | }; |
| 656 | struct Cmds { |
| 657 | cmds::GenFramebuffersImmediate gen; |
| 658 | GLuint data[2]; |
| 659 | }; |
| 660 | Cmds expected; |
| 661 | expected.gen.Init(arraysize(ids), &ids[0]); |
| 662 | expected.data[0] = kFramebuffersStartId; |
| 663 | expected.data[1] = kFramebuffersStartId + 1; |
| 664 | gl_->GenFramebuffers(arraysize(ids), &ids[0]); |
| 665 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 666 | EXPECT_EQ(kFramebuffersStartId, ids[0]); |
| 667 | EXPECT_EQ(kFramebuffersStartId + 1, ids[1]); |
| 668 | } |
| 669 | |
| 670 | TEST_F(GLES2ImplementationTest, GenRenderbuffers) { |
| 671 | GLuint ids[2] = { |
| 672 | 0, |
| 673 | }; |
| 674 | struct Cmds { |
| 675 | cmds::GenRenderbuffersImmediate gen; |
| 676 | GLuint data[2]; |
| 677 | }; |
| 678 | Cmds expected; |
| 679 | expected.gen.Init(arraysize(ids), &ids[0]); |
| 680 | expected.data[0] = kRenderbuffersStartId; |
| 681 | expected.data[1] = kRenderbuffersStartId + 1; |
| 682 | gl_->GenRenderbuffers(arraysize(ids), &ids[0]); |
| 683 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 684 | EXPECT_EQ(kRenderbuffersStartId, ids[0]); |
| 685 | EXPECT_EQ(kRenderbuffersStartId + 1, ids[1]); |
| 686 | } |
| 687 | |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 688 | TEST_F(GLES2ImplementationTest, GenSamplers) { |
| 689 | GLuint ids[2] = { |
| 690 | 0, |
| 691 | }; |
| 692 | struct Cmds { |
| 693 | cmds::GenSamplersImmediate gen; |
| 694 | GLuint data[2]; |
| 695 | }; |
| 696 | Cmds expected; |
| 697 | expected.gen.Init(arraysize(ids), &ids[0]); |
| 698 | expected.data[0] = kSamplersStartId; |
| 699 | expected.data[1] = kSamplersStartId + 1; |
| 700 | gl_->GenSamplers(arraysize(ids), &ids[0]); |
| 701 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 702 | EXPECT_EQ(kSamplersStartId, ids[0]); |
| 703 | EXPECT_EQ(kSamplersStartId + 1, ids[1]); |
| 704 | } |
| 705 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 706 | TEST_F(GLES2ImplementationTest, GenTextures) { |
| 707 | GLuint ids[2] = { |
| 708 | 0, |
| 709 | }; |
| 710 | struct Cmds { |
| 711 | cmds::GenTexturesImmediate gen; |
| 712 | GLuint data[2]; |
| 713 | }; |
| 714 | Cmds expected; |
| 715 | expected.gen.Init(arraysize(ids), &ids[0]); |
| 716 | expected.data[0] = kTexturesStartId; |
| 717 | expected.data[1] = kTexturesStartId + 1; |
| 718 | gl_->GenTextures(arraysize(ids), &ids[0]); |
| 719 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 720 | EXPECT_EQ(kTexturesStartId, ids[0]); |
| 721 | EXPECT_EQ(kTexturesStartId + 1, ids[1]); |
| 722 | } |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 723 | |
| 724 | TEST_F(GLES2ImplementationTest, GenTransformFeedbacks) { |
| 725 | GLuint ids[2] = { |
| 726 | 0, |
| 727 | }; |
| 728 | struct Cmds { |
| 729 | cmds::GenTransformFeedbacksImmediate gen; |
| 730 | GLuint data[2]; |
| 731 | }; |
| 732 | Cmds expected; |
| 733 | expected.gen.Init(arraysize(ids), &ids[0]); |
| 734 | expected.data[0] = kTransformFeedbacksStartId; |
| 735 | expected.data[1] = kTransformFeedbacksStartId + 1; |
| 736 | gl_->GenTransformFeedbacks(arraysize(ids), &ids[0]); |
| 737 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 738 | EXPECT_EQ(kTransformFeedbacksStartId, ids[0]); |
| 739 | EXPECT_EQ(kTransformFeedbacksStartId + 1, ids[1]); |
| 740 | } |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 741 | // TODO: Implement unit test for GetActiveAttrib |
| 742 | // TODO: Implement unit test for GetActiveUniform |
| 743 | // TODO: Implement unit test for GetAttachedShaders |
| 744 | // TODO: Implement unit test for GetAttribLocation |
| 745 | |
| 746 | TEST_F(GLES2ImplementationTest, GetBooleanv) { |
| 747 | struct Cmds { |
| 748 | cmds::GetBooleanv cmd; |
| 749 | }; |
| 750 | typedef cmds::GetBooleanv::Result Result; |
| 751 | Result::Type result = 0; |
| 752 | Cmds expected; |
| 753 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
| 754 | expected.cmd.Init(123, result1.id, result1.offset); |
| 755 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 756 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 757 | .RetiresOnSaturation(); |
| 758 | gl_->GetBooleanv(123, &result); |
| 759 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 760 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 761 | } |
| 762 | |
| 763 | TEST_F(GLES2ImplementationTest, GetBufferParameteriv) { |
| 764 | struct Cmds { |
| 765 | cmds::GetBufferParameteriv cmd; |
| 766 | }; |
| 767 | typedef cmds::GetBufferParameteriv::Result Result; |
| 768 | Result::Type result = 0; |
| 769 | Cmds expected; |
| 770 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
| 771 | expected.cmd.Init(123, GL_BUFFER_SIZE, result1.id, result1.offset); |
| 772 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 773 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 774 | .RetiresOnSaturation(); |
| 775 | gl_->GetBufferParameteriv(123, GL_BUFFER_SIZE, &result); |
| 776 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 777 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 778 | } |
| 779 | |
| 780 | TEST_F(GLES2ImplementationTest, GetFloatv) { |
| 781 | struct Cmds { |
| 782 | cmds::GetFloatv cmd; |
| 783 | }; |
| 784 | typedef cmds::GetFloatv::Result Result; |
| 785 | Result::Type result = 0; |
| 786 | Cmds expected; |
| 787 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
| 788 | expected.cmd.Init(123, result1.id, result1.offset); |
| 789 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 790 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 791 | .RetiresOnSaturation(); |
| 792 | gl_->GetFloatv(123, &result); |
| 793 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 794 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 795 | } |
| 796 | |
| 797 | TEST_F(GLES2ImplementationTest, GetFramebufferAttachmentParameteriv) { |
| 798 | struct Cmds { |
| 799 | cmds::GetFramebufferAttachmentParameteriv cmd; |
| 800 | }; |
| 801 | typedef cmds::GetFramebufferAttachmentParameteriv::Result Result; |
| 802 | Result::Type result = 0; |
| 803 | Cmds expected; |
| 804 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
James Robinson | 1ae030a | 2014-11-07 08:32:47 -0800 | [diff] [blame] | 805 | expected.cmd.Init(123, GL_COLOR_ATTACHMENT0, |
| 806 | GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, result1.id, |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 807 | result1.offset); |
| 808 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 809 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 810 | .RetiresOnSaturation(); |
| 811 | gl_->GetFramebufferAttachmentParameteriv( |
James Robinson | 1ae030a | 2014-11-07 08:32:47 -0800 | [diff] [blame] | 812 | 123, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 813 | &result); |
| 814 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 815 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 816 | } |
| 817 | |
| 818 | TEST_F(GLES2ImplementationTest, GetIntegerv) { |
| 819 | struct Cmds { |
| 820 | cmds::GetIntegerv cmd; |
| 821 | }; |
| 822 | typedef cmds::GetIntegerv::Result Result; |
| 823 | Result::Type result = 0; |
| 824 | Cmds expected; |
| 825 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
| 826 | expected.cmd.Init(123, result1.id, result1.offset); |
| 827 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 828 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 829 | .RetiresOnSaturation(); |
| 830 | gl_->GetIntegerv(123, &result); |
| 831 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 832 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 833 | } |
| 834 | |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 835 | TEST_F(GLES2ImplementationTest, GetInternalformativ) { |
| 836 | struct Cmds { |
| 837 | cmds::GetInternalformativ cmd; |
| 838 | }; |
| 839 | typedef cmds::GetInternalformativ::Result Result; |
| 840 | Result::Type result = 0; |
| 841 | Cmds expected; |
| 842 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
| 843 | expected.cmd.Init(123, GL_RGBA4, GL_RENDERBUFFER_RED_SIZE, 4, result1.id, |
| 844 | result1.offset); |
| 845 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 846 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 847 | .RetiresOnSaturation(); |
| 848 | gl_->GetInternalformativ(123, GL_RGBA4, GL_RENDERBUFFER_RED_SIZE, 4, &result); |
| 849 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 850 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 851 | } |
| 852 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 853 | TEST_F(GLES2ImplementationTest, GetProgramiv) { |
| 854 | struct Cmds { |
| 855 | cmds::GetProgramiv cmd; |
| 856 | }; |
| 857 | typedef cmds::GetProgramiv::Result Result; |
| 858 | Result::Type result = 0; |
| 859 | Cmds expected; |
| 860 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
| 861 | expected.cmd.Init(123, GL_DELETE_STATUS, result1.id, result1.offset); |
| 862 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 863 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 864 | .RetiresOnSaturation(); |
| 865 | gl_->GetProgramiv(123, GL_DELETE_STATUS, &result); |
| 866 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 867 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 868 | } |
| 869 | // TODO: Implement unit test for GetProgramInfoLog |
| 870 | |
| 871 | TEST_F(GLES2ImplementationTest, GetRenderbufferParameteriv) { |
| 872 | struct Cmds { |
| 873 | cmds::GetRenderbufferParameteriv cmd; |
| 874 | }; |
| 875 | typedef cmds::GetRenderbufferParameteriv::Result Result; |
| 876 | Result::Type result = 0; |
| 877 | Cmds expected; |
| 878 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
| 879 | expected.cmd.Init(123, GL_RENDERBUFFER_RED_SIZE, result1.id, result1.offset); |
| 880 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 881 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 882 | .RetiresOnSaturation(); |
| 883 | gl_->GetRenderbufferParameteriv(123, GL_RENDERBUFFER_RED_SIZE, &result); |
| 884 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 885 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 886 | } |
| 887 | |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 888 | TEST_F(GLES2ImplementationTest, GetSamplerParameterfv) { |
| 889 | struct Cmds { |
| 890 | cmds::GetSamplerParameterfv cmd; |
| 891 | }; |
| 892 | typedef cmds::GetSamplerParameterfv::Result Result; |
| 893 | Result::Type result = 0; |
| 894 | Cmds expected; |
| 895 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
| 896 | expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset); |
| 897 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 898 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 899 | .RetiresOnSaturation(); |
| 900 | gl_->GetSamplerParameterfv(123, GL_TEXTURE_MAG_FILTER, &result); |
| 901 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 902 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 903 | } |
| 904 | |
| 905 | TEST_F(GLES2ImplementationTest, GetSamplerParameteriv) { |
| 906 | struct Cmds { |
| 907 | cmds::GetSamplerParameteriv cmd; |
| 908 | }; |
| 909 | typedef cmds::GetSamplerParameteriv::Result Result; |
| 910 | Result::Type result = 0; |
| 911 | Cmds expected; |
| 912 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
| 913 | expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset); |
| 914 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 915 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 916 | .RetiresOnSaturation(); |
| 917 | gl_->GetSamplerParameteriv(123, GL_TEXTURE_MAG_FILTER, &result); |
| 918 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 919 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 920 | } |
| 921 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 922 | TEST_F(GLES2ImplementationTest, GetShaderiv) { |
| 923 | struct Cmds { |
| 924 | cmds::GetShaderiv cmd; |
| 925 | }; |
| 926 | typedef cmds::GetShaderiv::Result Result; |
| 927 | Result::Type result = 0; |
| 928 | Cmds expected; |
| 929 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
| 930 | expected.cmd.Init(123, GL_SHADER_TYPE, result1.id, result1.offset); |
| 931 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 932 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 933 | .RetiresOnSaturation(); |
| 934 | gl_->GetShaderiv(123, GL_SHADER_TYPE, &result); |
| 935 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 936 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 937 | } |
| 938 | // TODO: Implement unit test for GetShaderInfoLog |
| 939 | // TODO: Implement unit test for GetShaderPrecisionFormat |
| 940 | |
| 941 | TEST_F(GLES2ImplementationTest, GetTexParameterfv) { |
| 942 | struct Cmds { |
| 943 | cmds::GetTexParameterfv cmd; |
| 944 | }; |
| 945 | typedef cmds::GetTexParameterfv::Result Result; |
| 946 | Result::Type result = 0; |
| 947 | Cmds expected; |
| 948 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
| 949 | expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset); |
| 950 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 951 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 952 | .RetiresOnSaturation(); |
| 953 | gl_->GetTexParameterfv(123, GL_TEXTURE_MAG_FILTER, &result); |
| 954 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 955 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 956 | } |
| 957 | |
| 958 | TEST_F(GLES2ImplementationTest, GetTexParameteriv) { |
| 959 | struct Cmds { |
| 960 | cmds::GetTexParameteriv cmd; |
| 961 | }; |
| 962 | typedef cmds::GetTexParameteriv::Result Result; |
| 963 | Result::Type result = 0; |
| 964 | Cmds expected; |
| 965 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
| 966 | expected.cmd.Init(123, GL_TEXTURE_MAG_FILTER, result1.id, result1.offset); |
| 967 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 968 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 969 | .RetiresOnSaturation(); |
| 970 | gl_->GetTexParameteriv(123, GL_TEXTURE_MAG_FILTER, &result); |
| 971 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 972 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 973 | } |
| 974 | // TODO: Implement unit test for GetUniformfv |
| 975 | // TODO: Implement unit test for GetUniformiv |
| 976 | // TODO: Implement unit test for GetUniformLocation |
| 977 | |
| 978 | TEST_F(GLES2ImplementationTest, GetVertexAttribfv) { |
| 979 | struct Cmds { |
| 980 | cmds::GetVertexAttribfv cmd; |
| 981 | }; |
| 982 | typedef cmds::GetVertexAttribfv::Result Result; |
| 983 | Result::Type result = 0; |
| 984 | Cmds expected; |
| 985 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
James Robinson | 1ae030a | 2014-11-07 08:32:47 -0800 | [diff] [blame] | 986 | expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id, |
| 987 | result1.offset); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 988 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 989 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 990 | .RetiresOnSaturation(); |
| 991 | gl_->GetVertexAttribfv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result); |
| 992 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 993 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 994 | } |
| 995 | |
| 996 | TEST_F(GLES2ImplementationTest, GetVertexAttribiv) { |
| 997 | struct Cmds { |
| 998 | cmds::GetVertexAttribiv cmd; |
| 999 | }; |
| 1000 | typedef cmds::GetVertexAttribiv::Result Result; |
| 1001 | Result::Type result = 0; |
| 1002 | Cmds expected; |
| 1003 | ExpectedMemoryInfo result1 = GetExpectedResultMemory(4); |
James Robinson | 1ae030a | 2014-11-07 08:32:47 -0800 | [diff] [blame] | 1004 | expected.cmd.Init(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, result1.id, |
| 1005 | result1.offset); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1006 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1007 | .WillOnce(SetMemory(result1.ptr, SizedResultHelper<Result::Type>(1))) |
| 1008 | .RetiresOnSaturation(); |
| 1009 | gl_->GetVertexAttribiv(123, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &result); |
| 1010 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1011 | EXPECT_EQ(static_cast<Result::Type>(1), result); |
| 1012 | } |
| 1013 | |
| 1014 | TEST_F(GLES2ImplementationTest, Hint) { |
| 1015 | struct Cmds { |
| 1016 | cmds::Hint cmd; |
| 1017 | }; |
| 1018 | Cmds expected; |
| 1019 | expected.cmd.Init(GL_GENERATE_MIPMAP_HINT, GL_FASTEST); |
| 1020 | |
| 1021 | gl_->Hint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST); |
| 1022 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1023 | } |
| 1024 | |
James Robinson | d2015d9 | 2014-12-08 13:45:40 -0800 | [diff] [blame] | 1025 | TEST_F(GLES2ImplementationTest, InvalidateFramebuffer) { |
| 1026 | GLenum data[2][1] = {{0}}; |
| 1027 | struct Cmds { |
| 1028 | cmds::InvalidateFramebufferImmediate cmd; |
| 1029 | GLenum data[2][1]; |
| 1030 | }; |
| 1031 | |
| 1032 | Cmds expected; |
| 1033 | for (int ii = 0; ii < 2; ++ii) { |
| 1034 | for (int jj = 0; jj < 1; ++jj) { |
| 1035 | data[ii][jj] = static_cast<GLenum>(ii * 1 + jj); |
| 1036 | } |
| 1037 | } |
| 1038 | expected.cmd.Init(GL_FRAMEBUFFER, 2, &data[0][0]); |
| 1039 | gl_->InvalidateFramebuffer(GL_FRAMEBUFFER, 2, &data[0][0]); |
| 1040 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1041 | } |
| 1042 | |
| 1043 | TEST_F(GLES2ImplementationTest, InvalidateSubFramebuffer) { |
| 1044 | GLenum data[2][1] = {{0}}; |
| 1045 | struct Cmds { |
| 1046 | cmds::InvalidateSubFramebufferImmediate cmd; |
| 1047 | GLenum data[2][1]; |
| 1048 | }; |
| 1049 | |
| 1050 | Cmds expected; |
| 1051 | for (int ii = 0; ii < 2; ++ii) { |
| 1052 | for (int jj = 0; jj < 1; ++jj) { |
| 1053 | data[ii][jj] = static_cast<GLenum>(ii * 1 + jj); |
| 1054 | } |
| 1055 | } |
| 1056 | expected.cmd.Init(GL_FRAMEBUFFER, 2, &data[0][0], 4, 5, 6, 7); |
| 1057 | gl_->InvalidateSubFramebuffer(GL_FRAMEBUFFER, 2, &data[0][0], 4, 5, 6, 7); |
| 1058 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1059 | } |
| 1060 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1061 | TEST_F(GLES2ImplementationTest, IsBuffer) { |
| 1062 | struct Cmds { |
| 1063 | cmds::IsBuffer cmd; |
| 1064 | }; |
| 1065 | |
| 1066 | Cmds expected; |
| 1067 | ExpectedMemoryInfo result1 = |
| 1068 | GetExpectedResultMemory(sizeof(cmds::IsBuffer::Result)); |
| 1069 | expected.cmd.Init(1, result1.id, result1.offset); |
| 1070 | |
| 1071 | EXPECT_CALL(*command_buffer(), OnFlush()) |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 1072 | .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE))) |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1073 | .RetiresOnSaturation(); |
| 1074 | |
| 1075 | GLboolean result = gl_->IsBuffer(1); |
| 1076 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1077 | EXPECT_TRUE(result); |
| 1078 | } |
| 1079 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1080 | TEST_F(GLES2ImplementationTest, IsFramebuffer) { |
| 1081 | struct Cmds { |
| 1082 | cmds::IsFramebuffer cmd; |
| 1083 | }; |
| 1084 | |
| 1085 | Cmds expected; |
| 1086 | ExpectedMemoryInfo result1 = |
| 1087 | GetExpectedResultMemory(sizeof(cmds::IsFramebuffer::Result)); |
| 1088 | expected.cmd.Init(1, result1.id, result1.offset); |
| 1089 | |
| 1090 | EXPECT_CALL(*command_buffer(), OnFlush()) |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 1091 | .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE))) |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1092 | .RetiresOnSaturation(); |
| 1093 | |
| 1094 | GLboolean result = gl_->IsFramebuffer(1); |
| 1095 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1096 | EXPECT_TRUE(result); |
| 1097 | } |
| 1098 | |
| 1099 | TEST_F(GLES2ImplementationTest, IsProgram) { |
| 1100 | struct Cmds { |
| 1101 | cmds::IsProgram cmd; |
| 1102 | }; |
| 1103 | |
| 1104 | Cmds expected; |
| 1105 | ExpectedMemoryInfo result1 = |
| 1106 | GetExpectedResultMemory(sizeof(cmds::IsProgram::Result)); |
| 1107 | expected.cmd.Init(1, result1.id, result1.offset); |
| 1108 | |
| 1109 | EXPECT_CALL(*command_buffer(), OnFlush()) |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 1110 | .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE))) |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1111 | .RetiresOnSaturation(); |
| 1112 | |
| 1113 | GLboolean result = gl_->IsProgram(1); |
| 1114 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1115 | EXPECT_TRUE(result); |
| 1116 | } |
| 1117 | |
| 1118 | TEST_F(GLES2ImplementationTest, IsRenderbuffer) { |
| 1119 | struct Cmds { |
| 1120 | cmds::IsRenderbuffer cmd; |
| 1121 | }; |
| 1122 | |
| 1123 | Cmds expected; |
| 1124 | ExpectedMemoryInfo result1 = |
| 1125 | GetExpectedResultMemory(sizeof(cmds::IsRenderbuffer::Result)); |
| 1126 | expected.cmd.Init(1, result1.id, result1.offset); |
| 1127 | |
| 1128 | EXPECT_CALL(*command_buffer(), OnFlush()) |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 1129 | .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE))) |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1130 | .RetiresOnSaturation(); |
| 1131 | |
| 1132 | GLboolean result = gl_->IsRenderbuffer(1); |
| 1133 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1134 | EXPECT_TRUE(result); |
| 1135 | } |
| 1136 | |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 1137 | TEST_F(GLES2ImplementationTest, IsSampler) { |
| 1138 | struct Cmds { |
| 1139 | cmds::IsSampler cmd; |
| 1140 | }; |
| 1141 | |
| 1142 | Cmds expected; |
| 1143 | ExpectedMemoryInfo result1 = |
| 1144 | GetExpectedResultMemory(sizeof(cmds::IsSampler::Result)); |
| 1145 | expected.cmd.Init(1, result1.id, result1.offset); |
| 1146 | |
| 1147 | EXPECT_CALL(*command_buffer(), OnFlush()) |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 1148 | .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE))) |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 1149 | .RetiresOnSaturation(); |
| 1150 | |
| 1151 | GLboolean result = gl_->IsSampler(1); |
| 1152 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1153 | EXPECT_TRUE(result); |
| 1154 | } |
| 1155 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1156 | TEST_F(GLES2ImplementationTest, IsShader) { |
| 1157 | struct Cmds { |
| 1158 | cmds::IsShader cmd; |
| 1159 | }; |
| 1160 | |
| 1161 | Cmds expected; |
| 1162 | ExpectedMemoryInfo result1 = |
| 1163 | GetExpectedResultMemory(sizeof(cmds::IsShader::Result)); |
| 1164 | expected.cmd.Init(1, result1.id, result1.offset); |
| 1165 | |
| 1166 | EXPECT_CALL(*command_buffer(), OnFlush()) |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 1167 | .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE))) |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1168 | .RetiresOnSaturation(); |
| 1169 | |
| 1170 | GLboolean result = gl_->IsShader(1); |
| 1171 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1172 | EXPECT_TRUE(result); |
| 1173 | } |
| 1174 | |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 1175 | TEST_F(GLES2ImplementationTest, IsSync) { |
| 1176 | struct Cmds { |
| 1177 | cmds::IsSync cmd; |
| 1178 | }; |
| 1179 | |
| 1180 | Cmds expected; |
| 1181 | ExpectedMemoryInfo result1 = |
| 1182 | GetExpectedResultMemory(sizeof(cmds::IsSync::Result)); |
| 1183 | expected.cmd.Init(1, result1.id, result1.offset); |
| 1184 | |
| 1185 | EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1186 | .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE))) |
| 1187 | .RetiresOnSaturation(); |
| 1188 | |
| 1189 | GLboolean result = gl_->IsSync(reinterpret_cast<GLsync>(1)); |
| 1190 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1191 | EXPECT_TRUE(result); |
| 1192 | } |
| 1193 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1194 | TEST_F(GLES2ImplementationTest, IsTexture) { |
| 1195 | struct Cmds { |
| 1196 | cmds::IsTexture cmd; |
| 1197 | }; |
| 1198 | |
| 1199 | Cmds expected; |
| 1200 | ExpectedMemoryInfo result1 = |
| 1201 | GetExpectedResultMemory(sizeof(cmds::IsTexture::Result)); |
| 1202 | expected.cmd.Init(1, result1.id, result1.offset); |
| 1203 | |
| 1204 | EXPECT_CALL(*command_buffer(), OnFlush()) |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 1205 | .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE))) |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1206 | .RetiresOnSaturation(); |
| 1207 | |
| 1208 | GLboolean result = gl_->IsTexture(1); |
| 1209 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1210 | EXPECT_TRUE(result); |
| 1211 | } |
| 1212 | |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 1213 | TEST_F(GLES2ImplementationTest, IsTransformFeedback) { |
| 1214 | struct Cmds { |
| 1215 | cmds::IsTransformFeedback cmd; |
| 1216 | }; |
| 1217 | |
| 1218 | Cmds expected; |
| 1219 | ExpectedMemoryInfo result1 = |
| 1220 | GetExpectedResultMemory(sizeof(cmds::IsTransformFeedback::Result)); |
| 1221 | expected.cmd.Init(1, result1.id, result1.offset); |
| 1222 | |
| 1223 | EXPECT_CALL(*command_buffer(), OnFlush()) |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 1224 | .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE))) |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 1225 | .RetiresOnSaturation(); |
| 1226 | |
| 1227 | GLboolean result = gl_->IsTransformFeedback(1); |
| 1228 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1229 | EXPECT_TRUE(result); |
| 1230 | } |
| 1231 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1232 | TEST_F(GLES2ImplementationTest, LineWidth) { |
| 1233 | struct Cmds { |
| 1234 | cmds::LineWidth cmd; |
| 1235 | }; |
| 1236 | Cmds expected; |
| 1237 | expected.cmd.Init(0.5f); |
| 1238 | |
| 1239 | gl_->LineWidth(0.5f); |
| 1240 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1241 | } |
| 1242 | |
| 1243 | TEST_F(GLES2ImplementationTest, LinkProgram) { |
| 1244 | struct Cmds { |
| 1245 | cmds::LinkProgram cmd; |
| 1246 | }; |
| 1247 | Cmds expected; |
| 1248 | expected.cmd.Init(1); |
| 1249 | |
| 1250 | gl_->LinkProgram(1); |
| 1251 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1252 | } |
| 1253 | |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 1254 | TEST_F(GLES2ImplementationTest, PauseTransformFeedback) { |
| 1255 | struct Cmds { |
| 1256 | cmds::PauseTransformFeedback cmd; |
| 1257 | }; |
| 1258 | Cmds expected; |
| 1259 | expected.cmd.Init(); |
| 1260 | |
| 1261 | gl_->PauseTransformFeedback(); |
| 1262 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1263 | } |
| 1264 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1265 | TEST_F(GLES2ImplementationTest, PixelStorei) { |
| 1266 | struct Cmds { |
| 1267 | cmds::PixelStorei cmd; |
| 1268 | }; |
| 1269 | Cmds expected; |
| 1270 | expected.cmd.Init(GL_PACK_ALIGNMENT, 1); |
| 1271 | |
| 1272 | gl_->PixelStorei(GL_PACK_ALIGNMENT, 1); |
| 1273 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1274 | } |
| 1275 | |
| 1276 | TEST_F(GLES2ImplementationTest, PolygonOffset) { |
| 1277 | struct Cmds { |
| 1278 | cmds::PolygonOffset cmd; |
| 1279 | }; |
| 1280 | Cmds expected; |
| 1281 | expected.cmd.Init(1, 2); |
| 1282 | |
| 1283 | gl_->PolygonOffset(1, 2); |
| 1284 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1285 | } |
| 1286 | |
James Robinson | d2015d9 | 2014-12-08 13:45:40 -0800 | [diff] [blame] | 1287 | TEST_F(GLES2ImplementationTest, ReadBuffer) { |
| 1288 | struct Cmds { |
| 1289 | cmds::ReadBuffer cmd; |
| 1290 | }; |
| 1291 | Cmds expected; |
| 1292 | expected.cmd.Init(1); |
| 1293 | |
| 1294 | gl_->ReadBuffer(1); |
| 1295 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1296 | } |
| 1297 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1298 | TEST_F(GLES2ImplementationTest, ReleaseShaderCompiler) { |
| 1299 | struct Cmds { |
| 1300 | cmds::ReleaseShaderCompiler cmd; |
| 1301 | }; |
| 1302 | Cmds expected; |
| 1303 | expected.cmd.Init(); |
| 1304 | |
| 1305 | gl_->ReleaseShaderCompiler(); |
| 1306 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1307 | } |
| 1308 | |
| 1309 | TEST_F(GLES2ImplementationTest, RenderbufferStorage) { |
| 1310 | struct Cmds { |
| 1311 | cmds::RenderbufferStorage cmd; |
| 1312 | }; |
| 1313 | Cmds expected; |
| 1314 | expected.cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 3, 4); |
| 1315 | |
| 1316 | gl_->RenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, 3, 4); |
| 1317 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1318 | } |
| 1319 | |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 1320 | TEST_F(GLES2ImplementationTest, ResumeTransformFeedback) { |
| 1321 | struct Cmds { |
| 1322 | cmds::ResumeTransformFeedback cmd; |
| 1323 | }; |
| 1324 | Cmds expected; |
| 1325 | expected.cmd.Init(); |
| 1326 | |
| 1327 | gl_->ResumeTransformFeedback(); |
| 1328 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1329 | } |
| 1330 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1331 | TEST_F(GLES2ImplementationTest, SampleCoverage) { |
| 1332 | struct Cmds { |
| 1333 | cmds::SampleCoverage cmd; |
| 1334 | }; |
| 1335 | Cmds expected; |
| 1336 | expected.cmd.Init(1, true); |
| 1337 | |
| 1338 | gl_->SampleCoverage(1, true); |
| 1339 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1340 | } |
| 1341 | |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 1342 | TEST_F(GLES2ImplementationTest, SamplerParameterf) { |
| 1343 | struct Cmds { |
| 1344 | cmds::SamplerParameterf cmd; |
| 1345 | }; |
| 1346 | Cmds expected; |
| 1347 | expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1348 | |
| 1349 | gl_->SamplerParameterf(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1350 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1351 | } |
| 1352 | |
| 1353 | TEST_F(GLES2ImplementationTest, SamplerParameterfv) { |
| 1354 | GLfloat data[1] = {0}; |
| 1355 | struct Cmds { |
| 1356 | cmds::SamplerParameterfvImmediate cmd; |
| 1357 | GLfloat data[1]; |
| 1358 | }; |
| 1359 | |
| 1360 | for (int jj = 0; jj < 1; ++jj) { |
| 1361 | data[jj] = static_cast<GLfloat>(jj); |
| 1362 | } |
| 1363 | Cmds expected; |
| 1364 | expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, &data[0]); |
| 1365 | gl_->SamplerParameterfv(1, GL_TEXTURE_MAG_FILTER, &data[0]); |
| 1366 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1367 | } |
| 1368 | |
| 1369 | TEST_F(GLES2ImplementationTest, SamplerParameteri) { |
| 1370 | struct Cmds { |
| 1371 | cmds::SamplerParameteri cmd; |
| 1372 | }; |
| 1373 | Cmds expected; |
| 1374 | expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1375 | |
| 1376 | gl_->SamplerParameteri(1, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1377 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1378 | } |
| 1379 | |
| 1380 | TEST_F(GLES2ImplementationTest, SamplerParameteriv) { |
| 1381 | GLint data[1] = {0}; |
| 1382 | struct Cmds { |
| 1383 | cmds::SamplerParameterivImmediate cmd; |
| 1384 | GLint data[1]; |
| 1385 | }; |
| 1386 | |
| 1387 | for (int jj = 0; jj < 1; ++jj) { |
| 1388 | data[jj] = static_cast<GLint>(jj); |
| 1389 | } |
| 1390 | Cmds expected; |
| 1391 | expected.cmd.Init(1, GL_TEXTURE_MAG_FILTER, &data[0]); |
| 1392 | gl_->SamplerParameteriv(1, GL_TEXTURE_MAG_FILTER, &data[0]); |
| 1393 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1394 | } |
| 1395 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1396 | TEST_F(GLES2ImplementationTest, Scissor) { |
| 1397 | struct Cmds { |
| 1398 | cmds::Scissor cmd; |
| 1399 | }; |
| 1400 | Cmds expected; |
| 1401 | expected.cmd.Init(1, 2, 3, 4); |
| 1402 | |
| 1403 | gl_->Scissor(1, 2, 3, 4); |
| 1404 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1405 | } |
| 1406 | |
| 1407 | TEST_F(GLES2ImplementationTest, StencilFunc) { |
| 1408 | struct Cmds { |
| 1409 | cmds::StencilFunc cmd; |
| 1410 | }; |
| 1411 | Cmds expected; |
| 1412 | expected.cmd.Init(GL_NEVER, 2, 3); |
| 1413 | |
| 1414 | gl_->StencilFunc(GL_NEVER, 2, 3); |
| 1415 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1416 | } |
| 1417 | |
| 1418 | TEST_F(GLES2ImplementationTest, StencilFuncSeparate) { |
| 1419 | struct Cmds { |
| 1420 | cmds::StencilFuncSeparate cmd; |
| 1421 | }; |
| 1422 | Cmds expected; |
| 1423 | expected.cmd.Init(GL_FRONT, GL_NEVER, 3, 4); |
| 1424 | |
| 1425 | gl_->StencilFuncSeparate(GL_FRONT, GL_NEVER, 3, 4); |
| 1426 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1427 | } |
| 1428 | |
| 1429 | TEST_F(GLES2ImplementationTest, StencilMask) { |
| 1430 | struct Cmds { |
| 1431 | cmds::StencilMask cmd; |
| 1432 | }; |
| 1433 | Cmds expected; |
| 1434 | expected.cmd.Init(1); |
| 1435 | |
| 1436 | gl_->StencilMask(1); |
| 1437 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1438 | } |
| 1439 | |
| 1440 | TEST_F(GLES2ImplementationTest, StencilMaskSeparate) { |
| 1441 | struct Cmds { |
| 1442 | cmds::StencilMaskSeparate cmd; |
| 1443 | }; |
| 1444 | Cmds expected; |
| 1445 | expected.cmd.Init(GL_FRONT, 2); |
| 1446 | |
| 1447 | gl_->StencilMaskSeparate(GL_FRONT, 2); |
| 1448 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1449 | } |
| 1450 | |
| 1451 | TEST_F(GLES2ImplementationTest, StencilOp) { |
| 1452 | struct Cmds { |
| 1453 | cmds::StencilOp cmd; |
| 1454 | }; |
| 1455 | Cmds expected; |
| 1456 | expected.cmd.Init(GL_KEEP, GL_INCR, GL_KEEP); |
| 1457 | |
| 1458 | gl_->StencilOp(GL_KEEP, GL_INCR, GL_KEEP); |
| 1459 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1460 | } |
| 1461 | |
| 1462 | TEST_F(GLES2ImplementationTest, StencilOpSeparate) { |
| 1463 | struct Cmds { |
| 1464 | cmds::StencilOpSeparate cmd; |
| 1465 | }; |
| 1466 | Cmds expected; |
| 1467 | expected.cmd.Init(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP); |
| 1468 | |
| 1469 | gl_->StencilOpSeparate(GL_FRONT, GL_INCR, GL_KEEP, GL_KEEP); |
| 1470 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1471 | } |
| 1472 | |
| 1473 | TEST_F(GLES2ImplementationTest, TexParameterf) { |
| 1474 | struct Cmds { |
| 1475 | cmds::TexParameterf cmd; |
| 1476 | }; |
| 1477 | Cmds expected; |
| 1478 | expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1479 | |
| 1480 | gl_->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1481 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1482 | } |
| 1483 | |
| 1484 | TEST_F(GLES2ImplementationTest, TexParameterfv) { |
| 1485 | GLfloat data[1] = {0}; |
| 1486 | struct Cmds { |
| 1487 | cmds::TexParameterfvImmediate cmd; |
| 1488 | GLfloat data[1]; |
| 1489 | }; |
| 1490 | |
| 1491 | for (int jj = 0; jj < 1; ++jj) { |
| 1492 | data[jj] = static_cast<GLfloat>(jj); |
| 1493 | } |
| 1494 | Cmds expected; |
| 1495 | expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]); |
| 1496 | gl_->TexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]); |
| 1497 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1498 | } |
| 1499 | |
| 1500 | TEST_F(GLES2ImplementationTest, TexParameteri) { |
| 1501 | struct Cmds { |
| 1502 | cmds::TexParameteri cmd; |
| 1503 | }; |
| 1504 | Cmds expected; |
| 1505 | expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1506 | |
| 1507 | gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1508 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1509 | } |
| 1510 | |
| 1511 | TEST_F(GLES2ImplementationTest, TexParameteriv) { |
| 1512 | GLint data[1] = {0}; |
| 1513 | struct Cmds { |
| 1514 | cmds::TexParameterivImmediate cmd; |
| 1515 | GLint data[1]; |
| 1516 | }; |
| 1517 | |
| 1518 | for (int jj = 0; jj < 1; ++jj) { |
| 1519 | data[jj] = static_cast<GLint>(jj); |
| 1520 | } |
| 1521 | Cmds expected; |
| 1522 | expected.cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]); |
| 1523 | gl_->TexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &data[0]); |
| 1524 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1525 | } |
| 1526 | |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 1527 | TEST_F(GLES2ImplementationTest, TexStorage3D) { |
| 1528 | struct Cmds { |
| 1529 | cmds::TexStorage3D cmd; |
| 1530 | }; |
| 1531 | Cmds expected; |
| 1532 | expected.cmd.Init(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6); |
| 1533 | |
| 1534 | gl_->TexStorage3D(GL_TEXTURE_3D, 2, GL_RGB565, 4, 5, 6); |
| 1535 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1536 | } |
| 1537 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1538 | TEST_F(GLES2ImplementationTest, Uniform1f) { |
| 1539 | struct Cmds { |
| 1540 | cmds::Uniform1f cmd; |
| 1541 | }; |
| 1542 | Cmds expected; |
| 1543 | expected.cmd.Init(1, 2); |
| 1544 | |
| 1545 | gl_->Uniform1f(1, 2); |
| 1546 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1547 | } |
| 1548 | |
| 1549 | TEST_F(GLES2ImplementationTest, Uniform1fv) { |
| 1550 | GLfloat data[2][1] = {{0}}; |
| 1551 | struct Cmds { |
| 1552 | cmds::Uniform1fvImmediate cmd; |
| 1553 | GLfloat data[2][1]; |
| 1554 | }; |
| 1555 | |
| 1556 | Cmds expected; |
| 1557 | for (int ii = 0; ii < 2; ++ii) { |
| 1558 | for (int jj = 0; jj < 1; ++jj) { |
| 1559 | data[ii][jj] = static_cast<GLfloat>(ii * 1 + jj); |
| 1560 | } |
| 1561 | } |
| 1562 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1563 | gl_->Uniform1fv(1, 2, &data[0][0]); |
| 1564 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1565 | } |
| 1566 | |
| 1567 | TEST_F(GLES2ImplementationTest, Uniform1i) { |
| 1568 | struct Cmds { |
| 1569 | cmds::Uniform1i cmd; |
| 1570 | }; |
| 1571 | Cmds expected; |
| 1572 | expected.cmd.Init(1, 2); |
| 1573 | |
| 1574 | gl_->Uniform1i(1, 2); |
| 1575 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1576 | } |
| 1577 | |
| 1578 | TEST_F(GLES2ImplementationTest, Uniform1iv) { |
| 1579 | GLint data[2][1] = {{0}}; |
| 1580 | struct Cmds { |
| 1581 | cmds::Uniform1ivImmediate cmd; |
| 1582 | GLint data[2][1]; |
| 1583 | }; |
| 1584 | |
| 1585 | Cmds expected; |
| 1586 | for (int ii = 0; ii < 2; ++ii) { |
| 1587 | for (int jj = 0; jj < 1; ++jj) { |
| 1588 | data[ii][jj] = static_cast<GLint>(ii * 1 + jj); |
| 1589 | } |
| 1590 | } |
| 1591 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1592 | gl_->Uniform1iv(1, 2, &data[0][0]); |
| 1593 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1594 | } |
| 1595 | |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 1596 | TEST_F(GLES2ImplementationTest, Uniform1ui) { |
| 1597 | struct Cmds { |
| 1598 | cmds::Uniform1ui cmd; |
| 1599 | }; |
| 1600 | Cmds expected; |
| 1601 | expected.cmd.Init(1, 2); |
| 1602 | |
| 1603 | gl_->Uniform1ui(1, 2); |
| 1604 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1605 | } |
| 1606 | |
| 1607 | TEST_F(GLES2ImplementationTest, Uniform1uiv) { |
| 1608 | GLuint data[2][1] = {{0}}; |
| 1609 | struct Cmds { |
| 1610 | cmds::Uniform1uivImmediate cmd; |
| 1611 | GLuint data[2][1]; |
| 1612 | }; |
| 1613 | |
| 1614 | Cmds expected; |
| 1615 | for (int ii = 0; ii < 2; ++ii) { |
| 1616 | for (int jj = 0; jj < 1; ++jj) { |
| 1617 | data[ii][jj] = static_cast<GLuint>(ii * 1 + jj); |
| 1618 | } |
| 1619 | } |
| 1620 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1621 | gl_->Uniform1uiv(1, 2, &data[0][0]); |
| 1622 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1623 | } |
| 1624 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1625 | TEST_F(GLES2ImplementationTest, Uniform2f) { |
| 1626 | struct Cmds { |
| 1627 | cmds::Uniform2f cmd; |
| 1628 | }; |
| 1629 | Cmds expected; |
| 1630 | expected.cmd.Init(1, 2, 3); |
| 1631 | |
| 1632 | gl_->Uniform2f(1, 2, 3); |
| 1633 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1634 | } |
| 1635 | |
| 1636 | TEST_F(GLES2ImplementationTest, Uniform2fv) { |
| 1637 | GLfloat data[2][2] = {{0}}; |
| 1638 | struct Cmds { |
| 1639 | cmds::Uniform2fvImmediate cmd; |
| 1640 | GLfloat data[2][2]; |
| 1641 | }; |
| 1642 | |
| 1643 | Cmds expected; |
| 1644 | for (int ii = 0; ii < 2; ++ii) { |
| 1645 | for (int jj = 0; jj < 2; ++jj) { |
| 1646 | data[ii][jj] = static_cast<GLfloat>(ii * 2 + jj); |
| 1647 | } |
| 1648 | } |
| 1649 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1650 | gl_->Uniform2fv(1, 2, &data[0][0]); |
| 1651 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1652 | } |
| 1653 | |
| 1654 | TEST_F(GLES2ImplementationTest, Uniform2i) { |
| 1655 | struct Cmds { |
| 1656 | cmds::Uniform2i cmd; |
| 1657 | }; |
| 1658 | Cmds expected; |
| 1659 | expected.cmd.Init(1, 2, 3); |
| 1660 | |
| 1661 | gl_->Uniform2i(1, 2, 3); |
| 1662 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1663 | } |
| 1664 | |
| 1665 | TEST_F(GLES2ImplementationTest, Uniform2iv) { |
| 1666 | GLint data[2][2] = {{0}}; |
| 1667 | struct Cmds { |
| 1668 | cmds::Uniform2ivImmediate cmd; |
| 1669 | GLint data[2][2]; |
| 1670 | }; |
| 1671 | |
| 1672 | Cmds expected; |
| 1673 | for (int ii = 0; ii < 2; ++ii) { |
| 1674 | for (int jj = 0; jj < 2; ++jj) { |
| 1675 | data[ii][jj] = static_cast<GLint>(ii * 2 + jj); |
| 1676 | } |
| 1677 | } |
| 1678 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1679 | gl_->Uniform2iv(1, 2, &data[0][0]); |
| 1680 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1681 | } |
| 1682 | |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 1683 | TEST_F(GLES2ImplementationTest, Uniform2ui) { |
| 1684 | struct Cmds { |
| 1685 | cmds::Uniform2ui cmd; |
| 1686 | }; |
| 1687 | Cmds expected; |
| 1688 | expected.cmd.Init(1, 2, 3); |
| 1689 | |
| 1690 | gl_->Uniform2ui(1, 2, 3); |
| 1691 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1692 | } |
| 1693 | |
| 1694 | TEST_F(GLES2ImplementationTest, Uniform2uiv) { |
| 1695 | GLuint data[2][2] = {{0}}; |
| 1696 | struct Cmds { |
| 1697 | cmds::Uniform2uivImmediate cmd; |
| 1698 | GLuint data[2][2]; |
| 1699 | }; |
| 1700 | |
| 1701 | Cmds expected; |
| 1702 | for (int ii = 0; ii < 2; ++ii) { |
| 1703 | for (int jj = 0; jj < 2; ++jj) { |
| 1704 | data[ii][jj] = static_cast<GLuint>(ii * 2 + jj); |
| 1705 | } |
| 1706 | } |
| 1707 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1708 | gl_->Uniform2uiv(1, 2, &data[0][0]); |
| 1709 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1710 | } |
| 1711 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1712 | TEST_F(GLES2ImplementationTest, Uniform3f) { |
| 1713 | struct Cmds { |
| 1714 | cmds::Uniform3f cmd; |
| 1715 | }; |
| 1716 | Cmds expected; |
| 1717 | expected.cmd.Init(1, 2, 3, 4); |
| 1718 | |
| 1719 | gl_->Uniform3f(1, 2, 3, 4); |
| 1720 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1721 | } |
| 1722 | |
| 1723 | TEST_F(GLES2ImplementationTest, Uniform3fv) { |
| 1724 | GLfloat data[2][3] = {{0}}; |
| 1725 | struct Cmds { |
| 1726 | cmds::Uniform3fvImmediate cmd; |
| 1727 | GLfloat data[2][3]; |
| 1728 | }; |
| 1729 | |
| 1730 | Cmds expected; |
| 1731 | for (int ii = 0; ii < 2; ++ii) { |
| 1732 | for (int jj = 0; jj < 3; ++jj) { |
| 1733 | data[ii][jj] = static_cast<GLfloat>(ii * 3 + jj); |
| 1734 | } |
| 1735 | } |
| 1736 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1737 | gl_->Uniform3fv(1, 2, &data[0][0]); |
| 1738 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1739 | } |
| 1740 | |
| 1741 | TEST_F(GLES2ImplementationTest, Uniform3i) { |
| 1742 | struct Cmds { |
| 1743 | cmds::Uniform3i cmd; |
| 1744 | }; |
| 1745 | Cmds expected; |
| 1746 | expected.cmd.Init(1, 2, 3, 4); |
| 1747 | |
| 1748 | gl_->Uniform3i(1, 2, 3, 4); |
| 1749 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1750 | } |
| 1751 | |
| 1752 | TEST_F(GLES2ImplementationTest, Uniform3iv) { |
| 1753 | GLint data[2][3] = {{0}}; |
| 1754 | struct Cmds { |
| 1755 | cmds::Uniform3ivImmediate cmd; |
| 1756 | GLint data[2][3]; |
| 1757 | }; |
| 1758 | |
| 1759 | Cmds expected; |
| 1760 | for (int ii = 0; ii < 2; ++ii) { |
| 1761 | for (int jj = 0; jj < 3; ++jj) { |
| 1762 | data[ii][jj] = static_cast<GLint>(ii * 3 + jj); |
| 1763 | } |
| 1764 | } |
| 1765 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1766 | gl_->Uniform3iv(1, 2, &data[0][0]); |
| 1767 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1768 | } |
| 1769 | |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 1770 | TEST_F(GLES2ImplementationTest, Uniform3ui) { |
| 1771 | struct Cmds { |
| 1772 | cmds::Uniform3ui cmd; |
| 1773 | }; |
| 1774 | Cmds expected; |
| 1775 | expected.cmd.Init(1, 2, 3, 4); |
| 1776 | |
| 1777 | gl_->Uniform3ui(1, 2, 3, 4); |
| 1778 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1779 | } |
| 1780 | |
| 1781 | TEST_F(GLES2ImplementationTest, Uniform3uiv) { |
| 1782 | GLuint data[2][3] = {{0}}; |
| 1783 | struct Cmds { |
| 1784 | cmds::Uniform3uivImmediate cmd; |
| 1785 | GLuint data[2][3]; |
| 1786 | }; |
| 1787 | |
| 1788 | Cmds expected; |
| 1789 | for (int ii = 0; ii < 2; ++ii) { |
| 1790 | for (int jj = 0; jj < 3; ++jj) { |
| 1791 | data[ii][jj] = static_cast<GLuint>(ii * 3 + jj); |
| 1792 | } |
| 1793 | } |
| 1794 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1795 | gl_->Uniform3uiv(1, 2, &data[0][0]); |
| 1796 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1797 | } |
| 1798 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1799 | TEST_F(GLES2ImplementationTest, Uniform4f) { |
| 1800 | struct Cmds { |
| 1801 | cmds::Uniform4f cmd; |
| 1802 | }; |
| 1803 | Cmds expected; |
| 1804 | expected.cmd.Init(1, 2, 3, 4, 5); |
| 1805 | |
| 1806 | gl_->Uniform4f(1, 2, 3, 4, 5); |
| 1807 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1808 | } |
| 1809 | |
| 1810 | TEST_F(GLES2ImplementationTest, Uniform4fv) { |
| 1811 | GLfloat data[2][4] = {{0}}; |
| 1812 | struct Cmds { |
| 1813 | cmds::Uniform4fvImmediate cmd; |
| 1814 | GLfloat data[2][4]; |
| 1815 | }; |
| 1816 | |
| 1817 | Cmds expected; |
| 1818 | for (int ii = 0; ii < 2; ++ii) { |
| 1819 | for (int jj = 0; jj < 4; ++jj) { |
| 1820 | data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj); |
| 1821 | } |
| 1822 | } |
| 1823 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1824 | gl_->Uniform4fv(1, 2, &data[0][0]); |
| 1825 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1826 | } |
| 1827 | |
| 1828 | TEST_F(GLES2ImplementationTest, Uniform4i) { |
| 1829 | struct Cmds { |
| 1830 | cmds::Uniform4i cmd; |
| 1831 | }; |
| 1832 | Cmds expected; |
| 1833 | expected.cmd.Init(1, 2, 3, 4, 5); |
| 1834 | |
| 1835 | gl_->Uniform4i(1, 2, 3, 4, 5); |
| 1836 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1837 | } |
| 1838 | |
| 1839 | TEST_F(GLES2ImplementationTest, Uniform4iv) { |
| 1840 | GLint data[2][4] = {{0}}; |
| 1841 | struct Cmds { |
| 1842 | cmds::Uniform4ivImmediate cmd; |
| 1843 | GLint data[2][4]; |
| 1844 | }; |
| 1845 | |
| 1846 | Cmds expected; |
| 1847 | for (int ii = 0; ii < 2; ++ii) { |
| 1848 | for (int jj = 0; jj < 4; ++jj) { |
| 1849 | data[ii][jj] = static_cast<GLint>(ii * 4 + jj); |
| 1850 | } |
| 1851 | } |
| 1852 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1853 | gl_->Uniform4iv(1, 2, &data[0][0]); |
| 1854 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1855 | } |
| 1856 | |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 1857 | TEST_F(GLES2ImplementationTest, Uniform4ui) { |
| 1858 | struct Cmds { |
| 1859 | cmds::Uniform4ui cmd; |
| 1860 | }; |
| 1861 | Cmds expected; |
| 1862 | expected.cmd.Init(1, 2, 3, 4, 5); |
| 1863 | |
| 1864 | gl_->Uniform4ui(1, 2, 3, 4, 5); |
| 1865 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1866 | } |
| 1867 | |
| 1868 | TEST_F(GLES2ImplementationTest, Uniform4uiv) { |
| 1869 | GLuint data[2][4] = {{0}}; |
| 1870 | struct Cmds { |
| 1871 | cmds::Uniform4uivImmediate cmd; |
| 1872 | GLuint data[2][4]; |
| 1873 | }; |
| 1874 | |
| 1875 | Cmds expected; |
| 1876 | for (int ii = 0; ii < 2; ++ii) { |
| 1877 | for (int jj = 0; jj < 4; ++jj) { |
| 1878 | data[ii][jj] = static_cast<GLuint>(ii * 4 + jj); |
| 1879 | } |
| 1880 | } |
| 1881 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1882 | gl_->Uniform4uiv(1, 2, &data[0][0]); |
| 1883 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1884 | } |
| 1885 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1886 | TEST_F(GLES2ImplementationTest, UniformMatrix2fv) { |
| 1887 | GLfloat data[2][4] = {{0}}; |
| 1888 | struct Cmds { |
| 1889 | cmds::UniformMatrix2fvImmediate cmd; |
| 1890 | GLfloat data[2][4]; |
| 1891 | }; |
| 1892 | |
| 1893 | Cmds expected; |
| 1894 | for (int ii = 0; ii < 2; ++ii) { |
| 1895 | for (int jj = 0; jj < 4; ++jj) { |
| 1896 | data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj); |
| 1897 | } |
| 1898 | } |
| 1899 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1900 | gl_->UniformMatrix2fv(1, 2, false, &data[0][0]); |
| 1901 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1902 | } |
| 1903 | |
| 1904 | TEST_F(GLES2ImplementationTest, UniformMatrix2fvInvalidConstantArg2) { |
| 1905 | GLfloat data[2][4] = {{0}}; |
| 1906 | for (int ii = 0; ii < 2; ++ii) { |
| 1907 | for (int jj = 0; jj < 4; ++jj) { |
| 1908 | data[ii][jj] = static_cast<GLfloat>(ii * 4 + jj); |
| 1909 | } |
| 1910 | } |
| 1911 | gl_->UniformMatrix2fv(1, 2, true, &data[0][0]); |
| 1912 | EXPECT_TRUE(NoCommandsWritten()); |
| 1913 | EXPECT_EQ(GL_INVALID_VALUE, CheckError()); |
| 1914 | } |
| 1915 | |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 1916 | TEST_F(GLES2ImplementationTest, UniformMatrix2x3fv) { |
| 1917 | GLfloat data[2][6] = {{0}}; |
| 1918 | struct Cmds { |
| 1919 | cmds::UniformMatrix2x3fvImmediate cmd; |
| 1920 | GLfloat data[2][6]; |
| 1921 | }; |
| 1922 | |
| 1923 | Cmds expected; |
| 1924 | for (int ii = 0; ii < 2; ++ii) { |
| 1925 | for (int jj = 0; jj < 6; ++jj) { |
| 1926 | data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj); |
| 1927 | } |
| 1928 | } |
| 1929 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1930 | gl_->UniformMatrix2x3fv(1, 2, false, &data[0][0]); |
| 1931 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1932 | } |
| 1933 | |
| 1934 | TEST_F(GLES2ImplementationTest, UniformMatrix2x3fvInvalidConstantArg2) { |
| 1935 | GLfloat data[2][6] = {{0}}; |
| 1936 | for (int ii = 0; ii < 2; ++ii) { |
| 1937 | for (int jj = 0; jj < 6; ++jj) { |
| 1938 | data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj); |
| 1939 | } |
| 1940 | } |
| 1941 | gl_->UniformMatrix2x3fv(1, 2, true, &data[0][0]); |
| 1942 | EXPECT_TRUE(NoCommandsWritten()); |
| 1943 | EXPECT_EQ(GL_INVALID_VALUE, CheckError()); |
| 1944 | } |
| 1945 | |
| 1946 | TEST_F(GLES2ImplementationTest, UniformMatrix2x4fv) { |
| 1947 | GLfloat data[2][8] = {{0}}; |
| 1948 | struct Cmds { |
| 1949 | cmds::UniformMatrix2x4fvImmediate cmd; |
| 1950 | GLfloat data[2][8]; |
| 1951 | }; |
| 1952 | |
| 1953 | Cmds expected; |
| 1954 | for (int ii = 0; ii < 2; ++ii) { |
| 1955 | for (int jj = 0; jj < 8; ++jj) { |
| 1956 | data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj); |
| 1957 | } |
| 1958 | } |
| 1959 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1960 | gl_->UniformMatrix2x4fv(1, 2, false, &data[0][0]); |
| 1961 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1962 | } |
| 1963 | |
| 1964 | TEST_F(GLES2ImplementationTest, UniformMatrix2x4fvInvalidConstantArg2) { |
| 1965 | GLfloat data[2][8] = {{0}}; |
| 1966 | for (int ii = 0; ii < 2; ++ii) { |
| 1967 | for (int jj = 0; jj < 8; ++jj) { |
| 1968 | data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj); |
| 1969 | } |
| 1970 | } |
| 1971 | gl_->UniformMatrix2x4fv(1, 2, true, &data[0][0]); |
| 1972 | EXPECT_TRUE(NoCommandsWritten()); |
| 1973 | EXPECT_EQ(GL_INVALID_VALUE, CheckError()); |
| 1974 | } |
| 1975 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1976 | TEST_F(GLES2ImplementationTest, UniformMatrix3fv) { |
| 1977 | GLfloat data[2][9] = {{0}}; |
| 1978 | struct Cmds { |
| 1979 | cmds::UniformMatrix3fvImmediate cmd; |
| 1980 | GLfloat data[2][9]; |
| 1981 | }; |
| 1982 | |
| 1983 | Cmds expected; |
| 1984 | for (int ii = 0; ii < 2; ++ii) { |
| 1985 | for (int jj = 0; jj < 9; ++jj) { |
| 1986 | data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj); |
| 1987 | } |
| 1988 | } |
| 1989 | expected.cmd.Init(1, 2, &data[0][0]); |
| 1990 | gl_->UniformMatrix3fv(1, 2, false, &data[0][0]); |
| 1991 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1992 | } |
| 1993 | |
| 1994 | TEST_F(GLES2ImplementationTest, UniformMatrix3fvInvalidConstantArg2) { |
| 1995 | GLfloat data[2][9] = {{0}}; |
| 1996 | for (int ii = 0; ii < 2; ++ii) { |
| 1997 | for (int jj = 0; jj < 9; ++jj) { |
| 1998 | data[ii][jj] = static_cast<GLfloat>(ii * 9 + jj); |
| 1999 | } |
| 2000 | } |
| 2001 | gl_->UniformMatrix3fv(1, 2, true, &data[0][0]); |
| 2002 | EXPECT_TRUE(NoCommandsWritten()); |
| 2003 | EXPECT_EQ(GL_INVALID_VALUE, CheckError()); |
| 2004 | } |
| 2005 | |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 2006 | TEST_F(GLES2ImplementationTest, UniformMatrix3x2fv) { |
| 2007 | GLfloat data[2][6] = {{0}}; |
| 2008 | struct Cmds { |
| 2009 | cmds::UniformMatrix3x2fvImmediate cmd; |
| 2010 | GLfloat data[2][6]; |
| 2011 | }; |
| 2012 | |
| 2013 | Cmds expected; |
| 2014 | for (int ii = 0; ii < 2; ++ii) { |
| 2015 | for (int jj = 0; jj < 6; ++jj) { |
| 2016 | data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj); |
| 2017 | } |
| 2018 | } |
| 2019 | expected.cmd.Init(1, 2, &data[0][0]); |
| 2020 | gl_->UniformMatrix3x2fv(1, 2, false, &data[0][0]); |
| 2021 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2022 | } |
| 2023 | |
| 2024 | TEST_F(GLES2ImplementationTest, UniformMatrix3x2fvInvalidConstantArg2) { |
| 2025 | GLfloat data[2][6] = {{0}}; |
| 2026 | for (int ii = 0; ii < 2; ++ii) { |
| 2027 | for (int jj = 0; jj < 6; ++jj) { |
| 2028 | data[ii][jj] = static_cast<GLfloat>(ii * 6 + jj); |
| 2029 | } |
| 2030 | } |
| 2031 | gl_->UniformMatrix3x2fv(1, 2, true, &data[0][0]); |
| 2032 | EXPECT_TRUE(NoCommandsWritten()); |
| 2033 | EXPECT_EQ(GL_INVALID_VALUE, CheckError()); |
| 2034 | } |
| 2035 | |
| 2036 | TEST_F(GLES2ImplementationTest, UniformMatrix3x4fv) { |
| 2037 | GLfloat data[2][12] = {{0}}; |
| 2038 | struct Cmds { |
| 2039 | cmds::UniformMatrix3x4fvImmediate cmd; |
| 2040 | GLfloat data[2][12]; |
| 2041 | }; |
| 2042 | |
| 2043 | Cmds expected; |
| 2044 | for (int ii = 0; ii < 2; ++ii) { |
| 2045 | for (int jj = 0; jj < 12; ++jj) { |
| 2046 | data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj); |
| 2047 | } |
| 2048 | } |
| 2049 | expected.cmd.Init(1, 2, &data[0][0]); |
| 2050 | gl_->UniformMatrix3x4fv(1, 2, false, &data[0][0]); |
| 2051 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2052 | } |
| 2053 | |
| 2054 | TEST_F(GLES2ImplementationTest, UniformMatrix3x4fvInvalidConstantArg2) { |
| 2055 | GLfloat data[2][12] = {{0}}; |
| 2056 | for (int ii = 0; ii < 2; ++ii) { |
| 2057 | for (int jj = 0; jj < 12; ++jj) { |
| 2058 | data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj); |
| 2059 | } |
| 2060 | } |
| 2061 | gl_->UniformMatrix3x4fv(1, 2, true, &data[0][0]); |
| 2062 | EXPECT_TRUE(NoCommandsWritten()); |
| 2063 | EXPECT_EQ(GL_INVALID_VALUE, CheckError()); |
| 2064 | } |
| 2065 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 2066 | TEST_F(GLES2ImplementationTest, UniformMatrix4fv) { |
| 2067 | GLfloat data[2][16] = {{0}}; |
| 2068 | struct Cmds { |
| 2069 | cmds::UniformMatrix4fvImmediate cmd; |
| 2070 | GLfloat data[2][16]; |
| 2071 | }; |
| 2072 | |
| 2073 | Cmds expected; |
| 2074 | for (int ii = 0; ii < 2; ++ii) { |
| 2075 | for (int jj = 0; jj < 16; ++jj) { |
| 2076 | data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj); |
| 2077 | } |
| 2078 | } |
| 2079 | expected.cmd.Init(1, 2, &data[0][0]); |
| 2080 | gl_->UniformMatrix4fv(1, 2, false, &data[0][0]); |
| 2081 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2082 | } |
| 2083 | |
| 2084 | TEST_F(GLES2ImplementationTest, UniformMatrix4fvInvalidConstantArg2) { |
| 2085 | GLfloat data[2][16] = {{0}}; |
| 2086 | for (int ii = 0; ii < 2; ++ii) { |
| 2087 | for (int jj = 0; jj < 16; ++jj) { |
| 2088 | data[ii][jj] = static_cast<GLfloat>(ii * 16 + jj); |
| 2089 | } |
| 2090 | } |
| 2091 | gl_->UniformMatrix4fv(1, 2, true, &data[0][0]); |
| 2092 | EXPECT_TRUE(NoCommandsWritten()); |
| 2093 | EXPECT_EQ(GL_INVALID_VALUE, CheckError()); |
| 2094 | } |
| 2095 | |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 2096 | TEST_F(GLES2ImplementationTest, UniformMatrix4x2fv) { |
| 2097 | GLfloat data[2][8] = {{0}}; |
| 2098 | struct Cmds { |
| 2099 | cmds::UniformMatrix4x2fvImmediate cmd; |
| 2100 | GLfloat data[2][8]; |
| 2101 | }; |
| 2102 | |
| 2103 | Cmds expected; |
| 2104 | for (int ii = 0; ii < 2; ++ii) { |
| 2105 | for (int jj = 0; jj < 8; ++jj) { |
| 2106 | data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj); |
| 2107 | } |
| 2108 | } |
| 2109 | expected.cmd.Init(1, 2, &data[0][0]); |
| 2110 | gl_->UniformMatrix4x2fv(1, 2, false, &data[0][0]); |
| 2111 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2112 | } |
| 2113 | |
| 2114 | TEST_F(GLES2ImplementationTest, UniformMatrix4x2fvInvalidConstantArg2) { |
| 2115 | GLfloat data[2][8] = {{0}}; |
| 2116 | for (int ii = 0; ii < 2; ++ii) { |
| 2117 | for (int jj = 0; jj < 8; ++jj) { |
| 2118 | data[ii][jj] = static_cast<GLfloat>(ii * 8 + jj); |
| 2119 | } |
| 2120 | } |
| 2121 | gl_->UniformMatrix4x2fv(1, 2, true, &data[0][0]); |
| 2122 | EXPECT_TRUE(NoCommandsWritten()); |
| 2123 | EXPECT_EQ(GL_INVALID_VALUE, CheckError()); |
| 2124 | } |
| 2125 | |
| 2126 | TEST_F(GLES2ImplementationTest, UniformMatrix4x3fv) { |
| 2127 | GLfloat data[2][12] = {{0}}; |
| 2128 | struct Cmds { |
| 2129 | cmds::UniformMatrix4x3fvImmediate cmd; |
| 2130 | GLfloat data[2][12]; |
| 2131 | }; |
| 2132 | |
| 2133 | Cmds expected; |
| 2134 | for (int ii = 0; ii < 2; ++ii) { |
| 2135 | for (int jj = 0; jj < 12; ++jj) { |
| 2136 | data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj); |
| 2137 | } |
| 2138 | } |
| 2139 | expected.cmd.Init(1, 2, &data[0][0]); |
| 2140 | gl_->UniformMatrix4x3fv(1, 2, false, &data[0][0]); |
| 2141 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2142 | } |
| 2143 | |
| 2144 | TEST_F(GLES2ImplementationTest, UniformMatrix4x3fvInvalidConstantArg2) { |
| 2145 | GLfloat data[2][12] = {{0}}; |
| 2146 | for (int ii = 0; ii < 2; ++ii) { |
| 2147 | for (int jj = 0; jj < 12; ++jj) { |
| 2148 | data[ii][jj] = static_cast<GLfloat>(ii * 12 + jj); |
| 2149 | } |
| 2150 | } |
| 2151 | gl_->UniformMatrix4x3fv(1, 2, true, &data[0][0]); |
| 2152 | EXPECT_TRUE(NoCommandsWritten()); |
| 2153 | EXPECT_EQ(GL_INVALID_VALUE, CheckError()); |
| 2154 | } |
| 2155 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 2156 | TEST_F(GLES2ImplementationTest, UseProgram) { |
| 2157 | struct Cmds { |
| 2158 | cmds::UseProgram cmd; |
| 2159 | }; |
| 2160 | Cmds expected; |
| 2161 | expected.cmd.Init(1); |
| 2162 | |
| 2163 | gl_->UseProgram(1); |
| 2164 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2165 | ClearCommands(); |
| 2166 | gl_->UseProgram(1); |
| 2167 | EXPECT_TRUE(NoCommandsWritten()); |
| 2168 | } |
| 2169 | |
| 2170 | TEST_F(GLES2ImplementationTest, ValidateProgram) { |
| 2171 | struct Cmds { |
| 2172 | cmds::ValidateProgram cmd; |
| 2173 | }; |
| 2174 | Cmds expected; |
| 2175 | expected.cmd.Init(1); |
| 2176 | |
| 2177 | gl_->ValidateProgram(1); |
| 2178 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2179 | } |
| 2180 | |
| 2181 | TEST_F(GLES2ImplementationTest, VertexAttrib1f) { |
| 2182 | struct Cmds { |
| 2183 | cmds::VertexAttrib1f cmd; |
| 2184 | }; |
| 2185 | Cmds expected; |
| 2186 | expected.cmd.Init(1, 2); |
| 2187 | |
| 2188 | gl_->VertexAttrib1f(1, 2); |
| 2189 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2190 | } |
| 2191 | |
| 2192 | TEST_F(GLES2ImplementationTest, VertexAttrib1fv) { |
| 2193 | GLfloat data[1] = {0}; |
| 2194 | struct Cmds { |
| 2195 | cmds::VertexAttrib1fvImmediate cmd; |
| 2196 | GLfloat data[1]; |
| 2197 | }; |
| 2198 | |
| 2199 | for (int jj = 0; jj < 1; ++jj) { |
| 2200 | data[jj] = static_cast<GLfloat>(jj); |
| 2201 | } |
| 2202 | Cmds expected; |
| 2203 | expected.cmd.Init(1, &data[0]); |
| 2204 | gl_->VertexAttrib1fv(1, &data[0]); |
| 2205 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2206 | } |
| 2207 | |
| 2208 | TEST_F(GLES2ImplementationTest, VertexAttrib2f) { |
| 2209 | struct Cmds { |
| 2210 | cmds::VertexAttrib2f cmd; |
| 2211 | }; |
| 2212 | Cmds expected; |
| 2213 | expected.cmd.Init(1, 2, 3); |
| 2214 | |
| 2215 | gl_->VertexAttrib2f(1, 2, 3); |
| 2216 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2217 | } |
| 2218 | |
| 2219 | TEST_F(GLES2ImplementationTest, VertexAttrib2fv) { |
| 2220 | GLfloat data[2] = {0}; |
| 2221 | struct Cmds { |
| 2222 | cmds::VertexAttrib2fvImmediate cmd; |
| 2223 | GLfloat data[2]; |
| 2224 | }; |
| 2225 | |
| 2226 | for (int jj = 0; jj < 2; ++jj) { |
| 2227 | data[jj] = static_cast<GLfloat>(jj); |
| 2228 | } |
| 2229 | Cmds expected; |
| 2230 | expected.cmd.Init(1, &data[0]); |
| 2231 | gl_->VertexAttrib2fv(1, &data[0]); |
| 2232 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2233 | } |
| 2234 | |
| 2235 | TEST_F(GLES2ImplementationTest, VertexAttrib3f) { |
| 2236 | struct Cmds { |
| 2237 | cmds::VertexAttrib3f cmd; |
| 2238 | }; |
| 2239 | Cmds expected; |
| 2240 | expected.cmd.Init(1, 2, 3, 4); |
| 2241 | |
| 2242 | gl_->VertexAttrib3f(1, 2, 3, 4); |
| 2243 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2244 | } |
| 2245 | |
| 2246 | TEST_F(GLES2ImplementationTest, VertexAttrib3fv) { |
| 2247 | GLfloat data[3] = {0}; |
| 2248 | struct Cmds { |
| 2249 | cmds::VertexAttrib3fvImmediate cmd; |
| 2250 | GLfloat data[3]; |
| 2251 | }; |
| 2252 | |
| 2253 | for (int jj = 0; jj < 3; ++jj) { |
| 2254 | data[jj] = static_cast<GLfloat>(jj); |
| 2255 | } |
| 2256 | Cmds expected; |
| 2257 | expected.cmd.Init(1, &data[0]); |
| 2258 | gl_->VertexAttrib3fv(1, &data[0]); |
| 2259 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2260 | } |
| 2261 | |
| 2262 | TEST_F(GLES2ImplementationTest, VertexAttrib4f) { |
| 2263 | struct Cmds { |
| 2264 | cmds::VertexAttrib4f cmd; |
| 2265 | }; |
| 2266 | Cmds expected; |
| 2267 | expected.cmd.Init(1, 2, 3, 4, 5); |
| 2268 | |
| 2269 | gl_->VertexAttrib4f(1, 2, 3, 4, 5); |
| 2270 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2271 | } |
| 2272 | |
| 2273 | TEST_F(GLES2ImplementationTest, VertexAttrib4fv) { |
| 2274 | GLfloat data[4] = {0}; |
| 2275 | struct Cmds { |
| 2276 | cmds::VertexAttrib4fvImmediate cmd; |
| 2277 | GLfloat data[4]; |
| 2278 | }; |
| 2279 | |
| 2280 | for (int jj = 0; jj < 4; ++jj) { |
| 2281 | data[jj] = static_cast<GLfloat>(jj); |
| 2282 | } |
| 2283 | Cmds expected; |
| 2284 | expected.cmd.Init(1, &data[0]); |
| 2285 | gl_->VertexAttrib4fv(1, &data[0]); |
| 2286 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2287 | } |
| 2288 | |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 2289 | TEST_F(GLES2ImplementationTest, VertexAttribI4i) { |
| 2290 | struct Cmds { |
| 2291 | cmds::VertexAttribI4i cmd; |
| 2292 | }; |
| 2293 | Cmds expected; |
| 2294 | expected.cmd.Init(1, 2, 3, 4, 5); |
| 2295 | |
| 2296 | gl_->VertexAttribI4i(1, 2, 3, 4, 5); |
| 2297 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2298 | } |
| 2299 | |
| 2300 | TEST_F(GLES2ImplementationTest, VertexAttribI4iv) { |
| 2301 | GLint data[4] = {0}; |
| 2302 | struct Cmds { |
| 2303 | cmds::VertexAttribI4ivImmediate cmd; |
| 2304 | GLint data[4]; |
| 2305 | }; |
| 2306 | |
| 2307 | for (int jj = 0; jj < 4; ++jj) { |
| 2308 | data[jj] = static_cast<GLint>(jj); |
| 2309 | } |
| 2310 | Cmds expected; |
| 2311 | expected.cmd.Init(1, &data[0]); |
| 2312 | gl_->VertexAttribI4iv(1, &data[0]); |
| 2313 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2314 | } |
| 2315 | |
| 2316 | TEST_F(GLES2ImplementationTest, VertexAttribI4ui) { |
| 2317 | struct Cmds { |
| 2318 | cmds::VertexAttribI4ui cmd; |
| 2319 | }; |
| 2320 | Cmds expected; |
| 2321 | expected.cmd.Init(1, 2, 3, 4, 5); |
| 2322 | |
| 2323 | gl_->VertexAttribI4ui(1, 2, 3, 4, 5); |
| 2324 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2325 | } |
| 2326 | |
| 2327 | TEST_F(GLES2ImplementationTest, VertexAttribI4uiv) { |
| 2328 | GLuint data[4] = {0}; |
| 2329 | struct Cmds { |
| 2330 | cmds::VertexAttribI4uivImmediate cmd; |
| 2331 | GLuint data[4]; |
| 2332 | }; |
| 2333 | |
| 2334 | for (int jj = 0; jj < 4; ++jj) { |
| 2335 | data[jj] = static_cast<GLuint>(jj); |
| 2336 | } |
| 2337 | Cmds expected; |
| 2338 | expected.cmd.Init(1, &data[0]); |
| 2339 | gl_->VertexAttribI4uiv(1, &data[0]); |
| 2340 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2341 | } |
| 2342 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 2343 | TEST_F(GLES2ImplementationTest, Viewport) { |
| 2344 | struct Cmds { |
| 2345 | cmds::Viewport cmd; |
| 2346 | }; |
| 2347 | Cmds expected; |
| 2348 | expected.cmd.Init(1, 2, 3, 4); |
| 2349 | |
| 2350 | gl_->Viewport(1, 2, 3, 4); |
| 2351 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2352 | } |
| 2353 | |
| 2354 | TEST_F(GLES2ImplementationTest, BlitFramebufferCHROMIUM) { |
| 2355 | struct Cmds { |
| 2356 | cmds::BlitFramebufferCHROMIUM cmd; |
| 2357 | }; |
| 2358 | Cmds expected; |
| 2359 | expected.cmd.Init(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST); |
| 2360 | |
| 2361 | gl_->BlitFramebufferCHROMIUM(1, 2, 3, 4, 5, 6, 7, 8, 9, GL_NEAREST); |
| 2362 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2363 | } |
| 2364 | |
| 2365 | TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleCHROMIUM) { |
| 2366 | struct Cmds { |
| 2367 | cmds::RenderbufferStorageMultisampleCHROMIUM cmd; |
| 2368 | }; |
| 2369 | Cmds expected; |
| 2370 | expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5); |
| 2371 | |
James Robinson | 1ae030a | 2014-11-07 08:32:47 -0800 | [diff] [blame] | 2372 | gl_->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, 2, GL_RGBA4, 4, |
| 2373 | 5); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 2374 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2375 | } |
| 2376 | |
| 2377 | TEST_F(GLES2ImplementationTest, RenderbufferStorageMultisampleEXT) { |
| 2378 | struct Cmds { |
| 2379 | cmds::RenderbufferStorageMultisampleEXT cmd; |
| 2380 | }; |
| 2381 | Cmds expected; |
| 2382 | expected.cmd.Init(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5); |
| 2383 | |
| 2384 | gl_->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, 2, GL_RGBA4, 4, 5); |
| 2385 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2386 | } |
| 2387 | |
| 2388 | TEST_F(GLES2ImplementationTest, FramebufferTexture2DMultisampleEXT) { |
| 2389 | struct Cmds { |
| 2390 | cmds::FramebufferTexture2DMultisampleEXT cmd; |
| 2391 | }; |
| 2392 | Cmds expected; |
| 2393 | expected.cmd.Init(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4, 6); |
| 2394 | |
James Robinson | 1ae030a | 2014-11-07 08:32:47 -0800 | [diff] [blame] | 2395 | gl_->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 2396 | GL_TEXTURE_2D, 4, 0, 6); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 2397 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2398 | } |
| 2399 | |
| 2400 | TEST_F(GLES2ImplementationTest, |
| 2401 | FramebufferTexture2DMultisampleEXTInvalidConstantArg4) { |
James Robinson | 1ae030a | 2014-11-07 08:32:47 -0800 | [diff] [blame] | 2402 | gl_->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 2403 | GL_TEXTURE_2D, 4, 1, 6); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 2404 | EXPECT_TRUE(NoCommandsWritten()); |
| 2405 | EXPECT_EQ(GL_INVALID_VALUE, CheckError()); |
| 2406 | } |
| 2407 | |
| 2408 | TEST_F(GLES2ImplementationTest, TexStorage2DEXT) { |
| 2409 | struct Cmds { |
| 2410 | cmds::TexStorage2DEXT cmd; |
| 2411 | }; |
| 2412 | Cmds expected; |
| 2413 | expected.cmd.Init(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5); |
| 2414 | |
| 2415 | gl_->TexStorage2DEXT(GL_TEXTURE_2D, 2, GL_RGB565, 4, 5); |
| 2416 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2417 | } |
| 2418 | |
| 2419 | TEST_F(GLES2ImplementationTest, GenQueriesEXT) { |
| 2420 | GLuint ids[2] = { |
| 2421 | 0, |
| 2422 | }; |
| 2423 | struct Cmds { |
| 2424 | cmds::GenQueriesEXTImmediate gen; |
| 2425 | GLuint data[2]; |
| 2426 | }; |
| 2427 | Cmds expected; |
| 2428 | expected.gen.Init(arraysize(ids), &ids[0]); |
| 2429 | expected.data[0] = kQueriesStartId; |
| 2430 | expected.data[1] = kQueriesStartId + 1; |
| 2431 | gl_->GenQueriesEXT(arraysize(ids), &ids[0]); |
| 2432 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2433 | EXPECT_EQ(kQueriesStartId, ids[0]); |
| 2434 | EXPECT_EQ(kQueriesStartId + 1, ids[1]); |
| 2435 | } |
| 2436 | |
| 2437 | TEST_F(GLES2ImplementationTest, DeleteQueriesEXT) { |
| 2438 | GLuint ids[2] = {kQueriesStartId, kQueriesStartId + 1}; |
| 2439 | struct Cmds { |
| 2440 | cmds::DeleteQueriesEXTImmediate del; |
| 2441 | GLuint data[2]; |
| 2442 | }; |
| 2443 | Cmds expected; |
| 2444 | expected.del.Init(arraysize(ids), &ids[0]); |
| 2445 | expected.data[0] = kQueriesStartId; |
| 2446 | expected.data[1] = kQueriesStartId + 1; |
| 2447 | gl_->DeleteQueriesEXT(arraysize(ids), &ids[0]); |
| 2448 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2449 | } |
| 2450 | // TODO: Implement unit test for BeginQueryEXT |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 2451 | |
| 2452 | TEST_F(GLES2ImplementationTest, BeginTransformFeedback) { |
| 2453 | struct Cmds { |
| 2454 | cmds::BeginTransformFeedback cmd; |
| 2455 | }; |
| 2456 | Cmds expected; |
| 2457 | expected.cmd.Init(GL_POINTS); |
| 2458 | |
| 2459 | gl_->BeginTransformFeedback(GL_POINTS); |
| 2460 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2461 | } |
| 2462 | |
| 2463 | TEST_F(GLES2ImplementationTest, EndTransformFeedback) { |
| 2464 | struct Cmds { |
| 2465 | cmds::EndTransformFeedback cmd; |
| 2466 | }; |
| 2467 | Cmds expected; |
| 2468 | expected.cmd.Init(); |
| 2469 | |
| 2470 | gl_->EndTransformFeedback(); |
| 2471 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2472 | } |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 2473 | // TODO: Implement unit test for InsertEventMarkerEXT |
| 2474 | // TODO: Implement unit test for PushGroupMarkerEXT |
| 2475 | |
| 2476 | TEST_F(GLES2ImplementationTest, PopGroupMarkerEXT) { |
| 2477 | struct Cmds { |
| 2478 | cmds::PopGroupMarkerEXT cmd; |
| 2479 | }; |
| 2480 | Cmds expected; |
| 2481 | expected.cmd.Init(); |
| 2482 | |
| 2483 | gl_->PopGroupMarkerEXT(); |
| 2484 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2485 | } |
| 2486 | |
| 2487 | TEST_F(GLES2ImplementationTest, GenVertexArraysOES) { |
| 2488 | GLuint ids[2] = { |
| 2489 | 0, |
| 2490 | }; |
| 2491 | struct Cmds { |
| 2492 | cmds::GenVertexArraysOESImmediate gen; |
| 2493 | GLuint data[2]; |
| 2494 | }; |
| 2495 | Cmds expected; |
| 2496 | expected.gen.Init(arraysize(ids), &ids[0]); |
| 2497 | expected.data[0] = kVertexArraysStartId; |
| 2498 | expected.data[1] = kVertexArraysStartId + 1; |
| 2499 | gl_->GenVertexArraysOES(arraysize(ids), &ids[0]); |
| 2500 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2501 | EXPECT_EQ(kVertexArraysStartId, ids[0]); |
| 2502 | EXPECT_EQ(kVertexArraysStartId + 1, ids[1]); |
| 2503 | } |
| 2504 | |
| 2505 | TEST_F(GLES2ImplementationTest, DeleteVertexArraysOES) { |
| 2506 | GLuint ids[2] = {kVertexArraysStartId, kVertexArraysStartId + 1}; |
| 2507 | struct Cmds { |
| 2508 | cmds::DeleteVertexArraysOESImmediate del; |
| 2509 | GLuint data[2]; |
| 2510 | }; |
| 2511 | Cmds expected; |
| 2512 | expected.del.Init(arraysize(ids), &ids[0]); |
| 2513 | expected.data[0] = kVertexArraysStartId; |
| 2514 | expected.data[1] = kVertexArraysStartId + 1; |
| 2515 | gl_->DeleteVertexArraysOES(arraysize(ids), &ids[0]); |
| 2516 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2517 | } |
| 2518 | |
| 2519 | TEST_F(GLES2ImplementationTest, IsVertexArrayOES) { |
| 2520 | struct Cmds { |
| 2521 | cmds::IsVertexArrayOES cmd; |
| 2522 | }; |
| 2523 | |
| 2524 | Cmds expected; |
| 2525 | ExpectedMemoryInfo result1 = |
| 2526 | GetExpectedResultMemory(sizeof(cmds::IsVertexArrayOES::Result)); |
| 2527 | expected.cmd.Init(1, result1.id, result1.offset); |
| 2528 | |
| 2529 | EXPECT_CALL(*command_buffer(), OnFlush()) |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 2530 | .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE))) |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 2531 | .RetiresOnSaturation(); |
| 2532 | |
| 2533 | GLboolean result = gl_->IsVertexArrayOES(1); |
| 2534 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2535 | EXPECT_TRUE(result); |
| 2536 | } |
| 2537 | // TODO: Implement unit test for EnableFeatureCHROMIUM |
| 2538 | |
| 2539 | TEST_F(GLES2ImplementationTest, ResizeCHROMIUM) { |
| 2540 | struct Cmds { |
| 2541 | cmds::ResizeCHROMIUM cmd; |
| 2542 | }; |
| 2543 | Cmds expected; |
| 2544 | expected.cmd.Init(1, 2, 3); |
| 2545 | |
| 2546 | gl_->ResizeCHROMIUM(1, 2, 3); |
| 2547 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2548 | } |
| 2549 | // TODO: Implement unit test for GetRequestableExtensionsCHROMIUM |
| 2550 | // TODO: Implement unit test for CreateStreamTextureCHROMIUM |
| 2551 | // TODO: Implement unit test for GetTranslatedShaderSourceANGLE |
| 2552 | |
| 2553 | TEST_F(GLES2ImplementationTest, TexImageIOSurface2DCHROMIUM) { |
| 2554 | struct Cmds { |
| 2555 | cmds::TexImageIOSurface2DCHROMIUM cmd; |
| 2556 | }; |
| 2557 | Cmds expected; |
| 2558 | expected.cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5); |
| 2559 | |
| 2560 | gl_->TexImageIOSurface2DCHROMIUM(GL_TEXTURE_2D, 2, 3, 4, 5); |
| 2561 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2562 | } |
| 2563 | |
| 2564 | TEST_F(GLES2ImplementationTest, CopyTextureCHROMIUM) { |
| 2565 | struct Cmds { |
| 2566 | cmds::CopyTextureCHROMIUM cmd; |
| 2567 | }; |
| 2568 | Cmds expected; |
| 2569 | expected.cmd.Init(1, 2, 3, 4, GL_ALPHA, GL_UNSIGNED_BYTE); |
| 2570 | |
| 2571 | gl_->CopyTextureCHROMIUM(1, 2, 3, 4, GL_ALPHA, GL_UNSIGNED_BYTE); |
| 2572 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2573 | } |
| 2574 | |
| 2575 | TEST_F(GLES2ImplementationTest, DrawArraysInstancedANGLE) { |
| 2576 | struct Cmds { |
| 2577 | cmds::DrawArraysInstancedANGLE cmd; |
| 2578 | }; |
| 2579 | Cmds expected; |
| 2580 | expected.cmd.Init(GL_POINTS, 2, 3, 4); |
| 2581 | |
| 2582 | gl_->DrawArraysInstancedANGLE(GL_POINTS, 2, 3, 4); |
| 2583 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2584 | } |
| 2585 | |
| 2586 | TEST_F(GLES2ImplementationTest, VertexAttribDivisorANGLE) { |
| 2587 | struct Cmds { |
| 2588 | cmds::VertexAttribDivisorANGLE cmd; |
| 2589 | }; |
| 2590 | Cmds expected; |
| 2591 | expected.cmd.Init(1, 2); |
| 2592 | |
| 2593 | gl_->VertexAttribDivisorANGLE(1, 2); |
| 2594 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2595 | } |
| 2596 | // TODO: Implement unit test for GenMailboxCHROMIUM |
| 2597 | // TODO: Implement unit test for BindUniformLocationCHROMIUM |
| 2598 | |
James Robinson | 6e9a1c9 | 2014-11-13 17:05:42 -0800 | [diff] [blame] | 2599 | TEST_F(GLES2ImplementationTest, GenValuebuffersCHROMIUM) { |
| 2600 | GLuint ids[2] = { |
| 2601 | 0, |
| 2602 | }; |
| 2603 | struct Cmds { |
| 2604 | cmds::GenValuebuffersCHROMIUMImmediate gen; |
| 2605 | GLuint data[2]; |
| 2606 | }; |
| 2607 | Cmds expected; |
| 2608 | expected.gen.Init(arraysize(ids), &ids[0]); |
| 2609 | expected.data[0] = kValuebuffersStartId; |
| 2610 | expected.data[1] = kValuebuffersStartId + 1; |
| 2611 | gl_->GenValuebuffersCHROMIUM(arraysize(ids), &ids[0]); |
| 2612 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2613 | EXPECT_EQ(kValuebuffersStartId, ids[0]); |
| 2614 | EXPECT_EQ(kValuebuffersStartId + 1, ids[1]); |
| 2615 | } |
| 2616 | |
| 2617 | TEST_F(GLES2ImplementationTest, DeleteValuebuffersCHROMIUM) { |
| 2618 | GLuint ids[2] = {kValuebuffersStartId, kValuebuffersStartId + 1}; |
| 2619 | struct Cmds { |
| 2620 | cmds::DeleteValuebuffersCHROMIUMImmediate del; |
| 2621 | GLuint data[2]; |
| 2622 | }; |
| 2623 | Cmds expected; |
| 2624 | expected.del.Init(arraysize(ids), &ids[0]); |
| 2625 | expected.data[0] = kValuebuffersStartId; |
| 2626 | expected.data[1] = kValuebuffersStartId + 1; |
| 2627 | gl_->DeleteValuebuffersCHROMIUM(arraysize(ids), &ids[0]); |
| 2628 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2629 | } |
| 2630 | |
| 2631 | TEST_F(GLES2ImplementationTest, IsValuebufferCHROMIUM) { |
| 2632 | struct Cmds { |
| 2633 | cmds::IsValuebufferCHROMIUM cmd; |
| 2634 | }; |
| 2635 | |
| 2636 | Cmds expected; |
| 2637 | ExpectedMemoryInfo result1 = |
| 2638 | GetExpectedResultMemory(sizeof(cmds::IsValuebufferCHROMIUM::Result)); |
| 2639 | expected.cmd.Init(1, result1.id, result1.offset); |
| 2640 | |
| 2641 | EXPECT_CALL(*command_buffer(), OnFlush()) |
Benjamin Lerman | df06e5f | 2015-01-22 13:22:57 +0100 | [diff] [blame^] | 2642 | .WillOnce(SetMemory(result1.ptr, uint32_t(GL_TRUE))) |
James Robinson | 6e9a1c9 | 2014-11-13 17:05:42 -0800 | [diff] [blame] | 2643 | .RetiresOnSaturation(); |
| 2644 | |
| 2645 | GLboolean result = gl_->IsValuebufferCHROMIUM(1); |
| 2646 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2647 | EXPECT_TRUE(result); |
| 2648 | } |
| 2649 | |
| 2650 | TEST_F(GLES2ImplementationTest, BindValuebufferCHROMIUM) { |
| 2651 | struct Cmds { |
| 2652 | cmds::BindValuebufferCHROMIUM cmd; |
| 2653 | }; |
| 2654 | Cmds expected; |
| 2655 | expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2); |
| 2656 | |
| 2657 | gl_->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2); |
| 2658 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2659 | ClearCommands(); |
| 2660 | gl_->BindValuebufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 2); |
| 2661 | EXPECT_TRUE(NoCommandsWritten()); |
| 2662 | } |
| 2663 | |
| 2664 | TEST_F(GLES2ImplementationTest, SubscribeValueCHROMIUM) { |
| 2665 | struct Cmds { |
| 2666 | cmds::SubscribeValueCHROMIUM cmd; |
| 2667 | }; |
| 2668 | Cmds expected; |
| 2669 | expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, |
| 2670 | GL_MOUSE_POSITION_CHROMIUM); |
| 2671 | |
| 2672 | gl_->SubscribeValueCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, |
| 2673 | GL_MOUSE_POSITION_CHROMIUM); |
| 2674 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2675 | } |
| 2676 | |
| 2677 | TEST_F(GLES2ImplementationTest, PopulateSubscribedValuesCHROMIUM) { |
| 2678 | struct Cmds { |
| 2679 | cmds::PopulateSubscribedValuesCHROMIUM cmd; |
| 2680 | }; |
| 2681 | Cmds expected; |
| 2682 | expected.cmd.Init(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM); |
| 2683 | |
| 2684 | gl_->PopulateSubscribedValuesCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM); |
| 2685 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2686 | } |
| 2687 | |
| 2688 | TEST_F(GLES2ImplementationTest, UniformValuebufferCHROMIUM) { |
| 2689 | struct Cmds { |
| 2690 | cmds::UniformValuebufferCHROMIUM cmd; |
| 2691 | }; |
| 2692 | Cmds expected; |
| 2693 | expected.cmd.Init(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, |
| 2694 | GL_MOUSE_POSITION_CHROMIUM); |
| 2695 | |
| 2696 | gl_->UniformValuebufferCHROMIUM(1, GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, |
| 2697 | GL_MOUSE_POSITION_CHROMIUM); |
| 2698 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2699 | } |
| 2700 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 2701 | TEST_F(GLES2ImplementationTest, BindTexImage2DCHROMIUM) { |
| 2702 | struct Cmds { |
| 2703 | cmds::BindTexImage2DCHROMIUM cmd; |
| 2704 | }; |
| 2705 | Cmds expected; |
| 2706 | expected.cmd.Init(GL_TEXTURE_2D, 2); |
| 2707 | |
| 2708 | gl_->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, 2); |
| 2709 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2710 | } |
| 2711 | |
| 2712 | TEST_F(GLES2ImplementationTest, ReleaseTexImage2DCHROMIUM) { |
| 2713 | struct Cmds { |
| 2714 | cmds::ReleaseTexImage2DCHROMIUM cmd; |
| 2715 | }; |
| 2716 | Cmds expected; |
| 2717 | expected.cmd.Init(GL_TEXTURE_2D, 2); |
| 2718 | |
| 2719 | gl_->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, 2); |
| 2720 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2721 | } |
| 2722 | |
| 2723 | TEST_F(GLES2ImplementationTest, DiscardFramebufferEXT) { |
| 2724 | GLenum data[2][1] = {{0}}; |
| 2725 | struct Cmds { |
| 2726 | cmds::DiscardFramebufferEXTImmediate cmd; |
| 2727 | GLenum data[2][1]; |
| 2728 | }; |
| 2729 | |
| 2730 | Cmds expected; |
| 2731 | for (int ii = 0; ii < 2; ++ii) { |
| 2732 | for (int jj = 0; jj < 1; ++jj) { |
| 2733 | data[ii][jj] = static_cast<GLenum>(ii * 1 + jj); |
| 2734 | } |
| 2735 | } |
| 2736 | expected.cmd.Init(1, 2, &data[0][0]); |
| 2737 | gl_->DiscardFramebufferEXT(1, 2, &data[0][0]); |
| 2738 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2739 | } |
| 2740 | |
| 2741 | TEST_F(GLES2ImplementationTest, LoseContextCHROMIUM) { |
| 2742 | struct Cmds { |
| 2743 | cmds::LoseContextCHROMIUM cmd; |
| 2744 | }; |
| 2745 | Cmds expected; |
| 2746 | expected.cmd.Init(GL_GUILTY_CONTEXT_RESET_ARB, GL_GUILTY_CONTEXT_RESET_ARB); |
| 2747 | |
| 2748 | gl_->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 2749 | GL_GUILTY_CONTEXT_RESET_ARB); |
| 2750 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2751 | } |
| 2752 | // TODO: Implement unit test for InsertSyncPointCHROMIUM |
| 2753 | |
| 2754 | TEST_F(GLES2ImplementationTest, WaitSyncPointCHROMIUM) { |
| 2755 | struct Cmds { |
| 2756 | cmds::WaitSyncPointCHROMIUM cmd; |
| 2757 | }; |
| 2758 | Cmds expected; |
| 2759 | expected.cmd.Init(1); |
| 2760 | |
| 2761 | gl_->WaitSyncPointCHROMIUM(1); |
| 2762 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2763 | } |
| 2764 | |
| 2765 | TEST_F(GLES2ImplementationTest, DrawBuffersEXT) { |
| 2766 | GLenum data[1][1] = {{0}}; |
| 2767 | struct Cmds { |
| 2768 | cmds::DrawBuffersEXTImmediate cmd; |
| 2769 | GLenum data[1][1]; |
| 2770 | }; |
| 2771 | |
| 2772 | Cmds expected; |
| 2773 | for (int ii = 0; ii < 1; ++ii) { |
| 2774 | for (int jj = 0; jj < 1; ++jj) { |
| 2775 | data[ii][jj] = static_cast<GLenum>(ii * 1 + jj); |
| 2776 | } |
| 2777 | } |
| 2778 | expected.cmd.Init(1, &data[0][0]); |
| 2779 | gl_->DrawBuffersEXT(1, &data[0][0]); |
| 2780 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2781 | } |
| 2782 | |
| 2783 | TEST_F(GLES2ImplementationTest, DiscardBackbufferCHROMIUM) { |
| 2784 | struct Cmds { |
| 2785 | cmds::DiscardBackbufferCHROMIUM cmd; |
| 2786 | }; |
| 2787 | Cmds expected; |
| 2788 | expected.cmd.Init(); |
| 2789 | |
| 2790 | gl_->DiscardBackbufferCHROMIUM(); |
| 2791 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2792 | } |
| 2793 | |
| 2794 | TEST_F(GLES2ImplementationTest, MatrixLoadfCHROMIUM) { |
| 2795 | GLfloat data[16] = {0}; |
| 2796 | struct Cmds { |
| 2797 | cmds::MatrixLoadfCHROMIUMImmediate cmd; |
| 2798 | GLfloat data[16]; |
| 2799 | }; |
| 2800 | |
| 2801 | for (int jj = 0; jj < 16; ++jj) { |
| 2802 | data[jj] = static_cast<GLfloat>(jj); |
| 2803 | } |
| 2804 | Cmds expected; |
| 2805 | expected.cmd.Init(GL_PATH_PROJECTION_CHROMIUM, &data[0]); |
| 2806 | gl_->MatrixLoadfCHROMIUM(GL_PATH_PROJECTION_CHROMIUM, &data[0]); |
| 2807 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2808 | } |
| 2809 | |
| 2810 | TEST_F(GLES2ImplementationTest, MatrixLoadIdentityCHROMIUM) { |
| 2811 | struct Cmds { |
| 2812 | cmds::MatrixLoadIdentityCHROMIUM cmd; |
| 2813 | }; |
| 2814 | Cmds expected; |
| 2815 | expected.cmd.Init(GL_PATH_PROJECTION_CHROMIUM); |
| 2816 | |
| 2817 | gl_->MatrixLoadIdentityCHROMIUM(GL_PATH_PROJECTION_CHROMIUM); |
| 2818 | EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2819 | } |
| 2820 | #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_UNITTEST_AUTOGEN_H_ |