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 29 matching lines...) Expand all Loading... |
40 return; | 40 return; |
41 } | 41 } |
42 | 42 |
43 var testCase = this.testCases[this.currentTestCase]; | 43 var testCase = this.testCases[this.currentTestCase]; |
44 this.asyncTest = async_test(testCase.description); | 44 this.asyncTest = async_test(testCase.description); |
45 | 45 |
46 var scrollElement = this.scrollElement; | 46 var scrollElement = this.scrollElement; |
47 var scrollStartPoint = this.scrollStartPoint; | 47 var scrollStartPoint = this.scrollStartPoint; |
48 | 48 |
49 scrollElement.scrollTop = scrollStartPoint; | 49 scrollElement.scrollTop = scrollStartPoint; |
| 50 window.requestAnimationFrame(this.performSmoothScroll.bind(this)); |
| 51 } |
| 52 |
| 53 SmoothScrollInterruptionTest.prototype.performSmoothScroll = function() { |
| 54 var testCase = this.testCases[this.currentTestCase]; |
| 55 var scrollElement = this.scrollElement; |
| 56 var scrollStartPoint = this.scrollStartPoint; |
| 57 |
50 this.jsScroll(this.scrollEndPoint); | 58 this.jsScroll(this.scrollEndPoint); |
51 this.asyncTest.step(function() { | 59 this.asyncTest.step(function() { |
52 assert_equals(scrollElement.scrollTop, scrollStartPoint); | 60 assert_equals(scrollElement.scrollTop, scrollStartPoint); |
53 }); | 61 }); |
54 | 62 |
55 if (scrollElement.scrollTop == this.scrollEndPoint) { | 63 if (scrollElement.scrollTop == this.scrollEndPoint) { |
56 // We've instant-scrolled, and failed the assert above. | 64 // We've instant-scrolled, and failed the assert above. |
57 this.testCaseComplete(); | 65 this.testCaseComplete(); |
58 return; | 66 return; |
59 } | 67 } |
(...skipping 19 matching lines...) Expand all Loading... |
79 } | 87 } |
80 | 88 |
81 SmoothScrollInterruptionTest.prototype.testCaseComplete = function() { | 89 SmoothScrollInterruptionTest.prototype.testCaseComplete = function() { |
82 this.asyncTest.done(); | 90 this.asyncTest.done(); |
83 | 91 |
84 this.currentTestCase++; | 92 this.currentTestCase++; |
85 this.startNextTestCase(); | 93 this.startNextTestCase(); |
86 } | 94 } |
87 | 95 |
88 SmoothScrollInterruptionTest.prototype.run = function() { | 96 SmoothScrollInterruptionTest.prototype.run = function() { |
89 setup({explicit_done: true}); | 97 setup({explicit_done: true, explicit_timeout: true}); |
90 this.startNextTestCase(); | 98 this.startNextTestCase(); |
91 } | 99 } |
92 | 100 |
93 SmoothScrollInterruptionTest.prototype.allTestCasesComplete = function() { | 101 SmoothScrollInterruptionTest.prototype.allTestCasesComplete = function() { |
94 done(); | 102 done(); |
95 } | 103 } |
96 | 104 |
97 // A SmoothScrollInterruptionTestCase represents a single way of interrupting | 105 // A SmoothScrollInterruptionTestCase represents a single way of interrupting |
98 // a smooth scroll and verifying that the smooth scroll gets canceled. | 106 // a smooth scroll and verifying that the smooth scroll gets canceled. |
99 // | 107 // |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 189 } |
182 | 190 |
183 function interruptWithWheelScroll(smoothScrollTest) { | 191 function interruptWithWheelScroll(smoothScrollTest) { |
184 if (window.eventSender) { | 192 if (window.eventSender) { |
185 window.eventSender.mouseMoveTo(smoothScrollTest.innerPoint.x, smoothScro
llTest.innerPoint.y); | 193 window.eventSender.mouseMoveTo(smoothScrollTest.innerPoint.x, smoothScro
llTest.innerPoint.y); |
186 window.eventSender.mouseScrollBy(0, -10); | 194 window.eventSender.mouseScrollBy(0, -10); |
187 } else { | 195 } else { |
188 document.write("This test does not work in manual mode."); | 196 document.write("This test does not work in manual mode."); |
189 } | 197 } |
190 } | 198 } |
OLD | NEW |