OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 FencedAllocator class. | 5 // This file contains the tests for the FencedAllocator class. |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/scoped_nsautorelease_pool.h" | 10 #include "base/scoped_nsautorelease_pool.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 api_mock_->set_engine(gpu_processor_.get()); | 60 api_mock_->set_engine(gpu_processor_.get()); |
61 | 61 |
62 helper_.reset(new CommandBufferHelper(command_buffer_.get())); | 62 helper_.reset(new CommandBufferHelper(command_buffer_.get())); |
63 helper_->Initialize(); | 63 helper_->Initialize(); |
64 } | 64 } |
65 | 65 |
66 int32 GetToken() { | 66 int32 GetToken() { |
67 return command_buffer_->GetState().token; | 67 return command_buffer_->GetState().token; |
68 } | 68 } |
69 | 69 |
70 virtual void TearDown() { | |
71 helper_.release(); | |
72 } | |
73 | |
74 base::ScopedNSAutoreleasePool autorelease_pool_; | 70 base::ScopedNSAutoreleasePool autorelease_pool_; |
75 base::AtExitManager at_exit_manager_; | 71 base::AtExitManager at_exit_manager_; |
76 MessageLoop message_loop_; | 72 MessageLoop message_loop_; |
77 scoped_ptr<AsyncAPIMock> api_mock_; | 73 scoped_ptr<AsyncAPIMock> api_mock_; |
78 scoped_ptr<CommandBufferService> command_buffer_; | 74 scoped_ptr<CommandBufferService> command_buffer_; |
79 scoped_ptr<GPUProcessor> gpu_processor_; | 75 scoped_ptr<GPUProcessor> gpu_processor_; |
80 CommandParser* parser_; | 76 CommandParser* parser_; |
81 scoped_ptr<CommandBufferHelper> helper_; | 77 scoped_ptr<CommandBufferHelper> helper_; |
82 }; | 78 }; |
83 | 79 |
(...skipping 10 matching lines...) Expand all Loading... |
94 virtual void SetUp() { | 90 virtual void SetUp() { |
95 BaseFencedAllocatorTest::SetUp(); | 91 BaseFencedAllocatorTest::SetUp(); |
96 allocator_.reset(new FencedAllocator(kBufferSize, helper_.get())); | 92 allocator_.reset(new FencedAllocator(kBufferSize, helper_.get())); |
97 } | 93 } |
98 | 94 |
99 virtual void TearDown() { | 95 virtual void TearDown() { |
100 // If the GPUProcessor posts any tasks, this forces them to run. | 96 // If the GPUProcessor posts any tasks, this forces them to run. |
101 MessageLoop::current()->RunAllPending(); | 97 MessageLoop::current()->RunAllPending(); |
102 | 98 |
103 EXPECT_TRUE(allocator_->CheckConsistency()); | 99 EXPECT_TRUE(allocator_->CheckConsistency()); |
104 allocator_.release(); | |
105 | 100 |
106 BaseFencedAllocatorTest::TearDown(); | 101 BaseFencedAllocatorTest::TearDown(); |
107 } | 102 } |
108 | 103 |
109 scoped_ptr<FencedAllocator> allocator_; | 104 scoped_ptr<FencedAllocator> allocator_; |
110 }; | 105 }; |
111 | 106 |
112 // Checks basic alloc and free. | 107 // Checks basic alloc and free. |
113 TEST_F(FencedAllocatorTest, TestBasic) { | 108 TEST_F(FencedAllocatorTest, TestBasic) { |
114 allocator_->CheckConsistency(); | 109 allocator_->CheckConsistency(); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 buffer_.reset(new char[kBufferSize]); | 326 buffer_.reset(new char[kBufferSize]); |
332 allocator_.reset(new FencedAllocatorWrapper(kBufferSize, helper_.get(), | 327 allocator_.reset(new FencedAllocatorWrapper(kBufferSize, helper_.get(), |
333 buffer_.get())); | 328 buffer_.get())); |
334 } | 329 } |
335 | 330 |
336 virtual void TearDown() { | 331 virtual void TearDown() { |
337 // If the GPUProcessor posts any tasks, this forces them to run. | 332 // If the GPUProcessor posts any tasks, this forces them to run. |
338 MessageLoop::current()->RunAllPending(); | 333 MessageLoop::current()->RunAllPending(); |
339 | 334 |
340 EXPECT_TRUE(allocator_->CheckConsistency()); | 335 EXPECT_TRUE(allocator_->CheckConsistency()); |
341 allocator_.release(); | |
342 buffer_.release(); | |
343 | 336 |
344 BaseFencedAllocatorTest::TearDown(); | 337 BaseFencedAllocatorTest::TearDown(); |
345 } | 338 } |
346 | 339 |
347 scoped_ptr<FencedAllocatorWrapper> allocator_; | 340 scoped_ptr<FencedAllocatorWrapper> allocator_; |
348 scoped_array<char> buffer_; | 341 scoped_array<char> buffer_; |
349 }; | 342 }; |
350 | 343 |
351 // Checks basic alloc and free. | 344 // Checks basic alloc and free. |
352 TEST_F(FencedAllocatorWrapperTest, TestBasic) { | 345 TEST_F(FencedAllocatorWrapperTest, TestBasic) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 EXPECT_LE(token, GetToken()); | 455 EXPECT_LE(token, GetToken()); |
463 | 456 |
464 // Free up everything. | 457 // Free up everything. |
465 for (unsigned int i = 0; i < kAllocCount; ++i) { | 458 for (unsigned int i = 0; i < kAllocCount; ++i) { |
466 allocator_->Free(pointers[i]); | 459 allocator_->Free(pointers[i]); |
467 EXPECT_TRUE(allocator_->CheckConsistency()); | 460 EXPECT_TRUE(allocator_->CheckConsistency()); |
468 } | 461 } |
469 } | 462 } |
470 | 463 |
471 } // namespace gpu | 464 } // namespace gpu |
OLD | NEW |