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

Unified Diff: ui/events/event_unittest.cc

Issue 1260453006: ui: events: Add a class to hold common touch and stylus properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move mutators to MouseEvent/TouchEvent Created 5 years, 4 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 | « ui/events/event_constants.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/event_unittest.cc
diff --git a/ui/events/event_unittest.cc b/ui/events/event_unittest.cc
index 38ad283b5a9b6923cea437c51502563f772e6b92..ce3280175f1c4a8b03acde09e4345d429a1dd768 100644
--- a/ui/events/event_unittest.cc
+++ b/ui/events/event_unittest.cc
@@ -606,4 +606,90 @@ TEST(EventTest, TouchEventRotationAngleFixing) {
}
}
+TEST(EventTest, PointerEventDetailsTouch) {
+ ui::TouchEvent touch_event_plain(ET_TOUCH_PRESSED, gfx::Point(0, 0), 0,
+ ui::EventTimeForNow());
+
+ EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH,
+ touch_event_plain.pointer_details().pointer_type());
+ EXPECT_EQ(0.0f, touch_event_plain.pointer_details().radius_x());
+ EXPECT_EQ(0.0f, touch_event_plain.pointer_details().radius_y());
+ EXPECT_EQ(0.0f, touch_event_plain.pointer_details().force());
+ EXPECT_EQ(0.0f, touch_event_plain.pointer_details().tilt_x());
+ EXPECT_EQ(0.0f, touch_event_plain.pointer_details().tilt_y());
+
+ EXPECT_EQ(0.0f, touch_event_plain.radius_x());
+ EXPECT_EQ(0.0f, touch_event_plain.radius_y());
+ EXPECT_EQ(0.0f, touch_event_plain.force());
+
+ ui::TouchEvent touch_event_with_details(ET_TOUCH_PRESSED, gfx::Point(0, 0), 0,
+ 0, ui::EventTimeForNow(), 10.0f, 5.0f,
+ 0.0f, 15.0f);
+
+ EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH,
+ touch_event_with_details.pointer_details().pointer_type());
+ EXPECT_EQ(10.0f, touch_event_with_details.pointer_details().radius_x());
+ EXPECT_EQ(5.0f, touch_event_with_details.pointer_details().radius_y());
+ EXPECT_EQ(15.0f, touch_event_with_details.pointer_details().force());
+ EXPECT_EQ(0.0f, touch_event_with_details.pointer_details().tilt_x());
+ EXPECT_EQ(0.0f, touch_event_with_details.pointer_details().tilt_y());
+
+ ui::TouchEvent touch_event_copy(touch_event_with_details);
+ EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH,
+ touch_event_copy.pointer_details().pointer_type());
+ EXPECT_EQ(10.0f, touch_event_copy.pointer_details().radius_x());
+ EXPECT_EQ(5.0f, touch_event_copy.pointer_details().radius_y());
+ EXPECT_EQ(15.0f, touch_event_copy.pointer_details().force());
+ EXPECT_EQ(0.0f, touch_event_copy.pointer_details().tilt_x());
+ EXPECT_EQ(0.0f, touch_event_copy.pointer_details().tilt_y());
+}
+
+TEST(EventTest, PointerEventDetailsMouse) {
+ ui::MouseEvent mouse_event(ET_MOUSE_PRESSED, gfx::PointF(0, 0),
+ gfx::PointF(0, 0), ui::EventTimeForNow(), 0, 0);
+
+ EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE,
+ mouse_event.pointer_details().pointer_type());
+ EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_x());
+ EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_y());
+ EXPECT_EQ(0.0f, mouse_event.pointer_details().force());
+ EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_x());
+ EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_y());
+
+ ui::MouseEvent mouse_event_copy(mouse_event);
+ EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE,
+ mouse_event_copy.pointer_details().pointer_type());
+ EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().radius_x());
+ EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().radius_y());
+ EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().force());
+ EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().tilt_x());
+ EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().tilt_y());
+}
+
+TEST(EventTest, PointerEventDetailsStylus) {
+ ui::MouseEvent stylus_event(ET_MOUSE_PRESSED, gfx::PointF(0, 0),
+ gfx::PointF(0, 0), ui::EventTimeForNow(), 0, 0);
+ stylus_event.set_pointer_type(EventPointerType::POINTER_TYPE_PEN);
+ stylus_event.set_force(21.0f);
+ stylus_event.set_tilt_x(45.0f);
+ stylus_event.set_tilt_y(-45.0f);
+
+ EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
+ stylus_event.pointer_details().pointer_type());
+ EXPECT_EQ(21.0f, stylus_event.pointer_details().force());
+ EXPECT_EQ(45.0f, stylus_event.pointer_details().tilt_x());
+ EXPECT_EQ(-45.0f, stylus_event.pointer_details().tilt_y());
+ EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_x());
+ EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_y());
+
+ ui::MouseEvent stylus_event_copy(stylus_event);
+ EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
+ stylus_event_copy.pointer_details().pointer_type());
+ EXPECT_EQ(21.0f, stylus_event_copy.pointer_details().force());
+ EXPECT_EQ(45.0f, stylus_event_copy.pointer_details().tilt_x());
+ EXPECT_EQ(-45.0f, stylus_event_copy.pointer_details().tilt_y());
+ EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_x());
+ EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_y());
+}
+
} // namespace ui
« no previous file with comments | « ui/events/event_constants.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698