| 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) {
|
|
|