| Index: ui/views/controls/button/label_button_unittest.cc
|
| diff --git a/ui/views/controls/button/label_button_unittest.cc b/ui/views/controls/button/label_button_unittest.cc
|
| index a17a61001e9d52b7a16625e945b4635ef800ec99..fad48ffaacd166d0ba3be3640c1ef81469af1fc2 100644
|
| --- a/ui/views/controls/button/label_button_unittest.cc
|
| +++ b/ui/views/controls/button/label_button_unittest.cc
|
| @@ -19,7 +19,8 @@
|
| #include "ui/gfx/geometry/vector2d.h"
|
| #include "ui/gfx/text_utils.h"
|
| #include "ui/native_theme/native_theme.h"
|
| -#include "ui/views/animation/button_ink_drop_delegate.h"
|
| +#include "ui/views/animation/test/ink_drop_host_view_test_api.h"
|
| +#include "ui/views/animation/test/test_ink_drop.h"
|
| #include "ui/views/style/platform_style.h"
|
| #include "ui/views/test/views_test_base.h"
|
| #include "ui/views/test/widget_test.h"
|
| @@ -404,51 +405,6 @@ TEST_F(LabelButtonTest, HighlightedButtonStyle) {
|
| default_before->label()->enabled_color());
|
| }
|
|
|
| -// A ButtonInkDropDelegate that tracks the last hover state requested.
|
| -class TestButtonInkDropDelegate : public ButtonInkDropDelegate {
|
| - public:
|
| - TestButtonInkDropDelegate(InkDropHost* ink_drop_host, View* view)
|
| - : ButtonInkDropDelegate(ink_drop_host, view), is_hovered_(false) {}
|
| -
|
| - ~TestButtonInkDropDelegate() override {}
|
| -
|
| - bool is_hovered() const { return is_hovered_; }
|
| -
|
| - // ButtonInkDropDelegate:
|
| - void SetHovered(bool is_hovered) override {
|
| - is_hovered_ = is_hovered;
|
| - ButtonInkDropDelegate::SetHovered(is_hovered);
|
| - }
|
| -
|
| - private:
|
| - // The last |is_hover| value passed to SetHovered().
|
| - bool is_hovered_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(TestButtonInkDropDelegate);
|
| -};
|
| -
|
| -// A generic LabelButton configured with an |InkDropDelegate|.
|
| -class InkDropLabelButton : public LabelButton {
|
| - public:
|
| - InkDropLabelButton()
|
| - : LabelButton(nullptr, base::string16()),
|
| - test_ink_drop_delegate_(new TestButtonInkDropDelegate(this, this)) {
|
| - set_ink_drop_delegate(base::WrapUnique(test_ink_drop_delegate_));
|
| - }
|
| -
|
| - ~InkDropLabelButton() override {}
|
| -
|
| - TestButtonInkDropDelegate* test_ink_drop_delegate() {
|
| - return test_ink_drop_delegate_;
|
| - }
|
| -
|
| - private:
|
| - // Weak pointer.
|
| - TestButtonInkDropDelegate* test_ink_drop_delegate_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(InkDropLabelButton);
|
| -};
|
| -
|
| // Test fixture for a LabelButton that has an ink drop configured.
|
| class InkDropLabelButtonTest : public ViewsTestBase {
|
| public:
|
| @@ -469,7 +425,12 @@ class InkDropLabelButtonTest : public ViewsTestBase {
|
| widget_->Init(params);
|
| widget_->Show();
|
|
|
| - button_ = new InkDropLabelButton();
|
| + button_ = new LabelButton(nullptr, base::string16());
|
| +
|
| + test_ink_drop_ = new test::TestInkDrop();
|
| + test::InkDropHostViewTestApi(button_).SetInkDrop(
|
| + base::WrapUnique(test_ink_drop_));
|
| +
|
| widget_->SetContentsView(button_);
|
| }
|
|
|
| @@ -484,7 +445,10 @@ class InkDropLabelButtonTest : public ViewsTestBase {
|
| std::unique_ptr<Widget> widget_;
|
|
|
| // The test target.
|
| - InkDropLabelButton* button_ = nullptr;
|
| + LabelButton* button_ = nullptr;
|
| +
|
| + // Weak ptr, |button_| owns the instance.
|
| + test::TestInkDrop* test_ink_drop_ = nullptr;
|
|
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(InkDropLabelButtonTest);
|
| @@ -498,13 +462,13 @@ TEST_F(InkDropLabelButtonTest, HoverStateAfterMouseEnterAndExitEvents) {
|
| const gfx::Point in_bounds_point(button_->bounds().CenterPoint());
|
|
|
| event_generator.MoveMouseTo(out_of_bounds_point);
|
| - EXPECT_FALSE(button_->test_ink_drop_delegate()->is_hovered());
|
| + EXPECT_FALSE(test_ink_drop_->is_hovered());
|
|
|
| event_generator.MoveMouseTo(in_bounds_point);
|
| - EXPECT_TRUE(button_->test_ink_drop_delegate()->is_hovered());
|
| + EXPECT_TRUE(test_ink_drop_->is_hovered());
|
|
|
| event_generator.MoveMouseTo(out_of_bounds_point);
|
| - EXPECT_FALSE(button_->test_ink_drop_delegate()->is_hovered());
|
| + EXPECT_FALSE(test_ink_drop_->is_hovered());
|
| }
|
|
|
| // Verifies the target event handler View is the |LabelButton| and not any of
|
|
|