| OLD | NEW |
| 1 'use strict'; | 1 'use strict'; |
| 2 | 2 |
| 3 class CompositedAnimationTestCommon { | 3 class CompositedAnimationTestCommon { |
| 4 constructor(composited) { | 4 constructor(composited) { |
| 5 this.composited = composited; | 5 this.composited = composited; |
| 6 this.tests = []; | 6 this.tests = []; |
| 7 this.nextInstanceId = 1; | 7 this.nextInstanceId = 1; |
| 8 this.errorCount = 0; |
| 8 | 9 |
| 9 this.createStyles(); | 10 this.createStyles(); |
| 10 this.createStaticElements(); | 11 this.createStaticElements(); |
| 11 } | 12 } |
| 12 | 13 |
| 13 createStyles() { | 14 createStyles() { |
| 14 var styleSheet = document.createElement('style'); | 15 var styleSheet = document.createElement('style'); |
| 15 styleSheet.textContent = ` | 16 styleSheet.textContent = ` |
| 16 .item { | 17 .item { |
| 17 width: 20px; | 18 width: 20px; |
| 18 height: 20px; | 19 height: 20px; |
| 19 position: relative; | 20 position: relative; |
| 20 background: black; | 21 background: black; |
| 21 float: left; | 22 float: left; |
| 22 } | 23 } |
| 23 .marker { | 24 .marker { |
| 24 width: 5px; | 25 width: 5px; |
| 25 height: 5px; | 26 height: 5px; |
| 26 display: inline-block; | 27 display: inline-block; |
| 27 background: orange; | 28 background: orange; |
| 28 margin: 15px; | 29 margin: 15px; |
| 29 }`; | 30 }`; |
| 30 | 31 |
| 31 document.head.appendChild(styleSheet); | 32 document.head.appendChild(styleSheet); |
| 32 } | 33 } |
| 33 | 34 |
| 34 createStaticElements() { | 35 createStaticElements() { |
| 35 this.error = document.createElement('span'); | 36 this.error = document.createElement('span'); |
| 36 this.error.style.color = 'red'; | 37 this.error.style = 'color: red; font-family: monospace; font-size: 12px'; |
| 37 // The element must have some painted content in order to be composited. | 38 // The error element must have some painted content in order to be |
| 38 this.error.textContent = 'x'; | 39 // composited when animated in SPv2. |
| 40 this.error.innerText = '(no errors)'; |
| 39 document.body.appendChild(this.error); | 41 document.body.appendChild(this.error); |
| 40 | 42 |
| 41 this.wrapper = document.createElement('div'); | 43 this.wrapper = document.createElement('div'); |
| 42 document.body.appendChild(this.wrapper); | 44 document.body.appendChild(this.wrapper); |
| 43 } | 45 } |
| 44 | 46 |
| 45 createTestElements() { | 47 createTestElements() { |
| 46 this.tests.forEach(test => { | 48 this.tests.forEach(test => { |
| 47 test.testWrapper = document.createElement('div'); | 49 test.testWrapper = document.createElement('div'); |
| 48 this.wrapper.appendChild(test.testWrapper); | 50 this.wrapper.appendChild(test.testWrapper); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 124 |
| 123 if (window.internals) | 125 if (window.internals) |
| 124 internals.pauseAnimations(0); | 126 internals.pauseAnimations(0); |
| 125 } | 127 } |
| 126 | 128 |
| 127 assertAnimationCompositedState() { | 129 assertAnimationCompositedState() { |
| 128 this.tests.forEach(test => { | 130 this.tests.forEach(test => { |
| 129 test.instances.forEach(instance => { | 131 test.instances.forEach(instance => { |
| 130 var composited = internals.isCompositedAnimation(instance.animation); | 132 var composited = internals.isCompositedAnimation(instance.animation); |
| 131 if (composited != this.composited) | 133 if (composited != this.composited) |
| 132 this.reportError(test, `Animation ${composited ? 'is' : 'is not'} runn
ing on the compositor.`); | 134 this.reportError(test, `Animation ${composited ? 'is' : 'is not'} runn
ing on the compositor [id=${instance.id}].`); |
| 133 }); | 135 }); |
| 134 }); | 136 }); |
| 135 } | 137 } |
| 136 | 138 |
| 137 reportError(test, message) { | 139 reportError(test, message) { |
| 138 if (!this.error.textContent) | 140 if (this.errorCount == 0) |
| 139 this.error.textContent = `${this.composited ? 'Tests:' : 'TestExpectations
:'} `; | 141 this.error.innerHTML = `${this.composited ? 'Tests:' : 'TestExpectations:'
}<br>`; |
| 140 | 142 |
| 141 this.error.textContent += `${test.name}: ${message} `; | 143 if (this.errorCount > 0) |
| 144 this.error.innerHTML += '<br>'; |
| 145 this.error.innerHTML += `${test.name}: ${message} `; |
| 146 this.errorCount++; |
| 142 } | 147 } |
| 143 | 148 |
| 144 waitForCompositor() { | 149 waitForCompositor() { |
| 145 return this.error.animate({opacity: ['1', '1']}, 1).ready; | 150 return this.error.animate({opacity: ['1', '1']}, 1).ready; |
| 146 } | 151 } |
| 147 | 152 |
| 148 layoutAndPaint() { | 153 layoutAndPaint() { |
| 149 if (window.testRunner) | 154 if (window.testRunner) |
| 150 testRunner.waitUntilDone(); | 155 testRunner.waitUntilDone(); |
| 151 | 156 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 213 } |
| 209 | 214 |
| 210 var getLinearSamples = function(n, start, end) { | 215 var getLinearSamples = function(n, start, end) { |
| 211 var arr = []; | 216 var arr = []; |
| 212 var spread = end - start; | 217 var spread = end - start; |
| 213 for (var i = 0; i <= n; i++) | 218 for (var i = 0; i <= n; i++) |
| 214 arr.push(i * spread / n + start); | 219 arr.push(i * spread / n + start); |
| 215 return arr.map(t => { return {at: t} }); | 220 return arr.map(t => { return {at: t} }); |
| 216 } | 221 } |
| 217 | 222 |
| OLD | NEW |