summaryrefslogtreecommitdiffstats
path: root/o3d/gpu_plugin/gpu_processor_unittest.cc
diff options
context:
space:
mode:
authorapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-10 00:41:08 +0000
committerapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-10 00:41:08 +0000
commitf90ef342b3dcacd675f630caa63626573cfe032a (patch)
tree724d4466908a72d5bee0abd8ec0bb437acd26810 /o3d/gpu_plugin/gpu_processor_unittest.cc
parent07f25e82ef962a56a791d115720f57957d84d782 (diff)
downloadchromium_src-f90ef342b3dcacd675f630caa63626573cfe032a.zip
chromium_src-f90ef342b3dcacd675f630caa63626573cfe032a.tar.gz
chromium_src-f90ef342b3dcacd675f630caa63626573cfe032a.tar.bz2
Switched from NPObject shared memory wrapper to Chrome shared memory in preparation for moving from NPAPI to Chrome IPC for synchronous messages.
Started work on an O3D configuration that will use Pepper 3D to connect to a remote GPU plugin. This is not building yet. Updated to latest NPAPI from nixysa. Review URL: http://codereview.chromium.org/371074 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31519 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/gpu_plugin/gpu_processor_unittest.cc')
-rw-r--r--o3d/gpu_plugin/gpu_processor_unittest.cc48
1 files changed, 24 insertions, 24 deletions
diff --git a/o3d/gpu_plugin/gpu_processor_unittest.cc b/o3d/gpu_plugin/gpu_processor_unittest.cc
index 236f418..2a518c2 100644
--- a/o3d/gpu_plugin/gpu_processor_unittest.cc
+++ b/o3d/gpu_plugin/gpu_processor_unittest.cc
@@ -9,10 +9,11 @@
#include "o3d/gpu_plugin/gpu_processor.h"
#include "o3d/gpu_plugin/np_utils/np_browser_mock.h"
#include "o3d/gpu_plugin/np_utils/np_object_pointer.h"
-#include "o3d/gpu_plugin/system_services/shared_memory_mock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/gmock/include/gmock/gmock.h"
+using ::base::SharedMemory;
+
using testing::_;
using testing::DoAll;
using testing::Invoke;
@@ -23,15 +24,18 @@ using testing::StrictMock;
namespace gpu_plugin {
+const size_t kRingBufferSize = 1024;
+const size_t kRingBufferEntries = kRingBufferSize / sizeof(int32);
+
class GPUProcessorTest : public testing::Test {
protected:
virtual void SetUp() {
- shared_memory_ = NPCreateObject<NiceMock<MockSharedMemory> >(NULL);
- memset(buffer_, 0, sizeof(buffer_));
+ shared_memory_.reset(new SharedMemory);
+ shared_memory_->Create(std::wstring(), false, false, kRingBufferSize);
+ shared_memory_->Map(kRingBufferSize);
+ buffer_ = static_cast<int32*>(shared_memory_->memory());
- ON_CALL(mock_browser_, MapMemory(NULL, shared_memory_.Get(), _))
- .WillByDefault(DoAll(SetArgumentPointee<2>(sizeof(buffer_)),
- Return(buffer_)));
+ memset(buffer_, 0, kRingBufferSize);
// Don't mock PluginThreadAsyncCall. Have it schedule the task.
ON_CALL(mock_browser_, PluginThreadAsyncCall(_, _, _))
@@ -40,9 +44,9 @@ class GPUProcessorTest : public testing::Test {
command_buffer_ = NPCreateObject<MockCommandBuffer>(NULL);
ON_CALL(*command_buffer_.Get(), GetRingBuffer())
- .WillByDefault(Return(shared_memory_));
+ .WillByDefault(Return(shared_memory_.get()));
ON_CALL(*command_buffer_.Get(), GetSize())
- .WillByDefault(Return(sizeof(buffer_)));
+ .WillByDefault(Return(kRingBufferEntries));
#if defined(OS_WIN)
gapi_ = new GPUProcessor::GPUGAPIInterface;
@@ -53,9 +57,9 @@ class GPUProcessorTest : public testing::Test {
decoder_ = new command_buffer::o3d::GAPIDecoder(gapi_);
parser_ = new command_buffer::CommandParser(buffer_,
- sizeof(buffer_),
+ kRingBufferEntries,
0,
- sizeof(buffer_),
+ kRingBufferEntries,
0,
async_api_.get());
@@ -77,8 +81,8 @@ class GPUProcessorTest : public testing::Test {
MessageLoop message_loop;
MockNPBrowser mock_browser_;
NPObjectPointer<MockCommandBuffer> command_buffer_;
- NPObjectPointer<NiceMock<MockSharedMemory> > shared_memory_;
- int32 buffer_[1024 / sizeof(int32)];
+ scoped_ptr<SharedMemory> shared_memory_;
+ int32* buffer_;
command_buffer::o3d::GAPIDecoder* decoder_;
command_buffer::CommandParser* parser_;
scoped_ptr<command_buffer::AsyncAPIMock> async_api_;
@@ -273,8 +277,8 @@ TEST_F(GPUProcessorTest, ProcessCommandsDoesNothingAfterUnrecoverableError) {
}
TEST_F(GPUProcessorTest, CanGetAddressOfSharedMemory) {
- EXPECT_CALL(*command_buffer_.Get(), GetRegisteredObject(7))
- .WillOnce(Return(shared_memory_));
+ EXPECT_CALL(*command_buffer_.Get(), GetTransferBuffer(7))
+ .WillOnce(Return(shared_memory_.get()));
EXPECT_EQ(&buffer_[0], processor_->GetSharedMemoryAddress(7));
}
@@ -284,21 +288,17 @@ ACTION_P2(SetPointee, address, value) {
}
TEST_F(GPUProcessorTest, GetAddressOfSharedMemoryMapsMemoryIfUnmapped) {
- EXPECT_CALL(*command_buffer_.Get(), GetRegisteredObject(7))
- .WillOnce(Return(shared_memory_));
-
- EXPECT_CALL(mock_browser_, MapMemory(NULL, shared_memory_.Get(), _))
- .WillOnce(DoAll(SetArgumentPointee<2>(sizeof(buffer_)),
- Return(buffer_)));
+ EXPECT_CALL(*command_buffer_.Get(), GetTransferBuffer(7))
+ .WillOnce(Return(shared_memory_.get()));
EXPECT_EQ(&buffer_[0], processor_->GetSharedMemoryAddress(7));
}
TEST_F(GPUProcessorTest, CanGetSizeOfSharedMemory) {
- EXPECT_CALL(*command_buffer_.Get(), GetRegisteredObject(7))
- .WillOnce(Return(shared_memory_));
+ EXPECT_CALL(*command_buffer_.Get(), GetTransferBuffer(7))
+ .WillOnce(Return(shared_memory_.get()));
- EXPECT_EQ(sizeof(buffer_), processor_->GetSharedMemorySize(7));
+ EXPECT_EQ(kRingBufferSize, processor_->GetSharedMemorySize(7));
}
TEST_F(GPUProcessorTest, SetTokenForwardsToCommandBuffer) {
@@ -306,4 +306,4 @@ TEST_F(GPUProcessorTest, SetTokenForwardsToCommandBuffer) {
EXPECT_EQ(7, command_buffer_->GetToken());
}
-} // namespace gpu_plugin
+} // namespace gpu_plugin \ No newline at end of file