| OLD | NEW |
| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 196 } |
| 197 | 197 |
| 198 virtual void TearDown() { | 198 virtual void TearDown() { |
| 199 // If the GpuScheduler posts any tasks, this forces them to run. | 199 // If the GpuScheduler posts any tasks, this forces them to run. |
| 200 MessageLoop::current()->RunUntilIdle(); | 200 MessageLoop::current()->RunUntilIdle(); |
| 201 | 201 |
| 202 BaseRingBufferTest::TearDown(); | 202 BaseRingBufferTest::TearDown(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 scoped_ptr<RingBufferWrapper> allocator_; | 205 scoped_ptr<RingBufferWrapper> allocator_; |
| 206 scoped_array<int8> buffer_; | 206 scoped_ptr<int8[]> buffer_; |
| 207 int8* buffer_start_; | 207 int8* buffer_start_; |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 // Checks basic alloc and free. | 210 // Checks basic alloc and free. |
| 211 TEST_F(RingBufferWrapperTest, TestBasic) { | 211 TEST_F(RingBufferWrapperTest, TestBasic) { |
| 212 const unsigned int kSize = 16; | 212 const unsigned int kSize = 16; |
| 213 void* pointer = allocator_->Alloc(kSize); | 213 void* pointer = allocator_->Alloc(kSize); |
| 214 ASSERT_TRUE(pointer); | 214 ASSERT_TRUE(pointer); |
| 215 EXPECT_LE(buffer_start_, static_cast<int8*>(pointer)); | 215 EXPECT_LE(buffer_start_, static_cast<int8*>(pointer)); |
| 216 EXPECT_GE(kBufferSize, static_cast<int8*>(pointer) - buffer_start_ + kSize); | 216 EXPECT_GE(kBufferSize, static_cast<int8*>(pointer) - buffer_start_ + kSize); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 EXPECT_EQ(buffer_start_, static_cast<int8*>(pointer1)); | 260 EXPECT_EQ(buffer_start_, static_cast<int8*>(pointer1)); |
| 261 | 261 |
| 262 // Check that the token has indeed passed. | 262 // Check that the token has indeed passed. |
| 263 EXPECT_LE(tokens[0], GetToken()); | 263 EXPECT_LE(tokens[0], GetToken()); |
| 264 | 264 |
| 265 allocator_->FreePendingToken(pointer1, helper_->InsertToken()); | 265 allocator_->FreePendingToken(pointer1, helper_->InsertToken()); |
| 266 EXPECT_LE(command_buffer_->GetState().token, helper_->InsertToken()); | 266 EXPECT_LE(command_buffer_->GetState().token, helper_->InsertToken()); |
| 267 } | 267 } |
| 268 | 268 |
| 269 } // namespace gpu | 269 } // namespace gpu |
| OLD | NEW |