| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 "actions": [ | 211 "actions": [ |
| 212 { "name": "pointerDown", "x": xPosition, "y": yPosition }, | 212 { "name": "pointerDown", "x": xPosition, "y": yPosition }, |
| 213 { "name": "pointerUp" } | 213 { "name": "pointerUp" } |
| 214 ]}], resolve); | 214 ]}], resolve); |
| 215 } else { | 215 } else { |
| 216 reject(); | 216 reject(); |
| 217 } | 217 } |
| 218 }); | 218 }); |
| 219 } | 219 } |
| 220 | 220 |
| 221 function touchScrollInTarget(targetSelector, direction) { | 221 function pointerDragInTarget(pointerType, targetSelector, direction) { |
| 222 return new Promise(function(resolve, reject) { | 222 return new Promise(function(resolve, reject) { |
| 223 if (window.chrome && chrome.gpuBenchmarking) { | 223 if (window.chrome && chrome.gpuBenchmarking) { |
| 224 scrollPageIfNeeded(targetSelector, document); | 224 scrollPageIfNeeded(targetSelector, document); |
| 225 var target = document.querySelector(targetSelector); | 225 var target = document.querySelector(targetSelector); |
| 226 var targetRect = target.getBoundingClientRect(); | 226 var targetRect = target.getBoundingClientRect(); |
| 227 var xPosition = targetRect.left + boundaryOffset; | 227 var xPosition = targetRect.left + boundaryOffset; |
| 228 var yPosition = targetRect.top + boundaryOffset; | 228 var yPosition = targetRect.top + boundaryOffset; |
| 229 var newXPosition = xPosition; | 229 var newXPosition = xPosition; |
| 230 var newYPosition = yPosition; | 230 var newYPosition = yPosition; |
| 231 if (direction == "down") | 231 if (direction == "down") |
| 232 newYPosition += scrollOffset; |
| 233 else if (direction == "up") |
| 232 newYPosition -= scrollOffset; | 234 newYPosition -= scrollOffset; |
| 233 else if (direction == "up") | |
| 234 newYPosition += scrollOffset; | |
| 235 else if (direction == "right") | 235 else if (direction == "right") |
| 236 newXPosition += scrollOffset; |
| 237 else if (direction == "left") |
| 236 newXPosition -= scrollOffset; | 238 newXPosition -= scrollOffset; |
| 237 else if (direction == "left") | |
| 238 newXPosition += scrollOffset; | |
| 239 else | 239 else |
| 240 throw("Scroll direction '" + direction + "' is not expected, we expecte
'down', 'up', 'left' or 'right'"); | 240 throw("drag direction '" + direction + "' is not expected, direction sho
uld be 'down', 'up', 'left' or 'right'"); |
| 241 | 241 |
| 242 chrome.gpuBenchmarking.pointerActionSequence( [ | 242 chrome.gpuBenchmarking.pointerActionSequence( [ |
| 243 {"source": "touch", | 243 {"source": pointerType, |
| 244 "actions": [ | 244 "actions": [ |
| 245 { "name": "pointerDown", "x": xPosition, "y": yPosition }, | 245 { "name": "pointerDown", "x": xPosition, "y": yPosition }, |
| 246 { "name": "pointerMove", "x": newXPosition, "y": newYPosition }, | 246 { "name": "pointerMove", "x": newXPosition, "y": newYPosition }, |
| 247 { "name": "pause", "duration": 0.1 }, | 247 { "name": "pause", "duration": 0.1 }, |
| 248 { "name": "pointerUp" } | 248 { "name": "pointerUp" } |
| 249 ]}], resolve); | 249 ]}], resolve); |
| 250 } else { | 250 } else { |
| 251 reject(); | 251 reject(); |
| 252 } | 252 } |
| 253 }); | 253 }); |
| 254 } | 254 } |
| 255 | 255 |
| 256 function touchScrollInTarget(targetSelector, direction) { |
| 257 if (direction == "down") |
| 258 direction = "up"; |
| 259 else if (direction == "up") |
| 260 direction = "down"; |
| 261 else if (direction == "right") |
| 262 direction = "left"; |
| 263 else if (direction == "left") |
| 264 direction = "right"; |
| 265 return pointerDragInTarget('touch', targetSelector, direction); |
| 266 } |
| 267 |
| 256 function pinchZoomInTarget(targetSelector, scale) { | 268 function pinchZoomInTarget(targetSelector, scale) { |
| 257 return new Promise(function(resolve, reject) { | 269 return new Promise(function(resolve, reject) { |
| 258 if (window.chrome && chrome.gpuBenchmarking) { | 270 if (window.chrome && chrome.gpuBenchmarking) { |
| 259 scrollPageIfNeeded(targetSelector, document); | 271 scrollPageIfNeeded(targetSelector, document); |
| 260 var target = document.querySelector(targetSelector); | 272 var target = document.querySelector(targetSelector); |
| 261 var targetRect = target.getBoundingClientRect(); | 273 var targetRect = target.getBoundingClientRect(); |
| 262 var xPosition = targetRect.left + (targetRect.width/2); | 274 var xPosition = targetRect.left + (targetRect.width/2); |
| 263 var yPosition1 = targetRect.top + (targetRect.height/2) - 10; | 275 var yPosition1 = targetRect.top + (targetRect.height/2) - 10; |
| 264 var yPosition2 = targetRect.top + (targetRect.height/2) + 10; | 276 var yPosition2 = targetRect.top + (targetRect.height/2) + 10; |
| 265 var pointerActions = [{'source': 'touch'}, {'source': 'touch'}]; | 277 var pointerActions = [{'source': 'touch'}, {'source': 'touch'}]; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 } | 394 } |
| 383 | 395 |
| 384 { | 396 { |
| 385 var pointerevent_automation = async_test("PointerEvent Automation"); | 397 var pointerevent_automation = async_test("PointerEvent Automation"); |
| 386 // Defined in every test and should return a promise that gets resolved when i
nput is finished. | 398 // Defined in every test and should return a promise that gets resolved when i
nput is finished. |
| 387 inject_input().then(function() { | 399 inject_input().then(function() { |
| 388 pointerevent_automation.done(); | 400 pointerevent_automation.done(); |
| 389 }); | 401 }); |
| 390 } | 402 } |
| 391 | 403 |
| OLD | NEW |