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 17 matching lines...) Expand all Loading... |
28 #include "ui/gl/gl_mock.h" | 28 #include "ui/gl/gl_mock.h" |
29 #include "ui/gl/gl_surface_stub.h" | 29 #include "ui/gl/gl_surface_stub.h" |
30 | 30 |
31 | 31 |
32 #if !defined(GL_DEPTH24_STENCIL8) | 32 #if !defined(GL_DEPTH24_STENCIL8) |
33 #define GL_DEPTH24_STENCIL8 0x88F0 | 33 #define GL_DEPTH24_STENCIL8 0x88F0 |
34 #endif | 34 #endif |
35 | 35 |
36 using ::gfx::MockGLInterface; | 36 using ::gfx::MockGLInterface; |
37 using ::testing::_; | 37 using ::testing::_; |
| 38 using ::testing::AtLeast; |
38 using ::testing::DoAll; | 39 using ::testing::DoAll; |
39 using ::testing::InSequence; | 40 using ::testing::InSequence; |
40 using ::testing::Invoke; | 41 using ::testing::Invoke; |
41 using ::testing::MatcherCast; | 42 using ::testing::MatcherCast; |
42 using ::testing::Mock; | 43 using ::testing::Mock; |
43 using ::testing::Pointee; | 44 using ::testing::Pointee; |
44 using ::testing::Return; | 45 using ::testing::Return; |
45 using ::testing::SaveArg; | 46 using ::testing::SaveArg; |
46 using ::testing::SetArrayArgument; | 47 using ::testing::SetArrayArgument; |
47 using ::testing::SetArgumentPointee; | 48 using ::testing::SetArgumentPointee; |
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 // Check we get out of memory and no call to glBufferData if Ensure | 1203 // Check we get out of memory and no call to glBufferData if Ensure |
1203 // fails. | 1204 // fails. |
1204 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1205 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
1205 .WillOnce(Return(false)) | 1206 .WillOnce(Return(false)) |
1206 .RetiresOnSaturation(); | 1207 .RetiresOnSaturation(); |
1207 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1208 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
1208 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 1209 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
1209 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); | 1210 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); |
1210 } | 1211 } |
1211 | 1212 |
| 1213 TEST_P(GLES2DecoderManualInitTest, ImmutableCopyTexImage2D) { |
| 1214 const GLenum kTarget = GL_TEXTURE_2D; |
| 1215 const GLint kLevel = 0; |
| 1216 const GLenum kInternalFormat = GL_RGBA; |
| 1217 const GLenum kSizedInternalFormat = GL_RGBA8; |
| 1218 const GLsizei kWidth = 4; |
| 1219 const GLsizei kHeight = 8; |
| 1220 const GLint kBorder = 0; |
| 1221 InitState init; |
| 1222 init.extensions = "GL_EXT_texture_storage"; |
| 1223 init.gl_version = "3.0"; |
| 1224 init.has_alpha = true; |
| 1225 init.request_alpha = true; |
| 1226 init.bind_generates_resource = true; |
| 1227 InitDecoder(init); |
| 1228 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1229 |
| 1230 // CopyTexImage2D will call arbitrary amount of GetErrors. |
| 1231 EXPECT_CALL(*gl_, GetError()) |
| 1232 .Times(AtLeast(1)); |
| 1233 |
| 1234 EXPECT_CALL(*gl_, |
| 1235 CopyTexImage2D( |
| 1236 kTarget, kLevel, kInternalFormat, 0, 0, kWidth, kHeight, |
| 1237 kBorder)) |
| 1238 .Times(1); |
| 1239 |
| 1240 EXPECT_CALL(*gl_, |
| 1241 TexStorage2DEXT( |
| 1242 kTarget, kLevel, kSizedInternalFormat, kWidth, kHeight)) |
| 1243 .Times(1); |
| 1244 CopyTexImage2D copy_cmd; |
| 1245 copy_cmd.Init(kTarget, kLevel, kInternalFormat, 0, 0, kWidth, kHeight); |
| 1246 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd)); |
| 1247 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1248 |
| 1249 TexStorage2DEXT storage_cmd; |
| 1250 storage_cmd.Init(kTarget, kLevel, kSizedInternalFormat, kWidth, kHeight); |
| 1251 EXPECT_EQ(error::kNoError, ExecuteCmd(storage_cmd)); |
| 1252 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1253 |
| 1254 // This should not invoke CopyTexImage2D. |
| 1255 copy_cmd.Init(kTarget, kLevel, kInternalFormat, 0, 0, kWidth, kHeight); |
| 1256 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd)); |
| 1257 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 1258 } |
| 1259 |
1212 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest, ::testing::Bool()); | 1260 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest, ::testing::Bool()); |
1213 | 1261 |
1214 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderWithShaderTest, ::testing::Bool()); | 1262 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderWithShaderTest, ::testing::Bool()); |
1215 | 1263 |
1216 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); | 1264 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); |
1217 | 1265 |
1218 INSTANTIATE_TEST_CASE_P(Service, | 1266 INSTANTIATE_TEST_CASE_P(Service, |
1219 GLES2DecoderRGBBackbufferTest, | 1267 GLES2DecoderRGBBackbufferTest, |
1220 ::testing::Bool()); | 1268 ::testing::Bool()); |
1221 | 1269 |
1222 } // namespace gles2 | 1270 } // namespace gles2 |
1223 } // namespace gpu | 1271 } // namespace gpu |
OLD | NEW |