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

Unified Diff: ui/base/test/ui_controls_internal_win.cc

Issue 2904113002: Replacing WM_TOUCH with WM_POINTER for touch events on Wins 8+ (Closed)
Patch Set: Add a browser test Created 3 years, 6 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
Index: ui/base/test/ui_controls_internal_win.cc
diff --git a/ui/base/test/ui_controls_internal_win.cc b/ui/base/test/ui_controls_internal_win.cc
index ade37c9375840cb879cb213f184ecc652d2e5cd7..1dba3e1191f01c1cbb83d44ad926a2bc648260af 100644
--- a/ui/base/test/ui_controls_internal_win.cc
+++ b/ui/base/test/ui_controls_internal_win.cc
@@ -330,5 +330,77 @@ bool SendMouseEventsImpl(MouseButton type, int state,
return true;
}
+bool SendTouchEventsImpl(int action,
+ int num,
+ long x,
+ long y,
+ const base::Closure& task) {
+ InitializeTouchInjection(num, TOUCH_FEEDBACK_INDIRECT);
+ scoped_refptr<InputDispatcher> dispatcher(
+ !task.is_null() ? new InputDispatcher(task, WM_POINTERDOWN) : NULL);
+
+ POINTER_TOUCH_INFO contact_[3];
sky 2017/06/07 19:42:45 Where does the 3 come from?
sky 2017/06/07 19:42:45 trailing '_' is only for members.
lanwei 2017/06/22 18:38:45 I removed it.
lanwei 2017/06/22 18:38:45 Done.
+ for (int i = 0; i < num; i++) {
sky 2017/06/07 19:42:45 It's not at all clear to me what this code is doin
+ POINTER_TOUCH_INFO& contact = contact_[i];
+ memset(&contact, 0, sizeof(POINTER_TOUCH_INFO));
+ contact.pointerInfo.pointerType = PT_TOUCH;
+ contact.pointerInfo.pointerId = i;
+ contact.pointerInfo.ptPixelLocation.y = y;
+ contact.pointerInfo.ptPixelLocation.x = x + 50 * i;
+
+ contact.touchFlags = TOUCH_FLAG_NONE;
+ contact.touchMask =
+ TOUCH_MASK_CONTACTAREA | TOUCH_MASK_ORIENTATION | TOUCH_MASK_PRESSURE;
+ contact.orientation = 90;
+ contact.pressure = 32000;
+
+ // defining contact area
+ contact.rcContact.top = contact.pointerInfo.ptPixelLocation.y - 2;
+ contact.rcContact.bottom = contact.pointerInfo.ptPixelLocation.y + 2;
+ contact.rcContact.left = contact.pointerInfo.ptPixelLocation.x - 2;
+ contact.rcContact.right = contact.pointerInfo.ptPixelLocation.x + 2;
+
+ contact.pointerInfo.pointerFlags =
+ POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
+ }
+ bool result =
+ InjectTouchInput(num, contact_); // Injecting the touch down on screen
ananta 2017/06/09 03:13:12 The reason the tests are failing on Windows 7 is a
lanwei 2017/06/22 18:38:45 Done.
+ Sleep(20);
sky 2017/06/07 19:42:45 Why do you sleep between injecting events?
lanwei 2017/06/22 18:38:45 Because the test is flaky, I want to make sure we
sky 2017/06/22 20:54:21 The problem with random sleeps is that they genera
lanwei 2017/06/23 20:06:05 I removed them.
+
+ if (action & MOVE) {
+ for (int i = 0; i < num; i++) {
+ POINTER_TOUCH_INFO& contact = contact_[i];
+ contact.pointerInfo.ptPixelLocation.y = y + 10;
+ contact.pointerInfo.ptPixelLocation.x = x + 50 * i + 30;
+ contact.pointerInfo.pointerFlags =
+ POINTER_FLAG_UPDATE | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
+ }
+ result =
+ result &&
+ InjectTouchInput(num, contact_); // Injecting the touch move on screen
+ Sleep(20);
+ }
+
+ if (action & RELEASE) {
+ for (int i = 0; i < num; i++) {
+ POINTER_TOUCH_INFO& contact = contact_[i];
+ contact.pointerInfo.ptPixelLocation.y = y + 10;
+ contact.pointerInfo.ptPixelLocation.x = x + 50 * i + 30;
+ contact.pointerInfo.pointerFlags = POINTER_FLAG_UP | POINTER_FLAG_INRANGE;
+ }
+ result = result && InjectTouchInput(
+ num, contact_); // Injecting the touch up on screen
+ Sleep(20);
+ }
+
+ if (!result)
+ return false;
+
+ if (dispatcher.get())
+ dispatcher->AddRef();
+
+ return true;
+}
+
} // namespace internal
} // namespace ui_controls

Powered by Google App Engine
This is Rietveld 408576698