Chromium Code Reviews| 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..36cfc275c03deaaf1b68b6cb11cbe94380b0e50a 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,38 @@ 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); |
| + gfx::Point right_point(combobox_->x() + combobox_->width() - 1, |
|
tapted
2016/06/29 12:02:55
nit: const gfx::Point right_point
spqchan
2016/06/29 18:29:14
Done.
|
| + combobox_->y() + combobox_->height() / 2); |
| + |
| EXPECT_EQ(0, menu_show_count); |
| - PerformClick(gfx::Point(combobox_->x() + combobox_->width() - 1, |
| - combobox_->y() + combobox_->height() / 2)); |
| + |
| +// Since the menu appears on a mouse press on Mac, we need to check between |
| +// the mouse press and release on that platform. |
| +#if defined(OS_MACOSX) |
|
tapted
2016/06/29 12:02:55
I'd structure this something like the following. T
spqchan
2016/06/29 18:29:14
Done.
|
| + PerformMousePress(right_point); |
| + EXPECT_FALSE(listener.on_perform_action_called()); |
| + PerformMouseRelease(right_point); |
| +#else |
| + PerformClick(right_point); |
| EXPECT_FALSE(listener.on_perform_action_called()); |
| +#endif |
| + |
| EXPECT_EQ(1, menu_show_count); |
| // Click the left side (text button). The click event is notified. |
| + gfx::Point left_point( |
|
tapted
2016/06/29 12:02:55
nit: const
spqchan
2016/06/29 18:29:14
Done.
|
| + 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)); |
| + |
| +#if defined(OS_MACOSX) |
| + PerformMousePress(left_point); |
| + EXPECT_TRUE(listener.on_perform_action_called()); |
| + PerformMouseRelease(left_point); |
| +#else |
| + PerformClick(left_point); |
| EXPECT_TRUE(listener.on_perform_action_called()); |
| +#endif |
| + |
| EXPECT_EQ(1, menu_show_count); // Unchanged. |
| EXPECT_EQ(0, listener.perform_action_index()); |
| } |