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 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
7 | 7 |
8 #include "ui/gfx/transform.h" | 8 #include "ui/gfx/transform.h" |
9 | 9 |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 while (rotation < 0.0) | 1151 while (rotation < 0.0) |
1152 rotation += 360.0; | 1152 rotation += 360.0; |
1153 while (rotation > 360.0) | 1153 while (rotation > 360.0) |
1154 rotation -= 360.0; | 1154 rotation -= 360.0; |
1155 EXPECT_FLOAT_EQ(rotation, degrees); | 1155 EXPECT_FLOAT_EQ(rotation, degrees); |
1156 EXPECT_FLOAT_EQ(decomp.scale[0], degrees + 1); | 1156 EXPECT_FLOAT_EQ(decomp.scale[0], degrees + 1); |
1157 EXPECT_FLOAT_EQ(decomp.scale[1], 2 * degrees + 1); | 1157 EXPECT_FLOAT_EQ(decomp.scale[1], 2 * degrees + 1); |
1158 } | 1158 } |
1159 } | 1159 } |
1160 | 1160 |
| 1161 TEST(XFormTest, IntegerTranslation) { |
| 1162 gfx::Transform transform; |
| 1163 EXPECT_TRUE(transform.IsIdentityOrIntegerTranslation()); |
| 1164 |
| 1165 transform.Translate3d(1, 2, 3); |
| 1166 EXPECT_TRUE(transform.IsIdentityOrIntegerTranslation()); |
| 1167 |
| 1168 transform.MakeIdentity(); |
| 1169 transform.Translate3d(-1, -2, -3); |
| 1170 EXPECT_TRUE(transform.IsIdentityOrIntegerTranslation()); |
| 1171 |
| 1172 transform.MakeIdentity(); |
| 1173 transform.Translate3d(4.5, 0, 0); |
| 1174 EXPECT_FALSE(transform.IsIdentityOrIntegerTranslation()); |
| 1175 |
| 1176 transform.MakeIdentity(); |
| 1177 transform.Translate3d(0, -6.7, 0); |
| 1178 EXPECT_FALSE(transform.IsIdentityOrIntegerTranslation()); |
| 1179 |
| 1180 transform.MakeIdentity(); |
| 1181 transform.Translate3d(0, 0, 8.9); |
| 1182 EXPECT_FALSE(transform.IsIdentityOrIntegerTranslation()); |
| 1183 } |
| 1184 |
| 1185 |
1161 } // namespace | 1186 } // namespace |
1162 | 1187 |
1163 } // namespace gfx | 1188 } // namespace gfx |
OLD | NEW |