OLD | NEW |
(Empty) | |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "cc/tile_priority.h" |
| 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 |
| 9 namespace cc { |
| 10 |
| 11 TEST(TilePriorityTest, TimeForBoundsToIntersectWithScroll) { |
| 12 gfx::Rect target(0, 0, 800, 600); |
| 13 gfx::Rect current(100, 100, 100, 100); |
| 14 EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect( |
| 15 gfx::Rect(-200, 0, 100, 100), current, 1, target)); |
| 16 EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect( |
| 17 gfx::Rect(-100, 0, 100, 100), current, 1, target)); |
| 18 EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect( |
| 19 gfx::Rect(400, 400, 100, 100), current, 1, target)); |
| 20 |
| 21 current = gfx::Rect(-300, -300, 100, 100); |
| 22 EXPECT_EQ(1000, TilePriority::TimeForBoundsToIntersect( |
| 23 gfx::Rect(0, 0, 100, 100), current, 1, target)); |
| 24 EXPECT_EQ(1000, TilePriority::TimeForBoundsToIntersect( |
| 25 gfx::Rect(-200, -200, 100, 100), current, 1, target)); |
| 26 EXPECT_EQ(2, TilePriority::TimeForBoundsToIntersect( |
| 27 gfx::Rect(-400, -400, 100, 100), current, 1, target)); |
| 28 } |
| 29 |
| 30 TEST(TilePriorityTest, TimeForBoundsToIntersectWithScale) { |
| 31 gfx::Rect target(0, 0, 800, 600); |
| 32 gfx::Rect current(100, 100, 100, 100); |
| 33 EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect( |
| 34 gfx::Rect(-200, 0, 200, 200), current, 1, target)); |
| 35 EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect( |
| 36 gfx::Rect(-100, 0, 50, 50), current, 1, target)); |
| 37 EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect( |
| 38 gfx::Rect(400, 400, 400, 400), current, 1, target)); |
| 39 |
| 40 current = gfx::Rect(-300, -300, 100, 100); |
| 41 EXPECT_EQ(1000, TilePriority::TimeForBoundsToIntersect( |
| 42 gfx::Rect(-400, -400, 300, 300), current, 1, target)); |
| 43 EXPECT_EQ(8, TilePriority::TimeForBoundsToIntersect( |
| 44 gfx::Rect(-275, -275, 50, 50), current, 1, target)); |
| 45 EXPECT_EQ(1, TilePriority::TimeForBoundsToIntersect( |
| 46 gfx::Rect(-450, -450, 50, 50), current, 1, target)); |
| 47 } |
| 48 |
| 49 TEST(TilePriorityTest, ManhattanDistanceBetweenRects) { |
| 50 EXPECT_EQ(0, TilePriority::manhattanDistance( |
| 51 gfx::RectF(0, 0, 400, 400), gfx::RectF(0, 0, 100, 100))); |
| 52 |
| 53 EXPECT_EQ(2, TilePriority::manhattanDistance( |
| 54 gfx::Rect(0, 0, 400, 400), gfx::Rect(-100, -100, 100, 100))); |
| 55 |
| 56 EXPECT_EQ(1, TilePriority::manhattanDistance( |
| 57 gfx::Rect(0, 0, 400, 400), gfx::Rect(0, -100, 100, 100))); |
| 58 |
| 59 EXPECT_EQ(202, TilePriority::manhattanDistance( |
| 60 gfx::Rect(0, 0, 100, 100), gfx::Rect(200, 200, 100, 100))); |
| 61 } |
| 62 |
| 63 } // namespace cc |
OLD | NEW |