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

Unified Diff: ui/events/x/events_x_unittest.cc

Issue 869433007: Revert of Don't refcount tracking id -> slot id mapping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/x/events_x.cc ('k') | ui/views/controls/menu/menu_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/x/events_x_unittest.cc
diff --git a/ui/events/x/events_x_unittest.cc b/ui/events/x/events_x_unittest.cc
index a08974ab14e36fb3f3e5e771d6f7647df827c460..065e804e39b6a71d5d35116a4bc34bffe998c630 100644
--- a/ui/events/x/events_x_unittest.cc
+++ b/ui/events/x/events_x_unittest.cc
@@ -300,47 +300,54 @@
return -1;
}
-TEST_F(EventsXTest, TouchEventNotRemovingFromNativeMapping) {
+TEST_F(EventsXTest, TouchEventIdRefcounting) {
std::vector<unsigned int> devices;
devices.push_back(0);
ui::SetUpTouchDevicesForTest(devices);
std::vector<Valuator> valuators;
- const int kTrackingId = 5;
-
- // Two touch presses with the same tracking id.
+ const int kTrackingId0 = 5;
+ const int kTrackingId1 = 7;
+
+ // Increment ref count once for first touch.
ui::ScopedXI2Event xpress0;
xpress0.InitTouchEvent(
- 0, XI_TouchBegin, kTrackingId, gfx::Point(10, 10), valuators);
+ 0, XI_TouchBegin, kTrackingId0, gfx::Point(10, 10), valuators);
scoped_ptr<ui::TouchEvent> upress0(new ui::TouchEvent(xpress0));
- EXPECT_EQ(0, GetTouchIdForTrackingId(kTrackingId));
-
+ EXPECT_EQ(0, GetTouchIdForTrackingId(kTrackingId0));
+
+ // Increment ref count 4 times for second touch.
ui::ScopedXI2Event xpress1;
xpress1.InitTouchEvent(
- 0, XI_TouchBegin, kTrackingId, gfx::Point(20, 20), valuators);
- ui::TouchEvent upress1(xpress1);
- EXPECT_EQ(0, GetTouchIdForTrackingId(kTrackingId));
-
- // The first touch release shouldn't clear the mapping from the
- // tracking id.
+ 0, XI_TouchBegin, kTrackingId1, gfx::Point(20, 20), valuators);
+
+ for (int i = 0; i < 4; ++i) {
+ ui::TouchEvent upress1(xpress1);
+ EXPECT_EQ(1, GetTouchIdForTrackingId(kTrackingId1));
+ }
+
+ ui::ScopedXI2Event xrelease1;
+ xrelease1.InitTouchEvent(
+ 0, XI_TouchEnd, kTrackingId1, gfx::Point(10, 10), valuators);
+
+ // Decrement ref count 3 times for second touch.
+ for (int i = 0; i < 3; ++i) {
+ ui::TouchEvent urelease1(xrelease1);
+ EXPECT_EQ(1, GetTouchIdForTrackingId(kTrackingId1));
+ }
+
+ // This should clear the touch id of the second touch.
+ scoped_ptr<ui::TouchEvent> urelease1(new ui::TouchEvent(xrelease1));
+ urelease1.reset();
+ EXPECT_EQ(-1, GetTouchIdForTrackingId(kTrackingId1));
+
+ // This should clear the touch id of the first touch.
ui::ScopedXI2Event xrelease0;
xrelease0.InitTouchEvent(
- 0, XI_TouchEnd, kTrackingId, gfx::Point(10, 10), valuators);
- {
- ui::TouchEvent urelease0(xrelease0);
- urelease0.set_should_remove_native_touch_id_mapping(false);
- }
- EXPECT_EQ(0, GetTouchIdForTrackingId(kTrackingId));
-
- // The second touch release should clear the mapping from the
- // tracking id.
- ui::ScopedXI2Event xrelease1;
- xrelease1.InitTouchEvent(
- 0, XI_TouchEnd, kTrackingId, gfx::Point(10, 10), valuators);
- {
- ui::TouchEvent urelease1(xrelease1);
- }
- EXPECT_EQ(-1, GetTouchIdForTrackingId(kTrackingId));
+ 0, XI_TouchEnd, kTrackingId0, gfx::Point(10, 10), valuators);
+ scoped_ptr<ui::TouchEvent> urelease0(new ui::TouchEvent(xrelease0));
+ urelease0.reset();
+ EXPECT_EQ(-1, GetTouchIdForTrackingId(kTrackingId0));
}
TEST_F(EventsXTest, NumpadKeyEvents) {
« no previous file with comments | « ui/events/x/events_x.cc ('k') | ui/views/controls/menu/menu_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698