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_tile_manager.h" | 8 #include "cc/test/fake_tile_manager.h" |
9 #include "cc/test/fake_tile_manager_client.h" | 9 #include "cc/test/fake_tile_manager_client.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); | 135 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); |
136 TileVector active_pending_soon = CreateTiles( | 136 TileVector active_pending_soon = CreateTiles( |
137 3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); | 137 3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); |
138 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); | 138 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); |
139 | 139 |
140 tile_manager()->ManageTiles(); | 140 tile_manager()->ManageTiles(); |
141 | 141 |
142 EXPECT_EQ(3, AssignedMemoryCounts(active_now)); | 142 EXPECT_EQ(3, AssignedMemoryCounts(active_now)); |
143 EXPECT_EQ(3, AssignedMemoryCounts(pending_now)); | 143 EXPECT_EQ(3, AssignedMemoryCounts(pending_now)); |
144 EXPECT_EQ(3, AssignedMemoryCounts(active_pending_soon)); | 144 EXPECT_EQ(3, AssignedMemoryCounts(active_pending_soon)); |
145 EXPECT_EQ(1, AssignedMemoryCounts(never_bin)); | 145 EXPECT_EQ(0, AssignedMemoryCounts(never_bin)); |
146 | 146 |
147 active_now.clear(); | 147 active_now.clear(); |
148 pending_now.clear(); | 148 pending_now.clear(); |
149 active_pending_soon.clear(); | 149 active_pending_soon.clear(); |
150 never_bin.clear(); | 150 never_bin.clear(); |
151 | 151 |
152 TearDown(); | 152 TearDown(); |
153 } | 153 } |
154 | 154 |
155 TEST_F(TileManagerTest, EnoughMemoryAllowPrepaintOnly) { | 155 TEST_F(TileManagerTest, EnoughMemoryAllowPrepaintOnly) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 tile_manager()->ManageTiles(); | 289 tile_manager()->ManageTiles(); |
290 | 290 |
291 EXPECT_EQ(0, AssignedMemoryCounts(active_tree_tiles)); | 291 EXPECT_EQ(0, AssignedMemoryCounts(active_tree_tiles)); |
292 EXPECT_EQ(4, AssignedMemoryCounts(pending_tree_tiles)); | 292 EXPECT_EQ(4, AssignedMemoryCounts(pending_tree_tiles)); |
293 | 293 |
294 pending_tree_tiles.clear(); | 294 pending_tree_tiles.clear(); |
295 active_tree_tiles.clear(); | 295 active_tree_tiles.clear(); |
296 TearDown(); | 296 TearDown(); |
297 } | 297 } |
298 | 298 |
| 299 TEST_F(TileManagerTest, TotalOOMActiveSoonMemoryToPending) { |
| 300 // 5 tiles on active tree soon bin, 5 tiles on pending tree now bin, |
| 301 // but only enough memory for 4 tiles. The result is 4 pending tree tiles |
| 302 // get memory, and none of the active tree tiles get memory. |
| 303 |
| 304 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 305 TileVector active_tree_tiles = |
| 306 CreateTiles(5, TilePriorityForSoonBin(), TilePriority()); |
| 307 TileVector pending_tree_tiles = |
| 308 CreateTiles(5, TilePriority(), TilePriorityForNowBin()); |
| 309 |
| 310 tile_manager()->ManageTiles(); |
| 311 |
| 312 EXPECT_EQ(0, AssignedMemoryCounts(active_tree_tiles)); |
| 313 EXPECT_EQ(4, AssignedMemoryCounts(pending_tree_tiles)); |
| 314 |
| 315 pending_tree_tiles.clear(); |
| 316 active_tree_tiles.clear(); |
| 317 TearDown(); |
| 318 } |
| 319 |
299 TEST_F(TileManagerTest, TotalOOMMemoryToActive) { | 320 TEST_F(TileManagerTest, TotalOOMMemoryToActive) { |
300 // 5 tiles on active tree eventually bin, 5 tiles on pending tree now bin, | 321 // 5 tiles on active tree eventually bin, 5 tiles on pending tree now bin, |
301 // but only enough memory for 4 tiles. The result is 5 active tree tiles | 322 // but only enough memory for 4 tiles. The result is 5 active tree tiles |
302 // get memory, and none of the pending tree tiles get memory. | 323 // get memory, and none of the pending tree tiles get memory. |
303 | 324 |
304 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 325 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
305 TileVector active_tree_tiles = | 326 TileVector active_tree_tiles = |
306 CreateTiles(5, TilePriorityForNowBin(), TilePriority()); | 327 CreateTiles(5, TilePriorityForNowBin(), TilePriority()); |
307 TileVector pending_tree_tiles = | 328 TileVector pending_tree_tiles = |
308 CreateTiles(5, TilePriority(), TilePriorityForNowBin()); | 329 CreateTiles(5, TilePriority(), TilePriorityForNowBin()); |
309 | 330 |
310 tile_manager()->ManageTiles(); | 331 tile_manager()->ManageTiles(); |
311 | 332 |
312 EXPECT_EQ(4, AssignedMemoryCounts(active_tree_tiles)); | 333 EXPECT_EQ(4, AssignedMemoryCounts(active_tree_tiles)); |
313 EXPECT_EQ(0, AssignedMemoryCounts(pending_tree_tiles)); | 334 EXPECT_EQ(0, AssignedMemoryCounts(pending_tree_tiles)); |
314 | 335 |
315 pending_tree_tiles.clear(); | 336 pending_tree_tiles.clear(); |
316 active_tree_tiles.clear(); | 337 active_tree_tiles.clear(); |
317 TearDown(); | 338 TearDown(); |
318 } | 339 } |
319 | 340 |
320 } // namespace | 341 } // namespace |
321 } // namespace cc | 342 } // namespace cc |
OLD | NEW |