Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 #include "ui/base/clipboard/clipboard.h" | 49 #include "ui/base/clipboard/clipboard.h" |
| 50 #include "ui/base/test/ui_controls.h" | 50 #include "ui/base/test/ui_controls.h" |
| 51 #include "ui/events/keycodes/keyboard_codes.h" | 51 #include "ui/events/keycodes/keyboard_codes.h" |
| 52 #include "ui/views/controls/button/menu_button.h" | 52 #include "ui/views/controls/button/menu_button.h" |
| 53 #include "ui/views/controls/menu/menu_controller.h" | 53 #include "ui/views/controls/menu/menu_controller.h" |
| 54 #include "ui/views/controls/menu/menu_item_view.h" | 54 #include "ui/views/controls/menu/menu_item_view.h" |
| 55 #include "ui/views/controls/menu/submenu_view.h" | 55 #include "ui/views/controls/menu/submenu_view.h" |
| 56 #include "ui/views/widget/widget.h" | 56 #include "ui/views/widget/widget.h" |
| 57 | 57 |
| 58 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
| 59 #include "base/win/windows_version.h" | |
| 59 #include "ui/aura/window_tree_host.h" | 60 #include "ui/aura/window_tree_host.h" |
| 60 #endif | 61 #endif |
| 61 | 62 |
| 62 using base::ASCIIToUTF16; | 63 using base::ASCIIToUTF16; |
| 63 using bookmarks::BookmarkModel; | 64 using bookmarks::BookmarkModel; |
| 64 using bookmarks::BookmarkNode; | 65 using bookmarks::BookmarkNode; |
| 65 using content::BrowserThread; | 66 using content::BrowserThread; |
| 66 using content::OpenURLParams; | 67 using content::OpenURLParams; |
| 67 using content::PageNavigator; | 68 using content::PageNavigator; |
| 68 using content::WebContents; | 69 using content::WebContents; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 | 223 |
| 223 const std::vector<GURL>& urls() const { return urls_; } | 224 const std::vector<GURL>& urls() const { return urls_; } |
| 224 GURL last_url() const { return urls_.empty() ? GURL() : urls_.back(); } | 225 GURL last_url() const { return urls_.empty() ? GURL() : urls_.back(); } |
| 225 | 226 |
| 226 private: | 227 private: |
| 227 std::vector<GURL> urls_; | 228 std::vector<GURL> urls_; |
| 228 | 229 |
| 229 DISALLOW_COPY_AND_ASSIGN(TestingPageNavigator); | 230 DISALLOW_COPY_AND_ASSIGN(TestingPageNavigator); |
| 230 }; | 231 }; |
| 231 | 232 |
| 233 class TouchEventHandler : public ui::EventHandler { | |
| 234 public: | |
| 235 TouchEventHandler() : num_touch_presses_(0), num_touches_(0) {} | |
| 236 | |
| 237 ~TouchEventHandler() override {} | |
| 238 | |
| 239 void WaitForEvents() { | |
| 240 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); | |
| 241 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); | |
| 242 base::RunLoop run_loop; | |
| 243 quit_closure_ = run_loop.QuitClosure(); | |
| 244 run_loop.Run(); | |
| 245 } | |
| 246 | |
| 247 int num_touch_presses() const { return num_touch_presses_; } | |
| 248 | |
| 249 int num_touches() const { return num_touches_; } | |
| 250 | |
| 251 private: | |
| 252 // ui::EventHandler: | |
| 253 void OnTouchEvent(ui::TouchEvent* event) override { | |
| 254 switch (event->type()) { | |
| 255 case ui::ET_TOUCH_PRESSED: | |
| 256 num_touch_presses_++; | |
| 257 num_touches_++; | |
| 258 break; | |
| 259 case ui::ET_TOUCH_RELEASED: | |
| 260 num_touches_--; | |
| 261 if (!quit_closure_.is_null() && num_touches_ == 0) | |
| 262 quit_closure_.Run(); | |
| 263 break; | |
| 264 default: | |
| 265 break; | |
| 266 } | |
| 267 } | |
| 268 | |
| 269 int num_touch_presses_; | |
| 270 int num_touches_; | |
| 271 base::Closure quit_closure_; | |
| 272 DISALLOW_COPY_AND_ASSIGN(TouchEventHandler); | |
| 273 }; | |
| 274 | |
| 232 // TODO(erg): Fix bookmark DND tests on linux_aura. crbug.com/163931 | 275 // TODO(erg): Fix bookmark DND tests on linux_aura. crbug.com/163931 |
| 233 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 276 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 234 #define MAYBE(x) DISABLED_##x | 277 #define MAYBE(x) DISABLED_##x |
| 235 #else | 278 #else |
| 236 #define MAYBE(x) x | 279 #define MAYBE(x) x |
| 237 #endif | 280 #endif |
| 238 | 281 |
| 239 } // namespace | 282 } // namespace |
| 240 | 283 |
| 241 // Base class for event generating bookmark view tests. These test are intended | 284 // Base class for event generating bookmark view tests. These test are intended |
| (...skipping 2136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2378 ASSERT_EQ(2u, navigator_.urls().size()); | 2421 ASSERT_EQ(2u, navigator_.urls().size()); |
| 2379 EXPECT_EQ(navigator_.urls()[0], | 2422 EXPECT_EQ(navigator_.urls()[0], |
| 2380 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url()); | 2423 model_->bookmark_bar_node()->GetChild(0)->GetChild(0)->url()); |
| 2381 EXPECT_EQ(navigator_.urls()[1], | 2424 EXPECT_EQ(navigator_.urls()[1], |
| 2382 model_->bookmark_bar_node()->GetChild(0)->GetChild(2)->url()); | 2425 model_->bookmark_bar_node()->GetChild(0)->GetChild(2)->url()); |
| 2383 Done(); | 2426 Done(); |
| 2384 } | 2427 } |
| 2385 }; | 2428 }; |
| 2386 | 2429 |
| 2387 VIEW_TEST(BookmarkBarViewTest27, MiddleClickOnFolderOpensAllBookmarks); | 2430 VIEW_TEST(BookmarkBarViewTest27, MiddleClickOnFolderOpensAllBookmarks); |
| 2431 | |
| 2432 #if defined(OS_WIN) | |
| 2433 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.
| |
| 2434 protected: | |
| 2435 void DoTestOnMessageLoop() override { | |
| 2436 views::LabelButton* button = GetBookmarkButton(0); | |
| 2437 GetWidget()->GetNativeWindow()->GetHost()->window()->AddPreTargetHandler( | |
| 2438 &touch_event_handler_); | |
| 2439 | |
| 2440 gfx::Point in_content(button->width() / 2, button->height() / 2); | |
| 2441 views::View::ConvertPointToScreen(button, &in_content); | |
| 2442 ui_controls::SendTouchEventsNotifyWhenDone( | |
| 2443 ui_controls::PRESS, 3, in_content.x(), in_content.y(), | |
| 2444 CreateEventTask(this, &BookmarkBarViewTest28::Step2)); | |
| 2445 } | |
| 2446 | |
| 2447 private: | |
| 2448 void Step2() { | |
| 2449 if (base::win::GetVersion() <= base::win::VERSION_WIN7) { | |
| 2450 Done(); | |
| 2451 return; | |
| 2452 } | |
| 2453 | |
| 2454 touch_event_handler_.WaitForEvents(); | |
| 2455 ASSERT_EQ(3, touch_event_handler_.num_touch_presses()); | |
| 2456 ASSERT_EQ(0, touch_event_handler_.num_touches()); | |
| 2457 GetWidget()->GetNativeWindow()->GetHost()->window()->RemovePreTargetHandler( | |
| 2458 &touch_event_handler_); | |
| 2459 Done(); | |
| 2460 } | |
| 2461 TouchEventHandler touch_event_handler_; | |
| 2462 }; | |
| 2463 | |
| 2464 VIEW_TEST(BookmarkBarViewTest28, CheckWindowsNativeMessageForTouchEvents); | |
| 2465 #endif | |
| OLD | NEW |