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 = 20; | 3 const scrollOffset = 20; |
4 const boundaryOffset = 2; | 4 const boundaryOffset = 2; |
5 | 5 |
6 function delayPromise(delay) { | 6 function delayPromise(delay) { |
7 return new Promise(function(resolve, reject) { | 7 return new Promise(function(resolve, reject) { |
8 window.setTimeout(resolve, delay); | 8 window.setTimeout(resolve, delay); |
9 }); | 9 }); |
10 } | 10 } |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 eventSender.keyDown('ArrowRight'); | 444 eventSender.keyDown('ArrowRight'); |
445 else | 445 else |
446 reject(); | 446 reject(); |
447 resolve(); | 447 resolve(); |
448 } else { | 448 } else { |
449 reject(); | 449 reject(); |
450 } | 450 } |
451 }); | 451 }); |
452 } | 452 } |
453 | 453 |
| 454 function smoothDrag(targetSelector1, targetSelector2, pointerType) { |
| 455 return new Promise(function(resolve, reject) { |
| 456 if (window.chrome && chrome.gpuBenchmarking) { |
| 457 scrollPageIfNeeded(targetSelector1, document); |
| 458 var target1 = document.querySelector(targetSelector1); |
| 459 var targetRect1 = target1.getBoundingClientRect(); |
| 460 var xPosition1 = targetRect1.left + boundaryOffset; |
| 461 var yPosition1 = targetRect1.top + boundaryOffset; |
| 462 var target2 = document.querySelector(targetSelector2); |
| 463 var targetRect2 = target2.getBoundingClientRect(); |
| 464 var xPosition2 = targetRect2.left + boundaryOffset; |
| 465 var yPosition2 = targetRect2.top + boundaryOffset; |
| 466 var action = '[{"source": "' + pointerType + '", "actions": [{ "name": "po
interDown", "x":' + xPosition1 +', "y":' + yPosition1 +' },'; |
| 467 var maxStep = Math.max(1, Math.floor(Math.max(Math.abs(xPosition2 - xPosit
ion1), Math.abs(yPosition2 - yPosition1))/15)); |
| 468 for (var step=1; step<=maxStep; step++) |
| 469 action += '{ "name": "pointerMove", "x":' + (xPosition1 + Math.floor((st
ep/maxStep)*(xPosition2 - xPosition1))) +', "y":' + (yPosition1 + Math.floor((st
ep/maxStep)*(yPosition2 - yPosition1))) +' },'; |
| 470 action += '{ "name": "pointerUp" }]}]'; |
| 471 chrome.gpuBenchmarking.pointerActionSequence(JSON.parse(action), resolve); |
| 472 } else { |
| 473 reject(); |
| 474 } |
| 475 }); |
| 476 } |
| 477 |
454 { | 478 { |
455 var pointerevent_automation = async_test("PointerEvent Automation"); | 479 var pointerevent_automation = async_test("PointerEvent Automation"); |
456 // Defined in every test and should return a promise that gets resolved when i
nput is finished. | 480 // Defined in every test and should return a promise that gets resolved when i
nput is finished. |
457 inject_input().then(function() { | 481 inject_input().then(function() { |
458 pointerevent_automation.done(); | 482 pointerevent_automation.done(); |
459 }); | 483 }); |
460 } | 484 } |
461 | |
OLD | NEW |