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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/base/test/ui_controls_internal_win.h" 5 #include "ui/base/test/ui_controls_internal_win.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 input.mi.dwFlags = up_flags; 323 input.mi.dwFlags = up_flags;
324 if ((state & UP) && !::SendInput(1, &input, sizeof(INPUT))) 324 if ((state & UP) && !::SendInput(1, &input, sizeof(INPUT)))
325 return false; 325 return false;
326 326
327 if (dispatcher.get()) 327 if (dispatcher.get())
328 dispatcher->AddRef(); 328 dispatcher->AddRef();
329 329
330 return true; 330 return true;
331 } 331 }
332 332
333 bool SendTouchEventsImpl(int action,
334 int num,
335 long x,
336 long y,
337 const base::Closure& task) {
338 InitializeTouchInjection(num, TOUCH_FEEDBACK_INDIRECT);
339 scoped_refptr<InputDispatcher> dispatcher(
340 !task.is_null() ? new InputDispatcher(task, WM_POINTERDOWN) : NULL);
341
342 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.
343 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
344 POINTER_TOUCH_INFO& contact = contact_[i];
345 memset(&contact, 0, sizeof(POINTER_TOUCH_INFO));
346 contact.pointerInfo.pointerType = PT_TOUCH;
347 contact.pointerInfo.pointerId = i;
348 contact.pointerInfo.ptPixelLocation.y = y;
349 contact.pointerInfo.ptPixelLocation.x = x + 50 * i;
350
351 contact.touchFlags = TOUCH_FLAG_NONE;
352 contact.touchMask =
353 TOUCH_MASK_CONTACTAREA | TOUCH_MASK_ORIENTATION | TOUCH_MASK_PRESSURE;
354 contact.orientation = 90;
355 contact.pressure = 32000;
356
357 // defining contact area
358 contact.rcContact.top = contact.pointerInfo.ptPixelLocation.y - 2;
359 contact.rcContact.bottom = contact.pointerInfo.ptPixelLocation.y + 2;
360 contact.rcContact.left = contact.pointerInfo.ptPixelLocation.x - 2;
361 contact.rcContact.right = contact.pointerInfo.ptPixelLocation.x + 2;
362
363 contact.pointerInfo.pointerFlags =
364 POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
365 }
366 bool result =
367 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.
368 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.
369
370 if (action & MOVE) {
371 for (int i = 0; i < num; i++) {
372 POINTER_TOUCH_INFO& contact = contact_[i];
373 contact.pointerInfo.ptPixelLocation.y = y + 10;
374 contact.pointerInfo.ptPixelLocation.x = x + 50 * i + 30;
375 contact.pointerInfo.pointerFlags =
376 POINTER_FLAG_UPDATE | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
377 }
378 result =
379 result &&
380 InjectTouchInput(num, contact_); // Injecting the touch move on screen
381 Sleep(20);
382 }
383
384 if (action & RELEASE) {
385 for (int i = 0; i < num; i++) {
386 POINTER_TOUCH_INFO& contact = contact_[i];
387 contact.pointerInfo.ptPixelLocation.y = y + 10;
388 contact.pointerInfo.ptPixelLocation.x = x + 50 * i + 30;
389 contact.pointerInfo.pointerFlags = POINTER_FLAG_UP | POINTER_FLAG_INRANGE;
390 }
391 result = result && InjectTouchInput(
392 num, contact_); // Injecting the touch up on screen
393 Sleep(20);
394 }
395
396 if (!result)
397 return false;
398
399 if (dispatcher.get())
400 dispatcher->AddRef();
401
402 return true;
403 }
404
333 } // namespace internal 405 } // namespace internal
334 } // namespace ui_controls 406 } // namespace ui_controls
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698