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

Unified Diff: views/bubble/bubble_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_view.cc ('k') | views/examples/bubble_example.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/bubble/bubble_view_unittest.cc
diff --git a/views/bubble/bubble_view_unittest.cc b/views/bubble/bubble_view_unittest.cc
index 9fac7f44bdf26d96c3399b7cf13adb946aa59c03..c2a04fc9a24d912366eb463076ba7c09e7ae09e9 100644
--- a/views/bubble/bubble_view_unittest.cc
+++ b/views/bubble/bubble_view_unittest.cc
@@ -2,13 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/message_loop.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/animation/slide_animation.h"
-#include "views/bubble/bubble_border.h"
#include "views/bubble/bubble_delegate.h"
-#include "views/bubble/bubble_view.h"
#include "views/test/views_test_base.h"
#include "views/widget/widget.h"
@@ -17,75 +11,20 @@ namespace views {
namespace {
typedef ViewsTestBase BubbleViewBasicTest;
-typedef ViewsTestBase BubbleViewTest;
-
-class TestBubbleDelegate : public BubbleDelegateView {
- public:
- explicit TestBubbleDelegate(Widget *frame): BubbleDelegateView(frame) {}
- SkColor GetFrameBackgroundColor() { return SK_ColorGREEN; }
- gfx::Rect GetBounds() { return gfx::Rect(10, 10, 200, 200); }
- BubbleBorder::ArrowLocation GetFrameArrowLocation() {
- return BubbleBorder::LEFT_BOTTOM;
- }
- View* GetContentsView() { return &view_; }
-
- View view_;
-};
-
-class TestAnimationDelegate : public ui::AnimationDelegate {
- public:
- TestAnimationDelegate():animation_progressed_(0), animation_ended_(0) {}
- void AnimationProgressed(const ui::Animation* animation) {
- ++animation_progressed_;
- }
- void AnimationEnded(const ui::Animation* animation) {
- ++animation_ended_;
- }
- int animation_progressed_;
- int animation_ended_;
-};
-
TEST_F(BubbleViewBasicTest, CreateArrowBubble) {
- scoped_ptr<Widget> bubble_widget(new Widget());
- Widget::InitParams params(Widget::InitParams::TYPE_BUBBLE);
- TestBubbleDelegate delegate(bubble_widget.get());
- params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.delegate = &delegate;
- bubble_widget->Init(params);
+ BubbleDelegateView* bubble_delegate = new BubbleDelegateView();
+ scoped_ptr<Widget> bubble_widget(
+ views::BubbleDelegateView::CreateBubble(bubble_delegate, NULL));
- BubbleBorder* border =
- static_cast<BubbleBorder*>(bubble_widget->non_client_view()
- ->frame_view()->border());
- EXPECT_EQ(delegate.GetFrameArrowLocation(), border->arrow_location());
+ BubbleBorder* border = static_cast<BubbleBorder*>(
+ bubble_widget->non_client_view()->frame_view()->border());
+ EXPECT_EQ(bubble_delegate->GetArrowLocation(), border->arrow_location());
bubble_widget->CloseNow();
- bubble_widget.reset(NULL);
+ bubble_widget.reset();
RunPendingMessages();
}
} // namespace
-TEST_F(BubbleViewTest, FadeAnimation) {
- scoped_ptr<Widget> bubble_widget(new Widget());
- Widget::InitParams params(Widget::InitParams::TYPE_BUBBLE);
- TestBubbleDelegate delegate(bubble_widget.get());
- params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.delegate = &delegate;
- bubble_widget->Init(params);
- bubble_widget->Show();
- BubbleView* bubble_view = bubble_widget->client_view()->AsBubbleView();
- TestAnimationDelegate test_animation_delegate;
- bubble_view->set_animation_delegate(&test_animation_delegate);
- bubble_view->StartFade();
-
- bubble_view->AnimationProgressed(bubble_view->fade_animation_.get());
- bubble_view->AnimationEnded(bubble_view->fade_animation_.get());
-
- EXPECT_LT(0, test_animation_delegate.animation_progressed_);
- EXPECT_EQ(1, test_animation_delegate.animation_ended_);
- bubble_widget->CloseNow();
- bubble_widget.reset(NULL);
- RunPendingMessages();
-}
-
} // namespace views
« no previous file with comments | « views/bubble/bubble_view.cc ('k') | views/examples/bubble_example.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698