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

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

Issue 1682603002: [UI Views] Don't allow a ButtonListener and a MenuButtonListener (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 4 years, 10 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/menu_button.cc ('k') | ui/views/examples/menu_example.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/menu_button_unittest.cc
diff --git a/ui/views/controls/button/menu_button_unittest.cc b/ui/views/controls/button/menu_button_unittest.cc
index 8d554c9e5f7a637ad32507959ce33fbbc9032fb1..a260d166ff4bb756c42827091c39e6aae6ce32c6 100644
--- a/ui/views/controls/button/menu_button_unittest.cc
+++ b/ui/views/controls/button/menu_button_unittest.cc
@@ -41,30 +41,22 @@ class MenuButtonTest : public ViewsTestBase {
protected:
// Creates a MenuButton with no button listener.
- void CreateMenuButtonWithNoListener() { CreateMenuButton(nullptr, nullptr); }
-
- // Creates a MenuButton with a ButtonListener. In this case, the MenuButton
- // acts like a regular button.
- void CreateMenuButtonWithButtonListener(ButtonListener* button_listener) {
- CreateMenuButton(button_listener, nullptr);
- }
+ void CreateMenuButtonWithNoListener() { CreateMenuButton(nullptr); }
// Creates a MenuButton with a MenuButtonListener. In this case, when the
// MenuButton is pushed, it notifies the MenuButtonListener to open a
// drop-down menu.
void CreateMenuButtonWithMenuButtonListener(
MenuButtonListener* menu_button_listener) {
- CreateMenuButton(nullptr, menu_button_listener);
+ CreateMenuButton(menu_button_listener);
}
private:
- void CreateMenuButton(ButtonListener* button_listener,
- MenuButtonListener* menu_button_listener) {
+ void CreateMenuButton(MenuButtonListener* menu_button_listener) {
CreateWidget();
const base::string16 label(ASCIIToUTF16("button"));
- button_ =
- new MenuButton(button_listener, label, menu_button_listener, false);
+ button_ = new MenuButton(label, menu_button_listener, false);
button_->SetBoundsRect(gfx::Rect(0, 0, 200, 20));
widget_->SetContentsView(button_);
@@ -268,24 +260,6 @@ class TestShowSiblingButtonListener : public MenuButtonListener {
DISALLOW_COPY_AND_ASSIGN(TestShowSiblingButtonListener);
};
-// Tests if the listener is notified correctly, when a mouse click happens on a
-// MenuButton that has a regular ButtonListener.
-TEST_F(MenuButtonTest, ActivateNonDropDownOnMouseClick) {
- TestButtonListener button_listener;
- CreateMenuButtonWithButtonListener(&button_listener);
-
- ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow());
-
- generator.set_current_location(gfx::Point(10, 10));
- generator.ClickLeftButton();
-
- // Check that MenuButton has notified the listener on mouse-released event,
- // while it was in hovered state.
- EXPECT_EQ(button(), button_listener.last_sender());
- EXPECT_EQ(ui::ET_MOUSE_RELEASED, button_listener.last_event_type());
- EXPECT_EQ(Button::STATE_HOVERED, button_listener.last_sender_state());
-}
-
// Tests if the listener is notified correctly when a mouse click happens on a
// MenuButton that has a MenuButtonListener.
TEST_F(MenuButtonTest, ActivateDropDownOnMouseClick) {
@@ -424,31 +398,6 @@ TEST_F(MenuButtonTest, DraggableMenuButtonDoesNotActivateOnDrag) {
#if !defined(OS_MACOSX) || defined(USE_AURA)
// Tests if the listener is notified correctly when a gesture tap happens on a
-// MenuButton that has a regular ButtonListener.
-TEST_F(MenuButtonTest, ActivateNonDropDownOnGestureTap) {
- TestButtonListener button_listener;
- CreateMenuButtonWithButtonListener(&button_listener);
-
- ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow());
-
- // Move the mouse outside the menu button so that it doesn't impact the
- // button state.
- generator.MoveMouseTo(400, 400);
- EXPECT_FALSE(button()->IsMouseHovered());
-
- generator.GestureTapAt(gfx::Point(10, 10));
-
- // Check that MenuButton has notified the listener on gesture tap event, while
- // it was in hovered state.
- EXPECT_EQ(button(), button_listener.last_sender());
- EXPECT_EQ(ui::ET_GESTURE_TAP, button_listener.last_event_type());
- EXPECT_EQ(Button::STATE_HOVERED, button_listener.last_sender_state());
-
- // The button should go back to it's normal state since the gesture ended.
- EXPECT_EQ(Button::STATE_NORMAL, button()->state());
-}
-
-// Tests if the listener is notified correctly when a gesture tap happens on a
// MenuButton that has a MenuButtonListener.
TEST_F(MenuButtonTest, ActivateDropDownOnGestureTap) {
TestMenuButtonListener menu_button_listener;
« no previous file with comments | « ui/views/controls/button/menu_button.cc ('k') | ui/views/examples/menu_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698