OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 7 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
8 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" | 8 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" |
9 | 9 |
10 using ::gfx::MockGLInterface; | 10 using ::gfx::MockGLInterface; |
11 using ::testing::_; | 11 using ::testing::_; |
12 using ::testing::Return; | 12 using ::testing::Return; |
13 using ::testing::SetArgPointee; | 13 using ::testing::SetArgPointee; |
14 | 14 |
15 namespace gpu { | 15 namespace gpu { |
16 namespace gles2 { | 16 namespace gles2 { |
17 | 17 |
18 using namespace cmds; | 18 using namespace cmds; |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 } // namespace anonymous | 22 } // namespace anonymous |
23 | 23 |
24 TEST_P(GLES2DecoderTest, BindBufferBaseValidArgs) { | 24 TEST_P(GLES3DecoderTest, BindBufferBaseValidArgs) { |
25 EXPECT_CALL( | 25 EXPECT_CALL( |
26 *gl_, BindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 2, kServiceBufferId)); | 26 *gl_, BindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 2, kServiceBufferId)); |
27 SpecializedSetup<cmds::BindBufferBase, 0>(true); | 27 SpecializedSetup<cmds::BindBufferBase, 0>(true); |
28 cmds::BindBufferBase cmd; | 28 cmds::BindBufferBase cmd; |
29 cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, client_buffer_id_); | 29 cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, client_buffer_id_); |
30 decoder_->set_unsafe_es3_apis_enabled(true); | |
31 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 30 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
32 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 31 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
33 decoder_->set_unsafe_es3_apis_enabled(false); | |
34 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); | |
35 } | 32 } |
36 | 33 |
37 TEST_P(GLES2DecoderTest, BindBufferBaseValidArgsNewId) { | 34 TEST_P(GLES3DecoderTest, BindBufferBaseValidArgsNewId) { |
38 EXPECT_CALL(*gl_, | 35 EXPECT_CALL(*gl_, |
39 BindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 2, kNewServiceId)); | 36 BindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 2, kNewServiceId)); |
40 EXPECT_CALL(*gl_, GenBuffersARB(1, _)) | 37 EXPECT_CALL(*gl_, GenBuffersARB(1, _)) |
41 .WillOnce(SetArgPointee<1>(kNewServiceId)); | 38 .WillOnce(SetArgPointee<1>(kNewServiceId)); |
42 SpecializedSetup<cmds::BindBufferBase, 0>(true); | 39 SpecializedSetup<cmds::BindBufferBase, 0>(true); |
43 cmds::BindBufferBase cmd; | 40 cmds::BindBufferBase cmd; |
44 cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, kNewClientId); | 41 cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, kNewClientId); |
45 decoder_->set_unsafe_es3_apis_enabled(true); | |
46 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 42 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
47 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 43 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
48 EXPECT_TRUE(GetBuffer(kNewClientId) != NULL); | 44 EXPECT_TRUE(GetBuffer(kNewClientId) != NULL); |
49 decoder_->set_unsafe_es3_apis_enabled(false); | 45 } |
50 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); | 46 |
| 47 |
| 48 TEST_P(GLES3DecoderTest, BindBufferRangeValidArgs) { |
| 49 EXPECT_CALL(*gl_, BindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 2, |
| 50 kServiceBufferId, 4, 4)); |
| 51 SpecializedSetup<cmds::BindBufferRange, 0>(true); |
| 52 cmds::BindBufferRange cmd; |
| 53 cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, client_buffer_id_, 4, 4); |
| 54 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 55 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 56 } |
| 57 |
| 58 TEST_P(GLES3DecoderTest, BindBufferRangeValidArgsNewId) { |
| 59 EXPECT_CALL(*gl_, BindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 2, |
| 60 kNewServiceId, 4, 4)); |
| 61 EXPECT_CALL(*gl_, GenBuffersARB(1, _)) |
| 62 .WillOnce(SetArgPointee<1>(kNewServiceId)); |
| 63 SpecializedSetup<cmds::BindBufferRange, 0>(true); |
| 64 cmds::BindBufferRange cmd; |
| 65 cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, kNewClientId, 4, 4); |
| 66 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 67 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 68 EXPECT_TRUE(GetBuffer(kNewClientId) != NULL); |
51 } | 69 } |
52 | 70 |
53 TEST_P(GLES2DecoderTest, MapBufferRangeUnmapBufferReadSucceeds) { | 71 TEST_P(GLES2DecoderTest, MapBufferRangeUnmapBufferReadSucceeds) { |
54 const GLenum kTarget = GL_ARRAY_BUFFER; | 72 const GLenum kTarget = GL_ARRAY_BUFFER; |
55 const GLintptr kOffset = 10; | 73 const GLintptr kOffset = 10; |
56 const GLsizeiptr kSize = 64; | 74 const GLsizeiptr kSize = 64; |
57 const GLbitfield kAccess = GL_MAP_READ_BIT; | 75 const GLbitfield kAccess = GL_MAP_READ_BIT; |
58 | 76 |
59 uint32_t result_shm_id = kSharedMemoryId; | 77 uint32_t result_shm_id = kSharedMemoryId; |
60 uint32_t result_shm_offset = kSharedMemoryOffset; | 78 uint32_t result_shm_offset = kSharedMemoryOffset; |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 { // UnmapBuffer fails. | 511 { // UnmapBuffer fails. |
494 UnmapBuffer cmd; | 512 UnmapBuffer cmd; |
495 cmd.Init(kTarget); | 513 cmd.Init(kTarget); |
496 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 514 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
497 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 515 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
498 } | 516 } |
499 } | 517 } |
500 | 518 |
501 } // namespace gles2 | 519 } // namespace gles2 |
502 } // namespace gpu | 520 } // namespace gpu |
OLD | NEW |