Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3917)

Unified Diff: cc/tile_priority_unittest.cc

Issue 11414238: implement the logic to set tile priorities based on current matrix (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing comments Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« cc/tile_priority.cc ('K') | « cc/tile_priority.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f1576cdff0d8e09228bbc90f5411e3379f920e93
--- /dev/null
+++ b/cc/tile_priority_unittest.cc
@@ -0,0 +1,63 @@
+// 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 {
+
+TEST(TilePriorityTest, TimeForBoundsToIntersectWithScroll) {
+ gfx::Rect target(0, 0, 800, 600);
+ gfx::Rect current(100, 100, 100, 100);
+ EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect(
+ gfx::Rect(-200, 0, 100, 100), current, 1, target));
+ EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect(
+ gfx::Rect(-100, 0, 100, 100), current, 1, target));
+ EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect(
+ gfx::Rect(400, 400, 100, 100), current, 1, target));
+
+ current = gfx::Rect(-300, -300, 100, 100);
+ EXPECT_EQ(1000, TilePriority::TimeForBoundsToIntersect(
+ gfx::Rect(0, 0, 100, 100), current, 1, target));
+ EXPECT_EQ(1000, TilePriority::TimeForBoundsToIntersect(
+ gfx::Rect(-200, -200, 100, 100), current, 1, target));
+ EXPECT_EQ(2, TilePriority::TimeForBoundsToIntersect(
+ gfx::Rect(-400, -400, 100, 100), current, 1, target));
+}
+
+TEST(TilePriorityTest, TimeForBoundsToIntersectWithScale) {
+ gfx::Rect target(0, 0, 800, 600);
+ gfx::Rect current(100, 100, 100, 100);
+ EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect(
+ gfx::Rect(-200, 0, 200, 200), current, 1, target));
+ EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect(
+ gfx::Rect(-100, 0, 50, 50), current, 1, target));
+ EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect(
+ gfx::Rect(400, 400, 400, 400), current, 1, target));
+
+ current = gfx::Rect(-300, -300, 100, 100);
+ EXPECT_EQ(1000, TilePriority::TimeForBoundsToIntersect(
+ gfx::Rect(-400, -400, 300, 300), current, 1, target));
+ EXPECT_EQ(8, TilePriority::TimeForBoundsToIntersect(
+ gfx::Rect(-275, -275, 50, 50), current, 1, target));
+ EXPECT_EQ(1, TilePriority::TimeForBoundsToIntersect(
+ gfx::Rect(-450, -450, 50, 50), current, 1, target));
+}
+
+TEST(TilePriorityTest, ManhattanDistanceBetweenRects) {
+ EXPECT_EQ(0, TilePriority::manhattanDistance(
+ gfx::RectF(0, 0, 400, 400), gfx::RectF(0, 0, 100, 100)));
+
+ EXPECT_EQ(2, TilePriority::manhattanDistance(
+ gfx::Rect(0, 0, 400, 400), gfx::Rect(-100, -100, 100, 100)));
+
+ EXPECT_EQ(1, TilePriority::manhattanDistance(
+ gfx::Rect(0, 0, 400, 400), gfx::Rect(0, -100, 100, 100)));
+
+ EXPECT_EQ(202, TilePriority::manhattanDistance(
+ gfx::Rect(0, 0, 100, 100), gfx::Rect(200, 200, 100, 100)));
+}
+
+} // namespace cc
« cc/tile_priority.cc ('K') | « cc/tile_priority.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698