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

Unified Diff: ui/gfx/size_unittest.cc

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: vector length and conversion to size Created 8 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« ui/gfx/point_f.h ('K') | « ui/gfx/size_f.h ('k') | ui/gfx/vector2d.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/size_unittest.cc
diff --git a/ui/gfx/size_unittest.cc b/ui/gfx/size_unittest.cc
index 4a281ed42eacb2f0a1cfb1e596caf0153cef18c2..9dfcb424bdf4959eb8869b273b5882896ac4ba7f 100644
--- a/ui/gfx/size_unittest.cc
+++ b/ui/gfx/size_unittest.cc
@@ -4,6 +4,7 @@
#include "ui/gfx/size_base.h"
+#include "base/basictypes.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/size.h"
#include "ui/gfx/size_conversions.h"
@@ -136,4 +137,42 @@ TEST(SizeTest, ToRoundedSize) {
gfx::ToRoundedSize(gfx::SizeF(-10.9999f, -10.9999f)));
}
+TEST(SizeTest, SizeOfVector) {
+ int int_tests[][2] = {
+ { 0, 0 },
+ { 0, -1 },
+ { -1, 0 },
+ { 1, -1 },
+ { 1, 1 },
+ { -1, 1 },
+ { -1, -1 }
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(int_tests); ++i) {
+ int abs0 = std::abs(int_tests[i][0]);
+ int abs1 = std::abs(int_tests[i][1]);
+ gfx::Size expected(abs0, abs1);
+ gfx::Vector2d vector(int_tests[i][0], int_tests[i][1]);
+ EXPECT_EQ(expected.ToString(), SizeOfVector2d(vector).ToString());
+ }
+
+ float float_tests[][2] = {
+ { 0, 0 },
+ { 0, -0.1f },
+ { -0.1f, 0 },
+ { 0.1f, -0.1f },
+ { 0.1f, 0.1f },
+ { -0.1f, 0.1f },
+ { -0.1f, -0.1f }
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(float_tests); ++i) {
+ float abs0 = std::abs(float_tests[i][0]);
+ float abs1 = std::abs(float_tests[i][1]);
+ gfx::SizeF expected(abs0, abs1);
+ gfx::Vector2dF vector(float_tests[i][0], float_tests[i][1]);
+ EXPECT_EQ(expected.ToString(), SizeOfVector2d(vector).ToString());
+ }
+}
+
} // namespace ui
« ui/gfx/point_f.h ('K') | « ui/gfx/size_f.h ('k') | ui/gfx/vector2d.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698