Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "third_party/WebKit/public/web/WebInputEvent.h" | 8 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 9 #include "ui/display/display.h" | 9 #include "ui/display/display.h" |
| 10 #include "ui/display/display_switches.h" | 10 #include "ui/display/display_switches.h" |
| 11 #include "ui/events/event_constants.h" | 11 #include "ui/events/event_constants.h" |
| 12 | 12 |
| 13 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
| 14 #include "base/win/windows_version.h" | 14 #include "base/win/windows_version.h" |
| 15 #include "content/browser/renderer_host/input/web_input_event_builders_win.h" | 15 #include "ui/events/blink/web_input_event_builders_win.h" |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 using blink::WebMouseEvent; | 18 using blink::WebMouseEvent; |
| 19 using blink::WebMouseWheelEvent; | 19 using blink::WebMouseWheelEvent; |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
|
sadrul
2016/08/15 15:55:13
Remove the ifdefs from this file, and include this
jonross
2016/08/16 15:25:16
Done.
| |
| 24 // This test validates that Pixel to DIP conversion occurs as needed in the | 24 // This test validates that Pixel to DIP conversion occurs as needed in the |
| 25 // WebMouseEventBuilder::Build function. | 25 // WebMouseEventBuilder::Build function. |
| 26 TEST(WebInputEventBuilderTest, TestMouseEventScale) { | 26 TEST(WebInputEventBuilderTest, TestMouseEventScale) { |
| 27 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 27 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 28 return; | 28 return; |
| 29 | 29 |
| 30 display::Display::ResetForceDeviceScaleFactorForTesting(); | 30 display::Display::ResetForceDeviceScaleFactorForTesting(); |
| 31 | 31 |
| 32 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 32 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 33 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "2"); | 33 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "2"); |
| 34 | 34 |
| 35 // Synthesize a mouse move with x = 300 and y = 200. | 35 // Synthesize a mouse move with x = 300 and y = 200. |
| 36 WebMouseEvent mouse_move = WebMouseEventBuilder::Build( | 36 WebMouseEvent mouse_move = ui::WebMouseEventBuilder::Build( |
| 37 ::GetDesktopWindow(), WM_MOUSEMOVE, 0, MAKELPARAM(300, 200), 100, | 37 ::GetDesktopWindow(), WM_MOUSEMOVE, 0, MAKELPARAM(300, 200), 100, |
| 38 blink::WebPointerProperties::PointerType::Mouse); | 38 blink::WebPointerProperties::PointerType::Mouse); |
| 39 | 39 |
| 40 // The WebMouseEvent.x, WebMouseEvent.y, WebMouseEvent.windowX and | 40 // The WebMouseEvent.x, WebMouseEvent.y, WebMouseEvent.windowX and |
| 41 // WebMouseEvent.windowY fields should be in pixels on return and hence | 41 // WebMouseEvent.windowY fields should be in pixels on return and hence |
| 42 // should be the same value as the x and y coordinates passed in to the | 42 // should be the same value as the x and y coordinates passed in to the |
| 43 // WebMouseEventBuilder::Build function. | 43 // WebMouseEventBuilder::Build function. |
| 44 EXPECT_EQ(300, mouse_move.x); | 44 EXPECT_EQ(300, mouse_move.x); |
| 45 EXPECT_EQ(200, mouse_move.y); | 45 EXPECT_EQ(200, mouse_move.y); |
| 46 | 46 |
| 47 EXPECT_EQ(300, mouse_move.windowX); | 47 EXPECT_EQ(300, mouse_move.windowX); |
| 48 EXPECT_EQ(200, mouse_move.windowY); | 48 EXPECT_EQ(200, mouse_move.windowY); |
| 49 | 49 |
| 50 // WebMouseEvent.globalX and WebMouseEvent.globalY are calculated in DIPs. | 50 // WebMouseEvent.globalX and WebMouseEvent.globalY are calculated in DIPs. |
| 51 EXPECT_EQ(150, mouse_move.globalX); | 51 EXPECT_EQ(150, mouse_move.globalX); |
| 52 EXPECT_EQ(100, mouse_move.globalY); | 52 EXPECT_EQ(100, mouse_move.globalY); |
| 53 | 53 |
| 54 EXPECT_EQ(blink::WebPointerProperties::PointerType::Mouse, | 54 EXPECT_EQ(blink::WebPointerProperties::PointerType::Mouse, |
| 55 mouse_move.pointerType); | 55 mouse_move.pointerType); |
| 56 | 56 |
| 57 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1"); | 57 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1"); |
| 58 display::Display::ResetForceDeviceScaleFactorForTesting(); | 58 display::Display::ResetForceDeviceScaleFactorForTesting(); |
| 59 } | 59 } |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 } // namespace content | 62 } // namespace content |
| OLD | NEW |