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

Side by Side Diff: views/bubble/bubble_frame_view_unittest.cc

Issue 8368006: Support Windows native textfield, combobox, etc. in new bubbles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore Widget return; same as Patch Set 9 with updated CreateBubble comment. Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/bubble/bubble_delegate_unittest.cc ('k') | views/bubble/bubble_view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/bubble/bubble_delegate.h"
5 #include "views/bubble/bubble_frame_view.h" 6 #include "views/bubble/bubble_frame_view.h"
6 #include "views/bubble/bubble_delegate.h"
7 #include "views/test/views_test_base.h" 7 #include "views/test/views_test_base.h"
8 #include "views/widget/widget.h" 8 #include "views/widget/widget.h"
9 #if !defined(OS_WIN) 9 #if !defined(OS_WIN)
10 #include "views/window/hit_test.h" 10 #include "views/window/hit_test.h"
11 #endif 11 #endif
12 12
13 namespace views { 13 namespace views {
14 14
15 namespace { 15 namespace {
16 16
17 typedef ViewsTestBase BubbleFrameViewBasicTest; 17 typedef ViewsTestBase BubbleFrameViewBasicTest;
18 18
19 const BubbleBorder::ArrowLocation kArrow = BubbleBorder::LEFT_BOTTOM; 19 const BubbleBorder::ArrowLocation kArrow = BubbleBorder::LEFT_BOTTOM;
20 const gfx::Rect kRect(10, 10, 200, 200); 20 const gfx::Rect kRect(10, 10, 200, 200);
21 const SkColor kBackgroundColor = SK_ColorRED; 21 const SkColor kBackgroundColor = SK_ColorRED;
22 22
23 TEST_F(BubbleFrameViewBasicTest, GetBoundsForClientView) { 23 TEST_F(BubbleFrameViewBasicTest, GetBoundsForClientView) {
24 BubbleFrameView frame(kArrow, kRect.size(), kBackgroundColor); 24 BubbleFrameView frame(kArrow, kRect.size(), kBackgroundColor);
25 EXPECT_EQ(frame.GetWindowBoundsForClientBounds(kRect).size(), frame.size()); 25 EXPECT_EQ(frame.GetWindowBoundsForClientBounds(kRect).size(), frame.size());
26 BubbleBorder* bubble_border = static_cast<BubbleBorder*>(frame.border()); 26 BubbleBorder* bubble_border = static_cast<BubbleBorder*>(frame.border());
27 EXPECT_EQ(kArrow, bubble_border->arrow_location()); 27 EXPECT_EQ(kArrow, bubble_border->arrow_location());
28 EXPECT_EQ(kBackgroundColor, bubble_border->background_color()); 28 EXPECT_EQ(kBackgroundColor, bubble_border->background_color());
29 29
30 gfx::Insets expected_insets(frame.GetInsets()); 30 gfx::Insets expected_insets(frame.GetInsets());
31 EXPECT_EQ(expected_insets.left(), frame.GetBoundsForClientView().x()); 31 EXPECT_EQ(expected_insets.left(), frame.GetBoundsForClientView().x());
32 EXPECT_EQ(expected_insets.top(), frame.GetBoundsForClientView().y()); 32 EXPECT_EQ(expected_insets.top(), frame.GetBoundsForClientView().y());
33 } 33 }
34 34
35 } // namespace
36
37 class SizedBubbleDelegateView : public BubbleDelegateView {
38 public:
39 SizedBubbleDelegateView() {}
40 virtual ~SizedBubbleDelegateView() {}
41
42 // View overrides:
43 virtual gfx::Size GetPreferredSize() OVERRIDE;
44
45 private:
46 DISALLOW_COPY_AND_ASSIGN(SizedBubbleDelegateView);
47 };
48
49 gfx::Size SizedBubbleDelegateView::GetPreferredSize() { return kRect.size(); }
50
35 TEST_F(BubbleFrameViewBasicTest, NonClientHitTest) { 51 TEST_F(BubbleFrameViewBasicTest, NonClientHitTest) {
36 BubbleDelegateView* delegate = new BubbleDelegateView(); 52 SizedBubbleDelegateView* delegate = new SizedBubbleDelegateView();
37 scoped_ptr<Widget> widget( 53 scoped_ptr<Widget> widget(BubbleDelegateView::CreateBubble(delegate, NULL));
38 views::BubbleDelegateView::CreateBubble(delegate, NULL)); 54 delegate->Show();
39 widget->SetBounds(kRect);
40 widget->Show();
41 gfx::Point kPtInBound(100, 100); 55 gfx::Point kPtInBound(100, 100);
42 gfx::Point kPtOutsideBound(1000, 1000); 56 gfx::Point kPtOutsideBound(1000, 1000);
43 EXPECT_EQ(HTCLIENT, widget->non_client_view()->NonClientHitTest(kPtInBound)); 57 BubbleFrameView* bubble_frame_view = delegate->GetBubbleFrameView();
44 EXPECT_EQ(HTNOWHERE, 58 EXPECT_EQ(HTCLIENT, bubble_frame_view->NonClientHitTest(kPtInBound));
45 widget->non_client_view()->NonClientHitTest(kPtOutsideBound)); 59 EXPECT_EQ(HTNOWHERE, bubble_frame_view->NonClientHitTest(kPtOutsideBound));
46 widget->CloseNow(); 60 widget->CloseNow();
47 widget.reset(); 61 widget.reset();
48 RunPendingMessages(); 62 RunPendingMessages();
49 } 63 }
50 64
51 } // namespace
52
53 } // namespace views 65 } // namespace views
OLDNEW
« no previous file with comments | « views/bubble/bubble_delegate_unittest.cc ('k') | views/bubble/bubble_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698