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

Unified Diff: ui/display/win/scaling_util_unittest.cc

Issue 2012083002: Multiple DPI Tracking for ScreenWin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Feedback Created 4 years, 7 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
« no previous file with comments | « ui/display/win/scaling_util.cc ('k') | ui/display/win/screen_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/display/win/scaling_util_unittest.cc
diff --git a/ui/display/win/scaling_util_unittest.cc b/ui/display/win/scaling_util_unittest.cc
index a4fcba41b5fc31e4ab8214a7bbf25b88d40b6b6c..5806bf9627886bc3e438e7b00e8ba4864838a6eb 100644
--- a/ui/display/win/scaling_util_unittest.cc
+++ b/ui/display/win/scaling_util_unittest.cc
@@ -426,6 +426,89 @@ TEST(ScalingUtilTest, CalculateDisplayPlacement2xScale) {
CreateDisplayInfo(50, 650, 1000, 700, 2.0f)));
}
+TEST(ScalingUtilTest, SquaredDistanceBetweenRectsFullyIntersecting) {
+ gfx::Rect rect1(0, 0, 100, 100);
+ gfx::Rect rect2(5, 5, 10, 10);
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(rect1, rect2));
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(rect2, rect1));
+}
+
+TEST(ScalingUtilTest, SquaredDistanceBetweenRectsPartiallyIntersecting) {
+ gfx::Rect rect1(0, 0, 10, 10);
+ gfx::Rect rect2(5, 5, 10, 10);
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(rect1, rect2));
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(rect2, rect1));
+}
+
+TEST(ScalingUtilTest, SquaredDistanceBetweenRectsTouching) {
+ gfx::Rect ref(2, 2, 2, 2);
+
+ gfx::Rect top_left(0, 0, 2, 2);
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(ref, top_left));
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(top_left, ref));
+ gfx::Rect top_left_partial_top(1, 0, 2, 2);
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(ref, top_left_partial_top));
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(top_left_partial_top, ref));
+ gfx::Rect top(2, 0, 2, 2);
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(ref, top));
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(top, ref));
+ gfx::Rect top_right_partial_top(3, 0, 2, 2);
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(ref, top_right_partial_top));
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(top_right_partial_top, ref));
+ gfx::Rect top_right(4, 0, 2, 2);
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(ref, top_right));
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(top_right, ref));
+
+ gfx::Rect top_left_partial_left(0, 1, 2, 2);
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(ref, top_left_partial_left));
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(top_left_partial_left, ref));
+ gfx::Rect left(0, 2, 2, 2);
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(ref, left));
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(left, ref));
+ gfx::Rect bottom_left_partial(0, 3, 2, 2);
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(ref, bottom_left_partial));
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(bottom_left_partial, ref));
+ gfx::Rect bottom_left(0, 4, 2, 2);
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(ref, bottom_left));
+ EXPECT_EQ(0, SquaredDistanceBetweenRects(bottom_left, ref));
+}
+
+TEST(ScalingUtilTest, SquaredDistanceBetweenRectsOverlapping) {
+ gfx::Rect ref(5, 5, 2, 2);
+
+ gfx::Rect top_left_partial_top(4, 0, 2, 2);
+ EXPECT_EQ(9, SquaredDistanceBetweenRects(ref, top_left_partial_top));
+ EXPECT_EQ(9, SquaredDistanceBetweenRects(top_left_partial_top, ref));
+ gfx::Rect top(5, 0, 2, 2);
+ EXPECT_EQ(9, SquaredDistanceBetweenRects(ref, top));
+ EXPECT_EQ(9, SquaredDistanceBetweenRects(top, ref));
+ gfx::Rect top_right_partial(6, 0, 2, 2);
+ EXPECT_EQ(9, SquaredDistanceBetweenRects(ref, top_right_partial));
+ EXPECT_EQ(9, SquaredDistanceBetweenRects(top_right_partial, ref));
+
+ gfx::Rect top_left_partial_left(0, 4, 2, 2);
+ EXPECT_EQ(9, SquaredDistanceBetweenRects(ref, top_left_partial_left));
+ EXPECT_EQ(9, SquaredDistanceBetweenRects(top_left_partial_left, ref));
+ gfx::Rect left(0, 5, 2, 2);
+ EXPECT_EQ(9, SquaredDistanceBetweenRects(ref, left));
+ EXPECT_EQ(9, SquaredDistanceBetweenRects(left, ref));
+ gfx::Rect bottom_left_partial(0, 6, 2, 2);
+ EXPECT_EQ(9, SquaredDistanceBetweenRects(ref, bottom_left_partial));
+ EXPECT_EQ(9, SquaredDistanceBetweenRects(bottom_left_partial, ref));
+}
+
+TEST(ScalingUtilTest, SquaredDistanceBetweenRectsDiagonals) {
+ gfx::Rect ref(5, 5, 2, 2);
+
+ gfx::Rect top_left(0, 0, 2, 2);
+ EXPECT_EQ(18, SquaredDistanceBetweenRects(ref, top_left));
+ EXPECT_EQ(18, SquaredDistanceBetweenRects(top_left, ref));
+
+ gfx::Rect top_right(10, 0, 2, 2);
+ EXPECT_EQ(18, SquaredDistanceBetweenRects(ref, top_right));
+ EXPECT_EQ(18, SquaredDistanceBetweenRects(top_right, ref));
+}
+
} // namespace
} // namespace test
} // namespace win
« no previous file with comments | « ui/display/win/scaling_util.cc ('k') | ui/display/win/screen_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698