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

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

Issue 10441140: Make context groups share a TextureBufferManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/threading/thread.h" 7 #include "base/threading/thread.h"
8 #include "gpu/command_buffer/common/cmd_buffer_common.h" 8 #include "gpu/command_buffer/common/cmd_buffer_common.h"
9 #include "gpu/command_buffer/service/command_buffer_service.h" 9 #include "gpu/command_buffer/service/command_buffer_service.h"
10 #include "gpu/command_buffer/service/transfer_buffer_manager.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
12 13
13 using base::SharedMemory; 14 using base::SharedMemory;
14 using testing::_; 15 using testing::_;
15 using testing::DoAll; 16 using testing::DoAll;
16 using testing::Return; 17 using testing::Return;
17 using testing::SetArgumentPointee; 18 using testing::SetArgumentPointee;
18 using testing::StrictMock; 19 using testing::StrictMock;
19 20
20 namespace gpu { 21 namespace gpu {
21 22
22 class CommandBufferServiceTest : public testing::Test { 23 class CommandBufferServiceTest : public testing::Test {
23 protected: 24 protected:
24 virtual void SetUp() { 25 virtual void SetUp() {
25 command_buffer_.reset(new CommandBufferService); 26 {
27 TransferBufferManager* manager = new TransferBufferManager();
28 transfer_buffer_manager_.reset(manager);
29 EXPECT_TRUE(manager->Initialize());
30 }
31 command_buffer_.reset(
32 new CommandBufferService(transfer_buffer_manager_.get()));
26 EXPECT_TRUE(command_buffer_->Initialize()); 33 EXPECT_TRUE(command_buffer_->Initialize());
27 } 34 }
28 35
29 int32 GetGetOffset() { 36 int32 GetGetOffset() {
30 return command_buffer_->GetState().get_offset; 37 return command_buffer_->GetState().get_offset;
31 } 38 }
32 39
33 int32 GetPutOffset() { 40 int32 GetPutOffset() {
34 return command_buffer_->GetState().put_offset; 41 return command_buffer_->GetState().put_offset;
35 } 42 }
36 43
37 int32 GetToken() { 44 int32 GetToken() {
38 return command_buffer_->GetState().token; 45 return command_buffer_->GetState().token;
39 } 46 }
40 47
41 int32 GetError() { 48 int32 GetError() {
42 return command_buffer_->GetState().error; 49 return command_buffer_->GetState().error;
43 } 50 }
44 51
45 bool Initialize(size_t size) { 52 bool Initialize(size_t size) {
46 int32 id = command_buffer_->CreateTransferBuffer(size, -1); 53 int32 id = command_buffer_->CreateTransferBuffer(size, -1);
47 EXPECT_GT(id, 0); 54 EXPECT_GT(id, 0);
48 command_buffer_->SetGetBuffer(id); 55 command_buffer_->SetGetBuffer(id);
49 return true; 56 return true;
50 } 57 }
51 58
59 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_;
52 scoped_ptr<CommandBufferService> command_buffer_; 60 scoped_ptr<CommandBufferService> command_buffer_;
53 }; 61 };
54 62
55 TEST_F(CommandBufferServiceTest, InitializesCommandBuffer) { 63 TEST_F(CommandBufferServiceTest, InitializesCommandBuffer) {
56 EXPECT_TRUE(Initialize(1024)); 64 EXPECT_TRUE(Initialize(1024));
57 CommandBuffer::State state = command_buffer_->GetState(); 65 CommandBuffer::State state = command_buffer_->GetState();
58 EXPECT_EQ(0, state.get_offset); 66 EXPECT_EQ(0, state.get_offset);
59 EXPECT_EQ(0, state.put_offset); 67 EXPECT_EQ(0, state.put_offset);
60 EXPECT_EQ(0, state.token); 68 EXPECT_EQ(0, state.token);
61 EXPECT_EQ(error::kNoError, state.error); 69 EXPECT_EQ(error::kNoError, state.error);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 145
138 TEST_F(CommandBufferServiceTest, DefaultParseErrorIsNoError) { 146 TEST_F(CommandBufferServiceTest, DefaultParseErrorIsNoError) {
139 EXPECT_EQ(0, GetError()); 147 EXPECT_EQ(0, GetError());
140 } 148 }
141 149
142 TEST_F(CommandBufferServiceTest, CanSetParseError) { 150 TEST_F(CommandBufferServiceTest, CanSetParseError) {
143 command_buffer_->SetParseError(error::kInvalidSize); 151 command_buffer_->SetParseError(error::kInvalidSize);
144 EXPECT_EQ(1, GetError()); 152 EXPECT_EQ(1, GetError());
145 } 153 }
146 } // namespace gpu 154 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698