| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 } | 258 } |
| 259 | 259 |
| 260 TEST_P(GLES2DecoderTest, IsTexture) { | 260 TEST_P(GLES2DecoderTest, IsTexture) { |
| 261 EXPECT_FALSE(DoIsTexture(client_texture_id_)); | 261 EXPECT_FALSE(DoIsTexture(client_texture_id_)); |
| 262 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 262 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 263 EXPECT_TRUE(DoIsTexture(client_texture_id_)); | 263 EXPECT_TRUE(DoIsTexture(client_texture_id_)); |
| 264 DoDeleteTexture(client_texture_id_, kServiceTextureId); | 264 DoDeleteTexture(client_texture_id_, kServiceTextureId); |
| 265 EXPECT_FALSE(DoIsTexture(client_texture_id_)); | 265 EXPECT_FALSE(DoIsTexture(client_texture_id_)); |
| 266 } | 266 } |
| 267 | 267 |
| 268 TEST_P(GLES2DecoderTest, ClientWaitSyncValid) { | |
| 269 typedef cmds::ClientWaitSync::Result Result; | |
| 270 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 271 cmds::ClientWaitSync cmd; | |
| 272 uint32_t v32_0 = 0, v32_1 = 0; | |
| 273 GLES2Util::MapUint64ToTwoUint32(0, &v32_0, &v32_1); | |
| 274 cmd.Init(client_sync_id_, GL_SYNC_FLUSH_COMMANDS_BIT, v32_0, v32_1, | |
| 275 shared_memory_id_, shared_memory_offset_); | |
| 276 EXPECT_CALL(*gl_, | |
| 277 ClientWaitSync(reinterpret_cast<GLsync>(kServiceSyncId), | |
| 278 GL_SYNC_FLUSH_COMMANDS_BIT, 0)) | |
| 279 .WillOnce(Return(GL_CONDITION_SATISFIED)) | |
| 280 .RetiresOnSaturation(); | |
| 281 *result = GL_WAIT_FAILED; | |
| 282 decoder_->set_unsafe_es3_apis_enabled(true); | |
| 283 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 284 EXPECT_EQ(static_cast<GLenum>(GL_CONDITION_SATISFIED), *result); | |
| 285 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 286 decoder_->set_unsafe_es3_apis_enabled(false); | |
| 287 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); | |
| 288 } | |
| 289 | |
| 290 TEST_P(GLES2DecoderTest, ClientWaitSyncNonZeroTimeoutValid) { | |
| 291 typedef cmds::ClientWaitSync::Result Result; | |
| 292 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 293 cmds::ClientWaitSync cmd; | |
| 294 const GLuint64 kTimeout = 0xABCDEF0123456789; | |
| 295 uint32_t v32_0 = 0, v32_1 = 0; | |
| 296 GLES2Util::MapUint64ToTwoUint32(kTimeout, &v32_0, &v32_1); | |
| 297 cmd.Init(client_sync_id_, GL_SYNC_FLUSH_COMMANDS_BIT, v32_0, v32_1, | |
| 298 shared_memory_id_, shared_memory_offset_); | |
| 299 EXPECT_CALL(*gl_, | |
| 300 ClientWaitSync(reinterpret_cast<GLsync>(kServiceSyncId), | |
| 301 GL_SYNC_FLUSH_COMMANDS_BIT, kTimeout)) | |
| 302 .WillOnce(Return(GL_CONDITION_SATISFIED)) | |
| 303 .RetiresOnSaturation(); | |
| 304 *result = GL_WAIT_FAILED; | |
| 305 decoder_->set_unsafe_es3_apis_enabled(true); | |
| 306 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 307 EXPECT_EQ(static_cast<GLenum>(GL_CONDITION_SATISFIED), *result); | |
| 308 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 309 decoder_->set_unsafe_es3_apis_enabled(false); | |
| 310 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); | |
| 311 } | |
| 312 | |
| 313 TEST_P(GLES2DecoderTest, ClientWaitSyncInvalidSyncFails) { | |
| 314 typedef cmds::ClientWaitSync::Result Result; | |
| 315 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 316 cmds::ClientWaitSync cmd; | |
| 317 uint32_t v32_0 = 0, v32_1 = 0; | |
| 318 GLES2Util::MapUint64ToTwoUint32(0, &v32_0, &v32_1); | |
| 319 decoder_->set_unsafe_es3_apis_enabled(true); | |
| 320 cmd.Init(kInvalidClientId, GL_SYNC_FLUSH_COMMANDS_BIT, v32_0, v32_1, | |
| 321 shared_memory_id_, shared_memory_offset_); | |
| 322 *result = GL_WAIT_FAILED; | |
| 323 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 324 EXPECT_EQ(static_cast<GLenum>(GL_WAIT_FAILED), *result); | |
| 325 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 326 } | |
| 327 | |
| 328 TEST_P(GLES2DecoderTest, ClientWaitSyncResultNotInitFails) { | |
| 329 typedef cmds::ClientWaitSync::Result Result; | |
| 330 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 331 cmds::ClientWaitSync cmd; | |
| 332 uint32_t v32_0 = 0, v32_1 = 0; | |
| 333 GLES2Util::MapUint64ToTwoUint32(0, &v32_0, &v32_1); | |
| 334 decoder_->set_unsafe_es3_apis_enabled(true); | |
| 335 cmd.Init(client_sync_id_, GL_SYNC_FLUSH_COMMANDS_BIT, v32_0, v32_1, | |
| 336 shared_memory_id_, shared_memory_offset_); | |
| 337 *result = 1; // Any value other than GL_WAIT_FAILED | |
| 338 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 339 } | |
| 340 | |
| 341 TEST_P(GLES2DecoderTest, ClientWaitSyncBadSharedMemoryFails) { | |
| 342 typedef cmds::ClientWaitSync::Result Result; | |
| 343 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 344 cmds::ClientWaitSync cmd; | |
| 345 uint32_t v32_0 = 0, v32_1 = 0; | |
| 346 GLES2Util::MapUint64ToTwoUint32(0, &v32_0, &v32_1); | |
| 347 decoder_->set_unsafe_es3_apis_enabled(true); | |
| 348 *result = GL_WAIT_FAILED; | |
| 349 cmd.Init(client_sync_id_, GL_SYNC_FLUSH_COMMANDS_BIT, v32_0, v32_1, | |
| 350 kInvalidSharedMemoryId, shared_memory_offset_); | |
| 351 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 352 | |
| 353 *result = GL_WAIT_FAILED; | |
| 354 cmd.Init(client_sync_id_, GL_SYNC_FLUSH_COMMANDS_BIT, v32_0, v32_1, | |
| 355 shared_memory_id_, kInvalidSharedMemoryOffset); | |
| 356 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | |
| 357 } | |
| 358 | |
| 359 TEST_P(GLES2DecoderTest, WaitSyncValidArgs) { | |
| 360 const GLuint64 kTimeout = GL_TIMEOUT_IGNORED; | |
| 361 EXPECT_CALL(*gl_, WaitSync(reinterpret_cast<GLsync>(kServiceSyncId), | |
| 362 0, kTimeout)) | |
| 363 .Times(1) | |
| 364 .RetiresOnSaturation(); | |
| 365 | |
| 366 uint32_t v32_0 = 0, v32_1 = 0; | |
| 367 GLES2Util::MapUint64ToTwoUint32(kTimeout, &v32_0, &v32_1); | |
| 368 cmds::WaitSync cmd; | |
| 369 cmd.Init(client_sync_id_, 0, v32_0, v32_1); | |
| 370 decoder_->set_unsafe_es3_apis_enabled(true); | |
| 371 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 372 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 373 decoder_->set_unsafe_es3_apis_enabled(false); | |
| 374 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); | |
| 375 } | |
| 376 | |
| 377 TEST_P(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) { | 268 TEST_P(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) { |
| 378 InitState init; | 269 InitState init; |
| 379 InitDecoder(init); | 270 InitDecoder(init); |
| 380 | 271 |
| 381 BindTexture cmd1; | 272 BindTexture cmd1; |
| 382 cmd1.Init(GL_TEXTURE_2D, kInvalidClientId); | 273 cmd1.Init(GL_TEXTURE_2D, kInvalidClientId); |
| 383 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | 274 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 384 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 275 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 385 | 276 |
| 386 BindBuffer cmd2; | 277 BindBuffer cmd2; |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); | 1148 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); |
| 1258 | 1149 |
| 1259 INSTANTIATE_TEST_CASE_P(Service, | 1150 INSTANTIATE_TEST_CASE_P(Service, |
| 1260 GLES2DecoderRGBBackbufferTest, | 1151 GLES2DecoderRGBBackbufferTest, |
| 1261 ::testing::Bool()); | 1152 ::testing::Bool()); |
| 1262 | 1153 |
| 1263 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); | 1154 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); |
| 1264 | 1155 |
| 1265 } // namespace gles2 | 1156 } // namespace gles2 |
| 1266 } // namespace gpu | 1157 } // namespace gpu |
| OLD | NEW |