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

Unified Diff: ui/views/controls/button/label_button_unittest.cc

Issue 2041033002: Moved ButtonInkDropDelegate logic into InkDropHostView and deleted InkDropDelegates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed merge conflict in custom_button.cc Created 4 years, 6 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 | « ui/views/controls/button/custom_button_unittest.cc ('k') | ui/views/controls/button/md_text_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/views/controls/button/custom_button_unittest.cc ('k') | ui/views/controls/button/md_text_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698