Index: cc/tile_priority_unittest.cc |
diff --git a/cc/tile_priority_unittest.cc b/cc/tile_priority_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ce1383f9ca11a10352e4e9cbdfa127db5ccc2ef6 |
--- /dev/null |
+++ b/cc/tile_priority_unittest.cc |
@@ -0,0 +1,62 @@ |
+// Copyright 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "cc/tile_priority.h" |
+ |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace cc { |
+ |
+class TilePriorityTest : public testing::Test { |
+ public: |
+ TilePriorityTest() {} |
+ |
+ void VerifyTimeForBoundsToIntersect(gfx::Rect previous, |
+ gfx::Rect current, |
+ gfx::Rect target, |
+ double time) { |
+ EXPECT_EQ(time, TilePriority::TimeForBoundsToIntersect( |
+ previous, current, 1, target)); |
+ } |
+}; |
+ |
+TEST_F(TilePriorityTest, 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(TilePriorityTest, 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 |