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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/input/web_input_event_traits.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/input/web_input_event_traits_unittest.cc
diff --git a/content/common/input/web_input_event_traits_unittest.cc b/content/common/input/web_input_event_traits_unittest.cc
index 7a18f2a8a30468a58bfbcb1709d41e02e0f0acd3..6eafb0fabb6df013d0464d27065de80564e1b5c8 100644
--- a/content/common/input/web_input_event_traits_unittest.cc
+++ b/content/common/input/web_input_event_traits_unittest.cc
@@ -4,6 +4,8 @@
#include "content/common/input/web_input_event_traits.h"
+#include <limits>
+
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
@@ -11,6 +13,7 @@ using blink::WebGestureEvent;
using blink::WebInputEvent;
using blink::WebTouchEvent;
using blink::WebTouchPoint;
+using std::numeric_limits;
namespace content {
namespace {
@@ -135,6 +138,25 @@ TEST_F(WebInputEventTraitsTest, PinchEventCoalescing) {
EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch0));
WebInputEventTraits::Coalesce(pinch0, &pinch1);
EXPECT_EQ(2.f * 3.f, pinch1.data.pinchUpdate.scale);
+
+ // Scales have a minimum value and can never reach 0.
+ ASSERT_GT(numeric_limits<float>::min(), 0);
+ pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
+ pinch0.data.pinchUpdate.scale = numeric_limits<float>::min() * 2.0f;
+ pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
+ pinch1.data.pinchUpdate.scale = numeric_limits<float>::min() * 5.0f;
+ EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch1));
+ WebInputEventTraits::Coalesce(pinch0, &pinch1);
+ EXPECT_EQ(numeric_limits<float>::min(), pinch1.data.pinchUpdate.scale);
+
+ // Scales have a maximum value and can never reach Infinity.
+ pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
+ pinch0.data.pinchUpdate.scale = numeric_limits<float>::max() / 2.0f;
+ pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
+ pinch1.data.pinchUpdate.scale = 10.0f;
+ EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch1));
+ WebInputEventTraits::Coalesce(pinch0, &pinch1);
+ EXPECT_EQ(numeric_limits<float>::max(), pinch1.data.pinchUpdate.scale);
}
} // namespace
« 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