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

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

Issue 1859703002: convert //gpu to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 4 years, 8 months 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/service/command_executor.h" 5 #include "gpu/command_buffer/service/command_executor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
11
10 #include "gpu/command_buffer/common/command_buffer_mock.h" 12 #include "gpu/command_buffer/common/command_buffer_mock.h"
11 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 13 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
12 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" 14 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
13 #include "gpu/command_buffer/service/mocks.h" 15 #include "gpu/command_buffer/service/mocks.h"
14 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 18
17 using testing::_; 19 using testing::_;
18 using testing::DoAll; 20 using testing::DoAll;
19 using testing::Invoke; 21 using testing::Invoke;
20 using testing::NiceMock; 22 using testing::NiceMock;
21 using testing::Return; 23 using testing::Return;
22 using testing::SetArgumentPointee; 24 using testing::SetArgumentPointee;
23 using testing::StrictMock; 25 using testing::StrictMock;
24 26
25 namespace gpu { 27 namespace gpu {
26 28
27 const size_t kRingBufferSize = 1024; 29 const size_t kRingBufferSize = 1024;
28 30
29 class CommandExecutorTest : public testing::Test { 31 class CommandExecutorTest : public testing::Test {
30 protected: 32 protected:
31 static const int32_t kTransferBufferId = 123; 33 static const int32_t kTransferBufferId = 123;
32 34
33 void SetUp() override { 35 void SetUp() override {
34 scoped_ptr<base::SharedMemory> shared_memory(new ::base::SharedMemory); 36 std::unique_ptr<base::SharedMemory> shared_memory(new ::base::SharedMemory);
35 shared_memory->CreateAndMapAnonymous(kRingBufferSize); 37 shared_memory->CreateAndMapAnonymous(kRingBufferSize);
36 buffer_ = static_cast<int32_t*>(shared_memory->memory()); 38 buffer_ = static_cast<int32_t*>(shared_memory->memory());
37 shared_memory_buffer_ = 39 shared_memory_buffer_ =
38 MakeBufferFromSharedMemory(std::move(shared_memory), kRingBufferSize); 40 MakeBufferFromSharedMemory(std::move(shared_memory), kRingBufferSize);
39 memset(buffer_, 0, kRingBufferSize); 41 memset(buffer_, 0, kRingBufferSize);
40 42
41 command_buffer_.reset(new MockCommandBuffer); 43 command_buffer_.reset(new MockCommandBuffer);
42 44
43 CommandBuffer::State default_state; 45 CommandBuffer::State default_state;
44 ON_CALL(*command_buffer_.get(), GetLastState()) 46 ON_CALL(*command_buffer_.get(), GetLastState())
(...skipping 16 matching lines...) Expand all
61 } 63 }
62 64
63 void TearDown() override { 65 void TearDown() override {
64 // Ensure that any unexpected tasks posted by the GPU scheduler are executed 66 // Ensure that any unexpected tasks posted by the GPU scheduler are executed
65 // in order to fail the test. 67 // in order to fail the test.
66 base::MessageLoop::current()->RunUntilIdle(); 68 base::MessageLoop::current()->RunUntilIdle();
67 } 69 }
68 70
69 error::Error GetError() { return command_buffer_->GetLastState().error; } 71 error::Error GetError() { return command_buffer_->GetLastState().error; }
70 72
71 scoped_ptr<MockCommandBuffer> command_buffer_; 73 std::unique_ptr<MockCommandBuffer> command_buffer_;
72 scoped_refptr<Buffer> shared_memory_buffer_; 74 scoped_refptr<Buffer> shared_memory_buffer_;
73 int32_t* buffer_; 75 int32_t* buffer_;
74 scoped_ptr<gles2::MockGLES2Decoder> decoder_; 76 std::unique_ptr<gles2::MockGLES2Decoder> decoder_;
75 scoped_ptr<CommandExecutor> executor_; 77 std::unique_ptr<CommandExecutor> executor_;
76 base::MessageLoop message_loop_; 78 base::MessageLoop message_loop_;
77 }; 79 };
78 80
79 TEST_F(CommandExecutorTest, ExecutorDoesNothingIfRingBufferIsEmpty) { 81 TEST_F(CommandExecutorTest, ExecutorDoesNothingIfRingBufferIsEmpty) {
80 CommandBuffer::State state; 82 CommandBuffer::State state;
81 83
82 EXPECT_CALL(*command_buffer_, GetLastState()).WillRepeatedly(Return(state)); 84 EXPECT_CALL(*command_buffer_, GetLastState()).WillRepeatedly(Return(state));
83 85
84 EXPECT_CALL(*command_buffer_, SetParseError(_)).Times(0); 86 EXPECT_CALL(*command_buffer_, SetParseError(_)).Times(0);
85 87
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 197
196 EXPECT_EQ(kRingBufferSize, executor_->GetSharedMemoryBuffer(7)->size()); 198 EXPECT_EQ(kRingBufferSize, executor_->GetSharedMemoryBuffer(7)->size());
197 } 199 }
198 200
199 TEST_F(CommandExecutorTest, SetTokenForwardsToCommandBuffer) { 201 TEST_F(CommandExecutorTest, SetTokenForwardsToCommandBuffer) {
200 EXPECT_CALL(*command_buffer_, SetToken(7)); 202 EXPECT_CALL(*command_buffer_, SetToken(7));
201 executor_->set_token(7); 203 executor_->set_token(7);
202 } 204 }
203 205
204 } // namespace gpu 206 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/command_executor.h ('k') | gpu/command_buffer/service/common_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698