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

Unified Diff: ui/views/controls/combobox/combobox_unittest.cc

Issue 2070623003: [MacViews] Show combobox menu popup at mouse press (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test Created 4 years, 5 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/combobox/combobox.cc ('k') | ui/views/style/platform_style.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/combobox/combobox_unittest.cc
diff --git a/ui/views/controls/combobox/combobox_unittest.cc b/ui/views/controls/combobox/combobox_unittest.cc
index 8d585c63a94d1da3389929a29e5d4047ec7f362b..ea81193011ccb0beb9a4859d28330f18067974fe 100644
--- a/ui/views/controls/combobox/combobox_unittest.cc
+++ b/ui/views/controls/combobox/combobox_unittest.cc
@@ -233,17 +233,25 @@ class ComboboxTest : public ViewsTestBase {
return widget_->GetFocusManager()->GetFocusedView();
}
- void PerformClick(const gfx::Point& point) {
+ void PerformMousePress(const gfx::Point& point) {
ui::MouseEvent pressed_event = ui::MouseEvent(
ui::ET_MOUSE_PRESSED, point, point, ui::EventTimeForNow(),
ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
widget_->OnMouseEvent(&pressed_event);
+ }
+
+ void PerformMouseRelease(const gfx::Point& point) {
ui::MouseEvent released_event = ui::MouseEvent(
ui::ET_MOUSE_RELEASED, point, point, ui::EventTimeForNow(),
ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
widget_->OnMouseEvent(&released_event);
}
+ void PerformClick(const gfx::Point& point) {
+ PerformMousePress(point);
+ PerformMouseRelease(point);
+ }
+
// We need widget to populate wrapper class.
Widget* widget_;
@@ -586,17 +594,31 @@ TEST_F(ComboboxTest, NotifyOnClickWithMouse) {
// Click the right side (arrow button). The menu is shown.
int menu_show_count = 0;
test_api_->InstallTestMenuRunner(&menu_show_count);
+ const gfx::Point right_point(combobox_->x() + combobox_->width() - 1,
+ combobox_->y() + combobox_->height() / 2);
+
EXPECT_EQ(0, menu_show_count);
- PerformClick(gfx::Point(combobox_->x() + combobox_->width() - 1,
- combobox_->y() + combobox_->height() / 2));
- EXPECT_FALSE(listener.on_perform_action_called());
+
+// On Mac, actions occur on mouse down. Otherwise mouse up.
+#if defined(OS_MACOSX)
+ const int kActOnMouseDown = 1;
+#else
+ const int kActOnMouseDown = 0;
+#endif
+
+ PerformMousePress(right_point);
+ EXPECT_EQ(kActOnMouseDown, menu_show_count);
+ PerformMouseRelease(right_point);
EXPECT_EQ(1, menu_show_count);
// Click the left side (text button). The click event is notified.
+ const gfx::Point left_point(
+ gfx::Point(combobox_->x() + 1, combobox_->y() + combobox_->height() / 2));
test_api_->InstallTestMenuRunner(&menu_show_count);
- PerformClick(gfx::Point(combobox_->x() + 1,
- combobox_->y() + combobox_->height() / 2));
- EXPECT_TRUE(listener.on_perform_action_called());
+
+ PerformMousePress(left_point);
+ PerformMouseRelease(left_point);
+
EXPECT_EQ(1, menu_show_count); // Unchanged.
EXPECT_EQ(0, listener.perform_action_index());
}
« no previous file with comments | « ui/views/controls/combobox/combobox.cc ('k') | ui/views/style/platform_style.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698