Chromium Code Reviews| Index: chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc |
| diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc |
| index 58d8156b472df2335565122184c6482d630c3f3d..22fbd8c1ce1000c0ffda656b2a0c298ed84b3409 100644 |
| --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc |
| +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc |
| @@ -56,6 +56,7 @@ |
| #include "ui/views/widget/widget.h" |
| #if defined(OS_WIN) |
| +#include "base/win/windows_version.h" |
| #include "ui/aura/window_tree_host.h" |
| #endif |
| @@ -229,6 +230,48 @@ class TestingPageNavigator : public PageNavigator { |
| DISALLOW_COPY_AND_ASSIGN(TestingPageNavigator); |
| }; |
| +class TouchEventHandler : public ui::EventHandler { |
| + public: |
| + TouchEventHandler() : num_touch_presses_(0), num_touches_(0) {} |
| + |
| + ~TouchEventHandler() override {} |
| + |
| + void WaitForEvents() { |
| + base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
| + base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); |
| + base::RunLoop run_loop; |
| + quit_closure_ = run_loop.QuitClosure(); |
| + run_loop.Run(); |
| + } |
| + |
| + int num_touch_presses() const { return num_touch_presses_; } |
| + |
| + int num_touches() const { return num_touches_; } |
| + |
| + private: |
| + // ui::EventHandler: |
| + void OnTouchEvent(ui::TouchEvent* event) override { |
| + switch (event->type()) { |
| + case ui::ET_TOUCH_PRESSED: |
| + num_touch_presses_++; |
| + num_touches_++; |
| + break; |
| + case ui::ET_TOUCH_RELEASED: |
| + num_touches_--; |
| + if (!quit_closure_.is_null() && num_touches_ == 0) |
| + quit_closure_.Run(); |
| + break; |
| + default: |
| + break; |
| + } |
| + } |
| + |
| + int num_touch_presses_; |
| + int num_touches_; |
| + base::Closure quit_closure_; |
| + DISALLOW_COPY_AND_ASSIGN(TouchEventHandler); |
| +}; |
| + |
| // TODO(erg): Fix bookmark DND tests on linux_aura. crbug.com/163931 |
| #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| #define MAYBE(x) DISABLED_##x |
| @@ -2385,3 +2428,38 @@ class BookmarkBarViewTest27 : public BookmarkBarViewEventTestBase { |
| }; |
| VIEW_TEST(BookmarkBarViewTest27, MiddleClickOnFolderOpensAllBookmarks); |
| + |
| +#if defined(OS_WIN) |
| +class BookmarkBarViewTest28 : public BookmarkBarViewEventTestBase { |
|
sky
2017/06/22 20:54:21
This test has *nothing* to do with bookmark bars,
lanwei
2017/06/23 20:06:05
Done.
|
| + protected: |
| + void DoTestOnMessageLoop() override { |
| + views::LabelButton* button = GetBookmarkButton(0); |
| + GetWidget()->GetNativeWindow()->GetHost()->window()->AddPreTargetHandler( |
| + &touch_event_handler_); |
| + |
| + gfx::Point in_content(button->width() / 2, button->height() / 2); |
| + views::View::ConvertPointToScreen(button, &in_content); |
| + ui_controls::SendTouchEventsNotifyWhenDone( |
| + ui_controls::PRESS, 3, in_content.x(), in_content.y(), |
| + CreateEventTask(this, &BookmarkBarViewTest28::Step2)); |
| + } |
| + |
| + private: |
| + void Step2() { |
| + if (base::win::GetVersion() <= base::win::VERSION_WIN7) { |
| + Done(); |
| + return; |
| + } |
| + |
| + touch_event_handler_.WaitForEvents(); |
| + ASSERT_EQ(3, touch_event_handler_.num_touch_presses()); |
| + ASSERT_EQ(0, touch_event_handler_.num_touches()); |
| + GetWidget()->GetNativeWindow()->GetHost()->window()->RemovePreTargetHandler( |
| + &touch_event_handler_); |
| + Done(); |
| + } |
| + TouchEventHandler touch_event_handler_; |
| +}; |
| + |
| +VIEW_TEST(BookmarkBarViewTest28, CheckWindowsNativeMessageForTouchEvents); |
| +#endif |