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 GLuint64Union mapping; |
| 273 mapping.param64 = 0; |
| 274 cmd.Init(client_sync_id_, mapping.param32[0], mapping.param32[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, ClientWaitSyncNonZeroTimeoutFails) { |
| 291 typedef cmds::ClientWaitSync::Result Result; |
| 292 Result* result = static_cast<Result*>(shared_memory_address_); |
| 293 cmds::ClientWaitSync cmd; |
| 294 GLuint64Union mapping; |
| 295 decoder_->set_unsafe_es3_apis_enabled(true); |
| 296 mapping.param64 = 0xABCDEF0123456789; |
| 297 cmd.Init(client_sync_id_, mapping.param32[0], mapping.param32[1], |
| 298 shared_memory_id_, shared_memory_offset_); |
| 299 *result = GL_WAIT_FAILED; |
| 300 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 301 EXPECT_EQ(static_cast<GLenum>(GL_WAIT_FAILED), *result); |
| 302 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 303 } |
| 304 |
| 305 TEST_P(GLES2DecoderTest, ClientWaitSyncInvalidSyncFails) { |
| 306 typedef cmds::ClientWaitSync::Result Result; |
| 307 Result* result = static_cast<Result*>(shared_memory_address_); |
| 308 cmds::ClientWaitSync cmd; |
| 309 GLuint64Union mapping; |
| 310 decoder_->set_unsafe_es3_apis_enabled(true); |
| 311 mapping.param64 = 0; |
| 312 cmd.Init(kInvalidClientId, mapping.param32[0], mapping.param32[1], |
| 313 shared_memory_id_, shared_memory_offset_); |
| 314 *result = GL_WAIT_FAILED; |
| 315 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 316 EXPECT_EQ(static_cast<GLenum>(GL_WAIT_FAILED), *result); |
| 317 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 318 } |
| 319 |
| 320 TEST_P(GLES2DecoderTest, ClientWaitSyncResultNotInitFails) { |
| 321 typedef cmds::ClientWaitSync::Result Result; |
| 322 Result* result = static_cast<Result*>(shared_memory_address_); |
| 323 cmds::ClientWaitSync cmd; |
| 324 GLuint64Union mapping; |
| 325 decoder_->set_unsafe_es3_apis_enabled(true); |
| 326 mapping.param64 = 0; |
| 327 cmd.Init(client_sync_id_, mapping.param32[0], mapping.param32[1], |
| 328 shared_memory_id_, shared_memory_offset_); |
| 329 *result = 1; // Any value other than GL_WAIT_FAILED |
| 330 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 331 } |
| 332 |
| 333 TEST_P(GLES2DecoderTest, ClientWaitSyncBadSharedMemoryFails) { |
| 334 typedef cmds::ClientWaitSync::Result Result; |
| 335 Result* result = static_cast<Result*>(shared_memory_address_); |
| 336 cmds::ClientWaitSync cmd; |
| 337 GLuint64Union mapping; |
| 338 decoder_->set_unsafe_es3_apis_enabled(true); |
| 339 mapping.param64 = 0; |
| 340 *result = GL_WAIT_FAILED; |
| 341 cmd.Init(client_sync_id_, mapping.param32[0], mapping.param32[1], |
| 342 kInvalidSharedMemoryId, shared_memory_offset_); |
| 343 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 344 |
| 345 *result = GL_WAIT_FAILED; |
| 346 cmd.Init(client_sync_id_, mapping.param32[0], mapping.param32[1], |
| 347 shared_memory_id_, kInvalidSharedMemoryOffset); |
| 348 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 349 } |
| 350 |
268 TEST_P(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) { | 351 TEST_P(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) { |
269 InitState init; | 352 InitState init; |
270 InitDecoder(init); | 353 InitDecoder(init); |
271 | 354 |
272 BindTexture cmd1; | 355 BindTexture cmd1; |
273 cmd1.Init(GL_TEXTURE_2D, kInvalidClientId); | 356 cmd1.Init(GL_TEXTURE_2D, kInvalidClientId); |
274 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); | 357 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
275 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 358 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
276 | 359 |
277 BindBuffer cmd2; | 360 BindBuffer cmd2; |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); | 1231 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); |
1149 | 1232 |
1150 INSTANTIATE_TEST_CASE_P(Service, | 1233 INSTANTIATE_TEST_CASE_P(Service, |
1151 GLES2DecoderRGBBackbufferTest, | 1234 GLES2DecoderRGBBackbufferTest, |
1152 ::testing::Bool()); | 1235 ::testing::Bool()); |
1153 | 1236 |
1154 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); | 1237 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); |
1155 | 1238 |
1156 } // namespace gles2 | 1239 } // namespace gles2 |
1157 } // namespace gpu | 1240 } // namespace gpu |
OLD | NEW |