Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/files/file_path.h" | |
| 6 #include "base/macros.h" | |
| 7 #include "base/run_loop.h" | |
| 8 #include "base/strings/utf_string_conversions.h" | |
| 9 #include "build/build_config.h" | |
| 10 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" | |
| 11 #include "chrome/browser/renderer_context_menu/render_view_context_menu_browsert est_util.h" | |
| 12 #include "chrome/browser/ui/browser.h" | |
| 13 #include "chrome/browser/ui/browser_commands.h" | |
| 14 #include "chrome/browser/ui/browser_finder.h" | |
| 15 #include "chrome/browser/ui/browser_window.h" | |
| 16 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h" | |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 18 #include "chrome/test/base/in_process_browser_test.h" | |
| 19 #include "chrome/test/base/ui_test_utils.h" | |
| 20 #include "content/public/browser/render_frame_host.h" | |
| 21 #include "content/public/browser/web_contents.h" | |
| 22 #include "content/public/test/browser_test_utils.h" | |
| 23 #include "ui/base/test/ui_controls.h" | |
| 24 | |
| 25 #if defined(OS_WIN) | |
| 26 #include "base/win/windows_version.h" | |
| 27 #endif | |
| 28 | |
| 29 namespace { | |
| 30 | |
| 31 class TouchEventsTest : public InProcessBrowserTest { | |
| 32 public: | |
| 33 TouchEventsTest() {} | |
| 34 | |
| 35 void LoadTestPageAndWaitForMouseOver(content::WebContents* tab) { | |
| 36 gfx::Rect tab_view_bounds = tab->GetContainerBounds(); | |
| 37 GURL test_url = ui_test_utils::GetTestUrl( | |
| 38 base::FilePath(), | |
| 39 base::FilePath(FILE_PATH_LITERAL("touchevents.html"))); | |
| 40 | |
| 41 gfx::Point in_content(tab_view_bounds.x() + tab_view_bounds.width() / 2, | |
| 42 tab_view_bounds.y() + 10); | |
| 43 // Navigate to the test html page. | |
| 44 base::string16 load_expected_title(base::ASCIIToUTF16("onload")); | |
| 45 content::TitleWatcher load_title_watcher(tab, load_expected_title); | |
| 46 ui_test_utils::NavigateToURL(browser(), test_url); | |
| 47 // Wait for the onload() handler to complete so we can do the | |
| 48 // next part of the test. | |
| 49 EXPECT_EQ(load_expected_title, load_title_watcher.WaitAndGetTitle()); | |
| 50 } | |
| 51 | |
| 52 private: | |
| 53 DISALLOW_COPY_AND_ASSIGN(TouchEventsTest); | |
| 54 }; | |
| 55 | |
| 56 #if defined(OS_WIN) | |
| 57 IN_PROC_BROWSER_TEST_F(TouchEventsTest, TestNativeTouchEvents) { | |
|
sky
2017/06/22 20:54:21
Why is this test necessary? The test you are writi
lanwei
2017/06/23 20:06:05
I removed it, just keep the touch_events_interacti
| |
| 58 // InjectTouchInput works on Windows 8 and up. | |
| 59 if (base::win::GetVersion() <= base::win::VERSION_WIN7) | |
| 60 return; | |
| 61 | |
| 62 content::WebContents* tab = | |
| 63 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 64 | |
| 65 EXPECT_NO_FATAL_FAILURE(LoadTestPageAndWaitForMouseOver(tab)); | |
| 66 | |
| 67 gfx::Rect tab_view_bounds = tab->GetContainerBounds(); | |
| 68 gfx::Point in_content(tab_view_bounds.x() + tab_view_bounds.width() / 2, | |
| 69 tab_view_bounds.y() + 10); | |
| 70 ui_controls::SendTouchEvents( | |
| 71 ui_controls::PRESS | ui_controls::MOVE | ui_controls::RELEASE, 1, | |
| 72 in_content.x(), in_content.y()); | |
| 73 | |
| 74 // Wait on the correct title. | |
| 75 base::string16 down_expected_title(base::ASCIIToUTF16("pointerdown")); | |
| 76 content::TitleWatcher down_title_watcher(tab, down_expected_title); | |
| 77 EXPECT_EQ(down_expected_title, down_title_watcher.WaitAndGetTitle()); | |
| 78 | |
| 79 base::string16 move_expected_title(base::ASCIIToUTF16("pointermove")); | |
| 80 content::TitleWatcher move_title_watcher(tab, move_expected_title); | |
| 81 EXPECT_EQ(move_expected_title, move_title_watcher.WaitAndGetTitle()); | |
| 82 | |
| 83 base::string16 up_expected_title(base::ASCIIToUTF16("pointerup")); | |
| 84 content::TitleWatcher up_title_watcher(tab, up_expected_title); | |
| 85 EXPECT_EQ(up_expected_title, up_title_watcher.WaitAndGetTitle()); | |
| 86 } | |
| 87 #endif | |
| 88 | |
| 89 } // namespace | |
| OLD | NEW |