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

Side by Side Diff: ui/events/x/events_x_unittest.cc

Issue 2700623003: Make sure that the pressure is always 0 for pointerup events (Closed)
Patch Set: pressure Created 3 years, 10 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
« no previous file with comments | « ui/events/android/motion_event_android.cc ('k') | ui/events/x/events_x_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <X11/XKBlib.h> 5 #include <X11/XKBlib.h>
6 #include <X11/Xlib.h> 6 #include <X11/Xlib.h>
7 #include <X11/Xutil.h> 7 #include <X11/Xutil.h>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 scoped_xevent.InitTouchEvent( 298 scoped_xevent.InitTouchEvent(
299 0, XI_TouchEnd, 5, gfx::Point(30, 30), valuators); 299 0, XI_TouchEnd, 5, gfx::Point(30, 30), valuators);
300 EXPECT_EQ(ui::ET_TOUCH_RELEASED, ui::EventTypeFromNative(scoped_xevent)); 300 EXPECT_EQ(ui::ET_TOUCH_RELEASED, ui::EventTypeFromNative(scoped_xevent));
301 EXPECT_EQ("30,30", 301 EXPECT_EQ("30,30",
302 gfx::ToFlooredPoint(ui::EventLocationFromNative(scoped_xevent)) 302 gfx::ToFlooredPoint(ui::EventLocationFromNative(scoped_xevent))
303 .ToString()); 303 .ToString());
304 EXPECT_EQ(GetTouchId(scoped_xevent), 0); 304 EXPECT_EQ(GetTouchId(scoped_xevent), 0);
305 EXPECT_FLOAT_EQ(GetTouchAngle(scoped_xevent), 0.25f); 305 EXPECT_FLOAT_EQ(GetTouchAngle(scoped_xevent), 0.25f);
306 pointer_details = GetTouchPointerDetailsFromNative(scoped_xevent); 306 pointer_details = GetTouchPointerDetailsFromNative(scoped_xevent);
307 EXPECT_FLOAT_EQ(pointer_details.radius_x, 10.0f); 307 EXPECT_FLOAT_EQ(pointer_details.radius_x, 10.0f);
308 EXPECT_FLOAT_EQ(pointer_details.force, 0.05f); 308 EXPECT_FLOAT_EQ(pointer_details.force, 0.f);
309 309
310 // Touch with tracking id 6 should have old angle/pressure value and new 310 // Touch with tracking id 6 should have old angle/pressure value and new
311 // radius value. 311 // radius value.
312 valuators.clear(); 312 valuators.clear();
313 valuators.push_back(Valuator(DeviceDataManagerX11::DT_TOUCH_MAJOR, 50)); 313 valuators.push_back(Valuator(DeviceDataManagerX11::DT_TOUCH_MAJOR, 50));
314 scoped_xevent.InitTouchEvent( 314 scoped_xevent.InitTouchEvent(
315 0, XI_TouchEnd, 6, gfx::Point(200, 200), valuators); 315 0, XI_TouchEnd, 6, gfx::Point(200, 200), valuators);
316 EXPECT_EQ(ui::ET_TOUCH_RELEASED, ui::EventTypeFromNative(scoped_xevent)); 316 EXPECT_EQ(ui::ET_TOUCH_RELEASED, ui::EventTypeFromNative(scoped_xevent));
317 EXPECT_EQ("200,200", 317 EXPECT_EQ("200,200",
318 gfx::ToFlooredPoint(ui::EventLocationFromNative(scoped_xevent)) 318 gfx::ToFlooredPoint(ui::EventLocationFromNative(scoped_xevent))
319 .ToString()); 319 .ToString());
320 EXPECT_EQ(GetTouchId(scoped_xevent), 1); 320 EXPECT_EQ(GetTouchId(scoped_xevent), 1);
321 EXPECT_FLOAT_EQ(GetTouchAngle(scoped_xevent), 0.45f); 321 EXPECT_FLOAT_EQ(GetTouchAngle(scoped_xevent), 0.45f);
322 pointer_details = GetTouchPointerDetailsFromNative(scoped_xevent); 322 pointer_details = GetTouchPointerDetailsFromNative(scoped_xevent);
323 EXPECT_FLOAT_EQ(pointer_details.radius_x, 25.0f); 323 EXPECT_FLOAT_EQ(pointer_details.radius_x, 25.0f);
324 EXPECT_FLOAT_EQ(pointer_details.force, 0.5f); 324 EXPECT_FLOAT_EQ(pointer_details.force, 0.f);
325 } 325 }
326 326
327 int GetTouchIdForTrackingId(uint32_t tracking_id) { 327 int GetTouchIdForTrackingId(uint32_t tracking_id) {
328 int slot = 0; 328 int slot = 0;
329 bool success = 329 bool success =
330 TouchFactory::GetInstance()->QuerySlotForTrackingID(tracking_id, &slot); 330 TouchFactory::GetInstance()->QuerySlotForTrackingID(tracking_id, &slot);
331 if (success) 331 if (success)
332 return slot; 332 return slot;
333 return -1; 333 return -1;
334 } 334 }
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 585
586 ResetTimestampRolloverCountersForTesting( 586 ResetTimestampRolloverCountersForTesting(
587 base::MakeUnique<MockTickClock>(0x100000005)); 587 base::MakeUnique<MockTickClock>(0x100000005));
588 588
589 event.xbutton.time = 0xFFFFFFFF; 589 event.xbutton.time = 0xFFFFFFFF;
590 EXPECT_EQ(base::TimeDelta::FromMilliseconds(0xFFFFFFFF).ToInternalValue(), 590 EXPECT_EQ(base::TimeDelta::FromMilliseconds(0xFFFFFFFF).ToInternalValue(),
591 ui::EventTimeFromNative(&event).ToInternalValue()); 591 ui::EventTimeFromNative(&event).ToInternalValue());
592 } 592 }
593 593
594 } // namespace ui 594 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/android/motion_event_android.cc ('k') | ui/events/x/events_x_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698