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

Side by Side Diff: gpu/command_buffer/client/mapped_memory_unittest.cc

Issue 682743002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "gpu/command_buffer/client/mapped_memory.h" 5 #include "gpu/command_buffer/client/mapped_memory.h"
6 6
7 #include <list> 7 #include <list>
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 15 matching lines...) Expand all
26 using testing::Truly; 26 using testing::Truly;
27 using testing::Sequence; 27 using testing::Sequence;
28 using testing::DoAll; 28 using testing::DoAll;
29 using testing::Invoke; 29 using testing::Invoke;
30 using testing::_; 30 using testing::_;
31 31
32 class MappedMemoryTestBase : public testing::Test { 32 class MappedMemoryTestBase : public testing::Test {
33 protected: 33 protected:
34 static const unsigned int kBufferSize = 1024; 34 static const unsigned int kBufferSize = 1024;
35 35
36 virtual void SetUp() { 36 void SetUp() override {
37 api_mock_.reset(new AsyncAPIMock(true)); 37 api_mock_.reset(new AsyncAPIMock(true));
38 // ignore noops in the mock - we don't want to inspect the internals of the 38 // ignore noops in the mock - we don't want to inspect the internals of the
39 // helper. 39 // helper.
40 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, 0, _)) 40 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, 0, _))
41 .WillRepeatedly(Return(error::kNoError)); 41 .WillRepeatedly(Return(error::kNoError));
42 // Forward the SetToken calls to the engine 42 // Forward the SetToken calls to the engine
43 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) 43 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _))
44 .WillRepeatedly(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), 44 .WillRepeatedly(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken),
45 Return(error::kNoError))); 45 Return(error::kNoError)));
46 46
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 } 92 }
93 93
94 // Test fixture for MemoryChunk test - Creates a MemoryChunk, using a 94 // Test fixture for MemoryChunk test - Creates a MemoryChunk, using a
95 // CommandBufferHelper with a mock AsyncAPIInterface for its interface (calling 95 // CommandBufferHelper with a mock AsyncAPIInterface for its interface (calling
96 // it directly, not through the RPC mechanism), making sure Noops are ignored 96 // it directly, not through the RPC mechanism), making sure Noops are ignored
97 // and SetToken are properly forwarded to the engine. 97 // and SetToken are properly forwarded to the engine.
98 class MemoryChunkTest : public MappedMemoryTestBase { 98 class MemoryChunkTest : public MappedMemoryTestBase {
99 protected: 99 protected:
100 static const int32 kShmId = 123; 100 static const int32 kShmId = 123;
101 virtual void SetUp() { 101 void SetUp() override {
102 MappedMemoryTestBase::SetUp(); 102 MappedMemoryTestBase::SetUp();
103 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); 103 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory());
104 shared_memory->CreateAndMapAnonymous(kBufferSize); 104 shared_memory->CreateAndMapAnonymous(kBufferSize);
105 buffer_ = MakeBufferFromSharedMemory(shared_memory.Pass(), kBufferSize); 105 buffer_ = MakeBufferFromSharedMemory(shared_memory.Pass(), kBufferSize);
106 chunk_.reset(new MemoryChunk(kShmId, 106 chunk_.reset(new MemoryChunk(kShmId,
107 buffer_, 107 buffer_,
108 helper_.get(), 108 helper_.get(),
109 base::Bind(&EmptyPoll))); 109 base::Bind(&EmptyPoll)));
110 } 110 }
111 111
112 virtual void TearDown() { 112 void TearDown() override {
113 // If the GpuScheduler posts any tasks, this forces them to run. 113 // If the GpuScheduler posts any tasks, this forces them to run.
114 base::MessageLoop::current()->RunUntilIdle(); 114 base::MessageLoop::current()->RunUntilIdle();
115 115
116 MappedMemoryTestBase::TearDown(); 116 MappedMemoryTestBase::TearDown();
117 } 117 }
118 118
119 uint8* buffer_memory() { return static_cast<uint8*>(buffer_->memory()); } 119 uint8* buffer_memory() { return static_cast<uint8*>(buffer_->memory()); }
120 120
121 scoped_ptr<MemoryChunk> chunk_; 121 scoped_ptr<MemoryChunk> chunk_;
122 scoped_refptr<gpu::Buffer> buffer_; 122 scoped_refptr<gpu::Buffer> buffer_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 EXPECT_EQ(kBufferSize, chunk_->GetLargestFreeSizeWithWaiting()); 156 EXPECT_EQ(kBufferSize, chunk_->GetLargestFreeSizeWithWaiting());
157 } 157 }
158 158
159 class MappedMemoryManagerTest : public MappedMemoryTestBase { 159 class MappedMemoryManagerTest : public MappedMemoryTestBase {
160 public: 160 public:
161 MappedMemoryManager* manager() const { 161 MappedMemoryManager* manager() const {
162 return manager_.get(); 162 return manager_.get();
163 } 163 }
164 164
165 protected: 165 protected:
166 virtual void SetUp() { 166 void SetUp() override {
167 MappedMemoryTestBase::SetUp(); 167 MappedMemoryTestBase::SetUp();
168 manager_.reset(new MappedMemoryManager( 168 manager_.reset(new MappedMemoryManager(
169 helper_.get(), base::Bind(&EmptyPoll), MappedMemoryManager::kNoLimit)); 169 helper_.get(), base::Bind(&EmptyPoll), MappedMemoryManager::kNoLimit));
170 } 170 }
171 171
172 virtual void TearDown() { 172 void TearDown() override {
173 // If the GpuScheduler posts any tasks, this forces them to run. 173 // If the GpuScheduler posts any tasks, this forces them to run.
174 base::MessageLoop::current()->RunUntilIdle(); 174 base::MessageLoop::current()->RunUntilIdle();
175 manager_.reset(); 175 manager_.reset();
176 MappedMemoryTestBase::TearDown(); 176 MappedMemoryTestBase::TearDown();
177 } 177 }
178 178
179 scoped_ptr<MappedMemoryManager> manager_; 179 scoped_ptr<MappedMemoryManager> manager_;
180 }; 180 };
181 181
182 TEST_F(MappedMemoryManagerTest, Basic) { 182 TEST_F(MappedMemoryManagerTest, Basic) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 unsigned int offset3; 447 unsigned int offset3;
448 void* mem3 = manager_->Alloc(kSize, &id3, &offset3); 448 void* mem3 = manager_->Alloc(kSize, &id3, &offset3);
449 EXPECT_EQ(manager_->bytes_in_use(), kSize * 2); 449 EXPECT_EQ(manager_->bytes_in_use(), kSize * 2);
450 450
451 manager_->Free(mem2); 451 manager_->Free(mem2);
452 manager_->Free(mem3); 452 manager_->Free(mem3);
453 EXPECT_EQ(manager_->bytes_in_use(), static_cast<size_t>(0)); 453 EXPECT_EQ(manager_->bytes_in_use(), static_cast<size_t>(0));
454 } 454 }
455 455
456 } // namespace gpu 456 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation_unittest.cc ('k') | gpu/command_buffer/client/program_info_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698