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

Unified Diff: ui/views/rect_based_targeting_utils_unittest.cc

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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/views/rect_based_targeting_utils.cc ('k') | ui/views/repeat_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/rect_based_targeting_utils_unittest.cc
diff --git a/ui/views/rect_based_targeting_utils_unittest.cc b/ui/views/rect_based_targeting_utils_unittest.cc
deleted file mode 100644
index 134119b222eab92b6bbf53306cf4b76058343822..0000000000000000000000000000000000000000
--- a/ui/views/rect_based_targeting_utils_unittest.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/views/rect_based_targeting_utils.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/gfx/rect.h"
-
-namespace views {
-
-TEST(RectBasedTargetingUtils, UsePointBasedTargeting) {
- gfx::Rect rect_1(gfx::Point(-22, 30), gfx::Size(1, 1));
- gfx::Rect rect_2(gfx::Point(0, 0), gfx::Size(34, 55));
- gfx::Rect rect_3(gfx::Point(12, 12), gfx::Size(1, 0));
- gfx::Rect rect_4(gfx::Point(12, 120), gfx::Size(0, 0));
-
- EXPECT_TRUE(UsePointBasedTargeting(rect_1));
- EXPECT_FALSE(UsePointBasedTargeting(rect_2));
- EXPECT_FALSE(UsePointBasedTargeting(rect_3));
- EXPECT_FALSE(UsePointBasedTargeting(rect_4));
-}
-
-TEST(RectBasedTargetingUtils, PercentCoveredBy) {
- gfx::Rect rect_1(gfx::Point(0, 0), gfx::Size(300, 120));
- gfx::Rect rect_2(gfx::Point(20, 10), gfx::Size(30, 90));
- gfx::Rect rect_3(gfx::Point(160, 50), gfx::Size(150, 85));
- gfx::Rect rect_4(gfx::Point(20, 55), gfx::Size(0, 15));
- float error = 0.001f;
-
- // Passing in identical rectangles.
- EXPECT_FLOAT_EQ(1.0f, PercentCoveredBy(rect_1, rect_1));
-
- // |rect_1| completely contains |rect_2|.
- EXPECT_FLOAT_EQ(0.075f, PercentCoveredBy(rect_1, rect_2));
- EXPECT_FLOAT_EQ(1.0f, PercentCoveredBy(rect_2, rect_1));
-
- // |rect_2| and |rect_3| do not intersect.
- EXPECT_FLOAT_EQ(0.0f, PercentCoveredBy(rect_2, rect_3));
-
- // |rect_1| and |rect_3| have a nonzero area of intersection which
- // is smaller than the area of either rectangle.
- EXPECT_NEAR(0.272f, PercentCoveredBy(rect_1, rect_3), error);
- EXPECT_NEAR(0.768f, PercentCoveredBy(rect_3, rect_1), error);
-
- // |rect_4| has no area.
- EXPECT_FLOAT_EQ(0.0f, PercentCoveredBy(rect_2, rect_4));
- EXPECT_FLOAT_EQ(0.0f, PercentCoveredBy(rect_4, rect_2));
-}
-
-TEST(RectBasedTargetingUtils, DistanceSquaredFromCenterToPoint) {
- gfx::Rect rect_1(gfx::Point(0, 0), gfx::Size(10, 10));
- gfx::Rect rect_2(gfx::Point(20, 0), gfx::Size(80, 10));
- gfx::Rect rect_3(gfx::Point(0, 20), gfx::Size(10, 20));
-
- gfx::Point point_1(5, 5);
- gfx::Point point_2(25, 5);
- gfx::Point point_3(11, 15);
- gfx::Point point_4(33, 44);
-
- EXPECT_EQ(0, DistanceSquaredFromCenterToPoint(point_1, rect_1));
- EXPECT_EQ(1225, DistanceSquaredFromCenterToPoint(point_2, rect_2));
- EXPECT_EQ(3025, DistanceSquaredFromCenterToPoint(point_1, rect_2));
- EXPECT_EQ(1025, DistanceSquaredFromCenterToPoint(point_2, rect_3));
- EXPECT_EQ(2501, DistanceSquaredFromCenterToPoint(point_3, rect_2));
- EXPECT_EQ(136, DistanceSquaredFromCenterToPoint(point_3, rect_1));
- EXPECT_EQ(980, DistanceSquaredFromCenterToPoint(point_4, rect_3));
-}
-
-} // namespace views
« no previous file with comments | « ui/views/rect_based_targeting_utils.cc ('k') | ui/views/repeat_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698