Chromium Code Reviews| 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 = 20; |
| 4 const boundaryOffset = 5; | 4 const boundaryOffset = 2; |
| 5 const touchSourceType = 1; | |
| 6 | 5 |
| 7 function delayPromise(delay) { | 6 function delayPromise(delay) { |
| 8 return new Promise(function(resolve, reject) { | 7 return new Promise(function(resolve, reject) { |
| 9 window.setTimeout(resolve, delay); | 8 window.setTimeout(resolve, delay); |
| 10 }); | 9 }); |
| 11 } | 10 } |
| 12 | 11 |
| 13 function scrollPageIfNeeded(targetSelector, targetDocument) { | 12 function scrollPageIfNeeded(targetSelector, targetDocument) { |
| 14 var target = targetDocument.querySelector(targetSelector); | 13 var target = targetDocument.querySelector(targetSelector); |
| 15 var targetRect = target.getBoundingClientRect(); | 14 var targetRect = target.getBoundingClientRect(); |
| 16 if (targetRect.top < 0 || targetRect.left < 0 || targetRect.bottom > window.in nerHeight || targetRect.right > window.innerWidth) | 15 if (targetRect.top < 0 || targetRect.left < 0 || targetRect.bottom > window.in nerHeight || targetRect.right > window.innerWidth) |
| 17 window.scrollTo(targetRect.left, targetRect.top); | 16 window.scrollTo(targetRect.left, targetRect.top); |
| 18 } | 17 } |
| 19 | 18 |
| 20 // Mouse inputs. | 19 // Mouse inputs. |
| 21 function mouseMoveToDocument() { | 20 function mouseMoveToDocument() { |
| 22 return new Promise(function(resolve, reject) { | 21 return new Promise(function(resolve, reject) { |
| 23 if (window.chrome && chrome.gpuBenchmarking) { | 22 if (window.chrome && chrome.gpuBenchmarking) { |
| 24 chrome.gpuBenchmarking.pointerActionSequence( | 23 chrome.gpuBenchmarking.pointerActionSequence( |
| 25 [{ | 24 [{ |
| 26 'source': 'mouse', | 25 source: 'mouse', |
| 27 'actions': [{'name': 'pointerMove', 'x': 0, 'y': 0}] | 26 actions: [{name: 'pointerMove', x: 0, y: 0}] |
| 28 }], | 27 }], |
| 29 resolve); | 28 resolve); |
| 30 } else { | 29 } else { |
| 31 reject(); | 30 reject(); |
| 32 } | 31 } |
| 33 }); | 32 }); |
| 34 } | 33 } |
| 35 | 34 |
| 36 function mouseMoveIntoTarget(targetSelector, targetFrame) { | 35 function mouseMoveIntoTarget(targetSelector, targetFrame) { |
| 37 var targetDocument = document; | 36 var targetDocument = document; |
| 38 var frameLeft = 0; | 37 var frameLeft = 0; |
| 39 var frameTop = 0; | 38 var frameTop = 0; |
| 40 if (targetFrame !== undefined) { | 39 if (targetFrame !== undefined) { |
| 41 targetDocument = targetFrame.contentDocument; | 40 targetDocument = targetFrame.contentDocument; |
| 42 var frameRect = targetFrame.getBoundingClientRect(); | 41 var frameRect = targetFrame.getBoundingClientRect(); |
| 43 frameLeft = frameRect.left; | 42 frameLeft = frameRect.left; |
| 44 frameTop = frameRect.top; | 43 frameTop = frameRect.top; |
| 45 } | 44 } |
| 46 return new Promise(function(resolve, reject) { | 45 return new Promise(function(resolve, reject) { |
| 47 if (window.chrome && chrome.gpuBenchmarking) { | 46 if (window.chrome && chrome.gpuBenchmarking) { |
| 48 scrollPageIfNeeded(targetSelector, targetDocument); | 47 scrollPageIfNeeded(targetSelector, targetDocument); |
| 49 var target = targetDocument.querySelector(targetSelector); | 48 var target = targetDocument.querySelector(targetSelector); |
| 50 var targetRect = target.getBoundingClientRect(); | 49 var targetRect = target.getBoundingClientRect(); |
| 51 var xPosition = frameLeft + targetRect.left + boundaryOffset; | 50 var xPosition = frameLeft + targetRect.left + boundaryOffset; |
| 52 var yPosition = frameTop + targetRect.top + boundaryOffset; | 51 var yPosition = frameTop + targetRect.top + boundaryOffset; |
| 53 chrome.gpuBenchmarking.pointerActionSequence( | 52 chrome.gpuBenchmarking.pointerActionSequence( |
| 54 [{ | 53 [{ |
| 55 'source': 'mouse', | 54 source: 'mouse', |
| 56 'actions': | 55 actions: |
| 57 [{'name': 'pointerMove', 'x': xPosition, 'y': yPosition}] | 56 [{name: 'pointerMove', x: xPosition, y: yPosition}] |
| 58 }], | 57 }], |
| 59 resolve); | 58 resolve); |
| 60 } else { | 59 } else { |
| 61 reject(); | 60 reject(); |
| 62 } | 61 } |
| 63 }); | 62 }); |
| 64 } | 63 } |
| 65 | 64 |
| 66 function mouseChordedButtonPress(targetSelector) { | 65 function mouseChordedButtonPress(targetSelector) { |
| 67 return new Promise(function(resolve, reject) { | 66 return new Promise(function(resolve, reject) { |
| 68 if (window.chrome && chrome.gpuBenchmarking) { | 67 if (window.chrome && chrome.gpuBenchmarking) { |
| 69 scrollPageIfNeeded(targetSelector, document); | 68 scrollPageIfNeeded(targetSelector, document); |
| 70 var target = document.querySelector(targetSelector); | 69 var target = document.querySelector(targetSelector); |
| 71 var targetRect = target.getBoundingClientRect(); | 70 var targetRect = target.getBoundingClientRect(); |
| 72 var xPosition = targetRect.left + boundaryOffset; | 71 var xPosition = targetRect.left + boundaryOffset; |
| 73 var yPosition = targetRect.top + boundaryOffset; | 72 var yPosition = targetRect.top + boundaryOffset; |
| 74 chrome.gpuBenchmarking.pointerActionSequence( | 73 chrome.gpuBenchmarking.pointerActionSequence( |
| 75 [{ | 74 [{ |
| 76 'source': 'mouse', | 75 source: 'mouse', |
| 77 'actions': [ | 76 actions: [ |
| 78 { | 77 { |
| 79 'name': 'pointerDown', | 78 name: 'pointerDown', |
| 80 'x': xPosition, | 79 x: xPosition, |
| 81 'y': yPosition, | 80 y: yPosition, |
| 82 'button': 'left' | 81 button: 'left' |
| 83 }, | 82 }, |
| 84 { | 83 { |
| 85 'name': 'pointerDown', | 84 name: 'pointerDown', |
| 86 'x': xPosition, | 85 x: xPosition, |
| 87 'y': yPosition, | 86 y: yPosition, |
| 88 'button': 'middle' | 87 button: 'middle' |
| 89 }, | 88 }, |
| 90 {'name': 'pointerUp', 'button': 'middle'}, | 89 {name: 'pointerUp', button: 'middle'}, |
| 91 {'name': 'pointerUp', 'button': 'left'} | 90 {name: 'pointerUp', button: 'left'} |
| 92 ] | 91 ] |
| 93 }], | 92 }], |
| 94 resolve); | 93 resolve); |
| 95 } else { | 94 } else { |
| 96 reject(); | 95 reject(); |
| 97 } | 96 } |
| 98 }); | 97 }); |
| 99 } | 98 } |
| 100 | 99 |
| 101 function mouseClickInTarget(targetSelector, targetFrame) { | 100 function mouseClickInTarget(targetSelector, targetFrame) { |
| 102 var targetDocument = document; | 101 var targetDocument = document; |
| 103 var frameLeft = 0; | 102 var frameLeft = 0; |
| 104 var frameTop = 0; | 103 var frameTop = 0; |
| 105 if (targetFrame !== undefined) { | 104 if (targetFrame !== undefined) { |
| 106 targetDocument = targetFrame.contentDocument; | 105 targetDocument = targetFrame.contentDocument; |
| 107 var frameRect = targetFrame.getBoundingClientRect(); | 106 var frameRect = targetFrame.getBoundingClientRect(); |
| 108 frameLeft = frameRect.left; | 107 frameLeft = frameRect.left; |
| 109 frameTop = frameRect.top; | 108 frameTop = frameRect.top; |
| 110 } | 109 } |
| 111 return new Promise(function(resolve, reject) { | 110 return new Promise(function(resolve, reject) { |
| 112 if (window.chrome && chrome.gpuBenchmarking) { | 111 if (window.chrome && chrome.gpuBenchmarking) { |
| 113 scrollPageIfNeeded(targetSelector, targetDocument); | 112 scrollPageIfNeeded(targetSelector, targetDocument); |
| 114 var target = targetDocument.querySelector(targetSelector); | 113 var target = targetDocument.querySelector(targetSelector); |
| 115 var targetRect = target.getBoundingClientRect(); | 114 var targetRect = target.getBoundingClientRect(); |
| 116 var xPosition = frameLeft + targetRect.left + boundaryOffset; | 115 var xPosition = frameLeft + targetRect.left + boundaryOffset; |
| 117 var yPosition = frameTop + targetRect.top + boundaryOffset; | 116 var yPosition = frameTop + targetRect.top + boundaryOffset; |
| 118 chrome.gpuBenchmarking.pointerActionSequence( | 117 chrome.gpuBenchmarking.pointerActionSequence( |
| 119 [{ | 118 [{ |
| 120 'source': 'mouse', | 119 source: 'mouse', |
| 121 'actions': [ | 120 actions: [ |
| 122 {'name': 'pointerMove', 'x': xPosition, 'y': yPosition}, | 121 {name: 'pointerMove', x: xPosition, y: yPosition}, |
| 123 {'name': 'pointerDown', 'x': xPosition, 'y': yPosition}, | 122 {name: 'pointerDown', x: xPosition, y: yPosition}, |
| 124 {'name': 'pointerUp'} | 123 {name: 'pointerUp'} |
| 125 ] | 124 ] |
| 126 }], | 125 }], |
| 127 resolve); | 126 resolve); |
| 128 } else { | 127 } else { |
| 129 reject(); | 128 reject(); |
| 130 } | 129 } |
| 131 }); | 130 }); |
| 132 } | 131 } |
| 133 | 132 |
| 134 function mouseDragInTargets(targetSelectorList) { | 133 function mouseDragInTargets(targetSelectorList) { |
| 135 return new Promise(function(resolve, reject) { | 134 return new Promise(function(resolve, reject) { |
| 136 if (window.chrome && chrome.gpuBenchmarking) { | 135 if (window.chrome && chrome.gpuBenchmarking) { |
| 137 scrollPageIfNeeded(targetSelectorList[0], document); | 136 scrollPageIfNeeded(targetSelectorList[0], document); |
| 138 var target = document.querySelector(targetSelectorList[0]); | 137 var target = document.querySelector(targetSelectorList[0]); |
| 139 var targetRect = target.getBoundingClientRect(); | 138 var targetRect = target.getBoundingClientRect(); |
| 140 var xPosition = targetRect.left + boundaryOffset; | 139 var xPosition = targetRect.left + boundaryOffset; |
| 141 var yPosition = targetRect.top + boundaryOffset; | 140 var yPosition = targetRect.top + boundaryOffset; |
| 142 var pointerActions = [{'source': 'mouse'}]; | 141 var pointerActions = [{'source': 'mouse'}]; |
| 143 var pointerAction = pointerActions[0]; | 142 var pointerAction = pointerActions[0]; |
| 144 pointerAction.actions = []; | 143 pointerAction.actions = []; |
| 145 pointerAction.actions.push( | 144 pointerAction.actions.push( |
| 146 {'name': 'pointerDown', 'x': xPosition, 'y': yPosition}); | 145 {name: 'pointerDown', x: xPosition, y: yPosition}); |
| 147 for (var i = 1; i < targetSelectorList.length; i++) { | 146 for (var i = 1; i < targetSelectorList.length; i++) { |
| 148 scrollPageIfNeeded(targetSelectorList[i], document); | 147 scrollPageIfNeeded(targetSelectorList[i], document); |
| 149 target = document.querySelector(targetSelectorList[i]); | 148 target = document.querySelector(targetSelectorList[i]); |
| 150 targetRect = target.getBoundingClientRect(); | 149 targetRect = target.getBoundingClientRect(); |
| 151 xPosition = targetRect.left + boundaryOffset; | 150 xPosition = targetRect.left + boundaryOffset; |
| 152 yPosition = targetRect.top + boundaryOffset; | 151 yPosition = targetRect.top + boundaryOffset; |
| 153 pointerAction.actions.push( | 152 pointerAction.actions.push( |
| 154 {'name': 'pointerMove', 'x': xPosition, 'y': yPosition}); | 153 {name: 'pointerMove', x: xPosition, y: yPosition}); |
| 155 } | 154 } |
| 156 pointerAction.actions.push({'name': 'pointerUp'}); | 155 pointerAction.actions.push({name: 'pointerUp'}); |
| 157 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve); | 156 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve); |
| 158 } else { | 157 } else { |
| 159 reject(); | 158 reject(); |
| 160 } | 159 } |
| 161 }); | 160 }); |
| 162 } | 161 } |
| 163 | 162 |
| 164 function mouseDragInTarget(targetSelector) { | 163 function mouseDragInTarget(targetSelector) { |
| 165 return mouseDragInTargets([targetSelector, targetSelector]); | 164 return mouseDragInTargets([targetSelector, targetSelector]); |
| 166 } | 165 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 frameTop = frameRect.top; | 199 frameTop = frameRect.top; |
| 201 } | 200 } |
| 202 return new Promise(function(resolve, reject) { | 201 return new Promise(function(resolve, reject) { |
| 203 if (window.chrome && chrome.gpuBenchmarking) { | 202 if (window.chrome && chrome.gpuBenchmarking) { |
| 204 scrollPageIfNeeded(targetSelector, targetDocument); | 203 scrollPageIfNeeded(targetSelector, targetDocument); |
| 205 var target = targetDocument.querySelector(targetSelector); | 204 var target = targetDocument.querySelector(targetSelector); |
| 206 var targetRect = target.getBoundingClientRect(); | 205 var targetRect = target.getBoundingClientRect(); |
| 207 var xPosition = frameLeft + targetRect.left + boundaryOffset; | 206 var xPosition = frameLeft + targetRect.left + boundaryOffset; |
| 208 var yPosition = frameTop + targetRect.top + boundaryOffset; | 207 var yPosition = frameTop + targetRect.top + boundaryOffset; |
| 209 chrome.gpuBenchmarking.pointerActionSequence( [ | 208 chrome.gpuBenchmarking.pointerActionSequence( [ |
| 210 {"source": "touch", | 209 {source: 'touch', |
| 211 "actions": [ | 210 actions: [ |
| 212 { "name": "pointerDown", "x": xPosition, "y": yPosition }, | 211 { name: 'pointerDown', x: xPosition, y: yPosition }, |
| 213 { "name": "pointerUp" } | 212 { name: 'pointerUp' } |
| 214 ]}], resolve); | 213 ]}], resolve); |
| 215 } else { | 214 } else { |
| 216 reject(); | 215 reject(); |
| 216 } | |
| 217 }); | |
| 218 } | |
| 219 | |
| 220 function twoPointerDragInTarget(pointerType, targetSelector, direction) { | |
| 221 return new Promise(function(resolve, reject) { | |
| 222 if (window.chrome && chrome.gpuBenchmarking) { | |
| 223 scrollPageIfNeeded(targetSelector, document); | |
| 224 var target = document.querySelector(targetSelector); | |
| 225 var targetRect = target.getBoundingClientRect(); | |
| 226 var xPosition1 = targetRect.left + boundaryOffset + scrollOffset; | |
| 227 var yPosition1 = targetRect.top + boundaryOffset + scrollOffset; | |
| 228 var xPosition2 = xPosition1; | |
| 229 var yPosition2 = yPosition1; | |
| 230 var xPosition3 = xPosition1; | |
| 231 var yPosition3 = yPosition1; | |
| 232 if (direction == "down") { | |
| 233 yPosition1 -= scrollOffset; | |
| 234 yPosition3 += scrollOffset; | |
| 235 } else if (direction == "up") { | |
| 236 yPosition1 += scrollOffset; | |
| 237 yPosition3 -= scrollOffset; | |
| 238 } else if (direction == "right") { | |
| 239 xPosition1 -= scrollOffset; | |
| 240 xPosition3 += scrollOffset; | |
| 241 } else if (direction == "left") { | |
| 242 xPosition1 += scrollOffset; | |
| 243 xPosition3 -= scrollOffset; | |
| 244 } else | |
|
mustaq
2017/02/08 17:16:13
Nit: braces for the last |else| as well?
Navid Zolghadr
2017/02/08 17:36:23
Done.
| |
| 245 throw("drag direction '" + direction + "' is not expected, direction sho uld be 'down', 'up', 'left' or 'right'"); | |
| 246 | |
| 247 chrome.gpuBenchmarking.pointerActionSequence( [ | |
| 248 {"source": pointerType, | |
|
mustaq
2017/02/08 17:16:13
Omit double-quotes on keys ("source" etc) as in th
Navid Zolghadr
2017/02/08 17:36:23
Done.
| |
| 249 "actions": [ | |
| 250 { name: 'pointerDown', x: xPosition1, y: yPosition1 }, | |
| 251 { name: 'pointerMove', x: xPosition2, y: yPosition2 }, | |
| 252 { name: 'pointerMove', x: xPosition3, y: yPosition3 }, | |
| 253 { name: 'pause', duration: 0.1 }, | |
| 254 { name: 'pointerUp' } | |
| 255 ]}, | |
| 256 {"source": pointerType, | |
| 257 "actions": [ | |
| 258 { name: 'pointerDown', x: xPosition1 + boundaryOffset, y: yPosition1 }, | |
| 259 { name: 'pointerMove', x: xPosition2 + boundaryOffset, y: yPosition2 }, | |
| 260 { name: 'pointerMove', x: xPosition3 + boundaryOffset, y: yPosition3 }, | |
| 261 { name: 'pause', duration: 0.1 }, | |
| 262 { name: 'pointerUp' } | |
| 263 ]}], resolve); | |
| 264 } else { | |
| 265 reject(); | |
| 217 } | 266 } |
| 218 }); | 267 }); |
| 219 } | 268 } |
| 220 | 269 |
| 221 function pointerDragInTarget(pointerType, targetSelector, direction) { | 270 function pointerDragInTarget(pointerType, targetSelector, direction) { |
| 222 return new Promise(function(resolve, reject) { | 271 return new Promise(function(resolve, reject) { |
| 223 if (window.chrome && chrome.gpuBenchmarking) { | 272 if (window.chrome && chrome.gpuBenchmarking) { |
| 224 scrollPageIfNeeded(targetSelector, document); | 273 scrollPageIfNeeded(targetSelector, document); |
| 225 var target = document.querySelector(targetSelector); | 274 var target = document.querySelector(targetSelector); |
| 226 var targetRect = target.getBoundingClientRect(); | 275 var targetRect = target.getBoundingClientRect(); |
| 227 var xPosition = targetRect.left + boundaryOffset; | 276 var xPosition1 = targetRect.left + boundaryOffset + scrollOffset; |
| 228 var yPosition = targetRect.top + boundaryOffset; | 277 var yPosition1 = targetRect.top + boundaryOffset + scrollOffset; |
| 229 var newXPosition = xPosition; | 278 var xPosition2 = xPosition1; |
| 230 var newYPosition = yPosition; | 279 var yPosition2 = yPosition1; |
| 231 if (direction == "down") | 280 var xPosition3 = xPosition1; |
| 232 newYPosition += scrollOffset; | 281 var yPosition3 = yPosition1; |
| 233 else if (direction == "up") | 282 if (direction == "down") { |
| 234 newYPosition -= scrollOffset; | 283 yPosition1 -= scrollOffset; |
| 235 else if (direction == "right") | 284 yPosition3 += scrollOffset; |
| 236 newXPosition += scrollOffset; | 285 } else if (direction == "up") { |
| 237 else if (direction == "left") | 286 yPosition1 += scrollOffset; |
| 238 newXPosition -= scrollOffset; | 287 yPosition3 -= scrollOffset; |
| 239 else | 288 } else if (direction == "right") { |
| 289 xPosition1 -= scrollOffset; | |
| 290 xPosition3 += scrollOffset; | |
| 291 } else if (direction == "left") { | |
| 292 xPosition1 += scrollOffset; | |
| 293 xPosition3 -= scrollOffset; | |
| 294 } else | |
| 240 throw("drag direction '" + direction + "' is not expected, direction sho uld be 'down', 'up', 'left' or 'right'"); | 295 throw("drag direction '" + direction + "' is not expected, direction sho uld be 'down', 'up', 'left' or 'right'"); |
| 241 | 296 |
| 242 chrome.gpuBenchmarking.pointerActionSequence( [ | 297 chrome.gpuBenchmarking.pointerActionSequence( [ |
| 243 {"source": pointerType, | 298 {"source": pointerType, |
|
mustaq
2017/02/08 17:16:13
Ditto on double-quotes.
Navid Zolghadr
2017/02/08 17:36:23
Done.
| |
| 244 "actions": [ | 299 "actions": [ |
| 245 { "name": "pointerDown", "x": xPosition, "y": yPosition }, | 300 { name: 'pointerDown', x: xPosition1, y: yPosition1 }, |
| 246 { "name": "pointerMove", "x": newXPosition, "y": newYPosition }, | 301 { name: 'pointerMove', x: xPosition2, y: yPosition2 }, |
| 247 { "name": "pause", "duration": 0.1 }, | 302 { name: 'pointerMove', x: xPosition3, y: yPosition3 }, |
| 248 { "name": "pointerUp" } | 303 { name: 'pause', duration: 0.1 }, |
| 304 { name: 'pointerUp' } | |
| 249 ]}], resolve); | 305 ]}], resolve); |
| 250 } else { | 306 } else { |
| 251 reject(); | 307 reject(); |
| 252 } | 308 } |
| 253 }); | 309 }); |
| 254 } | 310 } |
| 255 | 311 |
| 256 function touchScrollInTarget(targetSelector, direction) { | 312 function touchScrollInTarget(targetSelector, direction) { |
| 257 if (direction == "down") | 313 if (direction == "down") |
| 258 direction = "up"; | 314 direction = "up"; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 273 var targetRect = target.getBoundingClientRect(); | 329 var targetRect = target.getBoundingClientRect(); |
| 274 var xPosition = targetRect.left + (targetRect.width/2); | 330 var xPosition = targetRect.left + (targetRect.width/2); |
| 275 var yPosition1 = targetRect.top + (targetRect.height/2) - 10; | 331 var yPosition1 = targetRect.top + (targetRect.height/2) - 10; |
| 276 var yPosition2 = targetRect.top + (targetRect.height/2) + 10; | 332 var yPosition2 = targetRect.top + (targetRect.height/2) + 10; |
| 277 var pointerActions = [{'source': 'touch'}, {'source': 'touch'}]; | 333 var pointerActions = [{'source': 'touch'}, {'source': 'touch'}]; |
| 278 var pointerAction1 = pointerActions[0]; | 334 var pointerAction1 = pointerActions[0]; |
| 279 var pointerAction2 = pointerActions[1]; | 335 var pointerAction2 = pointerActions[1]; |
| 280 pointerAction1.actions = []; | 336 pointerAction1.actions = []; |
| 281 pointerAction2.actions = []; | 337 pointerAction2.actions = []; |
| 282 pointerAction1.actions.push( | 338 pointerAction1.actions.push( |
| 283 {'name': 'pointerDown', 'x': xPosition, 'y': yPosition1}); | 339 {name: 'pointerDown', x: xPosition, y: yPosition1}); |
| 284 pointerAction2.actions.push( | 340 pointerAction2.actions.push( |
| 285 {'name': 'pointerDown', 'x': xPosition, 'y': yPosition2}); | 341 {name: 'pointerDown', x: xPosition, y: yPosition2}); |
| 286 for (var offset = 10; offset < 80; offset += 10) { | 342 for (var offset = 10; offset < 80; offset += 10) { |
| 287 pointerAction1.actions.push({ | 343 pointerAction1.actions.push({ |
| 288 'name': 'pointerMove', | 344 name: 'pointerMove', |
| 289 'x': xPosition, | 345 x: xPosition, |
| 290 'y': (yPosition1 - offset) | 346 y: (yPosition1 - offset) |
| 291 }); | 347 }); |
| 292 pointerAction2.actions.push({ | 348 pointerAction2.actions.push({ |
| 293 'name': 'pointerMove', | 349 name: 'pointerMove', |
| 294 'x': xPosition, | 350 x: xPosition, |
| 295 'y': (yPosition2 + offset) | 351 y: (yPosition2 + offset) |
| 296 }); | 352 }); |
| 297 } | 353 } |
| 298 pointerAction1.actions.push({'name': 'pointerUp'}); | 354 pointerAction1.actions.push({name: 'pointerUp'}); |
| 299 pointerAction2.actions.push({'name': 'pointerUp'}); | 355 pointerAction2.actions.push({name: 'pointerUp'}); |
| 300 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve); | 356 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve); |
| 301 } else { | 357 } else { |
| 302 reject(); | 358 reject(); |
| 303 } | 359 } |
| 304 }); | 360 }); |
| 305 } | 361 } |
| 306 | 362 |
| 307 // Pen inputs. | 363 // Pen inputs. |
| 308 function penMoveToDocument() { | 364 function penMoveToDocument() { |
| 309 return new Promise(function(resolve, reject) { | 365 return new Promise(function(resolve, reject) { |
| 310 if (window.chrome && chrome.gpuBenchmarking) { | 366 if (window.chrome && chrome.gpuBenchmarking) { |
| 311 chrome.gpuBenchmarking.pointerActionSequence( [ | 367 chrome.gpuBenchmarking.pointerActionSequence( [ |
| 312 {"source": "pen", | 368 {source: 'pen', |
| 313 "actions": [ | 369 actions: [ |
| 314 { "name": "pointerMove", "x": 0, "y": 0 } | 370 { name: 'pointerMove', x: 0, y: 0 } |
| 315 ]}], resolve); | 371 ]}], resolve); |
| 316 } else { | 372 } else { |
| 317 reject(); | 373 reject(); |
| 318 } | 374 } |
| 319 }); | 375 }); |
| 320 } | 376 } |
| 321 | 377 |
| 322 function penMoveIntoTarget(targetSelector, targetFrame) { | 378 function penMoveIntoTarget(targetSelector, targetFrame) { |
| 323 var targetDocument = document; | 379 var targetDocument = document; |
| 324 var frameLeft = 0; | 380 var frameLeft = 0; |
| 325 var frameTop = 0; | 381 var frameTop = 0; |
| 326 if (targetFrame !== undefined) { | 382 if (targetFrame !== undefined) { |
| 327 targetDocument = targetFrame.contentDocument; | 383 targetDocument = targetFrame.contentDocument; |
| 328 var frameRect = targetFrame.getBoundingClientRect(); | 384 var frameRect = targetFrame.getBoundingClientRect(); |
| 329 frameLeft = frameRect.left; | 385 frameLeft = frameRect.left; |
| 330 frameTop = frameRect.top; | 386 frameTop = frameRect.top; |
| 331 } | 387 } |
| 332 return new Promise(function(resolve, reject) { | 388 return new Promise(function(resolve, reject) { |
| 333 if (window.chrome && chrome.gpuBenchmarking) { | 389 if (window.chrome && chrome.gpuBenchmarking) { |
| 334 var target = targetDocument.querySelector(targetSelector); | 390 var target = targetDocument.querySelector(targetSelector); |
| 335 var targetRect = target.getBoundingClientRect(); | 391 var targetRect = target.getBoundingClientRect(); |
| 336 var xPosition = frameLeft + targetRect.left + boundaryOffset; | 392 var xPosition = frameLeft + targetRect.left + boundaryOffset; |
| 337 var yPosition = frameTop + targetRect.top + boundaryOffset; | 393 var yPosition = frameTop + targetRect.top + boundaryOffset; |
| 338 chrome.gpuBenchmarking.pointerActionSequence( [ | 394 chrome.gpuBenchmarking.pointerActionSequence( [ |
| 339 {"source": "pen", | 395 {source: 'pen', |
| 340 "actions": [ | 396 actions: [ |
| 341 { "name": "pointerMove", "x": xPosition, "y": yPosition } | 397 { name: 'pointerMove', x: xPosition, y: yPosition } |
| 342 ]}], resolve); | 398 ]}], resolve); |
| 343 } else { | 399 } else { |
| 344 reject(); | 400 reject(); |
| 345 } | 401 } |
| 346 }); | 402 }); |
| 347 } | 403 } |
| 348 | 404 |
| 349 function penClickInTarget(targetSelector, targetFrame) { | 405 function penClickInTarget(targetSelector, targetFrame) { |
| 350 var targetDocument = document; | 406 var targetDocument = document; |
| 351 var frameLeft = 0; | 407 var frameLeft = 0; |
| 352 var frameTop = 0; | 408 var frameTop = 0; |
| 353 if (targetFrame !== undefined) { | 409 if (targetFrame !== undefined) { |
| 354 targetDocument = targetFrame.contentDocument; | 410 targetDocument = targetFrame.contentDocument; |
| 355 var frameRect = targetFrame.getBoundingClientRect(); | 411 var frameRect = targetFrame.getBoundingClientRect(); |
| 356 frameLeft = frameRect.left; | 412 frameLeft = frameRect.left; |
| 357 frameTop = frameRect.top; | 413 frameTop = frameRect.top; |
| 358 } | 414 } |
| 359 return new Promise(function(resolve, reject) { | 415 return new Promise(function(resolve, reject) { |
| 360 if (window.chrome && chrome.gpuBenchmarking) { | 416 if (window.chrome && chrome.gpuBenchmarking) { |
| 361 scrollPageIfNeeded(targetSelector, targetDocument); | 417 scrollPageIfNeeded(targetSelector, targetDocument); |
| 362 var target = targetDocument.querySelector(targetSelector); | 418 var target = targetDocument.querySelector(targetSelector); |
| 363 var targetRect = target.getBoundingClientRect(); | 419 var targetRect = target.getBoundingClientRect(); |
| 364 var xPosition = frameLeft + targetRect.left + boundaryOffset; | 420 var xPosition = frameLeft + targetRect.left + boundaryOffset; |
| 365 var yPosition = frameTop + targetRect.top + boundaryOffset; | 421 var yPosition = frameTop + targetRect.top + boundaryOffset; |
| 366 chrome.gpuBenchmarking.pointerActionSequence( [ | 422 chrome.gpuBenchmarking.pointerActionSequence( [ |
| 367 {"source": "pen", | 423 {source: 'pen', |
| 368 "actions": [ | 424 actions: [ |
| 369 { "name": "pointerMove", "x": xPosition, "y": yPosition }, | 425 { name: 'pointerMove', x: xPosition, y: yPosition }, |
| 370 { "name": "pointerDown", "x": xPosition, "y": yPosition }, | 426 { name: 'pointerDown', x: xPosition, y: yPosition }, |
| 371 { "name": "pointerUp" } | 427 { name: 'pointerUp' } |
| 372 ]}], resolve); | 428 ]}], resolve); |
| 373 } else { | 429 } else { |
| 374 reject(); | 430 reject(); |
| 375 } | 431 } |
| 376 }); | 432 }); |
| 377 } | 433 } |
| 378 | 434 |
| 379 // Keyboard inputs. | 435 // Keyboard inputs. |
| 380 function keyboardScroll(direction) { | 436 function keyboardScroll(direction) { |
| 381 return new Promise(function(resolve, reject) { | 437 return new Promise(function(resolve, reject) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 394 } | 450 } |
| 395 | 451 |
| 396 { | 452 { |
| 397 var pointerevent_automation = async_test("PointerEvent Automation"); | 453 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. | 454 // Defined in every test and should return a promise that gets resolved when i nput is finished. |
| 399 inject_input().then(function() { | 455 inject_input().then(function() { |
| 400 pointerevent_automation.done(); | 456 pointerevent_automation.done(); |
| 401 }); | 457 }); |
| 402 } | 458 } |
| 403 | 459 |
| OLD | NEW |