diff options
author | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-09 17:59:34 +0000 |
---|---|---|
committer | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-09 17:59:34 +0000 |
commit | 6098b711dbc9d38459796a0aea769f5677ada3e5 (patch) | |
tree | f31e13842e0d3662a85b5d5eddf438c1ff1a21b5 /gpu/command_buffer/service | |
parent | f466a30ddd61518eb511aad85b71b2ccd231e4ee (diff) | |
download | chromium_src-6098b711dbc9d38459796a0aea769f5677ada3e5.zip chromium_src-6098b711dbc9d38459796a0aea769f5677ada3e5.tar.gz chromium_src-6098b711dbc9d38459796a0aea769f5677ada3e5.tar.bz2 |
Fixed GPU unit tests on Mac OS X.
- Fixed remaining issues with signed/unsigned comparisons, linkage of
constants, and unused variables.
- Fixed nasty bug where vtbl for GLES2Decoder was changing size during
compilation, causing bizarre test failures.
- Cleaned up AppKit warnings about no NSAutoreleasePool being present.
BUG=none
TEST=none (ran GPU unit tests on Mac OS X)
Review URL: http://codereview.chromium.org/594004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38473 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service')
6 files changed, 50 insertions, 18 deletions
diff --git a/gpu/command_buffer/service/command_buffer_service_unittest.cc b/gpu/command_buffer/service/command_buffer_service_unittest.cc index ca1ba83..44ea9f2 100644 --- a/gpu/command_buffer/service/command_buffer_service_unittest.cc +++ b/gpu/command_buffer/service/command_buffer_service_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/scoped_nsautorelease_pool.h" #include "base/thread.h" #include "gpu/command_buffer/common/cmd_buffer_common.h" #include "gpu/command_buffer/service/command_buffer_service.h" @@ -39,6 +40,7 @@ class CommandBufferServiceTest : public testing::Test { return command_buffer_->GetState().error; } + base::ScopedNSAutoreleasePool autorelease_pool_; scoped_ptr<CommandBufferService> command_buffer_; }; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index adfea53..81c3a66 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -652,7 +652,7 @@ class GLES2DecoderImpl : public GLES2Decoder { virtual bool MakeCurrent(); virtual uint32 GetServiceIdForTesting(uint32 client_id); -#if !defined(UNIT_TEST) && defined(OS_MACOSX) +#if defined(OS_MACOSX) // Overridden from GLES2Decoder. virtual uint64 SetWindowSize(int32 width, int32 height); #endif @@ -1350,7 +1350,8 @@ bool GLES2DecoderImpl::InitGlew() { return true; } -#if !defined(UNIT_TEST) && defined(OS_MACOSX) +#if defined(OS_MACOSX) +#if !defined(UNIT_TEST) static void AddBooleanValue(CFMutableDictionaryRef dictionary, const CFStringRef key, bool value) { @@ -1364,8 +1365,12 @@ static void AddIntegerValue(CFMutableDictionaryRef dictionary, CFNumberRef number = CFNumberCreate(NULL, kCFNumberSInt32Type, &value); CFDictionaryAddValue(dictionary, key, number); } +#endif // !defined(UNIT_TEST) uint64 GLES2DecoderImpl::SetWindowSize(int32 width, int32 height) { +#if defined(UNIT_TEST) + return 0; +#else if (surface_width_ == width && surface_height_ == height) { // Return 0 to indicate to the caller that no new backing store // allocation occurred. @@ -1468,8 +1473,9 @@ uint64 GLES2DecoderImpl::SetWindowSize(int32 width, int32 height) { // the browser process side the identifier is reconstituted into an // IOSurface for on-screen rendering. return io_surface_support->IOSurfaceGetID(io_surface_); +#endif // !defined(UNIT_TEST) } -#endif // !defined(UNIT_TEST) && defined(OS_MACOSX) +#endif // defined(OS_MACOSX) void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) { swap_buffers_callback_.reset(callback); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h index 9e6b9c8..913c7fb 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder.h @@ -56,7 +56,7 @@ class GLES2Decoder : public CommonDecoder { HWND hwnd() const { return hwnd_; } -#elif !defined(UNIT_TEST) && defined(OS_MACOSX) +#elif defined(OS_MACOSX) virtual uint64 SetWindowSize(int32 width, int32 height) = 0; #endif diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h index fa60d41..27b15d1 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h @@ -22,6 +22,9 @@ class MockGLES2Decoder : public GLES2Decoder { .WillByDefault(testing::Return(true)); } +#if defined(OS_MACOSX) + MOCK_METHOD2(SetWindowSize, uint64(int32 width, int32 height)); +#endif MOCK_METHOD0(Initialize, bool()); MOCK_METHOD0(Destroy, void()); MOCK_METHOD0(MakeCurrent, bool()); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 1b8d0e8..427f360 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -602,9 +602,33 @@ const int GLES2DecoderWithShaderTest::kOutOfRangeIndexRangeEnd; const char* GLES2DecoderWithShaderTest::kAttrib1Name = "attrib1"; const char* GLES2DecoderWithShaderTest::kAttrib2Name = "attrib2"; const char* GLES2DecoderWithShaderTest::kAttrib3Name = "attrib3"; +const GLint GLES2DecoderWithShaderTest::kAttrib1Size; +const GLint GLES2DecoderWithShaderTest::kAttrib2Size; +const GLint GLES2DecoderWithShaderTest::kAttrib3Size; +const GLint GLES2DecoderWithShaderTest::kAttrib1Location; +const GLint GLES2DecoderWithShaderTest::kAttrib2Location; +const GLint GLES2DecoderWithShaderTest::kAttrib3Location; +const GLenum GLES2DecoderWithShaderTest::kAttrib1Type; +const GLenum GLES2DecoderWithShaderTest::kAttrib2Type; +const GLenum GLES2DecoderWithShaderTest::kAttrib3Type; +const GLint GLES2DecoderWithShaderTest::kInvalidAttribLocation; +const GLint GLES2DecoderWithShaderTest::kBadAttribIndex; +const GLint GLES2DecoderWithShaderTest::kMaxUniformLength; const char* GLES2DecoderWithShaderTest::kUniform1Name = "uniform1"; const char* GLES2DecoderWithShaderTest::kUniform2Name = "uniform2"; const char* GLES2DecoderWithShaderTest::kUniform3Name = "uniform3"; +const GLint GLES2DecoderWithShaderTest::kUniform1Size; +const GLint GLES2DecoderWithShaderTest::kUniform2Size; +const GLint GLES2DecoderWithShaderTest::kUniform3Size; +const GLint GLES2DecoderWithShaderTest::kUniform1Location; +const GLint GLES2DecoderWithShaderTest::kUniform2Location; +const GLint GLES2DecoderWithShaderTest::kUniform2ElementLocation; +const GLint GLES2DecoderWithShaderTest::kUniform3Location; +const GLenum GLES2DecoderWithShaderTest::kUniform1Type; +const GLenum GLES2DecoderWithShaderTest::kUniform2Type; +const GLenum GLES2DecoderWithShaderTest::kUniform3Type; +const GLint GLES2DecoderWithShaderTest::kInvalidUniformLocation; +const GLint GLES2DecoderWithShaderTest::kBadUniformIndex; TEST_F(GLES2DecoderWithShaderTest, DrawArraysNoAttributesSucceeds) { EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) @@ -941,7 +965,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) { EXPECT_CALL(*gl_, GetUniformiv(_, _, _)) .Times(0); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); // Valid id that is not a program. The GL spec requires a different error for // this case. @@ -949,7 +973,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) { cmd.Init(client_texture_id_, kUniform2Location, kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); // Unlinked program EXPECT_CALL(*gl_, CreateProgram()) @@ -963,7 +987,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) { cmd.Init(kNewClientId, kUniform2Location, kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); } @@ -977,7 +1001,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadLocationFails) { EXPECT_CALL(*gl_, GetUniformiv(_, _, _)) .Times(0); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); } @@ -1028,7 +1052,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) { EXPECT_CALL(*gl_, GetUniformfv(_, _, _)) .Times(0); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); // Valid id that is not a program. The GL spec requires a different error for // this case. @@ -1036,7 +1060,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) { cmd.Init(client_texture_id_, kUniform2Location, kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); // Unlinked program EXPECT_CALL(*gl_, CreateProgram()) @@ -1050,7 +1074,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) { cmd.Init(kNewClientId, kUniform2Location, kSharedMemoryId, kSharedMemoryOffset); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); } @@ -1064,7 +1088,7 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadLocationFails) { EXPECT_CALL(*gl_, GetUniformfv(_, _, _)) .Times(0); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); } @@ -1104,14 +1128,13 @@ TEST_F(GLES2DecoderWithShaderTest, GetAttachedShadersBadProgramFails) { cmd.Init(kInvalidClientId, shared_memory_id_, shared_memory_offset_, Result::ComputeSize(1)); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); - EXPECT_EQ(0, result->size); + EXPECT_EQ(0U, result->size); EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); } TEST_F(GLES2DecoderWithShaderTest, GetAttachedShadersBadSharedMemoryFails) { GetAttachedShaders cmd; typedef GetAttachedShaders::Result Result; - Result* result = static_cast<Result*>(shared_memory_address_); cmd.Init(client_program_id_, kInvalidSharedMemoryId, shared_memory_offset_, Result::ComputeSize(1)); EXPECT_CALL(*gl_, GetAttachedShaders(_, _, _, _)) @@ -1140,8 +1163,6 @@ TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatSucceeds) { TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatBadArgsFails) { GetShaderPrecisionFormat cmd; - typedef GetShaderPrecisionFormat::Result Result; - Result* result = static_cast<Result*>(shared_memory_address_); cmd.Init(GL_TEXTURE_2D, GL_HIGH_FLOAT, shared_memory_id_, shared_memory_offset_); EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); @@ -1155,8 +1176,6 @@ TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatBadArgsFails) { TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatBadSharedMemoryFails) { GetShaderPrecisionFormat cmd; - typedef GetShaderPrecisionFormat::Result Result; - Result* result = static_cast<Result*>(shared_memory_address_); cmd.Init(GL_VERTEX_SHADER, GL_HIGH_FLOAT, kInvalidSharedMemoryId, shared_memory_offset_); EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); diff --git a/gpu/command_buffer/service/gpu_processor_unittest.cc b/gpu/command_buffer/service/gpu_processor_unittest.cc index ec6f094..a71905c 100644 --- a/gpu/command_buffer/service/gpu_processor_unittest.cc +++ b/gpu/command_buffer/service/gpu_processor_unittest.cc @@ -4,6 +4,7 @@ #include "base/at_exit.h" #include "base/message_loop.h" +#include "base/scoped_nsautorelease_pool.h" #include "gpu/command_buffer/common/command_buffer_mock.h" #include "gpu/command_buffer/service/mocks.h" #include "gpu/command_buffer/service/gpu_processor.h" @@ -72,6 +73,7 @@ class GPUProcessorTest : public testing::Test { return command_buffer_->GetState().error; } + base::ScopedNSAutoreleasePool autorelease_pool_; base::AtExitManager at_exit_manager; MessageLoop message_loop; scoped_ptr<MockCommandBuffer> command_buffer_; |