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

Unified Diff: views/bubble/bubble_frame_view_unittest.cc

Issue 8227003: Views Bubble API adjustments and cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add close_on_esc setting and fade-in functionality. Created 9 years, 2 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 | « views/bubble/bubble_frame_view.cc ('k') | views/bubble/bubble_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/bubble/bubble_frame_view_unittest.cc
diff --git a/views/bubble/bubble_frame_view_unittest.cc b/views/bubble/bubble_frame_view_unittest.cc
index d5cd8745f099b94c5766f25bfea900131f3a21f7..766bcec709d3a6f27644f102f4b35cb5e9a0f6f1 100644
--- a/views/bubble/bubble_frame_view_unittest.cc
+++ b/views/bubble/bubble_frame_view_unittest.cc
@@ -2,11 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "views/bubble/bubble_border.h"
#include "views/bubble/bubble_frame_view.h"
#include "views/bubble/bubble_delegate.h"
#include "views/test/views_test_base.h"
@@ -21,58 +16,38 @@ namespace {
typedef ViewsTestBase BubbleFrameViewBasicTest;
-gfx::Rect kBound = gfx::Rect(10, 10, 200, 200);
-SkColor kBackgroundColor = SK_ColorRED;
-BubbleBorder::ArrowLocation kArrow = BubbleBorder::LEFT_BOTTOM;
+const BubbleBorder::ArrowLocation kArrow = BubbleBorder::LEFT_BOTTOM;
+const gfx::Rect kRect(10, 10, 200, 200);
+const SkColor kBackgroundColor = SK_ColorRED;
TEST_F(BubbleFrameViewBasicTest, GetBoundsForClientView) {
- scoped_ptr<Widget> widget(new views::Widget());
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_BUBBLE);
- params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- widget->Init(params);
- BubbleFrameView frame(widget.get(), kBound, kBackgroundColor, kArrow);
- EXPECT_EQ(kBound, frame.bounds());
- EXPECT_EQ(kArrow,
- static_cast<BubbleBorder*>(frame.border())->arrow_location());
- EXPECT_EQ(kBackgroundColor,
- static_cast<BubbleBorder*>(frame.border())->background_color());
+ 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.border()->GetInsets(&expected_insets);
+ gfx::Insets expected_insets(frame.GetInsets());
EXPECT_EQ(expected_insets.left(), frame.GetBoundsForClientView().x());
EXPECT_EQ(expected_insets.top(), frame.GetBoundsForClientView().y());
- widget->CloseNow();
- widget.reset(NULL);
- RunPendingMessages();
}
-class TestBubbleDelegate : public BubbleDelegateView {
- public:
- explicit TestBubbleDelegate(Widget *frame): BubbleDelegateView(frame) {}
- SkColor GetFrameBackgroundColor() { return kBackgroundColor; }
- gfx::Rect GetBounds() { return gfx::Rect(10, 10, 200, 200); }
- BubbleBorder::ArrowLocation GetFrameArrowLocation() { return kArrow; }
- View* GetContentsView() { return &view_; }
-
- View view_;
-};
-
TEST_F(BubbleFrameViewBasicTest, NonClientHitTest) {
- scoped_ptr<Widget> widget(new Widget());
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_BUBBLE);
- TestBubbleDelegate delegate(widget.get());
- params.delegate = &delegate;
- params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- widget->Init(params);
+ 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(NULL);
+ widget.reset();
RunPendingMessages();
}
} // namespace
+
} // namespace views
« no previous file with comments | « views/bubble/bubble_frame_view.cc ('k') | views/bubble/bubble_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698