OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tile.h" | 5 #include "cc/resources/tile.h" |
6 #include "cc/resources/tile_priority.h" | 6 #include "cc/resources/tile_priority.h" |
7 #include "cc/test/fake_output_surface.h" | 7 #include "cc/test/fake_output_surface.h" |
| 8 #include "cc/test/fake_output_surface_client.h" |
8 #include "cc/test/fake_picture_pile_impl.h" | 9 #include "cc/test/fake_picture_pile_impl.h" |
9 #include "cc/test/fake_tile_manager.h" | 10 #include "cc/test/fake_tile_manager.h" |
10 #include "cc/test/fake_tile_manager_client.h" | 11 #include "cc/test/fake_tile_manager_client.h" |
11 #include "cc/test/test_tile_priorities.h" | 12 #include "cc/test/test_tile_priorities.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace cc { | 15 namespace cc { |
15 namespace { | 16 namespace { |
16 | 17 |
17 class TileManagerTest : public testing::TestWithParam<bool> { | 18 class TileManagerTest : public testing::TestWithParam<bool> { |
18 public: | 19 public: |
19 typedef std::vector<scoped_refptr<Tile> > TileVector; | 20 typedef std::vector<scoped_refptr<Tile> > TileVector; |
20 | 21 |
21 void Initialize(int max_tiles, | 22 void Initialize(int max_tiles, |
22 TileMemoryLimitPolicy memory_limit_policy, | 23 TileMemoryLimitPolicy memory_limit_policy, |
23 TreePriority tree_priority) { | 24 TreePriority tree_priority) { |
24 output_surface_ = FakeOutputSurface::Create3d(); | 25 output_surface_ = FakeOutputSurface::Create3d(); |
| 26 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 27 |
25 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); | 28 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 0); |
26 tile_manager_ = make_scoped_ptr( | 29 tile_manager_ = make_scoped_ptr( |
27 new FakeTileManager(&tile_manager_client_, resource_provider_.get())); | 30 new FakeTileManager(&tile_manager_client_, resource_provider_.get())); |
28 | 31 |
29 memory_limit_policy_ = memory_limit_policy; | 32 memory_limit_policy_ = memory_limit_policy; |
30 max_memory_tiles_ = max_tiles; | 33 max_memory_tiles_ = max_tiles; |
31 GlobalStateThatImpactsTilePriority state; | 34 GlobalStateThatImpactsTilePriority state; |
32 gfx::Size tile_size = settings_.default_tile_size; | 35 gfx::Size tile_size = settings_.default_tile_size; |
33 | 36 |
34 // The parametrization specifies whether the max tile limit should | 37 // The parametrization specifies whether the max tile limit should |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 ++has_lcd_count; | 115 ++has_lcd_count; |
113 } | 116 } |
114 return has_lcd_count; | 117 return has_lcd_count; |
115 } | 118 } |
116 | 119 |
117 private: | 120 private: |
118 FakeTileManagerClient tile_manager_client_; | 121 FakeTileManagerClient tile_manager_client_; |
119 LayerTreeSettings settings_; | 122 LayerTreeSettings settings_; |
120 scoped_ptr<FakeTileManager> tile_manager_; | 123 scoped_ptr<FakeTileManager> tile_manager_; |
121 scoped_refptr<FakePicturePileImpl> picture_pile_; | 124 scoped_refptr<FakePicturePileImpl> picture_pile_; |
| 125 FakeOutputSurfaceClient output_surface_client_; |
122 scoped_ptr<FakeOutputSurface> output_surface_; | 126 scoped_ptr<FakeOutputSurface> output_surface_; |
123 scoped_ptr<ResourceProvider> resource_provider_; | 127 scoped_ptr<ResourceProvider> resource_provider_; |
124 TileMemoryLimitPolicy memory_limit_policy_; | 128 TileMemoryLimitPolicy memory_limit_policy_; |
125 int max_memory_tiles_; | 129 int max_memory_tiles_; |
126 }; | 130 }; |
127 | 131 |
128 TEST_P(TileManagerTest, EnoughMemoryAllowAnything) { | 132 TEST_P(TileManagerTest, EnoughMemoryAllowAnything) { |
129 // A few tiles of each type of priority, with enough memory for all tiles. | 133 // A few tiles of each type of priority, with enough memory for all tiles. |
130 | 134 |
131 Initialize(10, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 135 Initialize(10, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 } | 466 } |
463 | 467 |
464 // If true, the max tile limit should be applied as bytes; if false, | 468 // If true, the max tile limit should be applied as bytes; if false, |
465 // as num_resources_limit. | 469 // as num_resources_limit. |
466 INSTANTIATE_TEST_CASE_P(TileManagerTests, | 470 INSTANTIATE_TEST_CASE_P(TileManagerTests, |
467 TileManagerTest, | 471 TileManagerTest, |
468 ::testing::Values(true, false)); | 472 ::testing::Values(true, false)); |
469 | 473 |
470 } // namespace | 474 } // namespace |
471 } // namespace cc | 475 } // namespace cc |
OLD | NEW |