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 "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
9 #include "cc/resources/resource_util.h" | 9 #include "cc/resources/resource_util.h" |
10 #include "cc/resources/scoped_resource.h" | 10 #include "cc/resources/scoped_resource.h" |
11 #include "cc/test/fake_output_surface.h" | 11 #include "cc/test/fake_output_surface.h" |
12 #include "cc/test/fake_output_surface_client.h" | 12 #include "cc/test/fake_output_surface_client.h" |
13 #include "cc/test/fake_resource_provider.h" | 13 #include "cc/test/fake_resource_provider.h" |
14 #include "cc/test/test_shared_bitmap_manager.h" | 14 #include "cc/test/test_shared_bitmap_manager.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 namespace { | 18 namespace { |
19 | 19 |
20 class ResourcePoolTest : public testing::Test { | 20 class ResourcePoolTest : public testing::Test { |
21 public: | 21 public: |
22 void SetUp() override { | 22 void SetUp() override { |
23 output_surface_ = FakeOutputSurface::Create3d(); | 23 output_surface_ = FakeOutputSurface::Create3d(); |
24 ASSERT_TRUE(output_surface_->BindToClient(&output_surface_client_)); | 24 ASSERT_TRUE(output_surface_->BindToClient(&output_surface_client_)); |
25 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 25 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
26 resource_provider_ = FakeResourceProvider::Create( | 26 resource_provider_ = FakeResourceProvider::Create( |
27 output_surface_.get(), shared_bitmap_manager_.get()); | 27 output_surface_.get(), shared_bitmap_manager_.get()); |
28 task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 28 task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
29 resource_pool_ = ResourcePool::Create(resource_provider_.get(), | 29 resource_pool_ = |
30 task_runner_.get(), GL_TEXTURE_2D); | 30 ResourcePool::Create(resource_provider_.get(), task_runner_.get()); |
31 } | 31 } |
32 | 32 |
33 protected: | 33 protected: |
34 FakeOutputSurfaceClient output_surface_client_; | 34 FakeOutputSurfaceClient output_surface_client_; |
35 scoped_ptr<FakeOutputSurface> output_surface_; | 35 scoped_ptr<FakeOutputSurface> output_surface_; |
36 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 36 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
37 scoped_ptr<ResourceProvider> resource_provider_; | 37 scoped_ptr<ResourceProvider> resource_provider_; |
38 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 38 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
39 scoped_ptr<ResourcePool> resource_pool_; | 39 scoped_ptr<ResourcePool> resource_pool_; |
40 }; | 40 }; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 task_runner_->PostDelayedTask(FROM_HERE, run_loop.QuitClosure(), | 213 task_runner_->PostDelayedTask(FROM_HERE, run_loop.QuitClosure(), |
214 base::TimeDelta::FromMillisecondsD(200)); | 214 base::TimeDelta::FromMillisecondsD(200)); |
215 run_loop.Run(); | 215 run_loop.Run(); |
216 | 216 |
217 EXPECT_EQ(0u, resource_provider_->num_resources()); | 217 EXPECT_EQ(0u, resource_provider_->num_resources()); |
218 EXPECT_EQ(0u, resource_pool_->GetTotalMemoryUsageForTesting()); | 218 EXPECT_EQ(0u, resource_pool_->GetTotalMemoryUsageForTesting()); |
219 } | 219 } |
220 | 220 |
221 } // namespace | 221 } // namespace |
222 } // namespace cc | 222 } // namespace cc |
OLD | NEW |