OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 EXPECT_FLOAT_EQ( | 908 EXPECT_FLOAT_EQ( |
909 0.0f, f.ManhattanInternalDistance(gfx::RectF(-1.0f, 0.0f, 1.1f, 1.0f))); | 909 0.0f, f.ManhattanInternalDistance(gfx::RectF(-1.0f, 0.0f, 1.1f, 1.0f))); |
910 EXPECT_FLOAT_EQ( | 910 EXPECT_FLOAT_EQ( |
911 0.1f + kEpsilon, | 911 0.1f + kEpsilon, |
912 f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.4f, 1.0f))); | 912 f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.4f, 1.0f))); |
913 EXPECT_FLOAT_EQ( | 913 EXPECT_FLOAT_EQ( |
914 kEpsilon, | 914 kEpsilon, |
915 f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.5f, 1.0f))); | 915 f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.5f, 1.0f))); |
916 } | 916 } |
917 | 917 |
| 918 TEST(RectTest, ConstrainToEnclosingRect) { |
| 919 Rect r(10, 10, 10, 10); |
| 920 EXPECT_EQ(ConstrainToEnclosingRect(r, Point(15, 15)), Point(15, 15)); |
| 921 |
| 922 EXPECT_EQ(ConstrainToEnclosingRect(r, Point(15, 0)), Point(15, 10)); |
| 923 EXPECT_EQ(ConstrainToEnclosingRect(r, Point(15, 30)), Point(15, 20)); |
| 924 |
| 925 EXPECT_EQ(ConstrainToEnclosingRect(r, Point(0, 15)), Point(10, 15)); |
| 926 EXPECT_EQ(ConstrainToEnclosingRect(r, Point(30, 15)), Point(20, 15)); |
| 927 |
| 928 EXPECT_EQ(ConstrainToEnclosingRect(r, Point(0, 0)), Point(10, 10)); |
| 929 EXPECT_EQ(ConstrainToEnclosingRect(r, Point(0, 30)), Point(10, 20)); |
| 930 EXPECT_EQ(ConstrainToEnclosingRect(r, Point(30, 0)), Point(20, 10)); |
| 931 EXPECT_EQ(ConstrainToEnclosingRect(r, Point(30, 30)), Point(20, 20)); |
| 932 |
| 933 Rect empty(10, 10, 0, 0); |
| 934 EXPECT_EQ(ConstrainToEnclosingRect(empty, Point(15, 15)), Point(10, 10)); |
| 935 |
| 936 EXPECT_EQ(ConstrainToEnclosingRect(empty, Point(15, 0)), Point(10, 10)); |
| 937 EXPECT_EQ(ConstrainToEnclosingRect(empty, Point(15, 30)), Point(10, 10)); |
| 938 |
| 939 EXPECT_EQ(ConstrainToEnclosingRect(empty, Point(0, 15)), Point(10, 10)); |
| 940 EXPECT_EQ(ConstrainToEnclosingRect(empty, Point(30, 15)), Point(10, 10)); |
| 941 |
| 942 EXPECT_EQ(ConstrainToEnclosingRect(empty, Point(0, 0)), Point(10, 10)); |
| 943 EXPECT_EQ(ConstrainToEnclosingRect(empty, Point(0, 30)), Point(10, 10)); |
| 944 EXPECT_EQ(ConstrainToEnclosingRect(empty, Point(30, 0)), Point(10, 10)); |
| 945 EXPECT_EQ(ConstrainToEnclosingRect(empty, Point(30, 30)), Point(10, 10)); |
| 946 } |
| 947 |
918 } // namespace gfx | 948 } // namespace gfx |
OLD | NEW |