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

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

Issue 992383002: Fix for the WebInputEventBuilderTest.TestMouseEventScale content_unittests failures on the DrMemory… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed boneheaded error 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
« no previous file with comments | « no previous file | ui/gfx/display.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "third_party/WebKit/public/web/WebInputEvent.h" 7 #include "third_party/WebKit/public/web/WebInputEvent.h"
8 #include "ui/events/event_constants.h" 8 #include "ui/events/event_constants.h"
9 #include "ui/gfx/display.h"
9 #include "ui/gfx/switches.h" 10 #include "ui/gfx/switches.h"
10 11
11 #if defined(OS_WIN) 12 #if defined(OS_WIN)
12 #include "base/win/windows_version.h" 13 #include "base/win/windows_version.h"
13 #include "content/browser/renderer_host/input/web_input_event_builders_win.h" 14 #include "content/browser/renderer_host/input/web_input_event_builders_win.h"
14 #endif 15 #endif
15 16
16 using blink::WebMouseEvent; 17 using blink::WebMouseEvent;
17 18
18 namespace content { 19 namespace content {
19 20
20 #if defined(OS_WIN) 21 #if defined(OS_WIN)
21 // This test validates that Pixel to DIP conversion occurs as needed in the 22 // This test validates that Pixel to DIP conversion occurs as needed in the
22 // WebMouseEventBuilder::Build function. 23 // WebMouseEventBuilder::Build function.
23 TEST(WebInputEventBuilderTest, TestMouseEventScale) { 24 TEST(WebInputEventBuilderTest, TestMouseEventScale) {
24 if (base::win::GetVersion() < base::win::VERSION_WIN7) 25 if (base::win::GetVersion() < base::win::VERSION_WIN7)
25 return; 26 return;
26 27
28 gfx::Display::ResetForceDeviceScaleFactorForTesting();
29
27 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 30 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
28 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "2"); 31 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "2");
29 32
30 // Synthesize a mouse move with x = 300 and y = 200. 33 // Synthesize a mouse move with x = 300 and y = 200.
31 WebMouseEvent mouse_move = 34 WebMouseEvent mouse_move =
32 WebMouseEventBuilder::Build(::GetDesktopWindow(), WM_MOUSEMOVE, 0, 35 WebMouseEventBuilder::Build(::GetDesktopWindow(), WM_MOUSEMOVE, 0,
33 MAKELPARAM(300, 200), 100); 36 MAKELPARAM(300, 200), 100);
34 37
35 // The WebMouseEvent.x, WebMouseEvent.y, WebMouseEvent.windowX and 38 // The WebMouseEvent.x, WebMouseEvent.y, WebMouseEvent.windowX and
36 // WebMouseEvent.windowY fields should be in pixels on return and hence 39 // 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 40 // should be the same value as the x and y coordinates passed in to the
38 // WebMouseEventBuilder::Build function. 41 // WebMouseEventBuilder::Build function.
39 EXPECT_EQ(300, mouse_move.x); 42 EXPECT_EQ(300, mouse_move.x);
40 EXPECT_EQ(200, mouse_move.y); 43 EXPECT_EQ(200, mouse_move.y);
41 44
42 EXPECT_EQ(300, mouse_move.windowX); 45 EXPECT_EQ(300, mouse_move.windowX);
43 EXPECT_EQ(200, mouse_move.windowY); 46 EXPECT_EQ(200, mouse_move.windowY);
44 47
45 // WebMouseEvent.globalX and WebMouseEvent.globalY are calculated in DIPs. 48 // WebMouseEvent.globalX and WebMouseEvent.globalY are calculated in DIPs.
46 EXPECT_EQ(150, mouse_move.globalX); 49 EXPECT_EQ(150, mouse_move.globalX);
47 EXPECT_EQ(100, mouse_move.globalY); 50 EXPECT_EQ(100, mouse_move.globalY);
48 51
49 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1"); 52 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1");
53 gfx::Display::ResetForceDeviceScaleFactorForTesting();
50 } 54 }
51 #endif 55 #endif
52 56
53 } // namespace content 57 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/display.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698