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

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

Issue 11613021: Removing the JumpRelative, Call, CallRelative and Return commands. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use Noops instead of Jump; Remove Jump command. Created 7 years, 11 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 // This file contains the tests for the RingBuffer class. 5 // This file contains the tests for the RingBuffer class.
6 6
7 #include "gpu/command_buffer/client/ring_buffer.h" 7 #include "gpu/command_buffer/client/ring_buffer.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 17 matching lines...) Expand all
28 using testing::Sequence; 28 using testing::Sequence;
29 using testing::DoAll; 29 using testing::DoAll;
30 using testing::Invoke; 30 using testing::Invoke;
31 using testing::_; 31 using testing::_;
32 32
33 class BaseRingBufferTest : public testing::Test { 33 class BaseRingBufferTest : public testing::Test {
34 protected: 34 protected:
35 static const unsigned int kBaseOffset = 128; 35 static const unsigned int kBaseOffset = 128;
36 static const unsigned int kBufferSize = 1024; 36 static const unsigned int kBufferSize = 1024;
37 37
38 class DoJumpCommand {
39 public:
40 explicit DoJumpCommand(GpuScheduler* gpu_scheduler)
41 : gpu_scheduler_(gpu_scheduler) {
42 }
43
44 error::Error DoCommand(
45 unsigned int command,
46 unsigned int arg_count,
47 const void* cmd_data) {
48 const cmd::Jump* jump_cmd = static_cast<const cmd::Jump*>(cmd_data);
49 gpu_scheduler_->parser()->set_get(jump_cmd->offset);
50 return error::kNoError;
51 };
52
53 private:
54 GpuScheduler* gpu_scheduler_;
55 };
56
57 virtual void SetUp() { 38 virtual void SetUp() {
58 api_mock_.reset(new AsyncAPIMock); 39 api_mock_.reset(new AsyncAPIMock);
59 // ignore noops in the mock - we don't want to inspect the internals of the 40 // ignore noops in the mock - we don't want to inspect the internals of the
60 // helper. 41 // helper.
61 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, 0, _)) 42 EXPECT_CALL(*api_mock_, DoCommand(cmd::kNoop, 0, _))
62 .WillRepeatedly(Return(error::kNoError)); 43 .WillRepeatedly(Return(error::kNoError));
63 // Forward the SetToken calls to the engine 44 // Forward the SetToken calls to the engine
64 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) 45 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _))
65 .WillRepeatedly(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), 46 .WillRepeatedly(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken),
66 Return(error::kNoError))); 47 Return(error::kNoError)));
67 48
68 { 49 {
69 TransferBufferManager* manager = new TransferBufferManager(); 50 TransferBufferManager* manager = new TransferBufferManager();
70 transfer_buffer_manager_.reset(manager); 51 transfer_buffer_manager_.reset(manager);
71 EXPECT_TRUE(manager->Initialize()); 52 EXPECT_TRUE(manager->Initialize());
72 } 53 }
73 command_buffer_.reset( 54 command_buffer_.reset(
74 new CommandBufferService(transfer_buffer_manager_.get())); 55 new CommandBufferService(transfer_buffer_manager_.get()));
75 EXPECT_TRUE(command_buffer_->Initialize()); 56 EXPECT_TRUE(command_buffer_->Initialize());
76 57
77 gpu_scheduler_.reset(new GpuScheduler( 58 gpu_scheduler_.reset(new GpuScheduler(
78 command_buffer_.get(), api_mock_.get(), NULL)); 59 command_buffer_.get(), api_mock_.get(), NULL));
79 command_buffer_->SetPutOffsetChangeCallback(base::Bind( 60 command_buffer_->SetPutOffsetChangeCallback(base::Bind(
80 &GpuScheduler::PutChanged, base::Unretained(gpu_scheduler_.get()))); 61 &GpuScheduler::PutChanged, base::Unretained(gpu_scheduler_.get())));
81 command_buffer_->SetGetBufferChangeCallback(base::Bind( 62 command_buffer_->SetGetBufferChangeCallback(base::Bind(
82 &GpuScheduler::SetGetBuffer, base::Unretained(gpu_scheduler_.get()))); 63 &GpuScheduler::SetGetBuffer, base::Unretained(gpu_scheduler_.get())));
83 64
84 api_mock_->set_engine(gpu_scheduler_.get()); 65 api_mock_->set_engine(gpu_scheduler_.get());
85 do_jump_command_.reset(new DoJumpCommand(gpu_scheduler_.get()));
86 EXPECT_CALL(*api_mock_, DoCommand(cmd::kJump, _, _))
87 .WillRepeatedly(
88 Invoke(do_jump_command_.get(), &DoJumpCommand::DoCommand));
89 66
90 helper_.reset(new CommandBufferHelper(command_buffer_.get())); 67 helper_.reset(new CommandBufferHelper(command_buffer_.get()));
91 helper_->Initialize(kBufferSize); 68 helper_->Initialize(kBufferSize);
92 } 69 }
93 70
94 int32 GetToken() { 71 int32 GetToken() {
95 return command_buffer_->GetState().token; 72 return command_buffer_->GetState().token;
96 } 73 }
97 74
98 #if defined(OS_MACOSX) 75 #if defined(OS_MACOSX)
99 base::mac::ScopedNSAutoreleasePool autorelease_pool_; 76 base::mac::ScopedNSAutoreleasePool autorelease_pool_;
100 #endif 77 #endif
101 MessageLoop message_loop_; 78 MessageLoop message_loop_;
102 scoped_ptr<AsyncAPIMock> api_mock_; 79 scoped_ptr<AsyncAPIMock> api_mock_;
103 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_; 80 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_;
104 scoped_ptr<CommandBufferService> command_buffer_; 81 scoped_ptr<CommandBufferService> command_buffer_;
105 scoped_ptr<GpuScheduler> gpu_scheduler_; 82 scoped_ptr<GpuScheduler> gpu_scheduler_;
106 scoped_ptr<CommandBufferHelper> helper_; 83 scoped_ptr<CommandBufferHelper> helper_;
107 scoped_ptr<DoJumpCommand> do_jump_command_;
108 }; 84 };
109 85
110 #ifndef _MSC_VER 86 #ifndef _MSC_VER
111 const unsigned int BaseRingBufferTest::kBaseOffset; 87 const unsigned int BaseRingBufferTest::kBaseOffset;
112 const unsigned int BaseRingBufferTest::kBufferSize; 88 const unsigned int BaseRingBufferTest::kBufferSize;
113 #endif 89 #endif
114 90
115 // Test fixture for RingBuffer test - Creates a RingBuffer, using a 91 // Test fixture for RingBuffer test - Creates a RingBuffer, using a
116 // CommandBufferHelper with a mock AsyncAPIInterface for its interface (calling 92 // CommandBufferHelper with a mock AsyncAPIInterface for its interface (calling
117 // it directly, not through the RPC mechanism), making sure Noops are ignored 93 // it directly, not through the RPC mechanism), making sure Noops are ignored
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 EXPECT_EQ(buffer_start_, static_cast<int8*>(pointer1)); 260 EXPECT_EQ(buffer_start_, static_cast<int8*>(pointer1));
285 261
286 // Check that the token has indeed passed. 262 // Check that the token has indeed passed.
287 EXPECT_LE(tokens[0], GetToken()); 263 EXPECT_LE(tokens[0], GetToken());
288 264
289 allocator_->FreePendingToken(pointer1, helper_->InsertToken()); 265 allocator_->FreePendingToken(pointer1, helper_->InsertToken());
290 EXPECT_LE(command_buffer_->GetState().token, helper_->InsertToken()); 266 EXPECT_LE(command_buffer_->GetState().token, helper_->InsertToken());
291 } 267 }
292 268
293 } // namespace gpu 269 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/cmd_buffer_helper_test.cc ('k') | gpu/command_buffer/common/cmd_buffer_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698