Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1345)

Side by Side Diff: ui/gfx/rect_unittest.cc

Issue 11358240: ui: Add methods to Rect classes to get points at each of the rect's corners. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update cc Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/rect_base.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 EXPECT_EQ(RectF(2.2f, 1.1f, 3.3f, 4.4f).ToString(), 736 EXPECT_EQ(RectF(2.2f, 1.1f, 3.3f, 4.4f).ToString(),
737 (Vector2dF(1.1f, -1.1f) + f).ToString()); 737 (Vector2dF(1.1f, -1.1f) + f).ToString());
738 f += Vector2dF(1.1f, -1.1f); 738 f += Vector2dF(1.1f, -1.1f);
739 EXPECT_EQ(RectF(2.2f, 1.1f, 3.3f, 4.4f).ToString(), f.ToString()); 739 EXPECT_EQ(RectF(2.2f, 1.1f, 3.3f, 4.4f).ToString(), f.ToString());
740 EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f).ToString(), 740 EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f).ToString(),
741 (f - Vector2dF(1.1f, -1.1f)).ToString()); 741 (f - Vector2dF(1.1f, -1.1f)).ToString());
742 f -= Vector2dF(1.1f, -1.1f); 742 f -= Vector2dF(1.1f, -1.1f);
743 EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f).ToString(), f.ToString()); 743 EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f).ToString(), f.ToString());
744 } 744 }
745 745
746 TEST(RectTest, Corners) {
747 Rect i(1, 2, 3, 4);
748 RectF f(1.1f, 2.1f, 3.1f, 4.1f);
749
750 EXPECT_EQ(Point(1, 2).ToString(), i.origin().ToString());
751 EXPECT_EQ(Point(4, 2).ToString(), i.top_right().ToString());
752 EXPECT_EQ(Point(1, 6).ToString(), i.bottom_left().ToString());
753 EXPECT_EQ(Point(4, 6).ToString(), i.bottom_right().ToString());
754
755 EXPECT_EQ(PointF(1.1f, 2.1f).ToString(), f.origin().ToString());
756 EXPECT_EQ(PointF(4.2f, 2.1f).ToString(), f.top_right().ToString());
757 EXPECT_EQ(PointF(1.1f, 6.2f).ToString(), f.bottom_left().ToString());
758 EXPECT_EQ(PointF(4.2f, 6.2f).ToString(), f.bottom_right().ToString());
759 }
760
746 } // namespace gfx 761 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/rect_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698