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

Side by Side Diff: content/browser/renderer_host/input/web_input_event_unittest.cc

Issue 981393002: Second attempt at fixing pointer lock issues with Windows HiDPI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added the files for the test Created 5 years, 9 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 2015 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/command_line.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "third_party/WebKit/public/web/WebInputEvent.h"
8 #include "ui/events/event_constants.h"
9 #include "ui/gfx/switches.h"
10
11 #if defined(OS_WIN)
12 #include "base/win/windows_version.h"
13 #include "content/browser/renderer_host/input/web_input_event_builders_win.h"
14 #endif
15
16 using blink::WebMouseEvent;
17
18 namespace content {
19
20 #if defined(OS_WIN)
21 // This test validates that Pixel to DIP conversion occurs as needed in the
22 // WebMouseEventBuilder::Build function.
23 TEST(WebInputEventBuilderTest, TestMouseEventScale) {
24 if (base::win::GetVersion() < base::win::VERSION_WIN7)
25 return;
26
27 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
28 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "2");
29
30 // Synthesize a mouse move with x = 300 and y = 200.
31 WebMouseEvent mouse_move =
32 WebMouseEventBuilder::Build(::GetDesktopWindow(), WM_MOUSEMOVE, 0,
33 MAKELPARAM(300, 200), 100);
34
35 // The WebMouseEvent.x, WebMouseEvent.y, WebMouseEvent.windowX and
36 // WebMouseEvent.windowY fields should be in pixels on return and hence
37 // should be the same value as the x and y coordinates passed in to the
38 // WebMouseEventBuilder::Build function.
39 EXPECT_EQ(300, mouse_move.x);
40 EXPECT_EQ(200, mouse_move.y);
41
42 EXPECT_EQ(300, mouse_move.windowX);
43 EXPECT_EQ(200, mouse_move.windowY);
44
45 // WebMouseEvent.globalX and WebMouseEvent.globalY are calculated in DIPs.
46 EXPECT_EQ(150, mouse_move.globalX);
47 EXPECT_EQ(100, mouse_move.globalY);
48
49 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1");
50 }
51 #endif
52
53 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698