Index: cc/resources/tile_manager_unittest.cc |
diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc |
index 80b2bbcbb1755cd4d9d821b86cda33c67de4f43a..1edbde08f23aabbff2476f7259b50854d80b5149 100644 |
--- a/cc/resources/tile_manager_unittest.cc |
+++ b/cc/resources/tile_manager_unittest.cc |
@@ -49,6 +49,16 @@ class TilePriorityForNowBin : public TilePriority { |
0) {} |
}; |
+class TilePriorityRequiredForActivation : public TilePriority { |
+ public: |
+ TilePriorityRequiredForActivation() : TilePriority( |
+ HIGH_RESOLUTION, |
+ 0, |
+ 0) { |
+ required_for_activation = true; |
+ } |
+}; |
+ |
class TileManagerTest : public testing::Test { |
public: |
typedef std::vector<scoped_refptr<Tile> > TileVector; |
@@ -109,9 +119,8 @@ class TileManagerTest : public testing::Test { |
for (TileVector::const_iterator it = tiles.begin(); |
it != tiles.end(); |
++it) { |
- if ((*it)->HasRasterTaskForTesting()) |
+ if (tile_manager_->HasBeenAssignedMemory(*it)) |
++has_memory_count; |
- (*it)->ResetRasterTaskForTesting(); |
} |
return has_memory_count; |
} |
@@ -234,18 +243,24 @@ TEST_F(TileManagerTest, EnoughMemoryAllowNothing) { |
} |
TEST_F(TileManagerTest, PartialOOMMemoryToPending) { |
- // 5 tiles on active tree eventually bin, 5 tiles on pending tree now bin, |
- // but only enough memory for 8 tiles. The result is all pending tree tiles |
- // get memory, and 3 of the active tree tiles get memory. |
+ // 5 tiles on active tree eventually bin, 5 tiles on pending tree that are |
+ // required for activation, but only enough memory for 8 tiles. The result |
+ // is all pending tree tiles get memory, and 3 of the active tree tiles |
+ // get memory. |
Initialize(8, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
TileVector active_tree_tiles = |
CreateTiles(5, TilePriorityForEventualBin(), TilePriority()); |
TileVector pending_tree_tiles = |
- CreateTiles(5, TilePriority(), TilePriorityForNowBin()); |
+ CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation()); |
tile_manager()->ManageTiles(); |
+ EXPECT_EQ(5, AssignedMemoryCounts(active_tree_tiles)); |
+ EXPECT_EQ(3, AssignedMemoryCounts(pending_tree_tiles)); |
+ |
+ tile_manager()->ReassignMemoryToOOMTilesRequiredForActivation(); |
+ |
EXPECT_EQ(3, AssignedMemoryCounts(active_tree_tiles)); |
EXPECT_EQ(5, AssignedMemoryCounts(pending_tree_tiles)); |
@@ -276,18 +291,24 @@ TEST_F(TileManagerTest, PartialOOMMemoryToActive) { |
} |
TEST_F(TileManagerTest, TotalOOMMemoryToPending) { |
- // 5 tiles on active tree eventually bin, 5 tiles on pending tree now bin, |
- // but only enough memory for 4 tiles. The result is 4 pending tree tiles |
- // get memory, and none of the active tree tiles get memory. |
+ // 5 tiles on active tree eventually bin, 5 tiles on pending tree that are |
+ // required for activation, but only enough memory for 4 tiles. The result |
+ // is 4 pending tree tiles get memory, and none of the active tree tiles |
+ // get memory. |
Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
TileVector active_tree_tiles = |
CreateTiles(5, TilePriorityForEventualBin(), TilePriority()); |
TileVector pending_tree_tiles = |
- CreateTiles(5, TilePriority(), TilePriorityForNowBin()); |
+ CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation()); |
tile_manager()->ManageTiles(); |
+ EXPECT_EQ(4, AssignedMemoryCounts(active_tree_tiles)); |
+ EXPECT_EQ(0, AssignedMemoryCounts(pending_tree_tiles)); |
+ |
+ tile_manager()->ReassignMemoryToOOMTilesRequiredForActivation(); |
+ |
EXPECT_EQ(0, AssignedMemoryCounts(active_tree_tiles)); |
EXPECT_EQ(4, AssignedMemoryCounts(pending_tree_tiles)); |
@@ -297,18 +318,24 @@ TEST_F(TileManagerTest, TotalOOMMemoryToPending) { |
} |
TEST_F(TileManagerTest, TotalOOMActiveSoonMemoryToPending) { |
- // 5 tiles on active tree soon bin, 5 tiles on pending tree now bin, |
- // but only enough memory for 4 tiles. The result is 4 pending tree tiles |
- // get memory, and none of the active tree tiles get memory. |
+ // 5 tiles on active tree soon bin, 5 tiles on pending tree that are |
+ // required for activation, but only enough memory for 4 tiles. The result |
+ // is 4 pending tree tiles get memory, and none of the active tree tiles |
+ // get memory. |
Initialize(4, ALLOW_ANYTHING, SMOOTHNESS_TAKES_PRIORITY); |
TileVector active_tree_tiles = |
CreateTiles(5, TilePriorityForSoonBin(), TilePriority()); |
TileVector pending_tree_tiles = |
- CreateTiles(5, TilePriority(), TilePriorityForNowBin()); |
+ CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation()); |
tile_manager()->ManageTiles(); |
+ EXPECT_EQ(4, AssignedMemoryCounts(active_tree_tiles)); |
+ EXPECT_EQ(0, AssignedMemoryCounts(pending_tree_tiles)); |
+ |
+ tile_manager()->ReassignMemoryToOOMTilesRequiredForActivation(); |
+ |
EXPECT_EQ(0, AssignedMemoryCounts(active_tree_tiles)); |
EXPECT_EQ(4, AssignedMemoryCounts(pending_tree_tiles)); |