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

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

Issue 1927463002: Rename gfx::Display/Screen to display::Display/Screen in content/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 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/web/WebInputEvent.h"
9 #include "ui/display/display.h"
9 #include "ui/events/event_constants.h" 10 #include "ui/events/event_constants.h"
10 #include "ui/gfx/display.h"
11 #include "ui/gfx/switches.h" 11 #include "ui/gfx/switches.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 "content/browser/renderer_host/input/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)
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 gfx::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 = 36 WebMouseEvent mouse_move =
37 WebMouseEventBuilder::Build(::GetDesktopWindow(), WM_MOUSEMOVE, 0, 37 WebMouseEventBuilder::Build(::GetDesktopWindow(), WM_MOUSEMOVE, 0,
38 MAKELPARAM(300, 200), 100); 38 MAKELPARAM(300, 200), 100);
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 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1"); 54 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1");
55 gfx::Display::ResetForceDeviceScaleFactorForTesting(); 55 display::Display::ResetForceDeviceScaleFactorForTesting();
56 } 56 }
57 #endif 57 #endif
58 58
59 } // namespace content 59 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/dip_util.cc ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698