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

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

Issue 465099: Removed command buffer's last dependency on NPAPI.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "gpu/command_buffer/common/command_buffer_mock.h" 7 #include "gpu/command_buffer/common/command_buffer_mock.h"
8 #include "gpu/command_buffer/service/mocks.h" 8 #include "gpu/command_buffer/service/mocks.h"
9 #include "gpu/command_buffer/service/gpu_processor.h" 9 #include "gpu/command_buffer/service/gpu_processor.h"
10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
11 #include "gpu/np_utils/np_browser_mock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
14 13
15 using testing::_; 14 using testing::_;
16 using testing::DoAll; 15 using testing::DoAll;
17 using testing::Invoke; 16 using testing::Invoke;
18 using testing::NiceMock; 17 using testing::NiceMock;
19 using testing::Return; 18 using testing::Return;
20 using testing::SetArgumentPointee; 19 using testing::SetArgumentPointee;
21 using testing::StrictMock; 20 using testing::StrictMock;
22 21
23 namespace command_buffer { 22 namespace command_buffer {
24 23
25 const size_t kRingBufferSize = 1024; 24 const size_t kRingBufferSize = 1024;
26 const size_t kRingBufferEntries = kRingBufferSize / sizeof(int32); 25 const size_t kRingBufferEntries = kRingBufferSize / sizeof(int32);
27 26
28 class GPUProcessorTest : public testing::Test { 27 class GPUProcessorTest : public testing::Test {
29 protected: 28 protected:
30 virtual void SetUp() { 29 virtual void SetUp() {
31 shared_memory_.reset(new ::base::SharedMemory); 30 shared_memory_.reset(new ::base::SharedMemory);
32 shared_memory_->Create(std::wstring(), false, false, kRingBufferSize); 31 shared_memory_->Create(std::wstring(), false, false, kRingBufferSize);
33 shared_memory_->Map(kRingBufferSize); 32 shared_memory_->Map(kRingBufferSize);
34 buffer_ = static_cast<int32*>(shared_memory_->memory()); 33 buffer_ = static_cast<int32*>(shared_memory_->memory());
35 34
36 memset(buffer_, 0, kRingBufferSize); 35 memset(buffer_, 0, kRingBufferSize);
37 36
38 // Don't mock PluginThreadAsyncCall. Have it schedule the task.
39 ON_CALL(mock_browser_, PluginThreadAsyncCall(_, _, _))
40 .WillByDefault(
41 Invoke(&mock_browser_,
42 &np_utils::MockNPBrowser::ConcretePluginThreadAsyncCall));
43
44 command_buffer_.reset(new MockCommandBuffer); 37 command_buffer_.reset(new MockCommandBuffer);
45 ON_CALL(*command_buffer_.get(), GetRingBuffer()) 38 ON_CALL(*command_buffer_.get(), GetRingBuffer())
46 .WillByDefault(Return(shared_memory_.get())); 39 .WillByDefault(Return(shared_memory_.get()));
47 ON_CALL(*command_buffer_.get(), GetSize()) 40 ON_CALL(*command_buffer_.get(), GetSize())
48 .WillByDefault(Return(kRingBufferEntries)); 41 .WillByDefault(Return(kRingBufferEntries));
49 42
50 async_api_.reset(new StrictMock<command_buffer::AsyncAPIMock>); 43 async_api_.reset(new StrictMock<command_buffer::AsyncAPIMock>);
51 44
52 decoder_ = gles2::GLES2Decoder::Create(); 45 decoder_ = gles2::GLES2Decoder::Create();
53 46
(...skipping 11 matching lines...) Expand all
65 } 58 }
66 59
67 virtual void TearDown() { 60 virtual void TearDown() {
68 // Ensure that any unexpected tasks posted by the GPU processor are executed 61 // Ensure that any unexpected tasks posted by the GPU processor are executed
69 // in order to fail the test. 62 // in order to fail the test.
70 MessageLoop::current()->RunAllPending(); 63 MessageLoop::current()->RunAllPending();
71 } 64 }
72 65
73 base::AtExitManager at_exit_manager; 66 base::AtExitManager at_exit_manager;
74 MessageLoop message_loop; 67 MessageLoop message_loop;
75 np_utils::MockNPBrowser mock_browser_;
76 scoped_ptr<MockCommandBuffer> command_buffer_; 68 scoped_ptr<MockCommandBuffer> command_buffer_;
77 scoped_ptr<::base::SharedMemory> shared_memory_; 69 scoped_ptr<::base::SharedMemory> shared_memory_;
78 int32* buffer_; 70 int32* buffer_;
79 command_buffer::gles2::GLES2Decoder* decoder_; 71 command_buffer::gles2::GLES2Decoder* decoder_;
80 command_buffer::CommandParser* parser_; 72 command_buffer::CommandParser* parser_;
81 scoped_ptr<command_buffer::AsyncAPIMock> async_api_; 73 scoped_ptr<command_buffer::AsyncAPIMock> async_api_;
82 scoped_refptr<GPUProcessor> processor_; 74 scoped_refptr<GPUProcessor> processor_;
83 }; 75 };
84 76
85 TEST_F(GPUProcessorTest, ProcessorDoesNothingIfRingBufferIsEmpty) { 77 TEST_F(GPUProcessorTest, ProcessorDoesNothingIfRingBufferIsEmpty) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 268
277 EXPECT_EQ(kRingBufferSize, processor_->GetSharedMemorySize(7)); 269 EXPECT_EQ(kRingBufferSize, processor_->GetSharedMemorySize(7));
278 } 270 }
279 271
280 TEST_F(GPUProcessorTest, SetTokenForwardsToCommandBuffer) { 272 TEST_F(GPUProcessorTest, SetTokenForwardsToCommandBuffer) {
281 EXPECT_CALL(*command_buffer_, SetToken(7)); 273 EXPECT_CALL(*command_buffer_, SetToken(7));
282 processor_->set_token(7); 274 processor_->set_token(7);
283 } 275 }
284 276
285 } // namespace command_buffer 277 } // namespace command_buffer
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gpu_processor_mock.h ('k') | gpu/command_buffer/service/gpu_processor_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698