Index: cc/picture_layer_tiling_unittest.cc |
diff --git a/cc/picture_layer_tiling_unittest.cc b/cc/picture_layer_tiling_unittest.cc |
index 03bd9aadb19d29f4e3b66b937cebed9e34fbda57..2e45af960348eba6d1c662b34999c534ec89bf42 100644 |
--- a/cc/picture_layer_tiling_unittest.cc |
+++ b/cc/picture_layer_tiling_unittest.cc |
@@ -64,6 +64,23 @@ class PictureLayerTilingIteratorTest : public testing::Test { |
DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); |
}; |
+class PictureLayerTilingTest : public testing::Test { |
+ public: |
+ PictureLayerTilingTest() { |
+ tiling_ = PictureLayerTiling::Create(0, gfx::Size(0, 0)); |
+ } |
+ |
+ void VerifyTimeForBoundsToIntersect(gfx::Rect previous, |
+ gfx::Rect current, |
+ gfx::Rect target, |
+ double time) { |
+ EXPECT_EQ(tiling_->TimeForBoundsToIntersect(previous, current, 1, target), |
+ time); |
+ } |
+ protected: |
+ scoped_ptr<PictureLayerTiling> tiling_; |
+}; |
+ |
TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsNoScale) { |
Initialize(gfx::Size(100, 100), 1, gfx::Size(1099, 801)); |
VerifyTilesExactlyCoverRect(1, gfx::Rect()); |
@@ -118,4 +135,42 @@ TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsBothScale) { |
VerifyTilesExactlyCoverRect(scale, gfx::Rect(2014, 1579, 867, 1033)); |
} |
+TEST_F(PictureLayerTilingTest, TimeForBoundsToIntersectWithScroll) { |
+ gfx::Rect target(0, 0, 800, 600); |
+ gfx::Rect current(100, 100, 100, 100); |
+ VerifyTimeForBoundsToIntersect( |
+ gfx::Rect(-200, 0, 100, 100), current, target, 0); |
+ VerifyTimeForBoundsToIntersect( |
+ gfx::Rect(-100, 0, 100, 100), current, target, 0); |
+ VerifyTimeForBoundsToIntersect( |
+ gfx::Rect(400, 400, 100, 100), current, target, 0); |
+ |
+ current = gfx::Rect(-300, -300, 100, 100); |
+ VerifyTimeForBoundsToIntersect( |
+ gfx::Rect(0, 0, 100, 100), current, target, 1000); |
+ VerifyTimeForBoundsToIntersect( |
+ gfx::Rect(-200, -200, 100, 100), current, target, 1000); |
+ VerifyTimeForBoundsToIntersect( |
+ gfx::Rect(-400, -400, 100, 100), current, target, 2); |
+} |
+ |
+TEST_F(PictureLayerTilingTest, TimeForBoundsToIntersectWithScale) { |
+ gfx::Rect target(0, 0, 800, 600); |
+ gfx::Rect current(100, 100, 100, 100); |
+ VerifyTimeForBoundsToIntersect( |
+ gfx::Rect(-200, 0, 200, 200), current, target, 0); |
+ VerifyTimeForBoundsToIntersect( |
+ gfx::Rect(-100, 0, 50, 50), current, target, 0); |
+ VerifyTimeForBoundsToIntersect( |
+ gfx::Rect(400, 400, 400, 400), current, target, 0); |
+ |
+ current = gfx::Rect(-300, -300, 100, 100); |
+ VerifyTimeForBoundsToIntersect( |
+ gfx::Rect(-400, -400, 300, 300), current, target, 1000); |
+ VerifyTimeForBoundsToIntersect( |
+ gfx::Rect(-275, -275, 50, 50), current, target, 8); |
+ VerifyTimeForBoundsToIntersect( |
+ gfx::Rect(-450, -450, 50, 50), current, target, 1); |
+} |
+ |
} // namespace cc |