Chromium Code Reviews| Index: cc/resources/picture_layer_tiling_unittest.cc |
| diff --git a/cc/resources/picture_layer_tiling_unittest.cc b/cc/resources/picture_layer_tiling_unittest.cc |
| index 91043e67b48006e13d72f42781c97fd55828fcdb..9e5091499fb055e8880d16fec694c09beb89cac2 100644 |
| --- a/cc/resources/picture_layer_tiling_unittest.cc |
| +++ b/cc/resources/picture_layer_tiling_unittest.cc |
| @@ -5,6 +5,7 @@ |
| #include "cc/resources/picture_layer_tiling.h" |
| #include "cc/test/fake_picture_layer_tiling_client.h" |
| +#include "cc/test/geometry_test_utils.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "ui/gfx/rect_conversions.h" |
| #include "ui/gfx/size_conversions.h" |
| @@ -180,7 +181,7 @@ TEST(PictureLayerTilingTest, ExpandRectEqual) { |
| int64 target_area = 100 * 200; |
| gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
| in, target_area, bounds); |
| - EXPECT_EQ(in.ToString(), out.ToString()); |
| + EXPECT_RECT_EQ(in, out); |
| } |
| TEST(PictureLayerTilingTest, ExpandRectSmaller) { |
| @@ -215,7 +216,7 @@ TEST(PictureLayerTilingTest, ExpandRectBoundedSmaller) { |
| int64 target_area = 200 * 200; |
| gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
| in, target_area, bounds); |
| - EXPECT_EQ(bounds.ToString(), out.ToString()); |
| + EXPECT_RECT_EQ(bounds, out); |
| } |
| TEST(PictureLayerTilingTest, ExpandRectBoundedEqual) { |
| @@ -224,7 +225,7 @@ TEST(PictureLayerTilingTest, ExpandRectBoundedEqual) { |
| int64 target_area = 200 * 200; |
| gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
| in, target_area, bounds); |
| - EXPECT_EQ(bounds.ToString(), out.ToString()); |
| + EXPECT_RECT_EQ(bounds, out); |
| } |
| TEST(PictureLayerTilingTest, ExpandRectBoundedSmallerStretchVertical) { |
| @@ -233,7 +234,7 @@ TEST(PictureLayerTilingTest, ExpandRectBoundedSmallerStretchVertical) { |
| int64 target_area = 200 * 200; |
| gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
| in, target_area, bounds); |
| - EXPECT_EQ(bounds.ToString(), out.ToString()); |
| + EXPECT_RECT_EQ(bounds, out); |
| } |
| TEST(PictureLayerTilingTest, ExpandRectBoundedEqualStretchVertical) { |
| @@ -242,7 +243,7 @@ TEST(PictureLayerTilingTest, ExpandRectBoundedEqualStretchVertical) { |
| int64 target_area = 200 * 200; |
| gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
| in, target_area, bounds); |
| - EXPECT_EQ(bounds.ToString(), out.ToString()); |
| + EXPECT_RECT_EQ(bounds, out); |
| } |
| TEST(PictureLayerTilingTest, ExpandRectBoundedSmallerStretchHorizontal) { |
| @@ -251,7 +252,7 @@ TEST(PictureLayerTilingTest, ExpandRectBoundedSmallerStretchHorizontal) { |
| int64 target_area = 200 * 200; |
| gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
| in, target_area, bounds); |
| - EXPECT_EQ(bounds.ToString(), out.ToString()); |
| + EXPECT_RECT_EQ(bounds, out); |
| } |
| TEST(PictureLayerTilingTest, ExpandRectBoundedEqualStretchHorizontal) { |
| @@ -260,7 +261,7 @@ TEST(PictureLayerTilingTest, ExpandRectBoundedEqualStretchHorizontal) { |
| int64 target_area = 200 * 200; |
| gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
| in, target_area, bounds); |
| - EXPECT_EQ(bounds.ToString(), out.ToString()); |
| + EXPECT_RECT_EQ(bounds, out); |
| } |
| TEST(PictureLayerTilingTest, ExpandRectBoundedLeft) { |
| @@ -349,8 +350,8 @@ TEST(PictureLayerTilingTest, ExpandRectSquishedVertically) { |
| EXPECT_TRUE(bounds.Contains(out)); |
| } |
| -TEST(PictureLayerTilingTest, ExpandRectOutOfBounds) { |
| - gfx::Rect in(40, 50, 100, 200); |
| +TEST(PictureLayerTilingTest, ExpandRectOutOfBoundsFarAway) { |
| + gfx::Rect in(400, 500, 100, 200); |
| gfx::Rect bounds(0, 0, 10, 10); |
| int64 target_area = 400 * 400; |
| gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
| @@ -358,5 +359,26 @@ TEST(PictureLayerTilingTest, ExpandRectOutOfBounds) { |
| EXPECT_TRUE(out.IsEmpty()); |
| } |
| +TEST(PictureLayerTilingTest, ExpandRectOutOfBoundsExpandedFullyCover) { |
| + gfx::Rect in(40, 50, 100, 100); |
| + gfx::Rect bounds(0, 0, 10, 10); |
| + int64 target_area = 400 * 400; |
| + gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
| + in, target_area, bounds); |
| + EXPECT_RECT_EQ(bounds, out); |
| +} |
| + |
| +TEST(PictureLayerTilingTest, ExpandRectOutOfBoundsExpandedPartlyCover) { |
| + gfx::Rect in(600, 600, 100, 100); |
| + gfx::Rect bounds(0, 0, 500, 500); |
| + int64 target_area = 400 * 400; |
| + gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
| + in, target_area, bounds); |
| + EXPECT_EQ(bounds.right(), out.right()); |
| + EXPECT_EQ(bounds.bottom(), out.bottom()); |
| + EXPECT_LE(out.width() * out.height(), target_area); |
|
danakj
2013/04/10 16:46:24
can you give a lower bound on the out rect's area
Xianzhu
2013/04/10 17:08:37
Done.
|
| + EXPECT_TRUE(bounds.Contains(out)); |
| +} |
| + |
| } // namespace |
| } // namespace cc |