OLD | NEW |
1 // A SmoothScrollInterruptionTest verifies that in-progress smooth scrolls | 1 // A SmoothScrollInterruptionTest verifies that in-progress smooth scrolls |
2 // stop when interrupted by an instant scroll, another smooth scroll, a | 2 // stop when interrupted by an instant scroll, another smooth scroll, a |
3 // touch scroll, or a mouse wheel scroll. | 3 // touch scroll, or a mouse wheel scroll. |
4 // | 4 // |
5 // The only SmoothScrollInerruptionTest method that should be called by | 5 // The only SmoothScrollInerruptionTest method that should be called by |
6 // outside code is run(). | 6 // outside code is run(). |
7 // | 7 // |
8 // Creates a SmoothScrollInterruptionTest with arguments: | 8 // Creates a SmoothScrollInterruptionTest with arguments: |
9 // scrollElement - Element being scrolled. | 9 // scrollElement - Element being scrolled. |
10 // innerPoint - Absolute position (expressed as a dictionary with x and y fields
) | 10 // innerPoint - Absolute position (expressed as a dictionary with x and y fields
) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 window.requestAnimationFrame(this.waitForSmoothScrollStart.bind(this)); | 69 window.requestAnimationFrame(this.waitForSmoothScrollStart.bind(this)); |
70 } | 70 } |
71 | 71 |
72 SmoothScrollInterruptionTest.prototype.waitForSmoothScrollStart = function() { | 72 SmoothScrollInterruptionTest.prototype.waitForSmoothScrollStart = function() { |
73 if (this.scrollElement.scrollTop == this.scrollStartPoint) { | 73 if (this.scrollElement.scrollTop == this.scrollStartPoint) { |
74 window.requestAnimationFrame(this.waitForSmoothScrollStart.bind(this)); | 74 window.requestAnimationFrame(this.waitForSmoothScrollStart.bind(this)); |
75 return; | 75 return; |
76 } | 76 } |
77 | 77 |
78 var scrollElement = this.scrollElement; | |
79 var scrollEndPoint = this.scrollEndPoint; | |
80 this.asyncTest.step(function() { | |
81 assert_not_equals(scrollElement.scrollTop, scrollEndPoint); | |
82 }); | |
83 | |
84 var testCase = this.testCases[this.currentTestCase]; | 78 var testCase = this.testCases[this.currentTestCase]; |
85 testCase.interruptSmoothScroll(this); | 79 testCase.interruptSmoothScroll(this); |
86 window.requestAnimationFrame(testCase.verifyScrollInterrupted.bind(testCase,
this, this.testCaseComplete.bind(this))); | 80 window.requestAnimationFrame(testCase.verifyScrollInterrupted.bind(testCase,
this, this.testCaseComplete.bind(this))); |
87 } | 81 } |
88 | 82 |
89 SmoothScrollInterruptionTest.prototype.testCaseComplete = function() { | 83 SmoothScrollInterruptionTest.prototype.testCaseComplete = function() { |
90 this.asyncTest.done(); | 84 this.asyncTest.done(); |
91 | 85 |
92 this.currentTestCase++; | 86 this.currentTestCase++; |
93 this.startNextTestCase(); | 87 this.startNextTestCase(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 smoothScrollTest.asyncTest.step(function() { | 134 smoothScrollTest.asyncTest.step(function() { |
141 assert_not_equals(smoothScrollTest.scrollElement.scrollTop, smoothScroll
Test.scrollNewEndpoint); | 135 assert_not_equals(smoothScrollTest.scrollElement.scrollTop, smoothScroll
Test.scrollNewEndpoint); |
142 }); | 136 }); |
143 | 137 |
144 this.scrollInterruptionPoint = smoothScrollTest.scrollElement.scrollTop; | 138 this.scrollInterruptionPoint = smoothScrollTest.scrollElement.scrollTop; |
145 } | 139 } |
146 | 140 |
147 function verifyScrollInterruptedBySmoothScroll(smoothScrollTest, verificationCom
plete) { | 141 function verifyScrollInterruptedBySmoothScroll(smoothScrollTest, verificationCom
plete) { |
148 var currentPosition = smoothScrollTest.scrollElement.scrollTop; | 142 var currentPosition = smoothScrollTest.scrollElement.scrollTop; |
149 | 143 |
150 if (currentPosition < this.scrollInterruptionPoint && currentPosition > smoo
thScrollTest.scrollNewEndpoint) { | 144 if (currentPosition < this.scrollInterruptionPoint && currentPosition >= smo
othScrollTest.scrollNewEndpoint) { |
151 verificationComplete(); | 145 verificationComplete(); |
152 } else { | 146 } else { |
153 window.requestAnimationFrame(this.verifyScrollInterrupted.bind(this, smo
othScrollTest, verificationComplete)); | 147 window.requestAnimationFrame(this.verifyScrollInterrupted.bind(this, smo
othScrollTest, verificationComplete)); |
154 } | 148 } |
155 } | 149 } |
156 | 150 |
157 function interruptWithTouchScroll(smoothScrollTest) { | 151 function interruptWithTouchScroll(smoothScrollTest) { |
158 if (window.eventSender) { | 152 if (window.eventSender) { |
159 window.eventSender.gestureScrollBegin(smoothScrollTest.innerPoint.x, smo
othScrollTest.innerPoint.y); | 153 window.eventSender.gestureScrollBegin(smoothScrollTest.innerPoint.x, smo
othScrollTest.innerPoint.y); |
160 window.eventSender.gestureScrollUpdate(0, -10); | 154 window.eventSender.gestureScrollUpdate(0, -10); |
(...skipping 28 matching lines...) Expand all Loading... |
189 } | 183 } |
190 | 184 |
191 function interruptWithWheelScroll(smoothScrollTest) { | 185 function interruptWithWheelScroll(smoothScrollTest) { |
192 if (window.eventSender) { | 186 if (window.eventSender) { |
193 window.eventSender.mouseMoveTo(smoothScrollTest.innerPoint.x, smoothScro
llTest.innerPoint.y); | 187 window.eventSender.mouseMoveTo(smoothScrollTest.innerPoint.x, smoothScro
llTest.innerPoint.y); |
194 window.eventSender.mouseScrollBy(0, -10); | 188 window.eventSender.mouseScrollBy(0, -10); |
195 } else { | 189 } else { |
196 document.write("This test does not work in manual mode."); | 190 document.write("This test does not work in manual mode."); |
197 } | 191 } |
198 } | 192 } |
OLD | NEW |