OLD | NEW |
1 // This file contains the commonly used functions in pointerevent tests. | 1 // This file contains the commonly used functions in pointerevent tests. |
2 | 2 |
3 const scrollOffset = 30; | 3 const scrollOffset = 30; |
4 const boundaryOffset = 5; | 4 const boundaryOffset = 5; |
5 const touchSourceType = 1; | 5 const touchSourceType = 1; |
6 | 6 |
7 function delayPromise(delay) { | 7 function delayPromise(delay) { |
8 return new Promise(function(resolve, reject) { | 8 return new Promise(function(resolve, reject) { |
9 window.setTimeout(resolve, delay); | 9 window.setTimeout(resolve, delay); |
10 }); | 10 }); |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 eventSender.keyDown('ArrowRight'); | 386 eventSender.keyDown('ArrowRight'); |
387 else | 387 else |
388 reject(); | 388 reject(); |
389 resolve(); | 389 resolve(); |
390 } else { | 390 } else { |
391 reject(); | 391 reject(); |
392 } | 392 } |
393 }); | 393 }); |
394 } | 394 } |
395 | 395 |
| 396 function smoothDrag(targetSelector1, targetSelector2, pointerType) { |
| 397 return new Promise(function(resolve, reject) { |
| 398 if (window.chrome && chrome.gpuBenchmarking) { |
| 399 scrollPageIfNeeded(targetSelector1, document); |
| 400 var target1 = document.querySelector(targetSelector1); |
| 401 var targetRect1 = target1.getBoundingClientRect(); |
| 402 var xPosition1 = targetRect1.left + boundaryOffset; |
| 403 var yPosition1 = targetRect1.top + boundaryOffset; |
| 404 var target2 = document.querySelector(targetSelector2); |
| 405 var targetRect2 = target2.getBoundingClientRect(); |
| 406 var xPosition2 = targetRect2.left + boundaryOffset; |
| 407 var yPosition2 = targetRect2.top + boundaryOffset; |
| 408 var action = '[{"source": "' + pointerType + '", "actions": [{ "name": "po
interDown", "x":' + xPosition1 +', "y":' + yPosition1 +' },'; |
| 409 var maxStep = Math.max(1, Math.floor(Math.max(Math.abs(xPosition2 - xPosit
ion1), Math.abs(yPosition2 - yPosition1))/15)); |
| 410 for (var step=1; step<=maxStep; step++) |
| 411 action += '{ "name": "pointerMove", "x":' + (xPosition1 + Math.floor((st
ep/maxStep)*(xPosition2 - xPosition1))) +', "y":' + (yPosition1 + Math.floor((st
ep/maxStep)*(yPosition2 - yPosition1))) +' },'; |
| 412 action += '{ "name": "pointerUp" }]}]'; |
| 413 chrome.gpuBenchmarking.pointerActionSequence(JSON.parse(action), resolve); |
| 414 } else { |
| 415 reject(); |
| 416 } |
| 417 }); |
| 418 } |
| 419 |
396 { | 420 { |
397 var pointerevent_automation = async_test("PointerEvent Automation"); | 421 var pointerevent_automation = async_test("PointerEvent Automation"); |
398 // Defined in every test and should return a promise that gets resolved when i
nput is finished. | 422 // Defined in every test and should return a promise that gets resolved when i
nput is finished. |
399 inject_input().then(function() { | 423 inject_input().then(function() { |
400 pointerevent_automation.done(); | 424 pointerevent_automation.done(); |
401 }); | 425 }); |
402 } | 426 } |
403 | |
OLD | NEW |