| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "cc/resources/resource_pool.h" | 5 #include "cc/resources/resource_pool.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 27 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
| 28 resource_provider_ = FakeResourceProvider::Create( | 28 resource_provider_ = FakeResourceProvider::Create( |
| 29 output_surface_.get(), shared_bitmap_manager_.get()); | 29 output_surface_.get(), shared_bitmap_manager_.get()); |
| 30 task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 30 task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| 31 resource_pool_ = | 31 resource_pool_ = |
| 32 ResourcePool::Create(resource_provider_.get(), task_runner_.get()); | 32 ResourcePool::Create(resource_provider_.get(), task_runner_.get()); |
| 33 } | 33 } |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 FakeOutputSurfaceClient output_surface_client_; | 36 FakeOutputSurfaceClient output_surface_client_; |
| 37 scoped_ptr<FakeOutputSurface> output_surface_; | 37 std::unique_ptr<FakeOutputSurface> output_surface_; |
| 38 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 38 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; |
| 39 scoped_ptr<ResourceProvider> resource_provider_; | 39 std::unique_ptr<ResourceProvider> resource_provider_; |
| 40 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 40 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 41 scoped_ptr<ResourcePool> resource_pool_; | 41 std::unique_ptr<ResourcePool> resource_pool_; |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 TEST_F(ResourcePoolTest, AcquireRelease) { | 44 TEST_F(ResourcePoolTest, AcquireRelease) { |
| 45 gfx::Size size(100, 100); | 45 gfx::Size size(100, 100); |
| 46 ResourceFormat format = RGBA_8888; | 46 ResourceFormat format = RGBA_8888; |
| 47 Resource* resource = resource_pool_->AcquireResource(size, format); | 47 Resource* resource = resource_pool_->AcquireResource(size, format); |
| 48 EXPECT_EQ(size, resource->size()); | 48 EXPECT_EQ(size, resource->size()); |
| 49 EXPECT_EQ(format, resource->format()); | 49 EXPECT_EQ(format, resource->format()); |
| 50 EXPECT_TRUE(resource_provider_->CanLockForWrite(resource->id())); | 50 EXPECT_TRUE(resource_provider_->CanLockForWrite(resource->id())); |
| 51 | 51 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 task_runner_->PostDelayedTask(FROM_HERE, run_loop.QuitClosure(), | 215 task_runner_->PostDelayedTask(FROM_HERE, run_loop.QuitClosure(), |
| 216 base::TimeDelta::FromMillisecondsD(200)); | 216 base::TimeDelta::FromMillisecondsD(200)); |
| 217 run_loop.Run(); | 217 run_loop.Run(); |
| 218 | 218 |
| 219 EXPECT_EQ(0u, resource_provider_->num_resources()); | 219 EXPECT_EQ(0u, resource_provider_->num_resources()); |
| 220 EXPECT_EQ(0u, resource_pool_->GetTotalMemoryUsageForTesting()); | 220 EXPECT_EQ(0u, resource_pool_->GetTotalMemoryUsageForTesting()); |
| 221 } | 221 } |
| 222 | 222 |
| 223 } // namespace | 223 } // namespace |
| 224 } // namespace cc | 224 } // namespace cc |
| OLD | NEW |