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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 var targetRect = target.getBoundingClientRect(); | 116 var targetRect = target.getBoundingClientRect(); |
117 chrome.gpuBenchmarking.smoothScrollBy(scrollOffset, function() { | 117 chrome.gpuBenchmarking.smoothScrollBy(scrollOffset, function() { |
118 resolve(); | 118 resolve(); |
119 }, targetRect.left + boundaryOffset, targetRect.top + boundaryOffset, touc
hSourceType, direction); | 119 }, targetRect.left + boundaryOffset, targetRect.top + boundaryOffset, touc
hSourceType, direction); |
120 } else { | 120 } else { |
121 reject(); | 121 reject(); |
122 } | 122 } |
123 }); | 123 }); |
124 } | 124 } |
125 | 125 |
| 126 function pinchZoomInTarget(targetSelector, scale) { |
| 127 return new Promise(function(resolve, reject) { |
| 128 if (window.chrome && chrome.gpuBenchmarking) { |
| 129 scrollPageIfNeeded(targetSelector); |
| 130 var target = document.querySelector(targetSelector); |
| 131 var targetRect = target.getBoundingClientRect(); |
| 132 chrome.gpuBenchmarking.pinchBy(scale, targetRect.left + (targetRect.width/
2), targetRect.top + (targetRect.height/2), function() { |
| 133 resolve(); |
| 134 }); |
| 135 } else { |
| 136 reject(); |
| 137 } |
| 138 }); |
| 139 } |
| 140 |
126 // Pen inputs. | 141 // Pen inputs. |
127 function penMoveToDocument() { | 142 function penMoveToDocument() { |
128 return new Promise(function(resolve, reject) { | 143 return new Promise(function(resolve, reject) { |
129 if (window.eventSender) { | 144 if (window.eventSender) { |
130 eventSender.mouseMoveTo(0, 0, [], "pen", 0); | 145 eventSender.mouseMoveTo(0, 0, [], "pen", 0); |
131 resolve(); | 146 resolve(); |
132 } else { | 147 } else { |
133 reject(); | 148 reject(); |
134 } | 149 } |
135 }); | 150 }); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 195 } |
181 | 196 |
182 { | 197 { |
183 var pointerevent_automation = async_test("PointerEvent Automation"); | 198 var pointerevent_automation = async_test("PointerEvent Automation"); |
184 // Defined in every test and should return a promise that gets resolved when i
nput is finished. | 199 // Defined in every test and should return a promise that gets resolved when i
nput is finished. |
185 inject_input().then(function() { | 200 inject_input().then(function() { |
186 pointerevent_automation.done(); | 201 pointerevent_automation.done(); |
187 }); | 202 }); |
188 } | 203 } |
189 | 204 |
OLD | NEW |