| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/base/hit_test.h" | |
| 6 #include "ui/views/test/views_test_base.h" | |
| 7 #include "views/bubble/border_contents_view.h" | |
| 8 #include "views/bubble/bubble_border.h" | |
| 9 #include "views/bubble/bubble_delegate.h" | |
| 10 #include "views/bubble/bubble_frame_view.h" | |
| 11 #include "views/widget/widget.h" | |
| 12 | |
| 13 namespace views { | |
| 14 | |
| 15 typedef ViewsTestBase BubbleFrameViewBasicTest; | |
| 16 | |
| 17 const BubbleBorder::ArrowLocation kArrow = BubbleBorder::TOP_LEFT; | |
| 18 const gfx::Rect kRect(10, 10, 200, 200); | |
| 19 const SkColor kBackgroundColor = SK_ColorRED; | |
| 20 const bool kAllowBubbleOffscreen = true; | |
| 21 | |
| 22 TEST_F(BubbleFrameViewBasicTest, GetBoundsForClientView) { | |
| 23 BubbleFrameView frame(kArrow, kRect.size(), kBackgroundColor, | |
| 24 kAllowBubbleOffscreen); | |
| 25 EXPECT_EQ(frame.GetWindowBoundsForClientBounds(kRect).size(), frame.size()); | |
| 26 EXPECT_EQ(kArrow, frame.bubble_border()->arrow_location()); | |
| 27 EXPECT_EQ(kBackgroundColor, frame.bubble_border()->background_color()); | |
| 28 | |
| 29 int margin_x = frame.border_contents_->content_margins().left(); | |
| 30 int margin_y = frame.border_contents_->content_margins().top(); | |
| 31 gfx::Insets insets; | |
| 32 frame.bubble_border()->GetInsets(&insets); | |
| 33 EXPECT_EQ(insets.left() + margin_x, frame.GetBoundsForClientView().x()); | |
| 34 EXPECT_EQ(insets.top() + margin_y, frame.GetBoundsForClientView().y()); | |
| 35 } | |
| 36 | |
| 37 namespace { | |
| 38 | |
| 39 class SizedBubbleDelegateView : public BubbleDelegateView { | |
| 40 public: | |
| 41 SizedBubbleDelegateView() {} | |
| 42 virtual ~SizedBubbleDelegateView() {} | |
| 43 | |
| 44 // View overrides: | |
| 45 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
| 46 | |
| 47 private: | |
| 48 DISALLOW_COPY_AND_ASSIGN(SizedBubbleDelegateView); | |
| 49 }; | |
| 50 | |
| 51 gfx::Size SizedBubbleDelegateView::GetPreferredSize() { return kRect.size(); } | |
| 52 | |
| 53 } // namespace | |
| 54 | |
| 55 TEST_F(BubbleFrameViewBasicTest, NonClientHitTest) { | |
| 56 BubbleDelegateView* delegate = new SizedBubbleDelegateView(); | |
| 57 Widget* widget(BubbleDelegateView::CreateBubble(delegate)); | |
| 58 delegate->Show(); | |
| 59 gfx::Point kPtInBound(100, 100); | |
| 60 gfx::Point kPtOutsideBound(1000, 1000); | |
| 61 BubbleFrameView* bubble_frame_view = delegate->GetBubbleFrameView(); | |
| 62 EXPECT_EQ(HTCLIENT, bubble_frame_view->NonClientHitTest(kPtInBound)); | |
| 63 EXPECT_EQ(HTNOWHERE, bubble_frame_view->NonClientHitTest(kPtOutsideBound)); | |
| 64 widget->CloseNow(); | |
| 65 RunPendingMessages(); | |
| 66 } | |
| 67 | |
| 68 } // namespace views | |
| OLD | NEW |