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

Side by Side Diff: ui/events/blink/web_input_event_builders_win_unittest.cc

Issue 2234023002: Refactor WebInputEventAura to ui/events/blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/win/windows_version.h"
6 #include "build/build_config.h" 7 #include "build/build_config.h"
7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/WebKit/public/web/WebInputEvent.h" 9 #include "third_party/WebKit/public/platform/WebInputEvent.h"
9 #include "ui/display/display.h" 10 #include "ui/display/display.h"
10 #include "ui/display/display_switches.h" 11 #include "ui/display/display_switches.h"
12 #include "ui/events/blink/web_input_event_builders_win.h"
11 #include "ui/events/event_constants.h" 13 #include "ui/events/event_constants.h"
12 14
13 #if defined(OS_WIN)
14 #include "base/win/windows_version.h"
15 #include "content/browser/renderer_host/input/web_input_event_builders_win.h"
16 #endif
17
18 using blink::WebMouseEvent; 15 using blink::WebMouseEvent;
19 using blink::WebMouseWheelEvent; 16 using blink::WebMouseWheelEvent;
20 17
21 namespace content { 18 namespace ui {
22 19
23 #if defined(OS_WIN)
24 // This test validates that Pixel to DIP conversion occurs as needed in the 20 // This test validates that Pixel to DIP conversion occurs as needed in the
25 // WebMouseEventBuilder::Build function. 21 // WebMouseEventBuilder::Build function.
26 TEST(WebInputEventBuilderTest, TestMouseEventScale) { 22 TEST(WebInputEventBuilderTest, TestMouseEventScale) {
27 if (base::win::GetVersion() < base::win::VERSION_WIN7) 23 if (base::win::GetVersion() < base::win::VERSION_WIN7)
28 return; 24 return;
29 25
30 display::Display::ResetForceDeviceScaleFactorForTesting(); 26 display::Display::ResetForceDeviceScaleFactorForTesting();
31 27
32 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 28 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
33 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "2"); 29 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "2");
34 30
35 // Synthesize a mouse move with x = 300 and y = 200. 31 // Synthesize a mouse move with x = 300 and y = 200.
36 WebMouseEvent mouse_move = WebMouseEventBuilder::Build( 32 WebMouseEvent mouse_move = ui::WebMouseEventBuilder::Build(
37 ::GetDesktopWindow(), WM_MOUSEMOVE, 0, MAKELPARAM(300, 200), 100, 33 ::GetDesktopWindow(), WM_MOUSEMOVE, 0, MAKELPARAM(300, 200), 100,
38 blink::WebPointerProperties::PointerType::Mouse); 34 blink::WebPointerProperties::PointerType::Mouse);
39 35
40 // The WebMouseEvent.x, WebMouseEvent.y, WebMouseEvent.windowX and 36 // The WebMouseEvent.x, WebMouseEvent.y, WebMouseEvent.windowX and
41 // WebMouseEvent.windowY fields should be in pixels on return and hence 37 // 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 38 // should be the same value as the x and y coordinates passed in to the
43 // WebMouseEventBuilder::Build function. 39 // WebMouseEventBuilder::Build function.
44 EXPECT_EQ(300, mouse_move.x); 40 EXPECT_EQ(300, mouse_move.x);
45 EXPECT_EQ(200, mouse_move.y); 41 EXPECT_EQ(200, mouse_move.y);
46 42
47 EXPECT_EQ(300, mouse_move.windowX); 43 EXPECT_EQ(300, mouse_move.windowX);
48 EXPECT_EQ(200, mouse_move.windowY); 44 EXPECT_EQ(200, mouse_move.windowY);
49 45
50 // WebMouseEvent.globalX and WebMouseEvent.globalY are calculated in DIPs. 46 // WebMouseEvent.globalX and WebMouseEvent.globalY are calculated in DIPs.
51 EXPECT_EQ(150, mouse_move.globalX); 47 EXPECT_EQ(150, mouse_move.globalX);
52 EXPECT_EQ(100, mouse_move.globalY); 48 EXPECT_EQ(100, mouse_move.globalY);
53 49
54 EXPECT_EQ(blink::WebPointerProperties::PointerType::Mouse, 50 EXPECT_EQ(blink::WebPointerProperties::PointerType::Mouse,
55 mouse_move.pointerType); 51 mouse_move.pointerType);
56 52
57 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1"); 53 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1");
58 display::Display::ResetForceDeviceScaleFactorForTesting(); 54 display::Display::ResetForceDeviceScaleFactorForTesting();
59 } 55 }
60 #endif
61 56
62 } // namespace content 57 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/blink/web_input_event_builders_win.cc ('k') | ui/events/blink/web_input_event_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698