| 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 | 8 |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 using testing::Invoke; | 31 using testing::Invoke; |
| 32 using testing::_; | 32 using testing::_; |
| 33 | 33 |
| 34 class BaseRingBufferTest : public testing::Test { | 34 class BaseRingBufferTest : public testing::Test { |
| 35 protected: | 35 protected: |
| 36 static const unsigned int kBaseOffset = 128; | 36 static const unsigned int kBaseOffset = 128; |
| 37 static const unsigned int kBufferSize = 1024; | 37 static const unsigned int kBufferSize = 1024; |
| 38 static const unsigned int kAlignment = 4; | 38 static const unsigned int kAlignment = 4; |
| 39 | 39 |
| 40 void RunPendingSetToken() { | 40 void RunPendingSetToken() { |
| 41 for (std::vector<const void*>::iterator it = set_token_arguments_.begin(); | 41 for (std::vector<const volatile void*>::iterator it = |
| 42 it != set_token_arguments_.end(); | 42 set_token_arguments_.begin(); |
| 43 ++it) { | 43 it != set_token_arguments_.end(); ++it) { |
| 44 api_mock_->SetToken(cmd::kSetToken, 1, *it); | 44 api_mock_->SetToken(cmd::kSetToken, 1, *it); |
| 45 } | 45 } |
| 46 set_token_arguments_.clear(); | 46 set_token_arguments_.clear(); |
| 47 delay_set_token_ = false; | 47 delay_set_token_ = false; |
| 48 } | 48 } |
| 49 | 49 |
| 50 void SetToken(unsigned int command, | 50 void SetToken(unsigned int command, |
| 51 unsigned int arg_count, | 51 unsigned int arg_count, |
| 52 const void* _args) { | 52 const volatile void* _args) { |
| 53 EXPECT_EQ(static_cast<unsigned int>(cmd::kSetToken), command); | 53 EXPECT_EQ(static_cast<unsigned int>(cmd::kSetToken), command); |
| 54 EXPECT_EQ(1u, arg_count); | 54 EXPECT_EQ(1u, arg_count); |
| 55 if (delay_set_token_) | 55 if (delay_set_token_) |
| 56 set_token_arguments_.push_back(_args); | 56 set_token_arguments_.push_back(_args); |
| 57 else | 57 else |
| 58 api_mock_->SetToken(cmd::kSetToken, 1, _args); | 58 api_mock_->SetToken(cmd::kSetToken, 1, _args); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void SetUp() override { | 61 void SetUp() override { |
| 62 delay_set_token_ = false; | 62 delay_set_token_ = false; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 91 helper_->Initialize(kBufferSize); | 91 helper_->Initialize(kBufferSize); |
| 92 } | 92 } |
| 93 | 93 |
| 94 int32_t GetToken() { return command_buffer_->GetLastState().token; } | 94 int32_t GetToken() { return command_buffer_->GetLastState().token; } |
| 95 | 95 |
| 96 std::unique_ptr<AsyncAPIMock> api_mock_; | 96 std::unique_ptr<AsyncAPIMock> api_mock_; |
| 97 scoped_refptr<TransferBufferManagerInterface> transfer_buffer_manager_; | 97 scoped_refptr<TransferBufferManagerInterface> transfer_buffer_manager_; |
| 98 std::unique_ptr<CommandBufferService> command_buffer_; | 98 std::unique_ptr<CommandBufferService> command_buffer_; |
| 99 std::unique_ptr<CommandExecutor> executor_; | 99 std::unique_ptr<CommandExecutor> executor_; |
| 100 std::unique_ptr<CommandBufferHelper> helper_; | 100 std::unique_ptr<CommandBufferHelper> helper_; |
| 101 std::vector<const void*> set_token_arguments_; | 101 std::vector<const volatile void*> set_token_arguments_; |
| 102 bool delay_set_token_; | 102 bool delay_set_token_; |
| 103 | 103 |
| 104 std::unique_ptr<int8_t[]> buffer_; | 104 std::unique_ptr<int8_t[]> buffer_; |
| 105 int8_t* buffer_start_; | 105 int8_t* buffer_start_; |
| 106 base::MessageLoop message_loop_; | 106 base::MessageLoop message_loop_; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 #ifndef _MSC_VER | 109 #ifndef _MSC_VER |
| 110 const unsigned int BaseRingBufferTest::kBaseOffset; | 110 const unsigned int BaseRingBufferTest::kBaseOffset; |
| 111 const unsigned int BaseRingBufferTest::kBufferSize; | 111 const unsigned int BaseRingBufferTest::kBufferSize; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 // Discarding the middle allocation should turn it into padding. | 426 // Discarding the middle allocation should turn it into padding. |
| 427 allocator_->DiscardBlock(ptr2); | 427 allocator_->DiscardBlock(ptr2); |
| 428 EXPECT_EQ(0u, allocator_->GetLargestFreeSizeNoWaiting()); | 428 EXPECT_EQ(0u, allocator_->GetLargestFreeSizeNoWaiting()); |
| 429 | 429 |
| 430 // Discarding the first allocation should discard the middle padding as well. | 430 // Discarding the first allocation should discard the middle padding as well. |
| 431 allocator_->DiscardBlock(ptr1); | 431 allocator_->DiscardBlock(ptr1); |
| 432 EXPECT_EQ(kAlloc1 + kAlloc2, allocator_->GetLargestFreeSizeNoWaiting()); | 432 EXPECT_EQ(kAlloc1 + kAlloc2, allocator_->GetLargestFreeSizeNoWaiting()); |
| 433 } | 433 } |
| 434 | 434 |
| 435 } // namespace gpu | 435 } // namespace gpu |
| OLD | NEW |