diff options
author | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-02 16:30:28 +0000 |
---|---|---|
committer | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-02 16:30:28 +0000 |
commit | 5e5952e18fa760f04f50c3300276cecdecc707b1 (patch) | |
tree | 88254dc4194ae815dfef24e3d8bf1d2ac3b20ce2 /gpu | |
parent | 0daa338fc4b8b4d72f5e06f3f998c7c6b0746aae (diff) | |
download | chromium_src-5e5952e18fa760f04f50c3300276cecdecc707b1.zip chromium_src-5e5952e18fa760f04f50c3300276cecdecc707b1.tar.gz chromium_src-5e5952e18fa760f04f50c3300276cecdecc707b1.tar.bz2 |
Fixed compile/link errors for gpu unit-tests. I had to mostly fix signed/unsigned mismatch and link failures due to non-definition of static member variables. I still do not understand why gcc is behaving arbitrarily for only a few static member variables. AFAIK the standard says that static const numeric types do not need to be defined anymore.
Review URL: http://codereview.chromium.org/560002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37837 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
5 files changed, 66 insertions, 27 deletions
diff --git a/gpu/command_buffer/service/cmd_parser_test.cc b/gpu/command_buffer/service/cmd_parser_test.cc index b4f2ca6..cacff99 100644 --- a/gpu/command_buffer/service/cmd_parser_test.cc +++ b/gpu/command_buffer/service/cmd_parser_test.cc @@ -70,8 +70,8 @@ class CommandParserTest : public testing::Test { // Tests initialization conditions. TEST_F(CommandParserTest, TestInit) { scoped_ptr<CommandParser> parser(MakeParser(10)); - EXPECT_EQ(0u, parser->get()); - EXPECT_EQ(0u, parser->put()); + EXPECT_EQ(0, parser->get()); + EXPECT_EQ(0, parser->put()); EXPECT_TRUE(parser->IsEmpty()); } @@ -201,7 +201,7 @@ TEST_F(CommandParserTest, TestWrap) { param.value_int32 = 5; AddDoCommandExpect(error::kNoError, 3, 1, ¶m); - DCHECK_EQ(5u, put); + DCHECK_EQ(5, put); put = 0; parser->set_put(put); EXPECT_EQ(put, parser->put()); diff --git a/gpu/command_buffer/service/command_buffer_service_unittest.cc b/gpu/command_buffer/service/command_buffer_service_unittest.cc index cd4cca3..ca1ba83 100644 --- a/gpu/command_buffer/service/command_buffer_service_unittest.cc +++ b/gpu/command_buffer/service/command_buffer_service_unittest.cc @@ -65,7 +65,6 @@ TEST_F(CommandBufferServiceTest, InitializationSizeIsInEntriesNotBytes) { } TEST_F(CommandBufferServiceTest, InitializeFailsSecondTime) { - SharedMemory* ring_buffer = new SharedMemory; EXPECT_TRUE(command_buffer_->Initialize(1024)); EXPECT_FALSE(command_buffer_->Initialize(1024)); } @@ -117,7 +116,7 @@ TEST_F(CommandBufferServiceTest, CanCreateTransferBuffers) { EXPECT_EQ(1, handle); Buffer buffer = command_buffer_->GetTransferBuffer(handle); ASSERT_TRUE(NULL != buffer.ptr); - EXPECT_EQ(1024, buffer.size); + EXPECT_EQ(1024u, buffer.size); } TEST_F(CommandBufferServiceTest, CreateTransferBufferReturnsDistinctHandles) { diff --git a/gpu/command_buffer/service/common_decoder_unittest.cc b/gpu/command_buffer/service/common_decoder_unittest.cc index 2ecaa15..bdab529 100644 --- a/gpu/command_buffer/service/common_decoder_unittest.cc +++ b/gpu/command_buffer/service/common_decoder_unittest.cc @@ -10,16 +10,16 @@ namespace gpu { TEST(CommonDecoderBucket, Basic) { CommonDecoder::Bucket bucket; - EXPECT_EQ(0, bucket.size()); + EXPECT_EQ(0u, bucket.size()); EXPECT_TRUE(NULL == bucket.GetData(0, 0)); } TEST(CommonDecoderBucket, Size) { CommonDecoder::Bucket bucket; bucket.SetSize(24); - EXPECT_EQ(24, bucket.size()); + EXPECT_EQ(24u, bucket.size()); bucket.SetSize(12); - EXPECT_EQ(12, bucket.size()); + EXPECT_EQ(12u, bucket.size()); } TEST(CommonDecoderBucket, GetData) { @@ -74,8 +74,8 @@ class MockCommandBufferEngine : public CommandBufferEngine { static const int32 kValidShmId = 2; static const int32 kInvalidShmId = 3; static const size_t kBufferSize = 1024; - static const uint32 kValidOffset = kBufferSize / 2; - static const uint32 kInvalidOffset = kBufferSize; + static const int32 kValidOffset = kBufferSize / 2; + static const int32 kInvalidOffset = kBufferSize; MockCommandBufferEngine() : CommandBufferEngine(), @@ -99,11 +99,11 @@ class MockCommandBufferEngine : public CommandBufferEngine { return reinterpret_cast<T>(&buffer_[offset]); } - uint32 GetSharedMemoryOffset(const void* memory) { + int32 GetSharedMemoryOffset(const void* memory) { ptrdiff_t offset = reinterpret_cast<const int8*>(memory) - &buffer_[0]; DCHECK_GE(offset, 0); - DCHECK(offset < kBufferSize); - return static_cast<uint32>(offset); + DCHECK(static_cast<size_t>(offset) < kBufferSize); + return static_cast<int32>(offset); } // Overridden from CommandBufferEngine. @@ -117,7 +117,7 @@ class MockCommandBufferEngine : public CommandBufferEngine { // Overridden from CommandBufferEngine. virtual bool SetGetOffset(int32 offset) { - if (offset < kBufferSize) { + if (static_cast<size_t>(offset) < kBufferSize) { get_offset_ = offset; return true; } @@ -139,6 +139,13 @@ class MockCommandBufferEngine : public CommandBufferEngine { int32 get_offset_; }; +const int32 MockCommandBufferEngine::kStartValidShmId; +const int32 MockCommandBufferEngine::kValidShmId; +const int32 MockCommandBufferEngine::kInvalidShmId; +const size_t MockCommandBufferEngine::kBufferSize; +const int32 MockCommandBufferEngine::kValidOffset; +const int32 MockCommandBufferEngine::kInvalidOffset; + class CommonDecoderTest : public testing::Test { protected: virtual void SetUp() { @@ -169,7 +176,7 @@ class CommonDecoderTest : public testing::Test { }; TEST_F(CommonDecoderTest, Initialize) { - EXPECT_EQ(0u, engine_.GetGetOffset()); + EXPECT_EQ(0, engine_.GetGetOffset()); } TEST_F(CommonDecoderTest, HandleNoop) { @@ -213,7 +220,7 @@ TEST_F(CommonDecoderTest, JumpRelative) { // Check valid positive offset succeeds. const int32 kPositiveOffset = 16; cmd.Init(kPositiveOffset); - uint32 read_pointer = engine_.GetGetOffset(); + int32 read_pointer = engine_.GetGetOffset(); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); // See note above. EXPECT_EQ(read_pointer + kPositiveOffset, engine_.GetGetOffset()); @@ -247,7 +254,7 @@ TEST_F(CommonDecoderTest, Call) { cmd::Return return_cmd; return_cmd.Init(); EXPECT_EQ(error::kNoError, ExecuteCmd(return_cmd)); - EXPECT_EQ(0u, engine_.GetGetOffset()); + EXPECT_EQ(0, engine_.GetGetOffset()); // Check that stack overflow fails. cmd.Init(MockCommandBufferEngine::kValidOffset); for (unsigned int ii = 0; ii < CommonDecoder::kMaxStackDepth; ++ii) { @@ -261,13 +268,13 @@ TEST_F(CommonDecoderTest, CallRelative) { // Check valid positive offset succeeds. const int32 kPositiveOffset = 16; cmd.Init(kPositiveOffset); - uint32 read_pointer_1 = engine_.GetGetOffset(); + int32 read_pointer_1 = engine_.GetGetOffset(); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); // See note above. EXPECT_EQ(read_pointer_1 + kPositiveOffset, engine_.GetGetOffset()); // Check valid negative offset succeeds. const int32 kNegativeOffset = -8; - uint32 read_pointer_2 = engine_.GetGetOffset(); + int32 read_pointer_2 = engine_.GetGetOffset(); cmd.Init(kNegativeOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); // See note above. @@ -287,7 +294,7 @@ TEST_F(CommonDecoderTest, CallRelative) { EXPECT_EQ(error::kNoError, ExecuteCmd(return_cmd)); // See note above. - EXPECT_EQ(0u, engine_.GetGetOffset()); + EXPECT_EQ(0, engine_.GetGetOffset()); // Check that stack overflow fails. cmd.Init(kPositiveOffset); for (unsigned int ii = 0; ii < CommonDecoder::kMaxStackDepth; ++ii) { @@ -328,7 +335,7 @@ TEST_F(CommonDecoderTest, SetBucketSize) { cmd.Init(kBucketId, 0); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); bucket = decoder_.GetBucket(kBucketId); - EXPECT_EQ(0, bucket->size()); + EXPECT_EQ(0u, bucket->size()); } TEST_F(CommonDecoderTest, SetBucketData) { @@ -484,7 +491,6 @@ TEST_F(CommonDecoderTest, GetBucketData) { size_cmd.Init(kBucketId, sizeof(kData)); EXPECT_EQ(error::kNoError, ExecuteCmd(size_cmd)); - CommonDecoder::Bucket* bucket = decoder_.GetBucket(kBucketId); const uint32 kSomeOffsetInSharedMemory = 50; uint8* memory = engine_.GetSharedMemoryAs<uint8*>(kSomeOffsetInSharedMemory); memcpy(memory, kData, sizeof(kData)); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 185c99f..7133eab 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -8,6 +8,7 @@ #include "gpu/command_buffer/service/cmd_buffer_engine.h" #include "testing/gtest/include/gtest/gtest.h" +using ::gles2::MockGLInterface; using ::testing::_; using ::testing::DoAll; using ::testing::InSequence; @@ -83,7 +84,7 @@ class GLES2DecoderTest : public testing::Test { } virtual void SetUp() { - gl_.reset(new ::gles2::MockGLInterface()); + gl_.reset(new MockGLInterface()); ::gles2::GLInterface::SetGLInterface(gl_.get()); EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _)) @@ -185,17 +186,23 @@ class GLES2DecoderTest : public testing::Test { return decoder_->GetServiceIdForTesting(client_id); } - GLenum GetGLError() { + // Note that the error is returned as GLint instead of GLenum. + // This is because there is a mismatch in the types of GLenum and + // the error values GL_NO_ERROR, GL_INVALID_ENUM, etc. GLenum is + // typedef'd as unsigned int while the error values are defined as + // integers. This is problematic for template functions such as + // EXPECT_EQ that expect both types to be the same. + GLint GetGLError() { EXPECT_CALL(*gl_, GetError()) .WillOnce(Return(GL_NO_ERROR)) .RetiresOnSaturation(); GetError cmd; cmd.Init(shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - return *GetSharedMemoryAs<GLenum*>(); + return static_cast<GLint>(*GetSharedMemoryAs<GLenum*>()); } - scoped_ptr<::gles2::MockGLInterface> gl_; + scoped_ptr<MockGLInterface> gl_; scoped_ptr<GLES2Decoder> decoder_; GLuint client_buffer_id_; @@ -254,6 +261,24 @@ class GLES2DecoderTest : public testing::Test { scoped_ptr<MockCommandBufferEngine> engine_; }; +const GLint GLES2DecoderTest::kNumVertexAttribs; +const GLuint GLES2DecoderTest::kServiceBufferId; +const GLuint GLES2DecoderTest::kServiceFramebufferId; +const GLuint GLES2DecoderTest::kServiceRenderbufferId; +const GLuint GLES2DecoderTest::kServiceTextureId; +const GLuint GLES2DecoderTest::kServiceProgramId; +const GLuint GLES2DecoderTest::kServiceShaderId; +const GLuint GLES2DecoderTest::kServiceElementBufferId; +const int32 GLES2DecoderTest::kSharedMemoryId; +const size_t GLES2DecoderTest::kSharedBufferSize; +const uint32 GLES2DecoderTest::kSharedMemoryOffset; +const int32 GLES2DecoderTest::kInvalidSharedMemoryId; +const uint32 GLES2DecoderTest::kInvalidSharedMemoryOffset; +const uint32 GLES2DecoderTest::kInitialResult; +const uint32 GLES2DecoderTest::kNewClientId; +const uint32 GLES2DecoderTest::kNewServiceId; +const uint32 GLES2DecoderTest::kInvalidClientId; + template <> void GLES2DecoderTest::SpecializedSetup<LinkProgram, 0>() { InSequence dummy; @@ -456,6 +481,15 @@ class GLES2DecoderWithShaderTest : public GLES2DecoderTest { } }; +const GLint GLES2DecoderWithShaderTest::kNumAttribs; +const GLint GLES2DecoderWithShaderTest::kMaxAttribLength; +const GLsizei GLES2DecoderWithShaderTest::kNumVertices; +const GLsizei GLES2DecoderWithShaderTest::kNumIndices; +const int GLES2DecoderWithShaderTest::kValidIndexRangeStart; +const int GLES2DecoderWithShaderTest::kValidIndexRangeCount; +const int GLES2DecoderWithShaderTest::kInvalidIndexRangeStart; +const int GLES2DecoderWithShaderTest::kInvalidIndexRangeCount; +const int GLES2DecoderWithShaderTest::kOutOfRangeIndexRangeEnd; const char* GLES2DecoderWithShaderTest::kAttrib1Name = "attrib1"; const char* GLES2DecoderWithShaderTest::kAttrib2Name = "attrib2"; const char* GLES2DecoderWithShaderTest::kAttrib3Name = "attrib3"; diff --git a/gpu/command_buffer/service/gpu_processor_unittest.cc b/gpu/command_buffer/service/gpu_processor_unittest.cc index 428b726..ec6f094 100644 --- a/gpu/command_buffer/service/gpu_processor_unittest.cc +++ b/gpu/command_buffer/service/gpu_processor_unittest.cc @@ -75,7 +75,7 @@ class GPUProcessorTest : public testing::Test { base::AtExitManager at_exit_manager; MessageLoop message_loop; scoped_ptr<MockCommandBuffer> command_buffer_; - scoped_ptr<::base::SharedMemory> shared_memory_; + scoped_ptr<base::SharedMemory> shared_memory_; Buffer shared_memory_buffer_; int32* buffer_; gles2::MockGLES2Decoder* decoder_; |