| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 Initialize(10, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 140 Initialize(10, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 141 TileVector active_now = | 141 TileVector active_now = |
| 142 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); | 142 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); |
| 143 TileVector pending_now = | 143 TileVector pending_now = |
| 144 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); | 144 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); |
| 145 TileVector active_pending_soon = CreateTiles( | 145 TileVector active_pending_soon = CreateTiles( |
| 146 3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); | 146 3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); |
| 147 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); | 147 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); |
| 148 | 148 |
| 149 tile_manager()->ManageTiles(); | 149 tile_manager()->AssignMemoryToTiles(); |
| 150 | 150 |
| 151 EXPECT_EQ(3, AssignedMemoryCounts(active_now)); | 151 EXPECT_EQ(3, AssignedMemoryCounts(active_now)); |
| 152 EXPECT_EQ(3, AssignedMemoryCounts(pending_now)); | 152 EXPECT_EQ(3, AssignedMemoryCounts(pending_now)); |
| 153 EXPECT_EQ(3, AssignedMemoryCounts(active_pending_soon)); | 153 EXPECT_EQ(3, AssignedMemoryCounts(active_pending_soon)); |
| 154 EXPECT_EQ(0, AssignedMemoryCounts(never_bin)); | 154 EXPECT_EQ(0, AssignedMemoryCounts(never_bin)); |
| 155 | 155 |
| 156 active_now.clear(); | 156 active_now.clear(); |
| 157 pending_now.clear(); | 157 pending_now.clear(); |
| 158 active_pending_soon.clear(); | 158 active_pending_soon.clear(); |
| 159 never_bin.clear(); | 159 never_bin.clear(); |
| 160 | 160 |
| 161 TearDown(); | 161 TearDown(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 TEST_F(TileManagerTest, EnoughMemoryAllowPrepaintOnly) { | 164 TEST_F(TileManagerTest, EnoughMemoryAllowPrepaintOnly) { |
| 165 // A few tiles of each type of priority, with enough memory for all tiles, | 165 // A few tiles of each type of priority, with enough memory for all tiles, |
| 166 // with the exception of never bin. | 166 // with the exception of never bin. |
| 167 | 167 |
| 168 Initialize(10, ALLOW_PREPAINT_ONLY, SMOOTHNESS_TAKES_PRIORITY); | 168 Initialize(10, ALLOW_PREPAINT_ONLY, SMOOTHNESS_TAKES_PRIORITY); |
| 169 TileVector active_now = | 169 TileVector active_now = |
| 170 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); | 170 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); |
| 171 TileVector pending_now = | 171 TileVector pending_now = |
| 172 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); | 172 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); |
| 173 TileVector active_pending_soon = CreateTiles( | 173 TileVector active_pending_soon = CreateTiles( |
| 174 3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); | 174 3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); |
| 175 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); | 175 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); |
| 176 | 176 |
| 177 tile_manager()->ManageTiles(); | 177 tile_manager()->AssignMemoryToTiles(); |
| 178 | 178 |
| 179 EXPECT_EQ(3, AssignedMemoryCounts(active_now)); | 179 EXPECT_EQ(3, AssignedMemoryCounts(active_now)); |
| 180 EXPECT_EQ(3, AssignedMemoryCounts(pending_now)); | 180 EXPECT_EQ(3, AssignedMemoryCounts(pending_now)); |
| 181 EXPECT_EQ(3, AssignedMemoryCounts(active_pending_soon)); | 181 EXPECT_EQ(3, AssignedMemoryCounts(active_pending_soon)); |
| 182 EXPECT_EQ(0, AssignedMemoryCounts(never_bin)); | 182 EXPECT_EQ(0, AssignedMemoryCounts(never_bin)); |
| 183 | 183 |
| 184 active_now.clear(); | 184 active_now.clear(); |
| 185 pending_now.clear(); | 185 pending_now.clear(); |
| 186 active_pending_soon.clear(); | 186 active_pending_soon.clear(); |
| 187 never_bin.clear(); | 187 never_bin.clear(); |
| 188 TearDown(); | 188 TearDown(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 TEST_F(TileManagerTest, EnoughMemoryAllowAbsoluteMinimum) { | 191 TEST_F(TileManagerTest, EnoughMemoryAllowAbsoluteMinimum) { |
| 192 // A few tiles of each type of priority, with enough memory for all tiles, | 192 // A few tiles of each type of priority, with enough memory for all tiles, |
| 193 // with the exception of never and soon bins. | 193 // with the exception of never and soon bins. |
| 194 | 194 |
| 195 Initialize(10, ALLOW_ABSOLUTE_MINIMUM, SMOOTHNESS_TAKES_PRIORITY); | 195 Initialize(10, ALLOW_ABSOLUTE_MINIMUM, SMOOTHNESS_TAKES_PRIORITY); |
| 196 TileVector active_now = | 196 TileVector active_now = |
| 197 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); | 197 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); |
| 198 TileVector pending_now = | 198 TileVector pending_now = |
| 199 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); | 199 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); |
| 200 TileVector active_pending_soon = CreateTiles( | 200 TileVector active_pending_soon = CreateTiles( |
| 201 3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); | 201 3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); |
| 202 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); | 202 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); |
| 203 | 203 |
| 204 tile_manager()->ManageTiles(); | 204 tile_manager()->AssignMemoryToTiles(); |
| 205 | 205 |
| 206 EXPECT_EQ(3, AssignedMemoryCounts(active_now)); | 206 EXPECT_EQ(3, AssignedMemoryCounts(active_now)); |
| 207 EXPECT_EQ(3, AssignedMemoryCounts(pending_now)); | 207 EXPECT_EQ(3, AssignedMemoryCounts(pending_now)); |
| 208 EXPECT_EQ(0, AssignedMemoryCounts(active_pending_soon)); | 208 EXPECT_EQ(0, AssignedMemoryCounts(active_pending_soon)); |
| 209 EXPECT_EQ(0, AssignedMemoryCounts(never_bin)); | 209 EXPECT_EQ(0, AssignedMemoryCounts(never_bin)); |
| 210 | 210 |
| 211 active_now.clear(); | 211 active_now.clear(); |
| 212 pending_now.clear(); | 212 pending_now.clear(); |
| 213 active_pending_soon.clear(); | 213 active_pending_soon.clear(); |
| 214 never_bin.clear(); | 214 never_bin.clear(); |
| 215 TearDown(); | 215 TearDown(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 TEST_F(TileManagerTest, EnoughMemoryAllowNothing) { | 218 TEST_F(TileManagerTest, EnoughMemoryAllowNothing) { |
| 219 // A few tiles of each type of priority, with enough memory for all tiles, | 219 // A few tiles of each type of priority, with enough memory for all tiles, |
| 220 // but allow nothing should not assign any memory. | 220 // but allow nothing should not assign any memory. |
| 221 | 221 |
| 222 Initialize(10, ALLOW_NOTHING, SMOOTHNESS_TAKES_PRIORITY); | 222 Initialize(10, ALLOW_NOTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 223 TileVector active_now = | 223 TileVector active_now = |
| 224 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); | 224 CreateTiles(3, TilePriorityForNowBin(), TilePriority()); |
| 225 TileVector pending_now = | 225 TileVector pending_now = |
| 226 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); | 226 CreateTiles(3, TilePriority(), TilePriorityForNowBin()); |
| 227 TileVector active_pending_soon = CreateTiles( | 227 TileVector active_pending_soon = CreateTiles( |
| 228 3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); | 228 3, TilePriorityForSoonBin(), TilePriorityForSoonBin()); |
| 229 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); | 229 TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority()); |
| 230 | 230 |
| 231 tile_manager()->ManageTiles(); | 231 tile_manager()->AssignMemoryToTiles(); |
| 232 | 232 |
| 233 EXPECT_EQ(0, AssignedMemoryCounts(active_now)); | 233 EXPECT_EQ(0, AssignedMemoryCounts(active_now)); |
| 234 EXPECT_EQ(0, AssignedMemoryCounts(pending_now)); | 234 EXPECT_EQ(0, AssignedMemoryCounts(pending_now)); |
| 235 EXPECT_EQ(0, AssignedMemoryCounts(active_pending_soon)); | 235 EXPECT_EQ(0, AssignedMemoryCounts(active_pending_soon)); |
| 236 EXPECT_EQ(0, AssignedMemoryCounts(never_bin)); | 236 EXPECT_EQ(0, AssignedMemoryCounts(never_bin)); |
| 237 | 237 |
| 238 active_now.clear(); | 238 active_now.clear(); |
| 239 pending_now.clear(); | 239 pending_now.clear(); |
| 240 active_pending_soon.clear(); | 240 active_pending_soon.clear(); |
| 241 never_bin.clear(); | 241 never_bin.clear(); |
| 242 TearDown(); | 242 TearDown(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 TEST_F(TileManagerTest, DISABLED_PartialOOMMemoryToPending) { | 245 TEST_F(TileManagerTest, DISABLED_PartialOOMMemoryToPending) { |
| 246 // 5 tiles on active tree eventually bin, 5 tiles on pending tree that are | 246 // 5 tiles on active tree eventually bin, 5 tiles on pending tree that are |
| 247 // required for activation, but only enough memory for 8 tiles. The result | 247 // required for activation, but only enough memory for 8 tiles. The result |
| 248 // is all pending tree tiles get memory, and 3 of the active tree tiles | 248 // is all pending tree tiles get memory, and 3 of the active tree tiles |
| 249 // get memory. | 249 // get memory. |
| 250 | 250 |
| 251 Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 251 Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 252 TileVector active_tree_tiles = | 252 TileVector active_tree_tiles = |
| 253 CreateTiles(5, TilePriorityForEventualBin(), TilePriority()); | 253 CreateTiles(5, TilePriorityForEventualBin(), TilePriority()); |
| 254 TileVector pending_tree_tiles = | 254 TileVector pending_tree_tiles = |
| 255 CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation()); | 255 CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation()); |
| 256 | 256 |
| 257 tile_manager()->ManageTiles(); | 257 tile_manager()->AssignMemoryToTiles(); |
| 258 | 258 |
| 259 EXPECT_EQ(3, AssignedMemoryCounts(active_tree_tiles)); | 259 EXPECT_EQ(3, AssignedMemoryCounts(active_tree_tiles)); |
| 260 EXPECT_EQ(5, AssignedMemoryCounts(pending_tree_tiles)); | 260 EXPECT_EQ(5, AssignedMemoryCounts(pending_tree_tiles)); |
| 261 | 261 |
| 262 pending_tree_tiles.clear(); | 262 pending_tree_tiles.clear(); |
| 263 active_tree_tiles.clear(); | 263 active_tree_tiles.clear(); |
| 264 TearDown(); | 264 TearDown(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 TEST_F(TileManagerTest, PartialOOMMemoryToActive) { | 267 TEST_F(TileManagerTest, PartialOOMMemoryToActive) { |
| 268 // 5 tiles on active tree eventually bin, 5 tiles on pending tree now bin, | 268 // 5 tiles on active tree eventually bin, 5 tiles on pending tree now bin, |
| 269 // but only enough memory for 8 tiles. The result is all active tree tiles | 269 // but only enough memory for 8 tiles. The result is all active tree tiles |
| 270 // get memory, and 3 of the pending tree tiles get memory. | 270 // get memory, and 3 of the pending tree tiles get memory. |
| 271 | 271 |
| 272 Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 272 Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 273 TileVector active_tree_tiles = | 273 TileVector active_tree_tiles = |
| 274 CreateTiles(5, TilePriorityForNowBin(), TilePriority()); | 274 CreateTiles(5, TilePriorityForNowBin(), TilePriority()); |
| 275 TileVector pending_tree_tiles = | 275 TileVector pending_tree_tiles = |
| 276 CreateTiles(5, TilePriority(), TilePriorityForNowBin()); | 276 CreateTiles(5, TilePriority(), TilePriorityForNowBin()); |
| 277 | 277 |
| 278 tile_manager()->ManageTiles(); | 278 tile_manager()->AssignMemoryToTiles(); |
| 279 | 279 |
| 280 EXPECT_EQ(5, AssignedMemoryCounts(active_tree_tiles)); | 280 EXPECT_EQ(5, AssignedMemoryCounts(active_tree_tiles)); |
| 281 EXPECT_EQ(3, AssignedMemoryCounts(pending_tree_tiles)); | 281 EXPECT_EQ(3, AssignedMemoryCounts(pending_tree_tiles)); |
| 282 | 282 |
| 283 pending_tree_tiles.clear(); | 283 pending_tree_tiles.clear(); |
| 284 active_tree_tiles.clear(); | 284 active_tree_tiles.clear(); |
| 285 TearDown(); | 285 TearDown(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 TEST_F(TileManagerTest, DISABLED_TotalOOMMemoryToPending) { | 288 TEST_F(TileManagerTest, DISABLED_TotalOOMMemoryToPending) { |
| 289 // 5 tiles on active tree eventually bin, 5 tiles on pending tree that are | 289 // 5 tiles on active tree eventually bin, 5 tiles on pending tree that are |
| 290 // required for activation, but only enough memory for 4 tiles. The result | 290 // required for activation, but only enough memory for 4 tiles. The result |
| 291 // is 4 pending tree tiles get memory, and none of the active tree tiles | 291 // is 4 pending tree tiles get memory, and none of the active tree tiles |
| 292 // get memory. | 292 // get memory. |
| 293 | 293 |
| 294 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 294 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 295 TileVector active_tree_tiles = | 295 TileVector active_tree_tiles = |
| 296 CreateTiles(5, TilePriorityForEventualBin(), TilePriority()); | 296 CreateTiles(5, TilePriorityForEventualBin(), TilePriority()); |
| 297 TileVector pending_tree_tiles = | 297 TileVector pending_tree_tiles = |
| 298 CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation()); | 298 CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation()); |
| 299 | 299 |
| 300 tile_manager()->ManageTiles(); | 300 tile_manager()->AssignMemoryToTiles(); |
| 301 | 301 |
| 302 EXPECT_EQ(0, AssignedMemoryCounts(active_tree_tiles)); | 302 EXPECT_EQ(0, AssignedMemoryCounts(active_tree_tiles)); |
| 303 EXPECT_EQ(4, AssignedMemoryCounts(pending_tree_tiles)); | 303 EXPECT_EQ(4, AssignedMemoryCounts(pending_tree_tiles)); |
| 304 | 304 |
| 305 pending_tree_tiles.clear(); | 305 pending_tree_tiles.clear(); |
| 306 active_tree_tiles.clear(); | 306 active_tree_tiles.clear(); |
| 307 TearDown(); | 307 TearDown(); |
| 308 } | 308 } |
| 309 | 309 |
| 310 TEST_F(TileManagerTest, DISABLED_TotalOOMActiveSoonMemoryToPending) { | 310 TEST_F(TileManagerTest, DISABLED_TotalOOMActiveSoonMemoryToPending) { |
| 311 // 5 tiles on active tree soon bin, 5 tiles on pending tree that are | 311 // 5 tiles on active tree soon bin, 5 tiles on pending tree that are |
| 312 // required for activation, but only enough memory for 4 tiles. The result | 312 // required for activation, but only enough memory for 4 tiles. The result |
| 313 // is 4 pending tree tiles get memory, and none of the active tree tiles | 313 // is 4 pending tree tiles get memory, and none of the active tree tiles |
| 314 // get memory. | 314 // get memory. |
| 315 | 315 |
| 316 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 316 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 317 TileVector active_tree_tiles = | 317 TileVector active_tree_tiles = |
| 318 CreateTiles(5, TilePriorityForSoonBin(), TilePriority()); | 318 CreateTiles(5, TilePriorityForSoonBin(), TilePriority()); |
| 319 TileVector pending_tree_tiles = | 319 TileVector pending_tree_tiles = |
| 320 CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation()); | 320 CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation()); |
| 321 | 321 |
| 322 tile_manager()->ManageTiles(); | 322 tile_manager()->AssignMemoryToTiles(); |
| 323 | 323 |
| 324 EXPECT_EQ(0, AssignedMemoryCounts(active_tree_tiles)); | 324 EXPECT_EQ(0, AssignedMemoryCounts(active_tree_tiles)); |
| 325 EXPECT_EQ(4, AssignedMemoryCounts(pending_tree_tiles)); | 325 EXPECT_EQ(4, AssignedMemoryCounts(pending_tree_tiles)); |
| 326 | 326 |
| 327 pending_tree_tiles.clear(); | 327 pending_tree_tiles.clear(); |
| 328 active_tree_tiles.clear(); | 328 active_tree_tiles.clear(); |
| 329 TearDown(); | 329 TearDown(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 TEST_F(TileManagerTest, TotalOOMMemoryToActive) { | 332 TEST_F(TileManagerTest, TotalOOMMemoryToActive) { |
| 333 // 5 tiles on active tree eventually bin, 5 tiles on pending tree now bin, | 333 // 5 tiles on active tree eventually bin, 5 tiles on pending tree now bin, |
| 334 // but only enough memory for 4 tiles. The result is 5 active tree tiles | 334 // but only enough memory for 4 tiles. The result is 5 active tree tiles |
| 335 // get memory, and none of the pending tree tiles get memory. | 335 // get memory, and none of the pending tree tiles get memory. |
| 336 | 336 |
| 337 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); | 337 Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
| 338 TileVector active_tree_tiles = | 338 TileVector active_tree_tiles = |
| 339 CreateTiles(5, TilePriorityForNowBin(), TilePriority()); | 339 CreateTiles(5, TilePriorityForNowBin(), TilePriority()); |
| 340 TileVector pending_tree_tiles = | 340 TileVector pending_tree_tiles = |
| 341 CreateTiles(5, TilePriority(), TilePriorityForNowBin()); | 341 CreateTiles(5, TilePriority(), TilePriorityForNowBin()); |
| 342 | 342 |
| 343 tile_manager()->ManageTiles(); | 343 tile_manager()->AssignMemoryToTiles(); |
| 344 | 344 |
| 345 EXPECT_EQ(4, AssignedMemoryCounts(active_tree_tiles)); | 345 EXPECT_EQ(4, AssignedMemoryCounts(active_tree_tiles)); |
| 346 EXPECT_EQ(0, AssignedMemoryCounts(pending_tree_tiles)); | 346 EXPECT_EQ(0, AssignedMemoryCounts(pending_tree_tiles)); |
| 347 | 347 |
| 348 pending_tree_tiles.clear(); | 348 pending_tree_tiles.clear(); |
| 349 active_tree_tiles.clear(); | 349 active_tree_tiles.clear(); |
| 350 TearDown(); | 350 TearDown(); |
| 351 } | 351 } |
| 352 | 352 |
| 353 } // namespace | 353 } // namespace |
| 354 } // namespace cc | 354 } // namespace cc |
| OLD | NEW |