summaryrefslogtreecommitdiffstats
path: root/views/bubble/bubble_frame_view_unittest.cc
blob: 766bcec709d3a6f27644f102f4b35cb5e9a0f6f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2011 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 "views/bubble/bubble_frame_view.h"
#include "views/bubble/bubble_delegate.h"
#include "views/test/views_test_base.h"
#include "views/widget/widget.h"
#if !defined(OS_WIN)
#include "views/window/hit_test.h"
#endif

namespace views {

namespace {

typedef ViewsTestBase BubbleFrameViewBasicTest;

const BubbleBorder::ArrowLocation kArrow =  BubbleBorder::LEFT_BOTTOM;
const gfx::Rect kRect(10, 10, 200, 200);
const SkColor kBackgroundColor = SK_ColorRED;

TEST_F(BubbleFrameViewBasicTest, GetBoundsForClientView) {
  BubbleFrameView frame(kArrow, kRect.size(), kBackgroundColor);
  EXPECT_EQ(frame.GetWindowBoundsForClientBounds(kRect).size(), frame.size());
  BubbleBorder* bubble_border = static_cast<BubbleBorder*>(frame.border());
  EXPECT_EQ(kArrow, bubble_border->arrow_location());
  EXPECT_EQ(kBackgroundColor, bubble_border->background_color());

  gfx::Insets expected_insets(frame.GetInsets());
  EXPECT_EQ(expected_insets.left(), frame.GetBoundsForClientView().x());
  EXPECT_EQ(expected_insets.top(), frame.GetBoundsForClientView().y());
}

TEST_F(BubbleFrameViewBasicTest, NonClientHitTest) {
  BubbleDelegateView* delegate = new BubbleDelegateView();
  scoped_ptr<Widget> widget(
      views::BubbleDelegateView::CreateBubble(delegate, NULL));
  widget->SetBounds(kRect);
  widget->Show();
  gfx::Point kPtInBound(100, 100);
  gfx::Point kPtOutsideBound(1000, 1000);
  EXPECT_EQ(HTCLIENT, widget->non_client_view()->NonClientHitTest(kPtInBound));
  EXPECT_EQ(HTNOWHERE,
            widget->non_client_view()->NonClientHitTest(kPtOutsideBound));
  widget->CloseNow();
  widget.reset();
  RunPendingMessages();
}

}  // namespace

}  // namespace views