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

Side by Side Diff: content/common/input/web_input_event_traits_unittest.cc

Issue 250923004: Synthesize ctrl-wheel events on touchpad pinch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ensure scales never coalesce to 0 or Infinity Created 6 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 | Annotate | Revision Log
« no previous file with comments | « content/common/input/web_input_event_traits.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/common/input/web_input_event_traits.h" 5 #include "content/common/input/web_input_event_traits.h"
6 6
7 #include <limits>
8
7 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/WebKit/public/web/WebInputEvent.h" 10 #include "third_party/WebKit/public/web/WebInputEvent.h"
9 11
10 using blink::WebGestureEvent; 12 using blink::WebGestureEvent;
11 using blink::WebInputEvent; 13 using blink::WebInputEvent;
12 using blink::WebTouchEvent; 14 using blink::WebTouchEvent;
13 using blink::WebTouchPoint; 15 using blink::WebTouchPoint;
16 using std::numeric_limits;
14 17
15 namespace content { 18 namespace content {
16 namespace { 19 namespace {
17 20
18 class WebInputEventTraitsTest : public testing::Test { 21 class WebInputEventTraitsTest : public testing::Test {
19 protected: 22 protected:
20 static WebTouchPoint CreateTouchPoint(WebTouchPoint::State state, int id) { 23 static WebTouchPoint CreateTouchPoint(WebTouchPoint::State state, int id) {
21 WebTouchPoint touch; 24 WebTouchPoint touch;
22 touch.state = state; 25 touch.state = state;
23 touch.id = id; 26 touch.id = id;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch0)); 131 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch0));
129 132
130 // Coalesced scales are multiplicative. 133 // Coalesced scales are multiplicative.
131 pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1); 134 pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
132 pinch0.data.pinchUpdate.scale = 2.f; 135 pinch0.data.pinchUpdate.scale = 2.f;
133 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1); 136 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
134 pinch1.data.pinchUpdate.scale = 3.f; 137 pinch1.data.pinchUpdate.scale = 3.f;
135 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch0)); 138 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch0));
136 WebInputEventTraits::Coalesce(pinch0, &pinch1); 139 WebInputEventTraits::Coalesce(pinch0, &pinch1);
137 EXPECT_EQ(2.f * 3.f, pinch1.data.pinchUpdate.scale); 140 EXPECT_EQ(2.f * 3.f, pinch1.data.pinchUpdate.scale);
141
142 // Scales have a minimum value and can never reach 0.
143 ASSERT_GT(numeric_limits<float>::min(), 0);
144 pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
145 pinch0.data.pinchUpdate.scale = numeric_limits<float>::min() * 2.0f;
146 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
147 pinch1.data.pinchUpdate.scale = numeric_limits<float>::min() * 5.0f;
148 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch1));
149 WebInputEventTraits::Coalesce(pinch0, &pinch1);
150 EXPECT_EQ(numeric_limits<float>::min(), pinch1.data.pinchUpdate.scale);
151
152 // Scales have a maximum value and can never reach Infinity.
153 pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
154 pinch0.data.pinchUpdate.scale = numeric_limits<float>::max() / 2.0f;
155 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
156 pinch1.data.pinchUpdate.scale = 10.0f;
157 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch1));
158 WebInputEventTraits::Coalesce(pinch0, &pinch1);
159 EXPECT_EQ(numeric_limits<float>::max(), pinch1.data.pinchUpdate.scale);
138 } 160 }
139 161
140 } // namespace 162 } // namespace
141 } // namespace content 163 } // namespace content
OLDNEW
« no previous file with comments | « content/common/input/web_input_event_traits.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698