Commit 1efe4cfa authored by Charlene Yan's avatar Charlene Yan Committed by Commit Bot

Fix HoverButton to correctly notify on mouse release.

This mirror's MenuButton's implementation.

Bug: 995182
Change-Id: I98f64d067980aed77a666fd8491c52b49d234da4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1760143
Commit-Queue: Charlene Yan <cyan@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688313}
parent 9da26acc
......@@ -60,13 +60,6 @@ class ExtensionsMenuButtonTest : public BrowserWithTestWindowTest {
BrowserWithTestWindowTest::TearDown();
}
void TriggerNotifyClick() {
ui::MouseEvent click_event(ui::ET_MOUSE_RELEASED, gfx::Point(),
gfx::Point(), base::TimeTicks(),
ui::EF_LEFT_MOUSE_BUTTON, 0);
button_->button_controller()->OnMouseReleased(click_event);
}
base::test::ScopedFeatureList scoped_feature_list_;
const base::string16 initial_extension_name_;
const base::string16 initial_tooltip_;
......@@ -86,7 +79,14 @@ TEST_F(ExtensionsMenuButtonTest, UpdatesToDisplayCorrectActionTitle) {
TEST_F(ExtensionsMenuButtonTest, NotifyClickExecutesAction) {
EXPECT_EQ(0, controller_->execute_action_count());
TriggerNotifyClick();
button_->SetBounds(0, 0, 100, 100);
ui::MouseEvent click_event(ui::ET_MOUSE_RELEASED,
button_->GetLocalBounds().CenterPoint(),
button_->GetLocalBounds().CenterPoint(),
base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0);
button_->button_controller()->OnMouseReleased(click_event);
EXPECT_EQ(1, controller_->execute_action_count());
}
......
......@@ -53,7 +53,9 @@ bool HoverButtonController::OnMousePressed(const ui::MouseEvent& event) {
void HoverButtonController::OnMouseReleased(const ui::MouseEvent& event) {
DCHECK(notify_action() ==
views::ButtonController::NotifyAction::NOTIFY_ON_RELEASE);
if (button()->state() != views::Button::STATE_DISABLED) {
if (button()->state() != views::Button::STATE_DISABLED &&
delegate()->IsTriggerableEvent(event) &&
button()->HitTestPoint(event.location()) && !delegate()->InDrag()) {
if (listener_)
listener_->ButtonPressed(button(), event);
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment