Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1014)

Side by Side Diff: chrome/browser/touchevents_browsertest.cc

Issue 2904113002: Replacing WM_TOUCH with WM_POINTER for touch events on Wins 8+ (Closed)
Patch Set: Add a browser test Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
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 DISALLOW_COPY_AND_ASSIGN(TouchEventsTest);
sky 2017/06/07 19:42:45 private:
lanwei 2017/06/22 18:38:45 Done.
53 };
54
55 #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
56 IN_PROC_BROWSER_TEST_F(TouchEventsTest, TestNativeTouchEvents) {
57 // InjectTouchInput works on Windows 8 and up.
58 if (base::win::GetVersion() <= base::win::VERSION_WIN7)
59 return;
60
61 content::WebContents* tab =
62 browser()->tab_strip_model()->GetActiveWebContents();
63
64 EXPECT_NO_FATAL_FAILURE(LoadTestPageAndWaitForMouseOver(tab));
65
66 gfx::Rect tab_view_bounds = tab->GetContainerBounds();
67 gfx::Point in_content(tab_view_bounds.x() + tab_view_bounds.width() / 2,
68 tab_view_bounds.y() + 10);
69 ui_controls::SendTouchEvents(
70 ui_controls::PRESS | ui_controls::MOVE | ui_controls::RELEASE, 3,
71 in_content.x(), in_content.y());
72
73 // Wait on the correct title.
74 base::string16 down_expected_title(base::ASCIIToUTF16("pointerdown 3"));
75 content::TitleWatcher down_title_watcher(tab, down_expected_title);
76 EXPECT_EQ(down_expected_title, down_title_watcher.WaitAndGetTitle());
77
78 base::string16 move_expected_title(base::ASCIIToUTF16("pointermove"));
79 content::TitleWatcher move_title_watcher(tab, move_expected_title);
80 EXPECT_EQ(move_expected_title, move_title_watcher.WaitAndGetTitle());
81
82 base::string16 up_expected_title(base::ASCIIToUTF16("pointerup"));
83 content::TitleWatcher up_title_watcher(tab, up_expected_title);
84 EXPECT_EQ(up_expected_title, up_title_watcher.WaitAndGetTitle());
85 }
86 #endif
87
88 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698