OLD | NEW |
(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 |
OLD | NEW |