Chromium Code Reviews| Index: chrome/browser/touchevents_browsertest.cc |
| diff --git a/chrome/browser/touchevents_browsertest.cc b/chrome/browser/touchevents_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f279b054928063a663ef30408929d0e02dc0519f |
| --- /dev/null |
| +++ b/chrome/browser/touchevents_browsertest.cc |
| @@ -0,0 +1,88 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/files/file_path.h" |
| +#include "base/macros.h" |
| +#include "base/run_loop.h" |
| +#include "base/strings/utf_string_conversions.h" |
| +#include "build/build_config.h" |
| +#include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
| +#include "chrome/browser/renderer_context_menu/render_view_context_menu_browsertest_util.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/browser_commands.h" |
| +#include "chrome/browser/ui/browser_finder.h" |
| +#include "chrome/browser/ui/browser_window.h" |
| +#include "chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h" |
| +#include "chrome/browser/ui/tabs/tab_strip_model.h" |
| +#include "chrome/test/base/in_process_browser_test.h" |
| +#include "chrome/test/base/ui_test_utils.h" |
| +#include "content/public/browser/render_frame_host.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "content/public/test/browser_test_utils.h" |
| +#include "ui/base/test/ui_controls.h" |
| + |
| +#if defined(OS_WIN) |
| +#include "base/win/windows_version.h" |
| +#endif |
| + |
| +namespace { |
| + |
| +class TouchEventsTest : public InProcessBrowserTest { |
| + public: |
| + TouchEventsTest() {} |
| + |
| + void LoadTestPageAndWaitForMouseOver(content::WebContents* tab) { |
| + gfx::Rect tab_view_bounds = tab->GetContainerBounds(); |
| + GURL test_url = ui_test_utils::GetTestUrl( |
| + base::FilePath(), |
| + base::FilePath(FILE_PATH_LITERAL("touchevents.html"))); |
| + |
| + gfx::Point in_content(tab_view_bounds.x() + tab_view_bounds.width() / 2, |
| + tab_view_bounds.y() + 10); |
| + // Navigate to the test html page. |
| + base::string16 load_expected_title(base::ASCIIToUTF16("onload")); |
| + content::TitleWatcher load_title_watcher(tab, load_expected_title); |
| + ui_test_utils::NavigateToURL(browser(), test_url); |
| + // Wait for the onload() handler to complete so we can do the |
| + // next part of the test. |
| + EXPECT_EQ(load_expected_title, load_title_watcher.WaitAndGetTitle()); |
| + } |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TouchEventsTest); |
|
sky
2017/06/07 19:42:45
private:
lanwei
2017/06/22 18:38:45
Done.
|
| +}; |
| + |
| +#if defined(OS_WIN) |
|
sky
2017/06/07 19:42:45
Make it so this file is only built for windows.
lanwei
2017/06/22 18:38:45
Yes, because we only test WM_POINTER on Windows.
sky
2017/06/22 20:54:21
Sorry if it I wasn't clear. The one test you have
|
| +IN_PROC_BROWSER_TEST_F(TouchEventsTest, TestNativeTouchEvents) { |
| + // InjectTouchInput works on Windows 8 and up. |
| + if (base::win::GetVersion() <= base::win::VERSION_WIN7) |
| + return; |
| + |
| + content::WebContents* tab = |
| + browser()->tab_strip_model()->GetActiveWebContents(); |
| + |
| + EXPECT_NO_FATAL_FAILURE(LoadTestPageAndWaitForMouseOver(tab)); |
| + |
| + gfx::Rect tab_view_bounds = tab->GetContainerBounds(); |
| + gfx::Point in_content(tab_view_bounds.x() + tab_view_bounds.width() / 2, |
| + tab_view_bounds.y() + 10); |
| + ui_controls::SendTouchEvents( |
| + ui_controls::PRESS | ui_controls::MOVE | ui_controls::RELEASE, 3, |
| + in_content.x(), in_content.y()); |
| + |
| + // Wait on the correct title. |
| + base::string16 down_expected_title(base::ASCIIToUTF16("pointerdown 3")); |
| + content::TitleWatcher down_title_watcher(tab, down_expected_title); |
| + EXPECT_EQ(down_expected_title, down_title_watcher.WaitAndGetTitle()); |
| + |
| + base::string16 move_expected_title(base::ASCIIToUTF16("pointermove")); |
| + content::TitleWatcher move_title_watcher(tab, move_expected_title); |
| + EXPECT_EQ(move_expected_title, move_title_watcher.WaitAndGetTitle()); |
| + |
| + base::string16 up_expected_title(base::ASCIIToUTF16("pointerup")); |
| + content::TitleWatcher up_title_watcher(tab, up_expected_title); |
| + EXPECT_EQ(up_expected_title, up_title_watcher.WaitAndGetTitle()); |
| +} |
| +#endif |
| + |
| +} // namespace |