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/resources/tile_priority.h" 6 7 #include "testing/gtest/include/gtest/gtest.h" 8 9 namespace cc { 10 namespace { 11 12 TEST(TilePriorityTest, TimeForBoundsToIntersectWithScroll) { 13 const float inf = std::numeric_limits<float>::infinity(); 14 gfx::Rect target(0, 0, 800, 600); 15 gfx::Rect current(100, 100, 100, 100); 16 EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect( 17 gfx::Rect(-200, 0, 100, 100), current, 1, target)); 18 EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect( 19 gfx::Rect(-100, 0, 100, 100), current, 1, target)); 20 EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect( 21 gfx::Rect(400, 400, 100, 100), current, 1, target)); 22 23 current = gfx::Rect(-300, -300, 100, 100); 24 EXPECT_EQ(inf, TilePriority::TimeForBoundsToIntersect( 25 gfx::Rect(0, 0, 100, 100), current, 1, target)); 26 EXPECT_EQ(inf, TilePriority::TimeForBoundsToIntersect( 27 gfx::Rect(-200, -200, 100, 100), current, 1, target)); 28 EXPECT_EQ(2, TilePriority::TimeForBoundsToIntersect( 29 gfx::Rect(-400, -400, 100, 100), current, 1, target)); 30 } 31 32 TEST(TilePriorityTest, TimeForBoundsToIntersectWithScale) { 33 const float inf = std::numeric_limits<float>::infinity(); 34 gfx::Rect target(0, 0, 800, 600); 35 gfx::Rect current(100, 100, 100, 100); 36 EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect( 37 gfx::Rect(-200, 0, 200, 200), current, 1, target)); 38 EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect( 39 gfx::Rect(-100, 0, 50, 50), current, 1, target)); 40 EXPECT_EQ(0, TilePriority::TimeForBoundsToIntersect( 41 gfx::Rect(400, 400, 400, 400), current, 1, target)); 42 43 current = gfx::Rect(-300, -300, 100, 100); 44 EXPECT_EQ(inf, TilePriority::TimeForBoundsToIntersect( 45 gfx::Rect(-400, -400, 300, 300), current, 1, target)); 46 EXPECT_EQ(8, TilePriority::TimeForBoundsToIntersect( 47 gfx::Rect(-275, -275, 50, 50), current, 1, target)); 48 EXPECT_EQ(1, TilePriority::TimeForBoundsToIntersect( 49 gfx::Rect(-450, -450, 50, 50), current, 1, target)); 50 } 51 52 } // namespace 53 } // namespace cc 54