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

Unified Diff: ui/views/view_unittest.cc

Issue 365263004: Remove hit test mask methods from views::View (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-upload Created 6 years, 5 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/view_targeter_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view_unittest.cc
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index 0a4f3b69dbd4373f69c830d8da80fa421bbd4986..2b6aac7380e5b8bf5d845c9dd11ffe4cd1139e67 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -785,50 +785,6 @@ TEST_F(ViewTest, RemoveNotification) {
}
namespace {
-class HitTestView : public View {
- public:
- explicit HitTestView(bool has_hittest_mask)
- : has_hittest_mask_(has_hittest_mask) {
- }
- virtual ~HitTestView() {}
-
- protected:
- // Overridden from View:
- virtual bool HasHitTestMask() const OVERRIDE {
- return has_hittest_mask_;
- }
- virtual void GetHitTestMaskDeprecated(HitTestSource source,
- gfx::Path* mask) const OVERRIDE {
- DCHECK(has_hittest_mask_);
- DCHECK(mask);
-
- SkScalar w = SkIntToScalar(width());
- SkScalar h = SkIntToScalar(height());
-
- // Create a triangular mask within the bounds of this View.
- mask->moveTo(w / 2, 0);
- mask->lineTo(w, h);
- mask->lineTo(0, h);
- mask->close();
- }
-
- private:
- bool has_hittest_mask_;
-
- DISALLOW_COPY_AND_ASSIGN(HitTestView);
-};
-
-gfx::Point ConvertPointToView(View* view, const gfx::Point& p) {
- gfx::Point tmp(p);
- View::ConvertPointToTarget(view->GetWidget()->GetRootView(), view, &tmp);
- return tmp;
-}
-
-gfx::Rect ConvertRectToView(View* view, const gfx::Rect& r) {
- gfx::Rect tmp(r);
- tmp.set_origin(ConvertPointToView(view, r.origin()));
- return tmp;
-}
void RotateCounterclockwise(gfx::Transform* transform) {
transform->matrix().set3x3(0, -1, 0,
@@ -844,72 +800,6 @@ void RotateClockwise(gfx::Transform* transform) {
} // namespace
-TEST_F(ViewTest, HitTestMasks) {
- Widget* widget = new Widget;
- Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
- widget->Init(params);
- View* root_view = widget->GetRootView();
- root_view->SetBoundsRect(gfx::Rect(0, 0, 500, 500));
-
- gfx::Rect v1_bounds = gfx::Rect(0, 0, 100, 100);
- HitTestView* v1 = new HitTestView(false);
- v1->SetBoundsRect(v1_bounds);
- root_view->AddChildView(v1);
-
- gfx::Rect v2_bounds = gfx::Rect(105, 0, 100, 100);
- HitTestView* v2 = new HitTestView(true);
- v2->SetBoundsRect(v2_bounds);
- root_view->AddChildView(v2);
-
- gfx::Point v1_centerpoint = v1_bounds.CenterPoint();
- gfx::Point v2_centerpoint = v2_bounds.CenterPoint();
- gfx::Point v1_origin = v1_bounds.origin();
- gfx::Point v2_origin = v2_bounds.origin();
-
- gfx::Rect r1(10, 10, 110, 15);
- gfx::Rect r2(106, 1, 98, 98);
- gfx::Rect r3(0, 0, 300, 300);
- gfx::Rect r4(115, 342, 200, 10);
-
- // Test HitTestPoint
- EXPECT_TRUE(v1->HitTestPoint(ConvertPointToView(v1, v1_centerpoint)));
- EXPECT_TRUE(v2->HitTestPoint(ConvertPointToView(v2, v2_centerpoint)));
-
- EXPECT_TRUE(v1->HitTestPoint(ConvertPointToView(v1, v1_origin)));
- EXPECT_FALSE(v2->HitTestPoint(ConvertPointToView(v2, v2_origin)));
-
- // Test HitTestRect
- EXPECT_TRUE(v1->HitTestRect(ConvertRectToView(v1, r1)));
- EXPECT_FALSE(v2->HitTestRect(ConvertRectToView(v2, r1)));
-
- EXPECT_FALSE(v1->HitTestRect(ConvertRectToView(v1, r2)));
- EXPECT_TRUE(v2->HitTestRect(ConvertRectToView(v2, r2)));
-
- EXPECT_TRUE(v1->HitTestRect(ConvertRectToView(v1, r3)));
- EXPECT_TRUE(v2->HitTestRect(ConvertRectToView(v2, r3)));
-
- EXPECT_FALSE(v1->HitTestRect(ConvertRectToView(v1, r4)));
- EXPECT_FALSE(v2->HitTestRect(ConvertRectToView(v2, r4)));
-
- // Test GetEventHandlerForPoint
- EXPECT_EQ(v1, root_view->GetEventHandlerForPoint(v1_centerpoint));
- EXPECT_EQ(v2, root_view->GetEventHandlerForPoint(v2_centerpoint));
-
- EXPECT_EQ(v1, root_view->GetEventHandlerForPoint(v1_origin));
- EXPECT_EQ(root_view, root_view->GetEventHandlerForPoint(v2_origin));
-
- // Test GetTooltipHandlerForPoint
- EXPECT_EQ(v1, root_view->GetTooltipHandlerForPoint(v1_centerpoint));
- EXPECT_EQ(v2, root_view->GetTooltipHandlerForPoint(v2_centerpoint));
-
- EXPECT_EQ(v1, root_view->GetTooltipHandlerForPoint(v1_origin));
- EXPECT_EQ(root_view, root_view->GetTooltipHandlerForPoint(v2_origin));
-
- EXPECT_FALSE(v1->GetTooltipHandlerForPoint(v2_origin));
-
- widget->CloseNow();
-}
-
// Tests the correctness of the rect-based targeting algorithm implemented in
// View::GetEventHandlerForRect(). See http://goo.gl/3Jp2BD for a description
// of rect-based targeting.
« no previous file with comments | « ui/views/view_targeter_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698