| 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 Rect just_below_no_edge(2, 8, 3, 2); // too narrow | 387 Rect just_below_no_edge(2, 8, 3, 2); // too narrow |
| 388 Rect just_left_no_edge(0, 3, 2, 6); // too tall | 388 Rect just_left_no_edge(0, 3, 2, 6); // too tall |
| 389 Rect just_right_no_edge(6, 3, 2, 4); // too short | 389 Rect just_right_no_edge(6, 3, 2, 4); // too short |
| 390 | 390 |
| 391 EXPECT_FALSE(r.SharesEdgeWith(just_above_no_edge)); | 391 EXPECT_FALSE(r.SharesEdgeWith(just_above_no_edge)); |
| 392 EXPECT_FALSE(r.SharesEdgeWith(just_below_no_edge)); | 392 EXPECT_FALSE(r.SharesEdgeWith(just_below_no_edge)); |
| 393 EXPECT_FALSE(r.SharesEdgeWith(just_left_no_edge)); | 393 EXPECT_FALSE(r.SharesEdgeWith(just_left_no_edge)); |
| 394 EXPECT_FALSE(r.SharesEdgeWith(just_right_no_edge)); | 394 EXPECT_FALSE(r.SharesEdgeWith(just_right_no_edge)); |
| 395 } | 395 } |
| 396 | 396 |
| 397 TEST(RectTest, SkRectToRect) { | 397 TEST(RectTest, SkiaRectConversions) { |
| 398 Rect src(10, 20, 30, 40); | 398 Rect isrc(10, 20, 30, 40); |
| 399 SkRect skrect = RectToSkRect(src); | 399 RectF fsrc(10.5f, 20.5f, 30.5f, 40.5f); |
| 400 EXPECT_EQ(src, SkRectToRect(skrect)); | 400 |
| 401 SkIRect skirect = RectToSkIRect(isrc); |
| 402 EXPECT_EQ(isrc.ToString(), SkIRectToRect(skirect).ToString()); |
| 403 |
| 404 SkRect skrect = RectToSkRect(isrc); |
| 405 EXPECT_EQ(gfx::RectF(isrc).ToString(), SkRectToRectF(skrect).ToString()); |
| 406 |
| 407 skrect = RectFToSkRect(fsrc); |
| 408 EXPECT_EQ(fsrc.ToString(), SkRectToRectF(skrect).ToString()); |
| 401 } | 409 } |
| 402 | 410 |
| 403 // Similar to EXPECT_FLOAT_EQ, but lets NaN equal NaN | 411 // Similar to EXPECT_FLOAT_EQ, but lets NaN equal NaN |
| 404 #define EXPECT_FLOAT_AND_NAN_EQ(a, b) \ | 412 #define EXPECT_FLOAT_AND_NAN_EQ(a, b) \ |
| 405 { if (a == a || b == b) { EXPECT_FLOAT_EQ(a, b); } } | 413 { if (a == a || b == b) { EXPECT_FLOAT_EQ(a, b); } } |
| 406 | 414 |
| 407 TEST(RectTest, ScaleRect) { | 415 TEST(RectTest, ScaleRect) { |
| 408 static const struct Test { | 416 static const struct Test { |
| 409 int x1; // source | 417 int x1; // source |
| 410 int y1; | 418 int y1; |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 (Vector2dF(1.1f, -1.1f) + f).ToString()); | 723 (Vector2dF(1.1f, -1.1f) + f).ToString()); |
| 716 f += Vector2dF(1.1f, -1.1f); | 724 f += Vector2dF(1.1f, -1.1f); |
| 717 EXPECT_EQ(RectF(2.2f, 1.1f, 3.3f, 4.4f).ToString(), f.ToString()); | 725 EXPECT_EQ(RectF(2.2f, 1.1f, 3.3f, 4.4f).ToString(), f.ToString()); |
| 718 EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f).ToString(), | 726 EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f).ToString(), |
| 719 (f - Vector2dF(1.1f, -1.1f)).ToString()); | 727 (f - Vector2dF(1.1f, -1.1f)).ToString()); |
| 720 f -= Vector2dF(1.1f, -1.1f); | 728 f -= Vector2dF(1.1f, -1.1f); |
| 721 EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f).ToString(), f.ToString()); | 729 EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f).ToString(), f.ToString()); |
| 722 } | 730 } |
| 723 | 731 |
| 724 } // namespace gfx | 732 } // namespace gfx |
| OLD | NEW |