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

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

Issue 674163003: MenuButtons enter Hover state upon Tap Down (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | « ui/views/controls/button/menu_button.cc ('k') | no next file » | 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 b75a55a75fd21a9cf98b33a66c8adb8c47a2d24f..355d1d0a67b53589f6f9b21bd02c886e08528eeb 100644
--- a/ui/views/controls/button/menu_button_unittest.cc
+++ b/ui/views/controls/button/menu_button_unittest.cc
@@ -4,9 +4,11 @@
#include "ui/views/controls/button/menu_button.h"
+#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/base/dragdrop/drag_drop_types.h"
+#include "ui/base/ui_base_switches.h"
#include "ui/events/test/event_generator.h"
#include "ui/views/controls/button/menu_button_listener.h"
#include "ui/views/drag_controller.h"
@@ -27,6 +29,12 @@ class MenuButtonTest : public ViewsTestBase {
MenuButtonTest() : widget_(nullptr), button_(nullptr) {}
virtual ~MenuButtonTest() {}
+ void SetUp() override {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableTouchFeedback);
+ ViewsTestBase::SetUp();
+ }
+
void TearDown() override {
if (widget_ && !widget_->IsClosed())
widget_->Close();
@@ -390,4 +398,34 @@ TEST_F(MenuButtonTest, DraggableMenuButtonDoesNotActivateOnDrag) {
}
#endif
+// Tests that the button enters a hovered state upon a tap down, before becoming
+// pressed at activation.
+TEST_F(MenuButtonTest, TouchFeedbackDuringTap) {
+ TestMenuButtonListener menu_button_listener;
+ CreateMenuButtonWithMenuButtonListener(&menu_button_listener);
+ ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow());
+ generator.set_current_location(gfx::Point(10, 10));
+ generator.PressTouch();
+ EXPECT_EQ(Button::STATE_HOVERED, button()->state());
+
+ generator.ReleaseTouch();
+ EXPECT_EQ(Button::STATE_PRESSED, menu_button_listener.last_source_state());
+}
+
+// Tests that a move event that exits the button returns it to the normal state,
+// and that the button did not activate the listener.
+TEST_F(MenuButtonTest, TouchFeedbackDuringTapCancel) {
+ TestMenuButtonListener menu_button_listener;
+ CreateMenuButtonWithMenuButtonListener(&menu_button_listener);
+ ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow());
+ generator.set_current_location(gfx::Point(10, 10));
+ generator.PressTouch();
+ EXPECT_EQ(Button::STATE_HOVERED, button()->state());
+
+ generator.MoveTouch(gfx::Point(10, 30));
+ generator.ReleaseTouch();
+ EXPECT_EQ(Button::STATE_NORMAL, button()->state());
+ EXPECT_EQ(nullptr, menu_button_listener.last_source());
+}
+
} // namespace views
« no previous file with comments | « ui/views/controls/button/menu_button.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698