Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(614)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc

Issue 196633009: Use CheckedNumerics in AsyncPixelTransfersCompletedQuery, add tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.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 6953 matching lines...) Expand 10 before | Expand all | Expand 10 after
6964 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, 1); 6964 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, 1);
6965 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); 6965 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd));
6966 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6966 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6967 EXPECT_TRUE(query->pending()); 6967 EXPECT_TRUE(query->pending());
6968 6968
6969 EXPECT_CALL(*gl_, DeleteQueriesARB(1, _)) 6969 EXPECT_CALL(*gl_, DeleteQueriesARB(1, _))
6970 .Times(1) 6970 .Times(1)
6971 .RetiresOnSaturation(); 6971 .RetiresOnSaturation();
6972 } 6972 }
6973 6973
6974 struct QueryType {
6975 GLenum type;
6976 bool is_gl;
6977 };
6978
6979 const QueryType kQueryTypes[] = {
6980 { GL_COMMANDS_ISSUED_CHROMIUM, false },
6981 { GL_LATENCY_QUERY_CHROMIUM, false },
6982 { GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, false },
6983 { GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, false },
6984 { GL_GET_ERROR_QUERY_CHROMIUM, false },
6985 { GL_ANY_SAMPLES_PASSED_EXT, true },
6986 };
6987
6974 static void CheckBeginEndQueryBadMemoryFails( 6988 static void CheckBeginEndQueryBadMemoryFails(
6975 GLES2DecoderTestBase* test, 6989 GLES2DecoderTestBase* test,
6976 GLuint client_id, 6990 GLuint client_id,
6977 GLuint service_id, 6991 GLuint service_id,
6992 const QueryType& query_type,
6978 int32 shm_id, 6993 int32 shm_id,
6979 uint32 shm_offset) { 6994 uint32 shm_offset) {
6995 // We need to reset the decoder on each iteration, because we lose the
6996 // context every time.
6997 test->InitDecoder(
6998 "GL_EXT_occlusion_query_boolean", // extensions
6999 "opengl es 2.0", // gl version
7000 true, // has alpha
7001 false, // has depth
7002 false, // has stencil
7003 true, // request alpha
7004 false, // request depth
7005 false, // request stencil
7006 true); // bind generates resource
6980 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); 7007 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock();
6981 7008
6982 BeginQueryEXT begin_cmd; 7009 BeginQueryEXT begin_cmd;
6983 7010
6984 test->GenHelper<GenQueriesEXTImmediate>(client_id); 7011 test->GenHelper<GenQueriesEXTImmediate>(client_id);
6985 7012
6986 EXPECT_CALL(*gl, GenQueriesARB(1, _)) 7013 if (query_type.is_gl) {
6987 .WillOnce(SetArgumentPointee<1>(service_id)) 7014 EXPECT_CALL(*gl, GenQueriesARB(1, _))
6988 .RetiresOnSaturation(); 7015 .WillOnce(SetArgumentPointee<1>(service_id))
6989 EXPECT_CALL(*gl, BeginQueryARB(GL_ANY_SAMPLES_PASSED_EXT, service_id)) 7016 .RetiresOnSaturation();
6990 .Times(1) 7017 EXPECT_CALL(*gl, BeginQueryARB(query_type.type, service_id))
6991 .RetiresOnSaturation(); 7018 .Times(1)
7019 .RetiresOnSaturation();
7020 }
6992 7021
6993 // Test bad shared memory fails 7022 // Test bad shared memory fails
6994 begin_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, client_id, shm_id, shm_offset); 7023 begin_cmd.Init(query_type.type, client_id, shm_id, shm_offset);
6995 error::Error error1 = test->ExecuteCmd(begin_cmd); 7024 error::Error error1 = test->ExecuteCmd(begin_cmd);
6996 7025
6997 EXPECT_CALL(*gl, EndQueryARB(GL_ANY_SAMPLES_PASSED_EXT)) 7026 if (query_type.is_gl) {
6998 .Times(1) 7027 EXPECT_CALL(*gl, EndQueryARB(query_type.type))
6999 .RetiresOnSaturation(); 7028 .Times(1)
7029 .RetiresOnSaturation();
7030 }
7031 if (query_type.type == GL_GET_ERROR_QUERY_CHROMIUM) {
7032 EXPECT_CALL(*gl, GetError())
7033 .WillOnce(Return(GL_NO_ERROR))
7034 .RetiresOnSaturation();
7035 }
7000 7036
7001 EndQueryEXT end_cmd; 7037 EndQueryEXT end_cmd;
7002 end_cmd.Init(GL_ANY_SAMPLES_PASSED_EXT, 1); 7038 end_cmd.Init(query_type.type, 1);
7003 error::Error error2 = test->ExecuteCmd(end_cmd); 7039 error::Error error2 = test->ExecuteCmd(end_cmd);
7004 7040
7005 EXPECT_CALL(*gl, 7041 if (query_type.is_gl) {
7006 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) 7042 EXPECT_CALL(*gl,
7007 .WillOnce(SetArgumentPointee<2>(1)) 7043 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _))
7008 .RetiresOnSaturation(); 7044 .WillOnce(SetArgumentPointee<2>(1))
7009 EXPECT_CALL(*gl, 7045 .RetiresOnSaturation();
7010 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_EXT, _)) 7046 EXPECT_CALL(*gl,
7011 .WillOnce(SetArgumentPointee<2>(1)) 7047 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_EXT, _))
7012 .RetiresOnSaturation(); 7048 .WillOnce(SetArgumentPointee<2>(1))
7049 .RetiresOnSaturation();
7050 }
7013 7051
7014 QueryManager* query_manager = test->GetDecoder()->GetQueryManager(); 7052 QueryManager* query_manager = test->GetDecoder()->GetQueryManager();
7015 ASSERT_TRUE(query_manager != NULL); 7053 ASSERT_TRUE(query_manager != NULL);
7016 bool process_success = query_manager->ProcessPendingQueries(); 7054 bool process_success = query_manager->ProcessPendingQueries();
7017 7055
7018 EXPECT_TRUE(error1 != error::kNoError || 7056 EXPECT_TRUE(error1 != error::kNoError ||
7019 error2 != error::kNoError || 7057 error2 != error::kNoError ||
7020 !process_success); 7058 !process_success);
7021 7059
7022 EXPECT_CALL(*gl, DeleteQueriesARB(1, _)) 7060 if (query_type.is_gl) {
7023 .Times(1) 7061 EXPECT_CALL(*gl, DeleteQueriesARB(1, _))
7024 .RetiresOnSaturation(); 7062 .Times(1)
7063 .RetiresOnSaturation();
7064 }
7065 test->ResetDecoder();
7025 } 7066 }
7026 7067
7027 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) { 7068 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) {
7028 InitDecoder( 7069 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) {
7029 "GL_EXT_occlusion_query_boolean", // extensions 7070 CheckBeginEndQueryBadMemoryFails(
7030 "opengl es 2.0", // gl version 7071 this, kNewClientId, kNewServiceId,
7031 true, // has alpha 7072 kQueryTypes[i],
7032 false, // has depth 7073 kInvalidSharedMemoryId, kSharedMemoryOffset);
7033 false, // has stencil 7074 }
7034 true, // request alpha
7035 false, // request depth
7036 false, // request stencil
7037 true); // bind generates resource
7038
7039 CheckBeginEndQueryBadMemoryFails(
7040 this, kNewClientId, kNewServiceId,
7041 kInvalidSharedMemoryId, kSharedMemoryOffset);
7042 } 7075 }
7043 7076
7044 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryOffsetFails) { 7077 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryOffsetFails) {
7045 InitDecoder( 7078 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) {
7046 "GL_EXT_occlusion_query_boolean", // extensions 7079 // Out-of-bounds.
7047 "opengl es 2.0", // gl version 7080 CheckBeginEndQueryBadMemoryFails(
7048 true, // has alpha 7081 this, kNewClientId, kNewServiceId,
7049 false, // has depth 7082 kQueryTypes[i],
7050 false, // has stencil 7083 kSharedMemoryId, kInvalidSharedMemoryOffset);
7051 true, // request alpha 7084 // Overflow.
7052 false, // request depth 7085 CheckBeginEndQueryBadMemoryFails(
7053 false, // request stencil 7086 this, kNewClientId, kNewServiceId,
7054 true); // bind generates resource 7087 kQueryTypes[i],
7055 7088 kSharedMemoryId, 0xfffffffcu);
7056 CheckBeginEndQueryBadMemoryFails( 7089 }
7057 this, kNewClientId, kNewServiceId,
7058 kSharedMemoryId, kInvalidSharedMemoryOffset);
7059 } 7090 }
7060 7091
7061 TEST_F(GLES2DecoderTest, BeginEndQueryEXTCommandsIssuedCHROMIUM) { 7092 TEST_F(GLES2DecoderTest, BeginEndQueryEXTCommandsIssuedCHROMIUM) {
7062 BeginQueryEXT begin_cmd; 7093 BeginQueryEXT begin_cmd;
7063 7094
7064 GenHelper<GenQueriesEXTImmediate>(kNewClientId); 7095 GenHelper<GenQueriesEXTImmediate>(kNewClientId);
7065 7096
7066 // Test valid parameters work. 7097 // Test valid parameters work.
7067 begin_cmd.Init( 7098 begin_cmd.Init(
7068 GL_COMMANDS_ISSUED_CHROMIUM, kNewClientId, 7099 GL_COMMANDS_ISSUED_CHROMIUM, kNewClientId,
(...skipping 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after
9110 // TODO(gman): TexImage2DImmediate 9141 // TODO(gman): TexImage2DImmediate
9111 9142
9112 // TODO(gman): TexSubImage2DImmediate 9143 // TODO(gman): TexSubImage2DImmediate
9113 9144
9114 // TODO(gman): UseProgram 9145 // TODO(gman): UseProgram
9115 9146
9116 // TODO(gman): SwapBuffers 9147 // TODO(gman): SwapBuffers
9117 9148
9118 } // namespace gles2 9149 } // namespace gles2
9119 } // namespace gpu 9150 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698