summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-05 17:56:39 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-05 17:56:39 +0000
commit3339229822e7af543067d5267d3b9795bd6e4485 (patch)
tree76d893bdea7b1895303aad3c265cbb0946c5154f /gpu
parent8cb02edc531a8334b2bd48087a91b4cbdf40c2d7 (diff)
downloadchromium_src-3339229822e7af543067d5267d3b9795bd6e4485.zip
chromium_src-3339229822e7af543067d5267d3b9795bd6e4485.tar.gz
chromium_src-3339229822e7af543067d5267d3b9795bd6e4485.tar.bz2
Move lots of GMock stuff out of line.
Nico did some treemapping of our build time on Mac, and (surprise!) gmock unittests dominated. Gmock works with several large, heavy templates, and previous patches that out of line the ctors/dtors have significantly sped up compilation (e.g.GLMock) and have reduced thrashing. Nico says I should plug this again: http://www.chromium.org/developers/coding-style/cpp-dos-and-donts BUG=none TEST=none Review URL: http://codereview.chromium.org/6056008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70516 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/common/command_buffer_mock.cc18
-rw-r--r--gpu/command_buffer/common/command_buffer_mock.h10
-rw-r--r--gpu/command_buffer/service/mocks.cc34
-rw-r--r--gpu/command_buffer/service/mocks.h21
-rw-r--r--gpu/gpu.gyp8
5 files changed, 67 insertions, 24 deletions
diff --git a/gpu/command_buffer/common/command_buffer_mock.cc b/gpu/command_buffer/common/command_buffer_mock.cc
new file mode 100644
index 0000000..d92c2c3
--- /dev/null
+++ b/gpu/command_buffer/common/command_buffer_mock.cc
@@ -0,0 +1,18 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/command_buffer/common/command_buffer_mock.h"
+
+namespace gpu {
+
+MockCommandBuffer::MockCommandBuffer() {
+ ON_CALL(*this, GetRingBuffer())
+ .WillByDefault(testing::Return(Buffer()));
+ ON_CALL(*this, GetTransferBuffer(testing::_))
+ .WillByDefault(testing::Return(Buffer()));
+}
+
+MockCommandBuffer::~MockCommandBuffer() {}
+
+} // namespace gpu
diff --git a/gpu/command_buffer/common/command_buffer_mock.h b/gpu/command_buffer/common/command_buffer_mock.h
index eb78b83..97cd3cf 100644
--- a/gpu/command_buffer/common/command_buffer_mock.h
+++ b/gpu/command_buffer/common/command_buffer_mock.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,12 +14,8 @@ namespace gpu {
// API to manage the put and get pointers.
class MockCommandBuffer : public CommandBuffer {
public:
- MockCommandBuffer() {
- ON_CALL(*this, GetRingBuffer())
- .WillByDefault(testing::Return(Buffer()));
- ON_CALL(*this, GetTransferBuffer(testing::_))
- .WillByDefault(testing::Return(Buffer()));
- }
+ MockCommandBuffer();
+ virtual ~MockCommandBuffer();
MOCK_METHOD1(Initialize, bool(int32 size));
MOCK_METHOD0(GetRingBuffer, Buffer());
diff --git a/gpu/command_buffer/service/mocks.cc b/gpu/command_buffer/service/mocks.cc
new file mode 100644
index 0000000..6f267be
--- /dev/null
+++ b/gpu/command_buffer/service/mocks.cc
@@ -0,0 +1,34 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/command_buffer/service/mocks.h"
+
+namespace gpu {
+
+AsyncAPIMock::AsyncAPIMock() {
+ testing::DefaultValue<error::Error>::Set(
+ error::kNoError);
+}
+
+AsyncAPIMock::~AsyncAPIMock() {}
+
+void AsyncAPIMock::SetToken(unsigned int command,
+ unsigned int arg_count,
+ const void* _args) {
+ DCHECK(engine_);
+ DCHECK_EQ(1u, command);
+ DCHECK_EQ(1u, arg_count);
+ const CommandBufferEntry* args =
+ static_cast<const CommandBufferEntry*>(_args);
+ engine_->set_token(args[0].value_uint32);
+}
+
+namespace gles2 {
+
+MockShaderTranslator::MockShaderTranslator() {}
+
+MockShaderTranslator::~MockShaderTranslator() {}
+
+} // namespace gles2
+} // namespace gpu
diff --git a/gpu/command_buffer/service/mocks.h b/gpu/command_buffer/service/mocks.h
index 8a11aee..0d341bd 100644
--- a/gpu/command_buffer/service/mocks.h
+++ b/gpu/command_buffer/service/mocks.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -23,10 +23,8 @@ namespace gpu {
// Mocks an AsyncAPIInterface, using GMock.
class AsyncAPIMock : public AsyncAPIInterface {
public:
- AsyncAPIMock() {
- testing::DefaultValue<error::Error>::Set(
- error::kNoError);
- }
+ AsyncAPIMock();
+ virtual ~AsyncAPIMock();
// Predicate that matches args passed to DoCommand, by looking at the values.
class IsArgs {
@@ -65,14 +63,8 @@ class AsyncAPIMock : public AsyncAPIInterface {
// Forwards the SetToken commands to the engine.
void SetToken(unsigned int command,
unsigned int arg_count,
- const void* _args) {
- DCHECK(engine_);
- DCHECK_EQ(1u, command);
- DCHECK_EQ(1u, arg_count);
- const CommandBufferEntry* args =
- static_cast<const CommandBufferEntry*>(_args);
- engine_->set_token(args[0].value_uint32);
- }
+ const void* _args);
+
private:
CommandBufferEngine *engine_;
};
@@ -81,7 +73,8 @@ namespace gles2 {
class MockShaderTranslator : public ShaderTranslatorInterface {
public:
- virtual ~MockShaderTranslator() { }
+ MockShaderTranslator();
+ virtual ~MockShaderTranslator();
MOCK_METHOD4(Init, bool(
ShShaderType shader_type,
diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp
index d6467e7..bd9fbb0 100644
--- a/gpu/gpu.gyp
+++ b/gpu/gpu.gyp
@@ -1,4 +1,4 @@
-# Copyright (c) 2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -24,7 +24,6 @@
'command_buffer/common/cmd_buffer_common.h',
'command_buffer/common/cmd_buffer_common.cc',
'command_buffer/common/command_buffer.h',
- 'command_buffer/common/command_buffer_mock.h',
'command_buffer/common/constants.h',
'command_buffer/common/gles2_cmd_ids_autogen.h',
'command_buffer/common/gles2_cmd_ids.h',
@@ -36,7 +35,6 @@
'command_buffer/common/id_allocator.cc',
'command_buffer/common/id_allocator.h',
'command_buffer/common/logging.h',
- 'command_buffer/common/mocks.h',
'command_buffer/common/thread_local.h',
'command_buffer/common/types.h',
],
@@ -229,6 +227,8 @@
'command_buffer/client/mapped_memory_unittest.cc',
'command_buffer/client/ring_buffer_test.cc',
'command_buffer/common/bitfield_helpers_test.cc',
+ 'command_buffer/common/command_buffer_mock.cc',
+ 'command_buffer/common/command_buffer_mock.h',
'command_buffer/common/gl_mock.h',
'command_buffer/common/gl_mock.cc',
'command_buffer/common/gles2_cmd_format_test.cc',
@@ -261,6 +261,8 @@
'command_buffer/service/gles2_cmd_decoder_unittest_2.cc',
'command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h',
'command_buffer/service/id_manager_unittest.cc',
+ 'command_buffer/service/mocks.cc',
+ 'command_buffer/service/mocks.h',
'command_buffer/service/program_manager_unittest.cc',
'command_buffer/service/renderbuffer_manager_unittest.cc',
'command_buffer/service/shader_manager_unittest.cc',