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

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

Issue 1574013002: Remove the % WHEEL_DELTA check in WebMouseWheelEventBuilder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: forgot rbyers nit Created 4 years, 11 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 | « content/browser/renderer_host/input/web_input_event_builders_win.cc ('k') | no next file » | 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 "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/events/event_constants.h" 9 #include "ui/events/event_constants.h"
10 #include "ui/gfx/display.h" 10 #include "ui/gfx/display.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 gfx::Display::ResetForceDeviceScaleFactorForTesting();
56 } 56 }
57
58 // Test that hasPreciseScrollingDeltas is true for wheel events that generate
59 // high precision scroll deltas.
60 TEST(WebInputEventBuilderTest, TestPreciseScrollingDelta) {
61 LPARAM lparam = MAKELPARAM(300, 200);
62
63 // wheel_delta is equal to WHEEL_DELTA, scroll up
64 WebMouseWheelEvent evt =
65 WebMouseWheelEventBuilder::Build(::GetDesktopWindow(), WM_MOUSEWHEEL,
66 MAKEWPARAM(0, 120), lparam, 100);
67 EXPECT_EQ(1, evt.wheelTicksY);
68 EXPECT_EQ(100, evt.deltaY);
69 EXPECT_FALSE(evt.hasPreciseScrollingDeltas);
70
71 // wheel_delta is a multiple of WHEEL_DELTA, scroll up
72 evt = WebMouseWheelEventBuilder::Build(::GetDesktopWindow(), WM_MOUSEWHEEL,
73 MAKEWPARAM(0, 360), lparam, 100);
74 EXPECT_EQ(3, evt.wheelTicksY);
75 EXPECT_EQ(300, evt.deltaY);
76 EXPECT_FALSE(evt.hasPreciseScrollingDeltas);
77
78 // wheel_delta is a multiple of WHEEL_DELTA, scroll down
79 evt = WebMouseWheelEventBuilder::Build(::GetDesktopWindow(), WM_MOUSEWHEEL,
80 MAKEWPARAM(0, -360), lparam, 100);
81 EXPECT_EQ(-3, evt.wheelTicksY);
82 EXPECT_EQ(-300, evt.deltaY);
83 EXPECT_FALSE(evt.hasPreciseScrollingDeltas);
84
85 // high precision scroll, wheel_delta not a multiple of WHEEL_DELTA
86 evt = WebMouseWheelEventBuilder::Build(::GetDesktopWindow(), WM_MOUSEWHEEL,
87 MAKEWPARAM(0, 3), lparam, 100);
88 EXPECT_FLOAT_EQ(0.025f, evt.wheelTicksY);
89 EXPECT_FLOAT_EQ(2.5f, evt.deltaY);
90 EXPECT_TRUE(evt.hasPreciseScrollingDeltas);
91 }
92 #endif 57 #endif
93 58
94 } // namespace content 59 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/web_input_event_builders_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698