OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 #include "ui/gfx/rect.h" | 7 #include "ui/gfx/rect.h" |
8 #include "ui/gfx/rect_conversions.h" | 8 #include "ui/gfx/rect_conversions.h" |
9 #include "ui/gfx/skia_util.h" | 9 #include "ui/gfx/skia_util.h" |
10 | 10 |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 { gfx::PointF(-4.2f, 6.8f), gfx::PointF(6.8f, -4.2f), | 664 { gfx::PointF(-4.2f, 6.8f), gfx::PointF(6.8f, -4.2f), |
665 gfx::RectF(-4.2f, -4.2f, 11.0f, 11.0f) } | 665 gfx::RectF(-4.2f, -4.2f, 11.0f, 11.0f) } |
666 }; | 666 }; |
667 | 667 |
668 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(float_tests); ++i) { | 668 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(float_tests); ++i) { |
669 gfx::RectF actual = BoundingRect(float_tests[i].a, float_tests[i].b); | 669 gfx::RectF actual = BoundingRect(float_tests[i].a, float_tests[i].b); |
670 EXPECT_EQ(float_tests[i].expected.ToString(), actual.ToString()); | 670 EXPECT_EQ(float_tests[i].expected.ToString(), actual.ToString()); |
671 } | 671 } |
672 } | 672 } |
673 | 673 |
| 674 TEST(RectTest, IsExpressibleAsRect) { |
| 675 //EXPECT_TRUE(gfx::RectF().IsExpressibleAsRect()); |
| 676 |
| 677 float min = std::numeric_limits<int>::min(); |
| 678 float max = std::numeric_limits<int>::max(); |
| 679 float infinity = std::numeric_limits<float>::infinity(); |
| 680 |
| 681 EXPECT_TRUE(gfx::RectF(min, min, max, max).IsExpressibleAsRect()); |
| 682 EXPECT_TRUE(gfx::RectF(min + 200, min, max, max).IsExpressibleAsRect()); |
| 683 EXPECT_TRUE(gfx::RectF(min, min + 200, max, max).IsExpressibleAsRect()); |
| 684 EXPECT_FALSE(gfx::RectF(min - 200, min, max, max).IsExpressibleAsRect()); |
| 685 EXPECT_FALSE(gfx::RectF(min, min - 200, max, max).IsExpressibleAsRect()); |
| 686 EXPECT_TRUE(gfx::RectF(min, min, max - 200, max).IsExpressibleAsRect()); |
| 687 EXPECT_TRUE(gfx::RectF(min, min, max, max - 200).IsExpressibleAsRect()); |
| 688 EXPECT_FALSE(gfx::RectF(min, min, max + 200, max).IsExpressibleAsRect()); |
| 689 EXPECT_FALSE(gfx::RectF(min, min, max, max + 200).IsExpressibleAsRect()); |
| 690 |
| 691 EXPECT_TRUE(gfx::RectF(0, 0, max, max).IsExpressibleAsRect()); |
| 692 EXPECT_FALSE(gfx::RectF(200, 0, max, max).IsExpressibleAsRect()); |
| 693 EXPECT_FALSE(gfx::RectF(0, 200, max, max).IsExpressibleAsRect()); |
| 694 EXPECT_TRUE(gfx::RectF(0, 0, max - 200, max).IsExpressibleAsRect()); |
| 695 EXPECT_TRUE(gfx::RectF(0, 0, max, max - 200).IsExpressibleAsRect()); |
| 696 EXPECT_FALSE(gfx::RectF(0, 0, max + 200, max).IsExpressibleAsRect()); |
| 697 EXPECT_FALSE(gfx::RectF(0, 0, max, max + 200).IsExpressibleAsRect()); |
| 698 |
| 699 EXPECT_FALSE(gfx::RectF(infinity, 0, 1, 1).IsExpressibleAsRect()); |
| 700 EXPECT_FALSE(gfx::RectF(0, infinity, 1, 1).IsExpressibleAsRect()); |
| 701 EXPECT_FALSE(gfx::RectF(0, 0, infinity, 1).IsExpressibleAsRect()); |
| 702 EXPECT_FALSE(gfx::RectF(0, 0, 1, infinity).IsExpressibleAsRect()); |
| 703 } |
| 704 |
674 } // namespace ui | 705 } // namespace ui |
OLD | NEW |