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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 std::numeric_limits<float>::quiet_NaN(), | 426 std::numeric_limits<float>::quiet_NaN(), |
427 std::numeric_limits<float>::quiet_NaN(), | 427 std::numeric_limits<float>::quiet_NaN(), |
428 std::numeric_limits<float>::quiet_NaN(), | 428 std::numeric_limits<float>::quiet_NaN(), |
429 std::numeric_limits<float>::quiet_NaN(), | 429 std::numeric_limits<float>::quiet_NaN(), |
430 std::numeric_limits<float>::quiet_NaN() }, | 430 std::numeric_limits<float>::quiet_NaN() }, |
431 { 3, 3, 3, 3, | 431 { 3, 3, 3, 3, |
432 std::numeric_limits<float>::max(), | 432 std::numeric_limits<float>::max(), |
433 std::numeric_limits<float>::max(), | 433 std::numeric_limits<float>::max(), |
434 std::numeric_limits<float>::max(), | 434 std::numeric_limits<float>::max(), |
435 std::numeric_limits<float>::max(), | 435 std::numeric_limits<float>::max(), |
436 std::numeric_limits<float>::max() }, | 436 std::numeric_limits<float>::max() } |
437 { 3, 3, 3, 3, | |
438 -1.0f, | |
439 -3.0f, -3.0f, 0.0f, 0.0f } | |
440 }; | 437 }; |
441 | 438 |
442 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 439 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
443 Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); | 440 Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); |
444 RectF r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); | 441 RectF r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); |
445 | 442 |
446 RectF scaled = ScaleRect(r1, tests[i].scale); | 443 RectF scaled = ScaleRect(r1, tests[i].scale); |
447 EXPECT_FLOAT_AND_NAN_EQ(r2.x(), scaled.x()); | 444 EXPECT_FLOAT_AND_NAN_EQ(r2.x(), scaled.x()); |
448 EXPECT_FLOAT_AND_NAN_EQ(r2.y(), scaled.y()); | 445 EXPECT_FLOAT_AND_NAN_EQ(r2.y(), scaled.y()); |
449 EXPECT_FLOAT_AND_NAN_EQ(r2.width(), scaled.width()); | 446 EXPECT_FLOAT_AND_NAN_EQ(r2.width(), scaled.width()); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 (Vector2dF(1.1f, -1.1f) + f).ToString()); | 715 (Vector2dF(1.1f, -1.1f) + f).ToString()); |
719 f += Vector2dF(1.1f, -1.1f); | 716 f += Vector2dF(1.1f, -1.1f); |
720 EXPECT_EQ(RectF(2.2f, 1.1f, 3.3f, 4.4f).ToString(), f.ToString()); | 717 EXPECT_EQ(RectF(2.2f, 1.1f, 3.3f, 4.4f).ToString(), f.ToString()); |
721 EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f).ToString(), | 718 EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f).ToString(), |
722 (f - Vector2dF(1.1f, -1.1f)).ToString()); | 719 (f - Vector2dF(1.1f, -1.1f)).ToString()); |
723 f -= Vector2dF(1.1f, -1.1f); | 720 f -= Vector2dF(1.1f, -1.1f); |
724 EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f).ToString(), f.ToString()); | 721 EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f).ToString(), f.ToString()); |
725 } | 722 } |
726 | 723 |
727 } // namespace gfx | 724 } // namespace gfx |
OLD | NEW |